blob: 217afe3775b1157d72463a13431b5840a5fb0fd8 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
5import os
Brad Bishopd7bf8c12018-02-25 22:55:05 -05006from oeqa.selftest.case import OESelftestTestCase
7from oeqa.selftest.cases.buildhistory import BuildhistoryBase
8from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009
10class BuildhistoryDiffTests(BuildhistoryBase):
11
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012 def test_buildhistory_diff(self):
13 target = 'xcursor-transparent-theme'
14 self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True)
15 self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080016 result = runCmd("oe-pkgdata-util read-value PKGV %s" % target)
17 pkgv = result.output.rstrip()
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018 result = runCmd("buildhistory-diff -p %s" % get_bb_var('BUILDHISTORY_DIR'))
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019 expected_endlines = [
20 "xcursor-transparent-theme-dev: RDEPENDS: removed \"xcursor-transparent-theme (['= %s-r1'])\", added \"xcursor-transparent-theme (['= %s-r0'])\"" % (pkgv, pkgv),
21 "xcursor-transparent-theme-staticdev: RDEPENDS: removed \"xcursor-transparent-theme-dev (['= %s-r1'])\", added \"xcursor-transparent-theme-dev (['= %s-r0'])\"" % (pkgv, pkgv)
22 ]
23 for line in result.output.splitlines():
24 for el in expected_endlines:
25 if line.endswith(el):
26 expected_endlines.remove(el)
27 break
28 else:
29 self.fail('Unexpected line:\n%s\nExpected line endings:\n %s' % (line, '\n '.join(expected_endlines)))
30 if expected_endlines:
31 self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines))
Brad Bishopc342db32019-05-15 21:57:59 -040032
33class OEScriptTests(OESelftestTestCase):
34
35 @classmethod
36 def setUpClass(cls):
37 super(OEScriptTests, cls).setUpClass()
38 try:
39 import cairo
40 except ImportError:
41 cls.skipTest('Python module cairo is not present')
42 bitbake("core-image-minimal -c rootfs -f")
43 cls.tmpdir = get_bb_var('TMPDIR')
44 cls.buildstats = cls.tmpdir + "/buildstats/" + sorted(os.listdir(cls.tmpdir + "/buildstats"))[-1]
45
46 scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts')
47
48class OEPybootchartguyTests(OEScriptTests):
49
50 def test_pybootchartguy_help(self):
51 runCmd('%s/pybootchartgui/pybootchartgui.py --help' % self.scripts_dir)
52
53 def test_pybootchartguy_to_generate_build_png_output(self):
54 runCmd('%s/pybootchartgui/pybootchartgui.py %s -o %s/charts -f png' % (self.scripts_dir, self.buildstats, self.tmpdir))
55 self.assertTrue(os.path.exists(self.tmpdir + "/charts.png"))
56
57 def test_pybootchartguy_to_generate_build_svg_output(self):
58 runCmd('%s/pybootchartgui/pybootchartgui.py %s -o %s/charts -f svg' % (self.scripts_dir, self.buildstats, self.tmpdir))
59 self.assertTrue(os.path.exists(self.tmpdir + "/charts.svg"))
60
61 def test_pybootchartguy_to_generate_build_pdf_output(self):
62 runCmd('%s/pybootchartgui/pybootchartgui.py %s -o %s/charts -f pdf' % (self.scripts_dir, self.buildstats, self.tmpdir))
63 self.assertTrue(os.path.exists(self.tmpdir + "/charts.pdf"))
64