# HG changeset patch # User Doug Simon # Date 1359542011 -3600 # Node ID c420a487b10f83efb777ffc5d6cb470031164036 # Parent 3aab15f429341719e1dd3ea4a7b8d61732506e31 changed convention for specifying constants versus named groups in a template for a value to extract from the output of a benchmark execution diff -r 3aab15f42934 -r c420a487b10f mx/outputparser.py --- a/mx/outputparser.py Wed Jan 30 11:03:32 2013 +0100 +++ b/mx/outputparser.py Wed Jan 30 11:33:31 2013 +0100 @@ -39,7 +39,13 @@ records.append(record) return records -class Matcher: +""" +Produces some named values for some given text if it matches a given +regular expression. The named values are specified by a dictionary +where any keys or value may be expressed as named group in the +regular expression. A named group is enclosed in '<' and '>'. +""" +class ValuesMatcher: def __init__(self, regex, valuesTemplate): assert isinstance(valuesTemplate, dict) @@ -52,13 +58,15 @@ return False values = {} for key, value in self.valuesTemplate.items(): - values[self.get_value_or_const(match, key)] = self.get_value_or_const(match, value) + values[self.get_template_value(match, key)] = self.get_template_value(match, value) return values - def get_value_or_const(self, match, name): - if name.startswith('const:'): - return name.split(':')[1] + def get_template_value(self, match, template): + if template.startswith('<'): + assert template.endswith('>') + groupName = template[1:-1] + return match.group(groupName) else: - return match.group(name) + return template diff -r 3aab15f42934 -r c420a487b10f mx/sanitycheck.py --- a/mx/sanitycheck.py Wed Jan 30 11:03:32 2013 +0100 +++ b/mx/sanitycheck.py Wed Jan 30 11:33:31 2013 +0100 @@ -23,7 +23,7 @@ # # ---------------------------------------------------------------------------------------------------- -from outputparser import OutputParser, Matcher +from outputparser import OutputParser, ValuesMatcher import re, mx, commands, os, sys, StringIO, subprocess from os.path import isfile, join, exists @@ -104,7 +104,7 @@ score = re.compile(r"^Valid run, Score is (?P[0-9]+)$", re.MULTILINE) error = re.compile(r"VALIDATION ERROR") success = re.compile(r"^Valid run, Score is [0-9]+$", re.MULTILINE) - matcher = Matcher(score, {'const:group' : "const:SPECjbb2005", 'const:name' : 'const:score', 'const:score' : 'score'}) + matcher = ValuesMatcher(score, {'group' : 'SPECjbb2005', 'name' : 'score', 'score' : ''}) classpath = ['jbb.jar', 'check.jar'] return Test("SPECjbb2005", ['spec.jbb.JBBmain', '-propfile', 'SPECjbb.props'] + benchArgs, [success], [error], [matcher], vmOpts=['-Xms3g', '-XX:+UseSerialGC', '-XX:-UseCompressedOops', '-cp', os.pathsep.join(classpath)], defaultCwd=specjbb2005) @@ -118,7 +118,7 @@ error = re.compile(r"^Errors in benchmark: ", re.MULTILINE) # The ' ops/m' at the end of the success string is important : it's how you can tell valid and invalid runs apart success = re.compile(r"^(Noncompliant c|C)omposite result: [0-9]+((,|\.)[0-9]+)?( SPECjvm2008 (Base|Peak))? ops/m$", re.MULTILINE) - matcher = Matcher(score, {'const:group' : "const:SPECjvm2008", 'const:name' : 'benchmark', 'const:score' : 'score'}) + matcher = ValuesMatcher(score, {'group' : 'SPECjvm2008', 'name' : '', 'score' : ''}) opts = [] if warmupTime is not None: @@ -159,8 +159,8 @@ dacapoTime = re.compile(r"===== DaCapo 9\.12 (?P[a-zA-Z0-9_]+) PASSED in (?P