Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
| 5 | import os |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 6 | import unittest |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7 | from oeqa.selftest.case import OESelftestTestCase |
| 8 | from oeqa.selftest.cases.buildhistory import BuildhistoryBase |
| 9 | from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10 | |
| 11 | class BuildhistoryDiffTests(BuildhistoryBase): |
| 12 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 13 | 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 17 | result = runCmd("oe-pkgdata-util read-value PKGV %s" % target) |
| 18 | pkgv = result.output.rstrip() |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 19 | result = runCmd("buildhistory-diff -p %s" % get_bb_var('BUILDHISTORY_DIR')) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 20 | 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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 33 | |
| 34 | class OEScriptTests(OESelftestTestCase): |
| 35 | |
| 36 | @classmethod |
| 37 | def setUpClass(cls): |
| 38 | super(OEScriptTests, cls).setUpClass() |
| 39 | try: |
| 40 | import cairo |
| 41 | except ImportError: |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 42 | raise unittest.SkipTest('Python module cairo is not present') |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 43 | 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 | |
| 49 | class 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 | |