1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
'''
__author__ = "Stefan Stanacar"
__copyright__ = "Copyright 2014 Intel Corporation"
__credits__ = ["Stefan Stanacar"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Stefan Stanacar"
__email__ = "stefanx.stanacar@intel.com"
'''
import platform
from buildbot.steps.shell import ShellCommand
from lib.ABTools import save_error_report, get_lsb_distro
from lib.buildsteps import BitbakeShellCommand
class RunOeSelftest(BitbakeShellCommand):
haltOnFailure = False
flunkOnFailure = True
name = "Running oe-selftest"
def __init__(self, factory, argdict=None, **kwargs):
self.tests = None
self.skiptests = None
self.factory = factory
for k, v in argdict.iteritems():
setattr(self, k, v)
self.description = "Running oe-selftest"
self.timeout = 100000
kwargs['timeout']=self.timeout
ShellCommand.__init__(self, **kwargs)
def start(self):
self.command = ""
self.command += ". ./oe-init-build-env; "
self.command += "checkvnc; "
self.layerversion_core = \
int(self.getProperty("layerversion_core", "0"))
if self.tests == '#SCRAPEDTARGETS':
self.tests = self.getProperty("scraped_targets")
testcmd = "--run-all-tests"
if self.skiptests and self.layerversion_core >= 11:
# -R/--skip-tests was only added in Rocko
testcmd = "--skip-tests " + self.skiptests
elif self.tests:
testcmd = "--run-tests " + self.tests
# test_checkpkg was only added in Rocko (layer version 11), filter that
# test out on layer versions prior to 11. If we filter the tests and
# the resulting filtered list is empty we need not run oe-selftest.
shouldrun = True
if self.tests and self.layerversion_core < 11:
self.tests = \
self.tests.replace("distrodata.Distrodata.test_checkpkg", "")
if len(self.tests.strip()) == 0:
shouldrun = False
if shouldrun:
self.command += "if [ -d ../meta-selftest ]; then export DISPLAY=:1; oe-selftest " + testcmd + "; else echo 'Skipping step - no meta-selftest layer here'; fi"
else:
self.skipStep("Skipping due to tests having been filtered out.")
ShellCommand.start(self)
def _createOESelftestErrorReport(self, log):
"""
Create a oe-selftest error report since oe-selftest
is intended to test the build system no information
about machine, distro and target_sys are provided so
use universal value.
"""
report = {}
report['machine'] = 'universal'
report['build_sys'] = "%s-%s" % (platform.machine(),
platform.system().lower())
# XXX: Set to universal because isn't easy to get Autobuilder
# worker distro.
report['nativelsb'] = 'universal'
report['distro'] = 'universal'
report['target_sys'] = 'universal'
report['component'] = 'oe-selftest'
report['branch_commit'] = self.getProperty('branch') + ': ' + \
self.getProperty('got_revision')
report['error_type'] = 'oe-selftest'
failure = {}
failure['package'] = 'oe-selftest'
failure['task'] = self.command[self.command.find('oe-selftest'):]
failure['log'] = log
report['failures'] = [failure]
return report
def commandComplete(self, cmd):
if cmd.didFail():
buildername = self.getProperty('buildername')
buildnumber = self.getProperty('buildnumber')
log = cmd.logs['stdio'].getText()
report = self._createOESelftestErrorReport(log)
save_error_report(buildername, buildnumber, report, 'oe_selftest')
|