From 7595196cc7274f9b6ef5391fbeb29ddcd1ad0426 Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Wed, 4 Feb 2015 20:32:58 -0500 Subject: [PATCH] Implementing diff against previous gdb.sum, instead of using a baseline --- lib/gdbcommand.py | 43 +++++++++++++++++++++++++++++++++++++++++-- lib/gdbgitdb.py | 2 ++ lib/sumfiles.py | 18 ++++++++++++++---- master.cfg | 3 ++- 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/lib/gdbcommand.py b/lib/gdbcommand.py index 7a150de..583b873 100644 --- a/lib/gdbcommand.py +++ b/lib/gdbcommand.py @@ -2,8 +2,36 @@ from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, EXCEPTION from buildbot.steps.shell import ShellCommand -from sumfiles import DejaResults +from sumfiles import DejaResults, get_web_base 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): name = 'regressions' @@ -27,20 +55,31 @@ class GdbCatSumfileCommand(ShellCommand): cur_results = parser.read_sum_text(self.getLog('stdio').getText()) if not istry or istry == 'no': baseline = parser.read_baseline (builder, branch) + old_sum = parser.read_old_sum_file (builder, branch) else: baseline = parser.read_sum_file(builder, rev) + old_sum = parser.read_old_sum_file (builder, rev) result = SUCCESS if baseline is not None: report = parser.compute_regressions (builder, branch, 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 '': self.addCompleteLog ('regressions', report) result = FAILURE + if not istry or istry == 'no': parser.write_sum_file (cur_results, builder, branch) # If there was no previous baseline, then this run # gets the honor. if baseline is None: baseline = cur_results - parser.write_baseline (baseline, builder, branch) + parser.write_baseline (baseline, builder, branch, rev) + return result diff --git a/lib/gdbgitdb.py b/lib/gdbgitdb.py index 04714f8..2bbb4a7 100644 --- a/lib/gdbgitdb.py +++ b/lib/gdbgitdb.py @@ -133,6 +133,8 @@ class SaveGDBResults (ShellCommand): repo.index.add (['gdb.sum', 'gdb.log', 'baseline']) + if os.path.exists ("%s/previous_gdb.sum"): + repo.index.add (['previous_gdb.sum']) if repo.is_dirty (): repo.index.commit ('Log files for %s -- branch %s' % (full_tag, branch)) repo.index.write () diff --git a/lib/sumfiles.py b/lib/sumfiles.py index d448155..0887776 100644 --- a/lib/sumfiles.py +++ b/lib/sumfiles.py @@ -46,7 +46,8 @@ class DejaResults(object): test_name = nname 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 if not rev_or_branch: bdir = os.path.join (gdb_web_base, subdir) @@ -57,15 +58,21 @@ class DejaResults(object): fname = os.path.join (bdir, filename) keys = sum_dict.keys () keys.sort () - with open (fname, 'w') as f: + mode = 'w' + if header: + with open (fname, 'w') as f: + f.write (header) + mode = 'a' + with open (fname, mode) as f: for k in keys: f.write (sum_dict[k] + ': ' + k + '\n') def write_sum_file(self, sum_dict, builder, branch): self._write_sum_file (sum_dict, builder, None, 'gdb.sum') - def write_baseline(self, sum_dict, builder, branch): - self._write_sum_file(sum_dict, builder, None, 'baseline') + def write_baseline(self, sum_dict, builder, branch, rev): + 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. # The builder name is BUILDER. @@ -98,6 +105,9 @@ class DejaResults(object): return self._read_sum_file (builder, os.path.join ('xfails', branch), '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 # dictionary. def read_sum_text (self, text): diff --git a/master.cfg b/master.cfg index a774fbd..0f55c6a 100644 --- a/master.cfg +++ b/master.cfg @@ -24,7 +24,7 @@ from buildbot.steps.slave import RemoveDirectory from buildbot.changes.filter import ChangeFilter from buildbot.buildslave import BuildSlave 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 urllib import quote @@ -472,6 +472,7 @@ The parameters of the class are: descriptionDone = r"removed old build dir")) self.addStep (CloneOrUpdateGDBMasterRepo ()) self.addStep (CloneOrUpdateGDBRepo ()) + self.addStep (CopyOldGDBSumFile ()) if not self.extra_conf_flags: self.extra_conf_flags = []