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