gdb-buildbot/lib/gdbcommand.py

150 lines
5.3 KiB
Python
Raw Normal View History

2013-08-01 17:32:44 +00:00
# GDB .sum-fetching command.
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE, EXCEPTION
from buildbot.plugins import steps, util
from sumfiles import DejaResults, get_web_base
2015-01-23 23:56:28 +00:00
from gdbgitdb import switch_to_branch
import os
import sqlite3
@util.renderer
def create_copy_command (props):
rev = props.getProperty ('got_revision')
builder = props.getProperty ('buildername')
istry = props.getProperty ('isTrySched')
branch = props.getProperty ('branch')
command = [ 'cp', '-a' ]
db_file = os.path.join (get_web_base (), builder, builder + '.db')
if not os.path.exists (db_file):
# This is probably the first commit being tested. Don't do anything.
return [ 'true' ]
con = sqlite3.connect (db_file)
c = con.cursor ()
c.execute ('SELECT commitid FROM logs WHERE branch = "%s" AND trysched = 0 ORDER BY timestamp DESC LIMIT 1' % branch)
comm = c.fetchone ()
con.close ()
if comm:
commit = comm[0]
else:
return [ 'true' ]
2016-11-10 17:58:55 +00:00
from_path = os.path.join (get_web_base (), builder, commit[:2], commit, 'gdb.sum.xz')
2016-11-16 18:56:54 +00:00
if not os.path.exists (from_path):
# Let's just return true here, because we want the build to
# continue.
return [ 'true' ]
2016-11-16 18:56:54 +00:00
if istry and istry == 'yes':
con = sqlite3.connect (db_file)
c = con.cursor ()
c.execute ('SELECT COUNT(*) FROM logs WHERE commitid = "%s" AND branch = "%s" AND trysched = 1' % (rev, branch))
count = int (c.fetchone ())
con.close ()
to_path = os.path.join (get_web_base (), builder, 'try', rev[:2], rev, count)
else:
to_path = os.path.join (get_web_base (), builder, rev[:2], rev)
if not os.path.exists (to_path):
old_umask = os.umask (0022)
os.makedirs (to_path)
os.umask (old_umask)
to_path = os.path.join (to_path, 'previous_gdb.sum.xz')
command += [ from_path, to_path ]
return command
class CopyOldGDBSumFile (steps.MasterShellCommand):
"""Copy the current gdb.sum file into the old_gdb.sum file."""
name = "copy gdb.sum file"
description = "copying previous gdb.sum file"
descriptionDone = "copied previous gdb.sum file"
2013-08-01 17:32:44 +00:00
def __init__ (self, **kwargs):
steps.MasterShellCommand.__init__ (self, command = create_copy_command, **kwargs)
2015-02-05 01:40:20 +00:00
class GdbCatSumfileCommand(steps.ShellCommand):
2013-08-01 17:32:44 +00:00
name = 'regressions'
command = ['cat', 'gdb.sum']
def __init__(self, **kwargs):
steps.ShellCommand.__init__(self, **kwargs)
2013-08-01 17:32:44 +00:00
def evaluateCommand(self, cmd):
rev = self.getProperty('got_revision')
builder = self.getProperty('buildername')
istrysched = self.getProperty('isTrySched')
istry = istrysched and istrysched == 'yes'
2013-08-01 17:32:44 +00:00
branch = self.getProperty('branch')
db_file = os.path.join (get_web_base (), builder, builder + '.db')
parser = DejaResults()
cur_results = parser.read_sum_text(self.getLog('stdio').getText())
baseline = None
2013-08-01 17:32:44 +00:00
if branch is None:
branch = 'master'
2015-01-23 23:56:28 +00:00
if not os.path.exists (db_file):
# This takes care of our very first build.
parser.write_sum_file (cur_results, builder, branch, rev, istry)
# 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, rev, istry)
return SUCCESS
con = sqlite3.connect (db_file)
c = con.cursor ()
2016-11-11 00:56:29 +00:00
c.execute ('SELECT commitid FROM logs WHERE branch = "%s" AND trysched = 0 ORDER BY timestamp DESC LIMIT 1' % branch)
prev = c.fetchone ()
con.close ()
if prev:
prevcommit = prev[0]
else:
# This takes care of our very first build.
parser.write_sum_file (cur_results, builder, branch, rev, istry)
# 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, rev, istry)
return SUCCESS
2015-01-23 23:56:28 +00:00
baseline = parser.read_baseline (builder, branch, prevcommit)
old_sum = parser.read_sum_file (builder, branch, prevcommit)
2013-08-01 17:32:44 +00:00
result = SUCCESS
2013-08-01 17:32:44 +00:00
if baseline is not None:
2015-01-23 23:56:28 +00:00
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)
2013-08-01 17:32:44 +00:00
if report is not '':
2015-01-23 23:56:28 +00:00
self.addCompleteLog ('regressions', report)
2013-08-01 17:32:44 +00:00
result = FAILURE
if istry:
parser.write_try_build_sum_file (cur_results, builder, branch, rev)
else:
parser.write_sum_file (cur_results, builder, branch, rev, istry)
2013-08-01 17:32:44 +00:00
# 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, rev, istry)
2013-08-01 17:32:44 +00:00
return result