Implementing diff against previous gdb.sum, instead of using a baseline

This commit is contained in:
Sergio Durigan Junior 2015-02-04 20:32:58 -05:00
parent 85ed927a4d
commit 7595196cc7
4 changed files with 59 additions and 7 deletions

View file

@ -2,8 +2,36 @@
from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, EXCEPTION from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, EXCEPTION
from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import ShellCommand
from sumfiles import DejaResults from sumfiles import DejaResults, get_web_base
from gdbgitdb import switch_to_branch from gdbgitdb import switch_to_branch
from shutil import copyfile
class CopyOldGDBSumFile (ShellCommand):
"""Copy the current gdb.sum file into the old_gdb.sum file."""
name = "copy gdb.sum file"
command = [ '/bin/true' ]
def __init__ (self, **kwargs):
ShellCommand.__init__ (self, **kwargs)
def evaluateCommand (self, cmd):
rev = self.getProperty('got_revision')
builder = self.getProperty('buildername')
istry = self.getProperty('isTryBuilder')
branch = self.getProperty('branch')
wb = get_web_base ()
if branch is None:
branch = 'master'
# Switch to the right branch inside the BUILDER repo
switch_to_branch (builder, branch)
try:
copyfile ("%d/%d/gdb.sum" % (wb, builder),
"%d/%d/previous_gdb.sum" % (wb, builder))
except IOError:
# If the dest file does not exist, ignore
pass
class GdbCatSumfileCommand(ShellCommand): class GdbCatSumfileCommand(ShellCommand):
name = 'regressions' name = 'regressions'
@ -27,20 +55,31 @@ class GdbCatSumfileCommand(ShellCommand):
cur_results = parser.read_sum_text(self.getLog('stdio').getText()) cur_results = parser.read_sum_text(self.getLog('stdio').getText())
if not istry or istry == 'no': if not istry or istry == 'no':
baseline = parser.read_baseline (builder, branch) baseline = parser.read_baseline (builder, branch)
old_sum = parser.read_old_sum_file (builder, branch)
else: else:
baseline = parser.read_sum_file(builder, rev) baseline = parser.read_sum_file(builder, rev)
old_sum = parser.read_old_sum_file (builder, rev)
result = SUCCESS result = SUCCESS
if baseline is not None: if baseline is not None:
report = parser.compute_regressions (builder, branch, report = parser.compute_regressions (builder, branch,
cur_results, baseline) cur_results, baseline)
if report is not '':
self.addCompleteLog ('baseline_diff', report)
result = WARNINGS
if old_sum is not None:
report = parser.compute_regressions (builder, branch,
cur_results, old_sum)
if report is not '': if report is not '':
self.addCompleteLog ('regressions', report) self.addCompleteLog ('regressions', report)
result = FAILURE result = FAILURE
if not istry or istry == 'no': if not istry or istry == 'no':
parser.write_sum_file (cur_results, builder, branch) parser.write_sum_file (cur_results, builder, branch)
# If there was no previous baseline, then this run # If there was no previous baseline, then this run
# gets the honor. # gets the honor.
if baseline is None: if baseline is None:
baseline = cur_results baseline = cur_results
parser.write_baseline (baseline, builder, branch) parser.write_baseline (baseline, builder, branch, rev)
return result return result

View file

@ -133,6 +133,8 @@ class SaveGDBResults (ShellCommand):
repo.index.add (['gdb.sum', repo.index.add (['gdb.sum',
'gdb.log', 'gdb.log',
'baseline']) 'baseline'])
if os.path.exists ("%s/previous_gdb.sum"):
repo.index.add (['previous_gdb.sum'])
if repo.is_dirty (): if repo.is_dirty ():
repo.index.commit ('Log files for %s -- branch %s' % (full_tag, branch)) repo.index.commit ('Log files for %s -- branch %s' % (full_tag, branch))
repo.index.write () repo.index.write ()

View file

@ -46,7 +46,8 @@ class DejaResults(object):
test_name = nname test_name = nname
out_dict[test_name] = result out_dict[test_name] = result
def _write_sum_file(self, sum_dict, subdir, rev_or_branch, filename): def _write_sum_file(self, sum_dict, subdir, rev_or_branch, filename,
header = None):
global gdb_web_base global gdb_web_base
if not rev_or_branch: if not rev_or_branch:
bdir = os.path.join (gdb_web_base, subdir) bdir = os.path.join (gdb_web_base, subdir)
@ -57,15 +58,21 @@ class DejaResults(object):
fname = os.path.join (bdir, filename) fname = os.path.join (bdir, filename)
keys = sum_dict.keys () keys = sum_dict.keys ()
keys.sort () keys.sort ()
mode = 'w'
if header:
with open (fname, 'w') as f: with open (fname, 'w') as f:
f.write (header)
mode = 'a'
with open (fname, mode) as f:
for k in keys: for k in keys:
f.write (sum_dict[k] + ': ' + k + '\n') f.write (sum_dict[k] + ': ' + k + '\n')
def write_sum_file(self, sum_dict, builder, branch): def write_sum_file(self, sum_dict, builder, branch):
self._write_sum_file (sum_dict, builder, None, 'gdb.sum') self._write_sum_file (sum_dict, builder, None, 'gdb.sum')
def write_baseline(self, sum_dict, builder, branch): def write_baseline(self, sum_dict, builder, branch, rev):
self._write_sum_file(sum_dict, builder, None, 'baseline') self._write_sum_file(sum_dict, builder, None, 'baseline',
header = "### THIS BASELINE WAS LAST UPDATED BY COMMIT %s ###\n\n" % rev)
# Read a .sum file. # Read a .sum file.
# The builder name is BUILDER. # The builder name is BUILDER.
@ -98,6 +105,9 @@ class DejaResults(object):
return self._read_sum_file (builder, os.path.join ('xfails', branch), return self._read_sum_file (builder, os.path.join ('xfails', branch),
'xfail') 'xfail')
def read_old_sum_file (self, builder, branch):
return self._read_sum_file (builder, None, 'previous_gdb.sum')
# 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):

View file

@ -24,7 +24,7 @@ from buildbot.steps.slave import RemoveDirectory
from buildbot.changes.filter import ChangeFilter from buildbot.changes.filter import ChangeFilter
from buildbot.buildslave import BuildSlave from buildbot.buildslave import BuildSlave
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE, EXCEPTION from buildbot.status.results import SUCCESS, WARNINGS, FAILURE, EXCEPTION
from gdbcommand import GdbCatSumfileCommand from gdbcommand import CopyOldGDBSumFile, GdbCatSumfileCommand
from gdbgitdb import SaveGDBResults, get_builder_commit_id from gdbgitdb import SaveGDBResults, get_builder_commit_id
from urllib import quote from urllib import quote
@ -472,6 +472,7 @@ The parameters of the class are:
descriptionDone = r"removed old build dir")) descriptionDone = r"removed old build dir"))
self.addStep (CloneOrUpdateGDBMasterRepo ()) self.addStep (CloneOrUpdateGDBMasterRepo ())
self.addStep (CloneOrUpdateGDBRepo ()) self.addStep (CloneOrUpdateGDBRepo ())
self.addStep (CopyOldGDBSumFile ())
if not self.extra_conf_flags: if not self.extra_conf_flags:
self.extra_conf_flags = [] self.extra_conf_flags = []