2013-08-01 17:32:44 +00:00
|
|
|
# GDB .sum-fetching command.
|
|
|
|
|
2016-11-10 06:45:57 +00:00
|
|
|
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE, EXCEPTION
|
2016-11-06 03:59:59 +00:00
|
|
|
from buildbot.plugins import steps, util
|
2015-02-05 01:32:58 +00:00
|
|
|
from sumfiles import DejaResults, get_web_base
|
2015-01-23 23:56:28 +00:00
|
|
|
from gdbgitdb import switch_to_branch
|
2016-11-06 03:59:59 +00:00
|
|
|
import os
|
|
|
|
import sqlite3
|
2015-02-05 01:32:58 +00:00
|
|
|
|
2016-11-06 03:59:59 +00:00
|
|
|
@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' ]
|
2015-02-05 01:32:58 +00:00
|
|
|
|
2016-11-06 03:59:59 +00:00
|
|
|
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' ]
|
2015-02-05 01:32:58 +00:00
|
|
|
|
2016-11-06 03:59:59 +00:00
|
|
|
con = sqlite3.connect (db_file)
|
|
|
|
c = con.cursor ()
|
2016-11-10 06:45:57 +00:00
|
|
|
c.execute ('SELECT commitid FROM logs WHERE branch = "%s" AND trysched = 0 ORDER BY timestamp DESC LIMIT 1' % branch)
|
|
|
|
comm = c.fetchone ()
|
2016-11-06 03:59:59 +00:00
|
|
|
con.close ()
|
2015-02-05 01:32:58 +00:00
|
|
|
|
2016-11-10 06:45:57 +00:00
|
|
|
if comm:
|
|
|
|
commit = comm[0]
|
|
|
|
else:
|
|
|
|
return [ 'true' ]
|
2015-02-08 21:04:04 +00:00
|
|
|
|
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):
|
2016-12-20 03:55:17 +00:00
|
|
|
# Let's just return true here, because we want the build to
|
|
|
|
# continue.
|
|
|
|
return [ 'true' ]
|
2016-11-16 18:56:54 +00:00
|
|
|
|
2016-11-06 03:59:59 +00:00
|
|
|
if istry and istry == 'yes':
|
2017-09-05 13:43:15 +00:00
|
|
|
try_count = props.getProperty ('try_count')
|
|
|
|
to_path = os.path.join (get_web_base (), builder, 'try', rev[:2], rev, try_count)
|
2016-11-06 03:59:59 +00:00
|
|
|
else:
|
2016-11-10 06:45:57 +00:00
|
|
|
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')
|
2016-11-06 03:59:59 +00:00
|
|
|
|
|
|
|
command += [ from_path, to_path ]
|
2015-02-05 01:32:58 +00:00
|
|
|
|
2016-11-06 03:59:59 +00:00
|
|
|
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
|
|
|
|
2016-11-06 03:59:59 +00:00
|
|
|
def __init__ (self, **kwargs):
|
|
|
|
steps.MasterShellCommand.__init__ (self, command = create_copy_command, **kwargs)
|
2015-02-05 01:40:20 +00:00
|
|
|
|
2016-11-06 03:59:59 +00:00
|
|
|
class GdbCatSumfileCommand(steps.ShellCommand):
|
2013-08-01 17:32:44 +00:00
|
|
|
name = 'regressions'
|
|
|
|
command = ['cat', 'gdb.sum']
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
2016-11-06 03:59:59 +00:00
|
|
|
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')
|
2016-07-23 04:04:34 +00:00
|
|
|
istrysched = self.getProperty('isTrySched')
|
2016-11-10 19:35:52 +00:00
|
|
|
istry = istrysched and istrysched == 'yes'
|
2013-08-01 17:32:44 +00:00
|
|
|
branch = self.getProperty('branch')
|
2016-11-06 03:59:59 +00:00
|
|
|
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
|
|
|
|
2016-11-06 03:59:59 +00:00
|
|
|
if not os.path.exists (db_file):
|
|
|
|
# This takes care of our very first build.
|
2017-10-02 13:17:35 +00:00
|
|
|
if istry:
|
|
|
|
parser.write_try_build_sum_file (cur_results, builder, branch,
|
|
|
|
rev, 0)
|
|
|
|
else:
|
|
|
|
parser.write_sum_file (cur_results, builder, branch, rev, istry)
|
2016-11-06 03:59:59 +00:00
|
|
|
# If there was no previous baseline, then this run
|
|
|
|
# gets the honor.
|
|
|
|
if baseline is None:
|
|
|
|
baseline = cur_results
|
2016-11-10 19:35:52 +00:00
|
|
|
parser.write_baseline (baseline, builder, branch, rev, istry)
|
2016-11-06 03:59:59 +00:00
|
|
|
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)
|
2016-11-10 06:45:57 +00:00
|
|
|
prev = c.fetchone ()
|
2016-11-06 03:59:59 +00:00
|
|
|
con.close ()
|
|
|
|
|
2016-11-10 06:45:57 +00:00
|
|
|
if prev:
|
|
|
|
prevcommit = prev[0]
|
|
|
|
else:
|
|
|
|
# This takes care of our very first build.
|
2017-10-02 13:17:35 +00:00
|
|
|
if istry:
|
|
|
|
parser.write_try_build_sum_file (cur_results, builder, branch,
|
|
|
|
rev, 0)
|
|
|
|
else:
|
|
|
|
parser.write_sum_file (cur_results, builder, branch, rev, istry)
|
2016-11-10 06:45:57 +00:00
|
|
|
# If there was no previous baseline, then this run
|
|
|
|
# gets the honor.
|
|
|
|
if baseline is None:
|
|
|
|
baseline = cur_results
|
2016-11-10 19:35:52 +00:00
|
|
|
parser.write_baseline (baseline, builder, branch, rev, istry)
|
2016-11-10 06:45:57 +00:00
|
|
|
return SUCCESS
|
2015-01-23 23:56:28 +00:00
|
|
|
|
2016-11-06 03:59:59 +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
|
2016-07-29 15:15:32 +00:00
|
|
|
|
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)
|
2015-02-05 01:32:58 +00:00
|
|
|
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
|
2015-02-05 01:32:58 +00:00
|
|
|
|
2016-11-10 19:35:52 +00:00
|
|
|
if istry:
|
2017-09-05 13:43:15 +00:00
|
|
|
try_count = self.getProperty ('try_count')
|
|
|
|
parser.write_try_build_sum_file (cur_results, builder, branch, rev,
|
|
|
|
try_count)
|
2016-11-06 03:59:59 +00:00
|
|
|
else:
|
2016-11-10 19:35:52 +00:00
|
|
|
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
|
2016-11-10 19:35:52 +00:00
|
|
|
parser.write_baseline (baseline, builder, branch, rev, istry)
|
2015-02-05 01:32:58 +00:00
|
|
|
|
2013-08-01 17:32:44 +00:00
|
|
|
return result
|