1#
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
10import bb
11import os
12import tempfile
13import subprocess
14import sys
15
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
29    def run_bitbakecmd(self, cmd, builddir, sstatevalid="", slowtasks="", extraenv=None, cleanup=False):
30        env = os.environ.copy()
31        env["BBPATH"] = os.path.realpath(os.path.join(os.path.dirname(__file__), "runqueue-tests"))
32        env["BB_ENV_EXTRAWHITE"] = "SSTATEVALID SLOWTASKS"
33        env["SSTATEVALID"] = sstatevalid
34        env["SLOWTASKS"] = slowtasks
35        if extraenv:
36            for k in extraenv:
37                env[k] = extraenv[k]
38                env["BB_ENV_EXTRAWHITE"] = env["BB_ENV_EXTRAWHITE"] + " " + k
39        try:
40            output = subprocess.check_output(cmd, env=env, stderr=subprocess.STDOUT,universal_newlines=True, cwd=builddir)
41            print(output)
42        except subprocess.CalledProcessError as e:
43            self.fail("Command %s failed with %s" % (cmd, e.output))
44        tasks = []
45        tasklog = builddir + "/task.log"
46        if os.path.exists(tasklog):
47            with open(tasklog, "r") as f:
48                tasks = [line.rstrip() for line in f]
49            if cleanup:
50                os.remove(tasklog)
51        return tasks
52
53    def test_no_setscenevalid(self):
54        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
55            cmd = ["bitbake", "a1"]
56            sstatevalid = ""
57            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
58            expected = ['a1:' + x for x in self.alltasks]
59            self.assertEqual(set(tasks), set(expected))
60
61    def test_single_setscenevalid(self):
62        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
63            cmd = ["bitbake", "a1"]
64            sstatevalid = "a1:do_package"
65            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
66            expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
67                        'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk',
68                        'a1:populate_sysroot', 'a1:build']
69            self.assertEqual(set(tasks), set(expected))
70
71    def test_intermediate_setscenevalid(self):
72        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
73            cmd = ["bitbake", "a1"]
74            sstatevalid = "a1:do_package a1:do_populate_sysroot"
75            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
76            expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk',
77                        'a1:populate_sysroot_setscene', 'a1:build']
78            self.assertEqual(set(tasks), set(expected))
79
80    def test_intermediate_notcovered(self):
81        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
82            cmd = ["bitbake", "a1"]
83            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"
84            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
85            expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
86                        'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene']
87            self.assertEqual(set(tasks), set(expected))
88
89    def test_all_setscenevalid(self):
90        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
91            cmd = ["bitbake", "a1"]
92            sstatevalid = self.a1_sstatevalid
93            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
94            expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
95                        'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene']
96            self.assertEqual(set(tasks), set(expected))
97
98    def test_no_settasks(self):
99        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
100            cmd = ["bitbake", "a1", "-c", "patch"]
101            sstatevalid = self.a1_sstatevalid
102            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
103            expected = ['a1:fetch', 'a1:unpack', 'a1:patch']
104            self.assertEqual(set(tasks), set(expected))
105
106    def test_mix_covered_notcovered(self):
107        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
108            cmd = ["bitbake", "a1:do_patch", "a1:do_populate_sysroot"]
109            sstatevalid = self.a1_sstatevalid
110            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
111            expected = ['a1:fetch', 'a1:unpack', 'a1:patch', 'a1:populate_sysroot_setscene']
112            self.assertEqual(set(tasks), set(expected))
113
114
115    # Test targets with intermediate setscene tasks alongside a target with no intermediate setscene tasks
116    def test_mixed_direct_tasks_setscene_tasks(self):
117        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
118            cmd = ["bitbake", "c1:do_patch", "a1"]
119            sstatevalid = self.a1_sstatevalid
120            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
121            expected = ['c1:fetch', 'c1:unpack', 'c1:patch', 'a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
122                        'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene']
123            self.assertEqual(set(tasks), set(expected))
124
125    # This test slows down the execution of do_package_setscene until after other real tasks have
126    # started running which tests for a bug where tasks were being lost from the buildable list of real
127    # tasks if they weren't in tasks_covered or tasks_notcovered
128    def test_slow_setscene(self):
129        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
130            cmd = ["bitbake", "a1"]
131            sstatevalid = "a1:do_package"
132            slowtasks = "a1:package_setscene"
133            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, slowtasks)
134            expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
135                        'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk',
136                        'a1:populate_sysroot', 'a1:build']
137            self.assertEqual(set(tasks), set(expected))
138
139    def test_setscenewhitelist(self):
140        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
141            cmd = ["bitbake", "a1"]
142            extraenv = {
143                "BB_SETSCENE_ENFORCE" : "1",
144                "BB_SETSCENE_ENFORCE_WHITELIST" : "a1:do_package_write_rpm a1:do_build"
145            }
146            sstatevalid = "a1:do_package a1:do_package_qa a1:do_packagedata a1:do_package_write_ipk a1:do_populate_lic a1:do_populate_sysroot"
147            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv)
148            expected = ['a1:packagedata_setscene', 'a1:package_qa_setscene', 'a1:package_write_ipk_setscene',
149                        'a1:populate_sysroot_setscene', 'a1:package_setscene']
150            self.assertEqual(set(tasks), set(expected))
151
152    # Tests for problems with dependencies between setscene tasks
153    def test_no_setscenevalid_harddeps(self):
154        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
155            cmd = ["bitbake", "d1"]
156            sstatevalid = ""
157            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
158            expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
159                        'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
160                        'a1:populate_sysroot', 'd1:package', 'd1:fetch', 'd1:unpack', 'd1:patch', 'd1:prepare_recipe_sysroot', 'd1:configure',
161                        'd1:compile', 'd1:install', 'd1:packagedata', 'd1:package_qa', 'd1:package_write_rpm', 'd1:package_write_ipk',
162                        'd1:populate_sysroot', 'd1:build']
163            self.assertEqual(set(tasks), set(expected))
164
165    def test_no_setscenevalid_withdeps(self):
166        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
167            cmd = ["bitbake", "b1"]
168            sstatevalid = ""
169            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
170            expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks]
171            expected.remove('a1:build')
172            expected.remove('a1:package_qa')
173            self.assertEqual(set(tasks), set(expected))
174
175    def test_single_a1_setscenevalid_withdeps(self):
176        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
177            cmd = ["bitbake", "b1"]
178            sstatevalid = "a1:do_package"
179            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
180            expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
181                        'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
182                        'a1:populate_sysroot'] + ['b1:' + x for x in self.alltasks]
183            self.assertEqual(set(tasks), set(expected))
184
185    def test_single_b1_setscenevalid_withdeps(self):
186        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
187            cmd = ["bitbake", "b1"]
188            sstatevalid = "b1:do_package"
189            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
190            expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
191                        'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
192                        'a1:populate_sysroot', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks]
193            expected.remove('b1:package')
194            self.assertEqual(set(tasks), set(expected))
195
196    def test_intermediate_setscenevalid_withdeps(self):
197        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
198            cmd = ["bitbake", "b1"]
199            sstatevalid = "a1:do_package a1:do_populate_sysroot b1:do_package"
200            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
201            expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
202                        'a1:populate_sysroot_setscene', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks]
203            expected.remove('b1:package')
204            self.assertEqual(set(tasks), set(expected))
205
206    def test_all_setscenevalid_withdeps(self):
207        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
208            cmd = ["bitbake", "b1"]
209            sstatevalid = self.a1_sstatevalid + " " + self.b1_sstatevalid
210            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
211            expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
212                        'b1:build', 'a1:populate_sysroot_setscene', 'b1:package_write_ipk_setscene', 'b1:package_write_rpm_setscene',
213                        'b1:packagedata_setscene', 'b1:package_qa_setscene', 'b1:populate_sysroot_setscene']
214            self.assertEqual(set(tasks), set(expected))
215
216    def test_multiconfig_setscene_optimise(self):
217        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
218            extraenv = {
219                "BBMULTICONFIG" : "mc1 mc2",
220                "BB_SIGNATURE_HANDLER" : "basic"
221            }
222            cmd = ["bitbake", "b1", "mc:mc1:b1", "mc:mc2:b1"]
223            setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
224                             'populate_sysroot_setscene', 'package_qa_setscene']
225            sstatevalid = ""
226            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv)
227            expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + \
228                       ['mc1:b1:' + x for x in setscenetasks] + ['mc1:a1:' + x for x in setscenetasks] + \
229                       ['mc2:b1:' + x for x in setscenetasks] + ['mc2:a1:' + x for x in setscenetasks] + \
230                       ['mc1:b1:build', 'mc2:b1:build']
231            for x in ['mc1:a1:package_qa_setscene', 'mc2:a1:package_qa_setscene', 'a1:build', 'a1:package_qa']:
232                expected.remove(x)
233            self.assertEqual(set(tasks), set(expected))
234
235
236    @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required')
237    def test_hashserv_single(self):
238        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
239            extraenv = {
240                "BB_HASHSERVE" : "auto",
241                "BB_SIGNATURE_HANDLER" : "TestEquivHash"
242            }
243            cmd = ["bitbake", "a1", "b1"]
244            setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
245                             'populate_sysroot_setscene', 'package_qa_setscene']
246            sstatevalid = ""
247            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
248            expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks]
249            self.assertEqual(set(tasks), set(expected))
250            cmd = ["bitbake", "a1", "-c", "install", "-f"]
251            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
252            expected = ['a1:install']
253            self.assertEqual(set(tasks), set(expected))
254            cmd = ["bitbake", "a1", "b1"]
255            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
256            expected = ['a1:populate_sysroot', 'a1:package', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
257                        'a1:package_write_ipk_setscene', 'a1:package_qa_setscene']
258            self.assertEqual(set(tasks), set(expected))
259
260    @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required')
261    def test_hashserv_double(self):
262        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
263            extraenv = {
264                "BB_HASHSERVE" : "auto",
265                "BB_SIGNATURE_HANDLER" : "TestEquivHash"
266            }
267            cmd = ["bitbake", "a1", "b1", "e1"]
268            setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
269                             'populate_sysroot_setscene', 'package_qa_setscene']
270            sstatevalid = ""
271            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
272            expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks]
273            self.assertEqual(set(tasks), set(expected))
274            cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"]
275            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
276            cmd = ["bitbake", "e1"]
277            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
278            expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot',
279                        'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene',
280                        'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene']
281            self.assertEqual(set(tasks), set(expected))
282
283
284    @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required')
285    def test_hashserv_multiple_setscene(self):
286        # Runs e1:do_package_setscene twice
287        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
288            extraenv = {
289                "BB_HASHSERVE" : "auto",
290                "BB_SIGNATURE_HANDLER" : "TestEquivHash"
291            }
292            cmd = ["bitbake", "a1", "b1", "e1"]
293            setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
294                             'populate_sysroot_setscene', 'package_qa_setscene']
295            sstatevalid = ""
296            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
297            expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks]
298            self.assertEqual(set(tasks), set(expected))
299            cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"]
300            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
301            cmd = ["bitbake", "e1"]
302            sstatevalid = "e1:do_package"
303            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True, slowtasks="a1:populate_sysroot b1:populate_sysroot")
304            expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot',
305                        'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene',
306                        'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene',
307                        'e1:package_setscene']
308            self.assertEqual(set(tasks), set(expected))
309            for i in expected:
310                if i in ["e1:package_setscene"]:
311                    self.assertEqual(tasks.count(i), 4, "%s not in task list four times" % i)
312                else:
313                    self.assertEqual(tasks.count(i), 1, "%s not in task list once" % i)
314
315    @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required')
316    def test_hashserv_partial_match(self):
317        # e1:do_package matches initial built but not second hash value
318        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
319            extraenv = {
320                "BB_HASHSERVE" : "auto",
321                "BB_SIGNATURE_HANDLER" : "TestEquivHash"
322            }
323            cmd = ["bitbake", "a1", "b1"]
324            setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
325                             'populate_sysroot_setscene', 'package_qa_setscene']
326            sstatevalid = ""
327            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
328            expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks]
329            self.assertEqual(set(tasks), set(expected))
330            with open(tempdir + "/stamps/a1.do_install.taint", "w") as f:
331               f.write("d460a29e-903f-4b76-a96b-3bcc22a65994")
332            with open(tempdir + "/stamps/b1.do_install.taint", "w") as f:
333               f.write("ed36d46a-2977-458a-b3de-eef885bc1817")
334            cmd = ["bitbake", "e1"]
335            sstatevalid = "e1:do_package:685e69a026b2f029483fdefe6a11e1e06641dd2a0f6f86e27b9b550f8f21229d"
336            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
337            expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot',
338                        'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene',
339                        'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene',
340                        'e1:package_setscene'] + ['e1:' + x for x in self.alltasks]
341            expected.remove('e1:package')
342            self.assertEqual(set(tasks), set(expected))
343
344    @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required')
345    def test_hashserv_partial_match2(self):
346        # e1:do_package + e1:do_populate_sysroot matches initial built but not second hash value
347        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
348            extraenv = {
349                "BB_HASHSERVE" : "auto",
350                "BB_SIGNATURE_HANDLER" : "TestEquivHash"
351            }
352            cmd = ["bitbake", "a1", "b1"]
353            setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
354                             'populate_sysroot_setscene', 'package_qa_setscene']
355            sstatevalid = ""
356            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
357            expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks]
358            self.assertEqual(set(tasks), set(expected))
359            with open(tempdir + "/stamps/a1.do_install.taint", "w") as f:
360               f.write("d460a29e-903f-4b76-a96b-3bcc22a65994")
361            with open(tempdir + "/stamps/b1.do_install.taint", "w") as f:
362               f.write("ed36d46a-2977-458a-b3de-eef885bc1817")
363            cmd = ["bitbake", "e1"]
364            sstatevalid = "e1:do_package:685e69a026b2f029483fdefe6a11e1e06641dd2a0f6f86e27b9b550f8f21229d e1:do_populate_sysroot:ef7dc0e2dd55d0534e75cba50731ff42f949818b6f29a65d72bc05856e56711d"
365            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
366            expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot',
367                        'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene',
368                        'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene',
369                        'e1:package_setscene', 'e1:populate_sysroot_setscene', 'e1:build', 'e1:package_qa', 'e1:package_write_rpm', 'e1:package_write_ipk', 'e1:packagedata']
370            self.assertEqual(set(tasks), set(expected))
371
372    @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required')
373    def test_hashserv_partial_match3(self):
374        # e1:do_package is valid for a1 but not after b1
375        # In former buggy code, this triggered e1:do_fetch, then e1:do_populate_sysroot to run
376        # with none of the intermediate tasks which is a serious bug
377        with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
378            extraenv = {
379                "BB_HASHSERVE" : "auto",
380                "BB_SIGNATURE_HANDLER" : "TestEquivHash"
381            }
382            cmd = ["bitbake", "a1", "b1"]
383            setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene',
384                             'populate_sysroot_setscene', 'package_qa_setscene']
385            sstatevalid = ""
386            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True)
387            expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks]
388            self.assertEqual(set(tasks), set(expected))
389            with open(tempdir + "/stamps/a1.do_install.taint", "w") as f:
390               f.write("d460a29e-903f-4b76-a96b-3bcc22a65994")
391            with open(tempdir + "/stamps/b1.do_install.taint", "w") as f:
392               f.write("ed36d46a-2977-458a-b3de-eef885bc1817")
393            cmd = ["bitbake", "e1", "-DD"]
394            sstatevalid = "e1:do_package:af056eae12a733a6a8c4f4da8c6757e588e13565852c94e2aad4d953a3989c13 e1:do_package:a3677703db82b22d28d57c1820a47851dd780104580863f5bd32e66e003a779d"
395            tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True, slowtasks="e1:fetch b1:install")
396            expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot',
397                        'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene',
398                        'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene',
399                        'e1:package_setscene']  + ['e1:' + x for x in self.alltasks]
400            expected.remove('e1:package')
401            self.assertEqual(set(tasks), set(expected))
402
403
404