blob: 061a5a1f800b2e55a71d74326e89974e951b2188 [file] [log] [blame]
Brad Bishop96ff1982019-08-19 13:50:42 -04001#
2# BitBake Tests for runqueue task processing
3#
4# Copyright (C) 2019 Richard Purdie
5#
6# SPDX-License-Identifier: GPL-2.0-only
7#
8
9import unittest
Brad Bishop96ff1982019-08-19 13:50:42 -040010import os
11import tempfile
12import subprocess
Brad Bishopa34c0302019-09-23 22:34:48 -040013import sys
Brad Bishop00e122a2019-10-05 11:10:57 -040014import time
Brad Bishop96ff1982019-08-19 13:50:42 -040015
16#
17# TODO:
18# Add tests on task ordering (X happens before Y after Z)
19#
20
21class RunQueueTests(unittest.TestCase):
22
23 alltasks = ['package', 'fetch', 'unpack', 'patch', 'prepare_recipe_sysroot', 'configure',
24 'compile', 'install', 'packagedata', 'package_qa', 'package_write_rpm', 'package_write_ipk',
25 'populate_sysroot', 'build']
26 a1_sstatevalid = "a1:do_package a1:do_package_qa a1:do_packagedata a1:do_package_write_ipk a1:do_package_write_rpm a1:do_populate_lic a1:do_populate_sysroot"
27 b1_sstatevalid = "b1:do_package b1:do_package_qa b1:do_packagedata b1:do_package_write_ipk b1:do_package_write_rpm b1:do_populate_lic b1:do_populate_sysroot"
28
Brad Bishop08902b02019-08-20 09:16:51 -040029 def run_bitbakecmd(self, cmd, builddir, sstatevalid="", slowtasks="", extraenv=None, cleanup=False):
Brad Bishop96ff1982019-08-19 13:50:42 -040030 env = os.environ.copy()
31 env["BBPATH"] = os.path.realpath(os.path.join(os.path.dirname(__file__), "runqueue-tests"))
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000032 env["BB_ENV_PASSTHROUGH_ADDITIONS"] = "SSTATEVALID SLOWTASKS TOPDIR"
Brad Bishop96ff1982019-08-19 13:50:42 -040033 env["SSTATEVALID"] = sstatevalid
34 env["SLOWTASKS"] = slowtasks
Andrew Geissler595f6302022-01-24 19:11:47 +000035 env["TOPDIR"] = builddir
Brad Bishop96ff1982019-08-19 13:50:42 -040036 if extraenv:
37 for k in extraenv:
38 env[k] = extraenv[k]
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000039 env["BB_ENV_PASSTHROUGH_ADDITIONS"] = env["BB_ENV_PASSTHROUGH_ADDITIONS"] + " " + k
Brad Bishop96ff1982019-08-19 13:50:42 -040040 try:
41 output = subprocess.check_output(cmd, env=env, stderr=subprocess.STDOUT,universal_newlines=True, cwd=builddir)
Brad Bishop08902b02019-08-20 09:16:51 -040042 print(output)
Brad Bishop96ff1982019-08-19 13:50:42 -040043 except subprocess.CalledProcessError as e:
44 self.fail("Command %s failed with %s" % (cmd, e.output))
45 tasks = []
Brad Bishop08902b02019-08-20 09:16:51 -040046 tasklog = builddir + "/task.log"
47 if os.path.exists(tasklog):
48 with open(tasklog, "r") as f:
49 tasks = [line.rstrip() for line in f]
50 if cleanup:
51 os.remove(tasklog)
Brad Bishop96ff1982019-08-19 13:50:42 -040052 return tasks
53
54 def test_no_setscenevalid(self):
55 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
56 cmd = ["bitbake", "a1"]
57 sstatevalid = ""
58 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
59 expected = ['a1:' + x for x in self.alltasks]
60 self.assertEqual(set(tasks), set(expected))
61
Andrew Geissler595f6302022-01-24 19:11:47 +000062 self.shutdown(tempdir)
63
Brad Bishop96ff1982019-08-19 13:50:42 -040064 def test_single_setscenevalid(self):
65 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
66 cmd = ["bitbake", "a1"]
67 sstatevalid = "a1:do_package"
68 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
69 expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
70 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk',
71 'a1:populate_sysroot', 'a1:build']
72 self.assertEqual(set(tasks), set(expected))
73
Andrew Geissler595f6302022-01-24 19:11:47 +000074 self.shutdown(tempdir)
75
Brad Bishop96ff1982019-08-19 13:50:42 -040076 def test_intermediate_setscenevalid(self):
77 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
78 cmd = ["bitbake", "a1"]
79 sstatevalid = "a1:do_package a1:do_populate_sysroot"
80 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
81 expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk',
82 'a1:populate_sysroot_setscene', 'a1:build']
83 self.assertEqual(set(tasks), set(expected))
84
Andrew Geissler595f6302022-01-24 19:11:47 +000085 self.shutdown(tempdir)
86
Brad Bishop96ff1982019-08-19 13:50:42 -040087 def test_intermediate_notcovered(self):
88 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
89 cmd = ["bitbake", "a1"]
90 sstatevalid = "a1:do_package_qa a1:do_packagedata a1:do_package_write_ipk a1:do_package_write_rpm a1:do_populate_lic a1:do_populate_sysroot"
91 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
92 expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
93 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene']
94 self.assertEqual(set(tasks), set(expected))
95
Andrew Geissler595f6302022-01-24 19:11:47 +000096 self.shutdown(tempdir)
97
Brad Bishop96ff1982019-08-19 13:50:42 -040098 def test_all_setscenevalid(self):
99 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
100 cmd = ["bitbake", "a1"]
101 sstatevalid = self.a1_sstatevalid
102 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
103 expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
104 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene']
105 self.assertEqual(set(tasks), set(expected))
106
Andrew Geissler595f6302022-01-24 19:11:47 +0000107 self.shutdown(tempdir)
108
Brad Bishop96ff1982019-08-19 13:50:42 -0400109 def test_no_settasks(self):
110 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
111 cmd = ["bitbake", "a1", "-c", "patch"]
112 sstatevalid = self.a1_sstatevalid
113 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
114 expected = ['a1:fetch', 'a1:unpack', 'a1:patch']
115 self.assertEqual(set(tasks), set(expected))
116
Andrew Geissler595f6302022-01-24 19:11:47 +0000117 self.shutdown(tempdir)
118
Brad Bishop96ff1982019-08-19 13:50:42 -0400119 def test_mix_covered_notcovered(self):
120 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
121 cmd = ["bitbake", "a1:do_patch", "a1:do_populate_sysroot"]
122 sstatevalid = self.a1_sstatevalid
123 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
124 expected = ['a1:fetch', 'a1:unpack', 'a1:patch', 'a1:populate_sysroot_setscene']
125 self.assertEqual(set(tasks), set(expected))
126
Andrew Geissler595f6302022-01-24 19:11:47 +0000127 self.shutdown(tempdir)
Brad Bishop96ff1982019-08-19 13:50:42 -0400128
129 # Test targets with intermediate setscene tasks alongside a target with no intermediate setscene tasks
130 def test_mixed_direct_tasks_setscene_tasks(self):
131 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
132 cmd = ["bitbake", "c1:do_patch", "a1"]
133 sstatevalid = self.a1_sstatevalid
134 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
135 expected = ['c1:fetch', 'c1:unpack', 'c1:patch', 'a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
136 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene']
137 self.assertEqual(set(tasks), set(expected))
138
Andrew Geissler595f6302022-01-24 19:11:47 +0000139 self.shutdown(tempdir)
140
Brad Bishop96ff1982019-08-19 13:50:42 -0400141 # This test slows down the execution of do_package_setscene until after other real tasks have
142 # started running which tests for a bug where tasks were being lost from the buildable list of real
143 # tasks if they weren't in tasks_covered or tasks_notcovered
144 def test_slow_setscene(self):
145 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
146 cmd = ["bitbake", "a1"]
147 sstatevalid = "a1:do_package"
148 slowtasks = "a1:package_setscene"
149 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, slowtasks)
150 expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
151 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk',
152 'a1:populate_sysroot', 'a1:build']
153 self.assertEqual(set(tasks), set(expected))
154
Andrew Geissler595f6302022-01-24 19:11:47 +0000155 self.shutdown(tempdir)
156
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000157 def test_setscene_ignore_tasks(self):
Brad Bishop96ff1982019-08-19 13:50:42 -0400158 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
159 cmd = ["bitbake", "a1"]
160 extraenv = {
161 "BB_SETSCENE_ENFORCE" : "1",
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000162 "BB_SETSCENE_ENFORCE_IGNORE_TASKS" : "a1:do_package_write_rpm a1:do_build"
Brad Bishop96ff1982019-08-19 13:50:42 -0400163 }
164 sstatevalid = "a1:do_package a1:do_package_qa a1:do_packagedata a1:do_package_write_ipk a1:do_populate_lic a1:do_populate_sysroot"
165 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv)
166 expected = ['a1:packagedata_setscene', 'a1:package_qa_setscene', 'a1:package_write_ipk_setscene',
167 'a1:populate_sysroot_setscene', 'a1:package_setscene']
168 self.assertEqual(set(tasks), set(expected))
169
Andrew Geissler595f6302022-01-24 19:11:47 +0000170 self.shutdown(tempdir)
171
Brad Bishop96ff1982019-08-19 13:50:42 -0400172 # Tests for problems with dependencies between setscene tasks
173 def test_no_setscenevalid_harddeps(self):
174 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
175 cmd = ["bitbake", "d1"]
176 sstatevalid = ""
177 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
178 expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
179 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
180 'a1:populate_sysroot', 'd1:package', 'd1:fetch', 'd1:unpack', 'd1:patch', 'd1:prepare_recipe_sysroot', 'd1:configure',
181 'd1:compile', 'd1:install', 'd1:packagedata', 'd1:package_qa', 'd1:package_write_rpm', 'd1:package_write_ipk',
182 'd1:populate_sysroot', 'd1:build']
183 self.assertEqual(set(tasks), set(expected))
184
Andrew Geissler595f6302022-01-24 19:11:47 +0000185 self.shutdown(tempdir)
186
Brad Bishop96ff1982019-08-19 13:50:42 -0400187 def test_no_setscenevalid_withdeps(self):
188 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
189 cmd = ["bitbake", "b1"]
190 sstatevalid = ""
191 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
192 expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks]
193 expected.remove('a1:build')
194 expected.remove('a1:package_qa')
195 self.assertEqual(set(tasks), set(expected))
196
Andrew Geissler595f6302022-01-24 19:11:47 +0000197 self.shutdown(tempdir)
198
Brad Bishop96ff1982019-08-19 13:50:42 -0400199 def test_single_a1_setscenevalid_withdeps(self):
200 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
201 cmd = ["bitbake", "b1"]
202 sstatevalid = "a1:do_package"
203 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
204 expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
205 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
206 'a1:populate_sysroot'] + ['b1:' + x for x in self.alltasks]
207 self.assertEqual(set(tasks), set(expected))
208
Andrew Geissler595f6302022-01-24 19:11:47 +0000209 self.shutdown(tempdir)
210
Brad Bishop96ff1982019-08-19 13:50:42 -0400211 def test_single_b1_setscenevalid_withdeps(self):
212 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
213 cmd = ["bitbake", "b1"]
214 sstatevalid = "b1:do_package"
215 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
216 expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
217 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
218 'a1:populate_sysroot', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks]
219 expected.remove('b1:package')
220 self.assertEqual(set(tasks), set(expected))
221
Andrew Geissler595f6302022-01-24 19:11:47 +0000222 self.shutdown(tempdir)
223
Brad Bishop96ff1982019-08-19 13:50:42 -0400224 def test_intermediate_setscenevalid_withdeps(self):
225 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
226 cmd = ["bitbake", "b1"]
227 sstatevalid = "a1:do_package a1:do_populate_sysroot b1:do_package"
228 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
229 expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
230 'a1:populate_sysroot_setscene', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks]
231 expected.remove('b1:package')
232 self.assertEqual(set(tasks), set(expected))
233
Andrew Geissler595f6302022-01-24 19:11:47 +0000234 self.shutdown(tempdir)
235
Brad Bishop96ff1982019-08-19 13:50:42 -0400236 def test_all_setscenevalid_withdeps(self):
237 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
238 cmd = ["bitbake", "b1"]
239 sstatevalid = self.a1_sstatevalid + " " + self.b1_sstatevalid
240 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
241 expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
242 'b1:build', 'a1:populate_sysroot_setscene', 'b1:package_write_ipk_setscene', 'b1:package_write_rpm_setscene',
243 'b1:packagedata_setscene', 'b1:package_qa_setscene', 'b1:populate_sysroot_setscene']
244 self.assertEqual(set(tasks), set(expected))
245
Andrew Geissler595f6302022-01-24 19:11:47 +0000246 self.shutdown(tempdir)
247
Brad Bishop96ff1982019-08-19 13:50:42 -0400248 def test_multiconfig_setscene_optimise(self):
249 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
250 extraenv = {
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600251 "BBMULTICONFIG" : "mc-1 mc_2",
Brad Bishop96ff1982019-08-19 13:50:42 -0400252 "BB_SIGNATURE_HANDLER" : "basic"
253 }
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600254 cmd = ["bitbake", "b1", "mc:mc-1:b1", "mc:mc_2:b1"]
Brad Bishop96ff1982019-08-19 13:50:42 -0400255 setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
256 'populate_sysroot_setscene', 'package_qa_setscene']
257 sstatevalid = ""
258 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv)
259 expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + \
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600260 ['mc-1:b1:' + x for x in setscenetasks] + ['mc-1:a1:' + x for x in setscenetasks] + \
261 ['mc_2:b1:' + x for x in setscenetasks] + ['mc_2:a1:' + x for x in setscenetasks] + \
262 ['mc-1:b1:build', 'mc_2:b1:build']
263 for x in ['mc-1:a1:package_qa_setscene', 'mc_2:a1:package_qa_setscene', 'a1:build', 'a1:package_qa']:
Brad Bishop96ff1982019-08-19 13:50:42 -0400264 expected.remove(x)
265 self.assertEqual(set(tasks), set(expected))
266
Andrew Geissler595f6302022-01-24 19:11:47 +0000267 self.shutdown(tempdir)
268
Andrew Geissler5a43b432020-06-13 10:46:56 -0500269 def test_multiconfig_bbmask(self):
270 # This test validates that multiconfigs can independently mask off
271 # recipes they do not want with BBMASK. It works by having recipes
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600272 # that will fail to parse for mc-1 and mc_2, then making each multiconfig
Andrew Geissler5a43b432020-06-13 10:46:56 -0500273 # build the one that does parse. This ensures that the recipes are in
274 # each multiconfigs BBFILES, but each is masking only the one that
275 # doesn't parse
276 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
277 extraenv = {
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600278 "BBMULTICONFIG" : "mc-1 mc_2",
Andrew Geissler5a43b432020-06-13 10:46:56 -0500279 "BB_SIGNATURE_HANDLER" : "basic",
280 "EXTRA_BBFILES": "${COREBASE}/recipes/fails-mc/*.bb",
281 }
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600282 cmd = ["bitbake", "mc:mc-1:fails-mc2", "mc:mc_2:fails-mc1"]
Andrew Geissler5a43b432020-06-13 10:46:56 -0500283 self.run_bitbakecmd(cmd, tempdir, "", extraenv=extraenv)
284
Andrew Geissler595f6302022-01-24 19:11:47 +0000285 self.shutdown(tempdir)
286
Andrew Geissler5a43b432020-06-13 10:46:56 -0500287 def test_multiconfig_mcdepends(self):
288 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
289 extraenv = {
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600290 "BBMULTICONFIG" : "mc-1 mc_2",
Andrew Geissler5a43b432020-06-13 10:46:56 -0500291 "BB_SIGNATURE_HANDLER" : "TestMulticonfigDepends",
292 "EXTRA_BBFILES": "${COREBASE}/recipes/fails-mc/*.bb",
293 }
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600294 tasks = self.run_bitbakecmd(["bitbake", "mc:mc-1:f1"], tempdir, "", extraenv=extraenv, cleanup=True)
295 expected = ["mc-1:f1:%s" % t for t in self.alltasks] + \
296 ["mc_2:a1:%s" % t for t in self.alltasks]
Andrew Geissler5a43b432020-06-13 10:46:56 -0500297 self.assertEqual(set(tasks), set(expected))
298
299 # A rebuild does nothing
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600300 tasks = self.run_bitbakecmd(["bitbake", "mc:mc-1:f1"], tempdir, "", extraenv=extraenv, cleanup=True)
Andrew Geissler5a43b432020-06-13 10:46:56 -0500301 self.assertEqual(set(tasks), set())
302
303 # Test that a signature change in the dependent task causes
304 # mcdepends to rebuild
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600305 tasks = self.run_bitbakecmd(["bitbake", "mc:mc_2:a1", "-c", "compile", "-f"], tempdir, "", extraenv=extraenv, cleanup=True)
306 expected = ["mc_2:a1:compile"]
Andrew Geissler5a43b432020-06-13 10:46:56 -0500307 self.assertEqual(set(tasks), set(expected))
308
309 rerun_tasks = self.alltasks[:]
310 for x in ("fetch", "unpack", "patch", "prepare_recipe_sysroot", "configure", "compile"):
311 rerun_tasks.remove(x)
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600312 tasks = self.run_bitbakecmd(["bitbake", "mc:mc-1:f1"], tempdir, "", extraenv=extraenv, cleanup=True)
313 expected = ["mc-1:f1:%s" % t for t in rerun_tasks] + \
314 ["mc_2:a1:%s" % t for t in rerun_tasks]
Andrew Geissler5a43b432020-06-13 10:46:56 -0500315 self.assertEqual(set(tasks), set(expected))
Brad Bishop08902b02019-08-20 09:16:51 -0400316
Andrew Geissler595f6302022-01-24 19:11:47 +0000317 self.shutdown(tempdir)
318
Brad Bishop08902b02019-08-20 09:16:51 -0400319 def test_hashserv_single(self):
320 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
321 extraenv = {
Brad Bishopa34c0302019-09-23 22:34:48 -0400322 "BB_HASHSERVE" : "auto",
Brad Bishop08902b02019-08-20 09:16:51 -0400323 "BB_SIGNATURE_HANDLER" : "TestEquivHash"
324 }
325 cmd = ["bitbake", "a1", "b1"]
326 setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
327 'populate_sysroot_setscene', 'package_qa_setscene']
328 sstatevalid = ""
329 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
330 expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks]
331 self.assertEqual(set(tasks), set(expected))
332 cmd = ["bitbake", "a1", "-c", "install", "-f"]
333 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
334 expected = ['a1:install']
335 self.assertEqual(set(tasks), set(expected))
336 cmd = ["bitbake", "a1", "b1"]
337 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
338 expected = ['a1:populate_sysroot', 'a1:package', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
Andrew Geissler82c905d2020-04-13 13:39:40 -0500339 'a1:package_write_ipk_setscene', 'a1:package_qa_setscene', 'a1:build']
Brad Bishop08902b02019-08-20 09:16:51 -0400340 self.assertEqual(set(tasks), set(expected))
341
Brad Bishop00e122a2019-10-05 11:10:57 -0400342 self.shutdown(tempdir)
343
Brad Bishop08902b02019-08-20 09:16:51 -0400344 def test_hashserv_double(self):
345 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
346 extraenv = {
Brad Bishopa34c0302019-09-23 22:34:48 -0400347 "BB_HASHSERVE" : "auto",
Brad Bishop08902b02019-08-20 09:16:51 -0400348 "BB_SIGNATURE_HANDLER" : "TestEquivHash"
349 }
350 cmd = ["bitbake", "a1", "b1", "e1"]
351 setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
352 'populate_sysroot_setscene', 'package_qa_setscene']
353 sstatevalid = ""
354 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
355 expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks]
356 self.assertEqual(set(tasks), set(expected))
357 cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"]
358 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
359 cmd = ["bitbake", "e1"]
360 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
361 expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot',
362 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene',
363 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene']
364 self.assertEqual(set(tasks), set(expected))
365
Brad Bishop00e122a2019-10-05 11:10:57 -0400366 self.shutdown(tempdir)
Brad Bishop08902b02019-08-20 09:16:51 -0400367
368 def test_hashserv_multiple_setscene(self):
369 # Runs e1:do_package_setscene twice
370 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
371 extraenv = {
Brad Bishopa34c0302019-09-23 22:34:48 -0400372 "BB_HASHSERVE" : "auto",
Brad Bishop08902b02019-08-20 09:16:51 -0400373 "BB_SIGNATURE_HANDLER" : "TestEquivHash"
374 }
375 cmd = ["bitbake", "a1", "b1", "e1"]
376 setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
377 'populate_sysroot_setscene', 'package_qa_setscene']
378 sstatevalid = ""
379 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
380 expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks]
381 self.assertEqual(set(tasks), set(expected))
382 cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"]
383 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
384 cmd = ["bitbake", "e1"]
385 sstatevalid = "e1:do_package"
386 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True, slowtasks="a1:populate_sysroot b1:populate_sysroot")
387 expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot',
388 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene',
389 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene',
390 'e1:package_setscene']
391 self.assertEqual(set(tasks), set(expected))
392 for i in expected:
Brad Bishop00e122a2019-10-05 11:10:57 -0400393 self.assertEqual(tasks.count(i), 1, "%s not in task list once" % i)
Brad Bishop08902b02019-08-20 09:16:51 -0400394
Brad Bishop00e122a2019-10-05 11:10:57 -0400395 self.shutdown(tempdir)
Brad Bishop08902b02019-08-20 09:16:51 -0400396
Brad Bishop00e122a2019-10-05 11:10:57 -0400397 def shutdown(self, tempdir):
398 # Wait for the hashserve socket to disappear else we'll see races with the tempdir cleanup
Andrew Geissler595f6302022-01-24 19:11:47 +0000399 while (os.path.exists(tempdir + "/hashserve.sock") or os.path.exists(tempdir + "cache/hashserv.db-wal") or os.path.exists(tempdir + "/bitbake.lock")):
Brad Bishop00e122a2019-10-05 11:10:57 -0400400 time.sleep(0.5)
Brad Bishop08902b02019-08-20 09:16:51 -0400401