Fixing racy sumfile read

This commit is contained in:
Sergio Durigan Junior 2016-03-20 15:38:28 -04:00
parent a2bd0f0a9f
commit c70ee83436
2 changed files with 22 additions and 13 deletions

View file

@ -21,9 +21,9 @@ class GDBAnalyzeRacyTests (ShellCommand):
racy_tests = p.read_sum_text (self.getLog ('stdio').getText ()) racy_tests = p.read_sum_text (self.getLog ('stdio').getText ())
xfails = p.read_xfail (builder, branch) xfails = p.read_xfail (builder, branch)
if not racy_tests[1]: if not racy_tests or not racy_tests[1]:
return SUCCESS return SUCCESS
elif not xfails[1]: elif not xfails or not xfails[1]:
unique_tests = racy_tests[1]['NONE'] unique_tests = racy_tests[1]['NONE']
else: else:
unique_tests = racy_tests[1]['NONE'] - xfails[1]['FAIL'] unique_tests = racy_tests[1]['NONE'] - xfails[1]['FAIL']

View file

@ -8,7 +8,8 @@ from StringIO import StringIO
from collections import OrderedDict from collections import OrderedDict
# Helper regex for parse_sum_line. # Helper regex for parse_sum_line.
sum_matcher = re.compile('^(.?(PASS|FAIL))?(: )?(.*)$') sum_matcher = re.compile('^(.?(PASS|FAIL)): (.*)$')
racy_file_matcher = re.compile ('^(gdb\.*)')
# You must call set_web_base at startup to set this. # You must call set_web_base at startup to set this.
gdb_web_base = None gdb_web_base = None
@ -32,17 +33,23 @@ class DejaResults(object):
# Parse a single line from a .sum file. # Parse a single line from a .sum file.
# Uniquify the name, and put the result into OUT_DICT. # Uniquify the name, and put the result into OUT_DICT.
# If the line does not appear to be about a test, ignore it. # If the line does not appear to be about a test, ignore it.
def parse_sum_line(self, out_dict, line): def parse_sum_line(self, out_dict, line, is_racy_file = False):
global sum_matcher global sum_matcher
line = line.rstrip() line = line.rstrip()
m = re.match(sum_matcher, line) if not is_racy_file:
m = re.match(sum_matcher, line)
else:
m = re.match (racy_file_matcher, line)
if m: if m:
result = m.group(1) if is_racy_file:
if not result:
# On racy.sum files, there is no result to parse. # On racy.sum files, there is no result to parse.
result = 'NONE' result = 'NONE'
test_name = m.group(4) test_name = m.group (1)
else:
result = m.group (1)
test_name = m.group (3)
# Remove tail parentheses # Remove tail parentheses
test_name = re.sub ('(\s+)?\(.*$', '', test_name) test_name = re.sub ('(\s+)?\(.*$', '', test_name)
if result not in out_dict[1].keys (): if result not in out_dict[1].keys ():
@ -93,7 +100,8 @@ class DejaResults(object):
# revision; to read the baseline file for a branch, use `read_baseline'. # revision; to read the baseline file for a branch, use `read_baseline'.
# Returns a dictionary holding the .sum contents, or None if the # Returns a dictionary holding the .sum contents, or None if the
# file did not exist. # file did not exist.
def _read_sum_file(self, subdir, rev_or_branch, filename): def _read_sum_file(self, subdir, rev_or_branch, filename,
is_racy_file = False):
global gdb_web_base global gdb_web_base
if not rev_or_branch: if not rev_or_branch:
fname = os.path.join (gdb_web_base, subdir, filename) fname = os.path.join (gdb_web_base, subdir, filename)
@ -108,7 +116,7 @@ class DejaResults(object):
result.append (dict ()) result.append (dict ())
with open (fname, 'r') as f: with open (fname, 'r') as f:
for line in f: for line in f:
self.parse_sum_line (result, line) self.parse_sum_line (result, line, is_racy_file)
else: else:
result = None result = None
return result return result
@ -128,19 +136,20 @@ class DejaResults(object):
# Parse some text as a .sum file and return the resulting # Parse some text as a .sum file and return the resulting
# dictionary. # dictionary.
def read_sum_text (self, text): def read_sum_text (self, text, is_racy_file = False):
cur_file = StringIO (text) cur_file = StringIO (text)
cur_results = [] cur_results = []
cur_results.append (OrderedDict ()) cur_results.append (OrderedDict ())
cur_results.append (dict ()) cur_results.append (dict ())
for line in cur_file.readlines (): for line in cur_file.readlines ():
self.parse_sum_line (cur_results, line) self.parse_sum_line (cur_results, line,
is_racy_file = is_racy_file)
return cur_results return cur_results
# Parse some text as the racy.sum file and return the resulting # Parse some text as the racy.sum file and return the resulting
# dictionary. # dictionary.
def read_racy_sum_text (self, text): def read_racy_sum_text (self, text):
return self.read_sum_text (text) return self.read_sum_text (text, is_racy_file = True)
# Compute regressions between RESULTS and BASELINE on BUILDER. # Compute regressions between RESULTS and BASELINE on BUILDER.
# BASELINE will be modified if any new PASSes are seen. # BASELINE will be modified if any new PASSes are seen.