blob: f69efccfee6a2164f5989b9ddf1fb4704a27a29c [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
7import os
Brad Bishopa34c0302019-09-23 22:34:48 -04008import shutil
Andrew Geissler82c905d2020-04-13 13:39:40 -05009import importlib
Brad Bishop15ae2502019-06-18 21:44:24 -040010import unittest
Brad Bishopd7bf8c12018-02-25 22:55:05 -050011from oeqa.selftest.case import OESelftestTestCase
12from oeqa.selftest.cases.buildhistory import BuildhistoryBase
Patrick Williams45852732022-04-02 08:58:32 -050013from oeqa.utils.commands import runCmd, bitbake, get_bb_var
Brad Bishopa34c0302019-09-23 22:34:48 -040014from oeqa.utils import CommandError
Brad Bishopd7bf8c12018-02-25 22:55:05 -050015
16class BuildhistoryDiffTests(BuildhistoryBase):
17
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018 def test_buildhistory_diff(self):
19 target = 'xcursor-transparent-theme'
20 self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True)
21 self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022 result = runCmd("oe-pkgdata-util read-value PKGV %s" % target)
23 pkgv = result.output.rstrip()
Brad Bishopd7bf8c12018-02-25 22:55:05 -050024 result = runCmd("buildhistory-diff -p %s" % get_bb_var('BUILDHISTORY_DIR'))
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025 expected_endlines = [
Andrew Geissler615f2f12022-07-15 14:00:58 -050026 "xcursor-transparent-theme-dev: RRECOMMENDS: removed \"xcursor-transparent-theme (['= %s-r1'])\", added \"xcursor-transparent-theme (['= %s-r0'])\"" % (pkgv, pkgv),
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027 "xcursor-transparent-theme-staticdev: RDEPENDS: removed \"xcursor-transparent-theme-dev (['= %s-r1'])\", added \"xcursor-transparent-theme-dev (['= %s-r0'])\"" % (pkgv, pkgv)
28 ]
29 for line in result.output.splitlines():
30 for el in expected_endlines:
31 if line.endswith(el):
32 expected_endlines.remove(el)
33 break
34 else:
35 self.fail('Unexpected line:\n%s\nExpected line endings:\n %s' % (line, '\n '.join(expected_endlines)))
36 if expected_endlines:
37 self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines))
Brad Bishopc342db32019-05-15 21:57:59 -040038
Patrick Williams45852732022-04-02 08:58:32 -050039@unittest.skipUnless(importlib.util.find_spec("cairo"), "Python cairo module is not present")
Andrew Geissler220dafd2023-10-04 10:18:08 -050040class OEPybootchartguyTests(OESelftestTestCase):
Brad Bishopc342db32019-05-15 21:57:59 -040041
42 @classmethod
43 def setUpClass(cls):
Andrew Geissler220dafd2023-10-04 10:18:08 -050044 super().setUpClass()
Brad Bishopc342db32019-05-15 21:57:59 -040045 bitbake("core-image-minimal -c rootfs -f")
46 cls.tmpdir = get_bb_var('TMPDIR')
47 cls.buildstats = cls.tmpdir + "/buildstats/" + sorted(os.listdir(cls.tmpdir + "/buildstats"))[-1]
Andrew Geissler220dafd2023-10-04 10:18:08 -050048 cls.scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts')
Brad Bishopc342db32019-05-15 21:57:59 -040049
Brad Bishopc342db32019-05-15 21:57:59 -040050 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
Brad Bishop1d80a2e2019-11-15 16:35:03 -050065
Andrew Geissler220dafd2023-10-04 10:18:08 -050066class OEGitproxyTests(OESelftestTestCase):
67
68 @classmethod
69 def setUpClass(cls):
70 super().setUpClass()
71 cls.scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts')
Brad Bishopa34c0302019-09-23 22:34:48 -040072
73 def test_oegitproxy_help(self):
74 try:
75 res = runCmd('%s/oe-git-proxy --help' % self.scripts_dir, assert_error=False)
76 self.assertTrue(False)
77 except CommandError as e:
78 self.assertEqual(2, e.retcode)
79
80 def run_oegitproxy(self, custom_shell=None):
81 os.environ['SOCAT'] = shutil.which("echo")
82 os.environ['ALL_PROXY'] = "https://proxy.example.com:3128"
83 os.environ['NO_PROXY'] = "*.example.com,.no-proxy.org,192.168.42.0/24,127.*.*.*"
84
85 if custom_shell is None:
86 prefix = ''
87 else:
88 prefix = custom_shell + ' '
89
90 # outside, use the proxy
91 res = runCmd('%s%s/oe-git-proxy host.outside-example.com 9418' %
92 (prefix,self.scripts_dir))
93 self.assertIn('PROXY:', res.output)
94 # match with wildcard suffix
95 res = runCmd('%s%s/oe-git-proxy host.example.com 9418' %
96 (prefix, self.scripts_dir))
97 self.assertIn('TCP:', res.output)
98 # match just suffix
99 res = runCmd('%s%s/oe-git-proxy host.no-proxy.org 9418' %
100 (prefix, self.scripts_dir))
101 self.assertIn('TCP:', res.output)
102 # match IP subnet
103 res = runCmd('%s%s/oe-git-proxy 192.168.42.42 9418' %
104 (prefix, self.scripts_dir))
105 self.assertIn('TCP:', res.output)
106 # match IP wildcard
107 res = runCmd('%s%s/oe-git-proxy 127.1.2.3 9418' %
108 (prefix, self.scripts_dir))
109 self.assertIn('TCP:', res.output)
110
111 # test that * globbering is off
112 os.environ['NO_PROXY'] = "*"
113 res = runCmd('%s%s/oe-git-proxy host.example.com 9418' %
114 (prefix, self.scripts_dir))
115 self.assertIn('TCP:', res.output)
116
117 def test_oegitproxy_proxy(self):
118 self.run_oegitproxy()
119
120 def test_oegitproxy_proxy_dash(self):
121 dash = shutil.which("dash")
122 if dash is None:
123 self.skipTest("No \"dash\" found on test system.")
124 self.run_oegitproxy(custom_shell=dash)
Brad Bishop64c979e2019-11-04 13:55:29 -0500125
126class OeRunNativeTest(OESelftestTestCase):
127 def test_oe_run_native(self):
128 bitbake("qemu-helper-native -c addto_recipe_sysroot")
Patrick Williams520786c2023-06-25 16:20:36 -0500129 result = runCmd("oe-run-native qemu-helper-native qemu-oe-bridge-helper --help")
130 self.assertIn("Helper function to find and exec qemu-bridge-helper", result.output)
Brad Bishop1d80a2e2019-11-15 16:35:03 -0500131
Andrew Geissler220dafd2023-10-04 10:18:08 -0500132class OEListPackageconfigTests(OESelftestTestCase):
133
134 @classmethod
135 def setUpClass(cls):
136 super().setUpClass()
137 cls.scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts')
138
Brad Bishop1d80a2e2019-11-15 16:35:03 -0500139 #oe-core.scripts.List_all_the_PACKAGECONFIG's_flags
140 def check_endlines(self, results, expected_endlines):
141 for line in results.output.splitlines():
142 for el in expected_endlines:
Andrew Geissler78b72792022-06-14 06:47:25 -0500143 if line and line.split()[0] == el.split()[0] and \
144 ' '.join(sorted(el.split())) in ' '.join(sorted(line.split())):
Brad Bishop1d80a2e2019-11-15 16:35:03 -0500145 expected_endlines.remove(el)
146 break
147
148 if expected_endlines:
149 self.fail('Missing expected listings:\n %s' % '\n '.join(expected_endlines))
150
151
152 #oe-core.scripts.List_all_the_PACKAGECONFIG's_flags
153 def test_packageconfig_flags_help(self):
154 runCmd('%s/contrib/list-packageconfig-flags.py -h' % self.scripts_dir)
155
156 def test_packageconfig_flags_default(self):
157 results = runCmd('%s/contrib/list-packageconfig-flags.py' % self.scripts_dir)
158 expected_endlines = []
159 expected_endlines.append("RECIPE NAME PACKAGECONFIG FLAGS")
Patrick Williams2390b1b2022-11-03 13:47:49 -0500160 expected_endlines.append("pinentry gtk2 ncurses qt secret")
Andrew Geissler5199d832021-09-24 16:47:35 -0500161 expected_endlines.append("tar acl selinux")
Brad Bishop1d80a2e2019-11-15 16:35:03 -0500162
163 self.check_endlines(results, expected_endlines)
164
165
166 def test_packageconfig_flags_option_flags(self):
167 results = runCmd('%s/contrib/list-packageconfig-flags.py -f' % self.scripts_dir)
168 expected_endlines = []
169 expected_endlines.append("PACKAGECONFIG FLAG RECIPE NAMES")
170 expected_endlines.append("qt nativesdk-pinentry pinentry pinentry-native")
171 expected_endlines.append("secret nativesdk-pinentry pinentry pinentry-native")
172
173 self.check_endlines(results, expected_endlines)
174
175 def test_packageconfig_flags_option_all(self):
176 results = runCmd('%s/contrib/list-packageconfig-flags.py -a' % self.scripts_dir)
177 expected_endlines = []
Patrick Williams2390b1b2022-11-03 13:47:49 -0500178 expected_endlines.append("pinentry-1.2.1")
179 expected_endlines.append("PACKAGECONFIG ncurses")
Brad Bishop1d80a2e2019-11-15 16:35:03 -0500180 expected_endlines.append("PACKAGECONFIG[qt] --enable-pinentry-qt, --disable-pinentry-qt, qtbase-native qtbase")
181 expected_endlines.append("PACKAGECONFIG[gtk2] --enable-pinentry-gtk2, --disable-pinentry-gtk2, gtk+ glib-2.0")
Brad Bishop1d80a2e2019-11-15 16:35:03 -0500182 expected_endlines.append("PACKAGECONFIG[ncurses] --enable-ncurses --with-ncurses-include-dir=${STAGING_INCDIR}, --disable-ncurses, ncurses")
183 expected_endlines.append("PACKAGECONFIG[secret] --enable-libsecret, --disable-libsecret, libsecret")
184
185 self.check_endlines(results, expected_endlines)
186
Andrew Geissler475cb722020-07-10 16:00:51 -0500187 def test_packageconfig_flags_options_preferred_only(self):
Brad Bishop1d80a2e2019-11-15 16:35:03 -0500188 results = runCmd('%s/contrib/list-packageconfig-flags.py -p' % self.scripts_dir)
189 expected_endlines = []
190 expected_endlines.append("RECIPE NAME PACKAGECONFIG FLAGS")
Patrick Williams2390b1b2022-11-03 13:47:49 -0500191 expected_endlines.append("pinentry gtk2 ncurses qt secret")
Brad Bishop1d80a2e2019-11-15 16:35:03 -0500192
193 self.check_endlines(results, expected_endlines)
194