196ff1984SBrad Bishop# 296ff1984SBrad Bishop# BitBake Tests for runqueue task processing 396ff1984SBrad Bishop# 496ff1984SBrad Bishop# Copyright (C) 2019 Richard Purdie 596ff1984SBrad Bishop# 696ff1984SBrad Bishop# SPDX-License-Identifier: GPL-2.0-only 796ff1984SBrad Bishop# 896ff1984SBrad Bishop 996ff1984SBrad Bishopimport unittest 1096ff1984SBrad Bishopimport bb 1196ff1984SBrad Bishopimport os 1296ff1984SBrad Bishopimport tempfile 1396ff1984SBrad Bishopimport subprocess 14*a34c030eSBrad Bishopimport sys 1596ff1984SBrad Bishop 1696ff1984SBrad Bishop# 1796ff1984SBrad Bishop# TODO: 1896ff1984SBrad Bishop# Add tests on task ordering (X happens before Y after Z) 1996ff1984SBrad Bishop# 2096ff1984SBrad Bishop 2196ff1984SBrad Bishopclass RunQueueTests(unittest.TestCase): 2296ff1984SBrad Bishop 2396ff1984SBrad Bishop alltasks = ['package', 'fetch', 'unpack', 'patch', 'prepare_recipe_sysroot', 'configure', 2496ff1984SBrad Bishop 'compile', 'install', 'packagedata', 'package_qa', 'package_write_rpm', 'package_write_ipk', 2596ff1984SBrad Bishop 'populate_sysroot', 'build'] 2696ff1984SBrad Bishop 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" 2796ff1984SBrad Bishop 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" 2896ff1984SBrad Bishop 2908902b01SBrad Bishop def run_bitbakecmd(self, cmd, builddir, sstatevalid="", slowtasks="", extraenv=None, cleanup=False): 3096ff1984SBrad Bishop env = os.environ.copy() 3196ff1984SBrad Bishop env["BBPATH"] = os.path.realpath(os.path.join(os.path.dirname(__file__), "runqueue-tests")) 3296ff1984SBrad Bishop env["BB_ENV_EXTRAWHITE"] = "SSTATEVALID SLOWTASKS" 3396ff1984SBrad Bishop env["SSTATEVALID"] = sstatevalid 3496ff1984SBrad Bishop env["SLOWTASKS"] = slowtasks 3596ff1984SBrad Bishop if extraenv: 3696ff1984SBrad Bishop for k in extraenv: 3796ff1984SBrad Bishop env[k] = extraenv[k] 3896ff1984SBrad Bishop env["BB_ENV_EXTRAWHITE"] = env["BB_ENV_EXTRAWHITE"] + " " + k 3996ff1984SBrad Bishop try: 4096ff1984SBrad Bishop output = subprocess.check_output(cmd, env=env, stderr=subprocess.STDOUT,universal_newlines=True, cwd=builddir) 4108902b01SBrad Bishop print(output) 4296ff1984SBrad Bishop except subprocess.CalledProcessError as e: 4396ff1984SBrad Bishop self.fail("Command %s failed with %s" % (cmd, e.output)) 4496ff1984SBrad Bishop tasks = [] 4508902b01SBrad Bishop tasklog = builddir + "/task.log" 4608902b01SBrad Bishop if os.path.exists(tasklog): 4708902b01SBrad Bishop with open(tasklog, "r") as f: 4896ff1984SBrad Bishop tasks = [line.rstrip() for line in f] 4908902b01SBrad Bishop if cleanup: 5008902b01SBrad Bishop os.remove(tasklog) 5196ff1984SBrad Bishop return tasks 5296ff1984SBrad Bishop 5396ff1984SBrad Bishop def test_no_setscenevalid(self): 5496ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 5596ff1984SBrad Bishop cmd = ["bitbake", "a1"] 5696ff1984SBrad Bishop sstatevalid = "" 5796ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 5896ff1984SBrad Bishop expected = ['a1:' + x for x in self.alltasks] 5996ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 6096ff1984SBrad Bishop 6196ff1984SBrad Bishop def test_single_setscenevalid(self): 6296ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 6396ff1984SBrad Bishop cmd = ["bitbake", "a1"] 6496ff1984SBrad Bishop sstatevalid = "a1:do_package" 6596ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 6696ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 6796ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk', 6896ff1984SBrad Bishop 'a1:populate_sysroot', 'a1:build'] 6996ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 7096ff1984SBrad Bishop 7196ff1984SBrad Bishop def test_intermediate_setscenevalid(self): 7296ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 7396ff1984SBrad Bishop cmd = ["bitbake", "a1"] 7496ff1984SBrad Bishop sstatevalid = "a1:do_package a1:do_populate_sysroot" 7596ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 7696ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk', 7796ff1984SBrad Bishop 'a1:populate_sysroot_setscene', 'a1:build'] 7896ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 7996ff1984SBrad Bishop 8096ff1984SBrad Bishop def test_intermediate_notcovered(self): 8196ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 8296ff1984SBrad Bishop cmd = ["bitbake", "a1"] 8396ff1984SBrad Bishop 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" 8496ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 8596ff1984SBrad Bishop expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 8696ff1984SBrad Bishop 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene'] 8796ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 8896ff1984SBrad Bishop 8996ff1984SBrad Bishop def test_all_setscenevalid(self): 9096ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 9196ff1984SBrad Bishop cmd = ["bitbake", "a1"] 9296ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 9396ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 9496ff1984SBrad Bishop expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 9596ff1984SBrad Bishop 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene'] 9696ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 9796ff1984SBrad Bishop 9896ff1984SBrad Bishop def test_no_settasks(self): 9996ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 10096ff1984SBrad Bishop cmd = ["bitbake", "a1", "-c", "patch"] 10196ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 10296ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 10396ff1984SBrad Bishop expected = ['a1:fetch', 'a1:unpack', 'a1:patch'] 10496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 10596ff1984SBrad Bishop 10696ff1984SBrad Bishop def test_mix_covered_notcovered(self): 10796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 10896ff1984SBrad Bishop cmd = ["bitbake", "a1:do_patch", "a1:do_populate_sysroot"] 10996ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 11096ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 11196ff1984SBrad Bishop expected = ['a1:fetch', 'a1:unpack', 'a1:patch', 'a1:populate_sysroot_setscene'] 11296ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 11396ff1984SBrad Bishop 11496ff1984SBrad Bishop 11596ff1984SBrad Bishop # Test targets with intermediate setscene tasks alongside a target with no intermediate setscene tasks 11696ff1984SBrad Bishop def test_mixed_direct_tasks_setscene_tasks(self): 11796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 11896ff1984SBrad Bishop cmd = ["bitbake", "c1:do_patch", "a1"] 11996ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 12096ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 12196ff1984SBrad Bishop expected = ['c1:fetch', 'c1:unpack', 'c1:patch', 'a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 12296ff1984SBrad Bishop 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene'] 12396ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 12496ff1984SBrad Bishop 12596ff1984SBrad Bishop # This test slows down the execution of do_package_setscene until after other real tasks have 12696ff1984SBrad Bishop # started running which tests for a bug where tasks were being lost from the buildable list of real 12796ff1984SBrad Bishop # tasks if they weren't in tasks_covered or tasks_notcovered 12896ff1984SBrad Bishop def test_slow_setscene(self): 12996ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 13096ff1984SBrad Bishop cmd = ["bitbake", "a1"] 13196ff1984SBrad Bishop sstatevalid = "a1:do_package" 13296ff1984SBrad Bishop slowtasks = "a1:package_setscene" 13396ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, slowtasks) 13496ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 13596ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk', 13696ff1984SBrad Bishop 'a1:populate_sysroot', 'a1:build'] 13796ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 13896ff1984SBrad Bishop 13996ff1984SBrad Bishop def test_setscenewhitelist(self): 14096ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 14196ff1984SBrad Bishop cmd = ["bitbake", "a1"] 14296ff1984SBrad Bishop extraenv = { 14396ff1984SBrad Bishop "BB_SETSCENE_ENFORCE" : "1", 14496ff1984SBrad Bishop "BB_SETSCENE_ENFORCE_WHITELIST" : "a1:do_package_write_rpm a1:do_build" 14596ff1984SBrad Bishop } 14696ff1984SBrad Bishop sstatevalid = "a1:do_package a1:do_package_qa a1:do_packagedata a1:do_package_write_ipk a1:do_populate_lic a1:do_populate_sysroot" 14796ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv) 14896ff1984SBrad Bishop expected = ['a1:packagedata_setscene', 'a1:package_qa_setscene', 'a1:package_write_ipk_setscene', 14996ff1984SBrad Bishop 'a1:populate_sysroot_setscene', 'a1:package_setscene'] 15096ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 15196ff1984SBrad Bishop 15296ff1984SBrad Bishop # Tests for problems with dependencies between setscene tasks 15396ff1984SBrad Bishop def test_no_setscenevalid_harddeps(self): 15496ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 15596ff1984SBrad Bishop cmd = ["bitbake", "d1"] 15696ff1984SBrad Bishop sstatevalid = "" 15796ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 15896ff1984SBrad Bishop expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 15996ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 16096ff1984SBrad Bishop 'a1:populate_sysroot', 'd1:package', 'd1:fetch', 'd1:unpack', 'd1:patch', 'd1:prepare_recipe_sysroot', 'd1:configure', 16196ff1984SBrad Bishop 'd1:compile', 'd1:install', 'd1:packagedata', 'd1:package_qa', 'd1:package_write_rpm', 'd1:package_write_ipk', 16296ff1984SBrad Bishop 'd1:populate_sysroot', 'd1:build'] 16396ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 16496ff1984SBrad Bishop 16596ff1984SBrad Bishop def test_no_setscenevalid_withdeps(self): 16696ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 16796ff1984SBrad Bishop cmd = ["bitbake", "b1"] 16896ff1984SBrad Bishop sstatevalid = "" 16996ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 17096ff1984SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] 17196ff1984SBrad Bishop expected.remove('a1:build') 17296ff1984SBrad Bishop expected.remove('a1:package_qa') 17396ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 17496ff1984SBrad Bishop 17596ff1984SBrad Bishop def test_single_a1_setscenevalid_withdeps(self): 17696ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 17796ff1984SBrad Bishop cmd = ["bitbake", "b1"] 17896ff1984SBrad Bishop sstatevalid = "a1:do_package" 17996ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 18096ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 18196ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 18296ff1984SBrad Bishop 'a1:populate_sysroot'] + ['b1:' + x for x in self.alltasks] 18396ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 18496ff1984SBrad Bishop 18596ff1984SBrad Bishop def test_single_b1_setscenevalid_withdeps(self): 18696ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 18796ff1984SBrad Bishop cmd = ["bitbake", "b1"] 18896ff1984SBrad Bishop sstatevalid = "b1:do_package" 18996ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 19096ff1984SBrad Bishop expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 19196ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 19296ff1984SBrad Bishop 'a1:populate_sysroot', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks] 19396ff1984SBrad Bishop expected.remove('b1:package') 19496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 19596ff1984SBrad Bishop 19696ff1984SBrad Bishop def test_intermediate_setscenevalid_withdeps(self): 19796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 19896ff1984SBrad Bishop cmd = ["bitbake", "b1"] 19996ff1984SBrad Bishop sstatevalid = "a1:do_package a1:do_populate_sysroot b1:do_package" 20096ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 20196ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 20296ff1984SBrad Bishop 'a1:populate_sysroot_setscene', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks] 20396ff1984SBrad Bishop expected.remove('b1:package') 20496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 20596ff1984SBrad Bishop 20696ff1984SBrad Bishop def test_all_setscenevalid_withdeps(self): 20796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 20896ff1984SBrad Bishop cmd = ["bitbake", "b1"] 20996ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid + " " + self.b1_sstatevalid 21096ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 21196ff1984SBrad Bishop expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 21296ff1984SBrad Bishop 'b1:build', 'a1:populate_sysroot_setscene', 'b1:package_write_ipk_setscene', 'b1:package_write_rpm_setscene', 21396ff1984SBrad Bishop 'b1:packagedata_setscene', 'b1:package_qa_setscene', 'b1:populate_sysroot_setscene'] 21496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 21596ff1984SBrad Bishop 21696ff1984SBrad Bishop def test_multiconfig_setscene_optimise(self): 21796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 21896ff1984SBrad Bishop extraenv = { 21996ff1984SBrad Bishop "BBMULTICONFIG" : "mc1 mc2", 22096ff1984SBrad Bishop "BB_SIGNATURE_HANDLER" : "basic" 22196ff1984SBrad Bishop } 22296ff1984SBrad Bishop cmd = ["bitbake", "b1", "mc:mc1:b1", "mc:mc2:b1"] 22396ff1984SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 22496ff1984SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 22596ff1984SBrad Bishop sstatevalid = "" 22696ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv) 22796ff1984SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + \ 22896ff1984SBrad Bishop ['mc1:b1:' + x for x in setscenetasks] + ['mc1:a1:' + x for x in setscenetasks] + \ 22996ff1984SBrad Bishop ['mc2:b1:' + x for x in setscenetasks] + ['mc2:a1:' + x for x in setscenetasks] + \ 23096ff1984SBrad Bishop ['mc1:b1:build', 'mc2:b1:build'] 23196ff1984SBrad Bishop for x in ['mc1:a1:package_qa_setscene', 'mc2:a1:package_qa_setscene', 'a1:build', 'a1:package_qa']: 23296ff1984SBrad Bishop expected.remove(x) 23396ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 23496ff1984SBrad Bishop 23508902b01SBrad Bishop 236*a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 23708902b01SBrad Bishop def test_hashserv_single(self): 23808902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 23908902b01SBrad Bishop extraenv = { 240*a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 24108902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 24208902b01SBrad Bishop } 24308902b01SBrad Bishop cmd = ["bitbake", "a1", "b1"] 24408902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 24508902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 24608902b01SBrad Bishop sstatevalid = "" 24708902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 24808902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] 24908902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 25008902b01SBrad Bishop cmd = ["bitbake", "a1", "-c", "install", "-f"] 25108902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 25208902b01SBrad Bishop expected = ['a1:install'] 25308902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 25408902b01SBrad Bishop cmd = ["bitbake", "a1", "b1"] 25508902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 25608902b01SBrad Bishop expected = ['a1:populate_sysroot', 'a1:package', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 25708902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'a1:package_qa_setscene'] 25808902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 25908902b01SBrad Bishop 260*a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 26108902b01SBrad Bishop def test_hashserv_double(self): 26208902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 26308902b01SBrad Bishop extraenv = { 264*a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 26508902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 26608902b01SBrad Bishop } 26708902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "e1"] 26808902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 26908902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 27008902b01SBrad Bishop sstatevalid = "" 27108902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 27208902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks] 27308902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 27408902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"] 27508902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 27608902b01SBrad Bishop cmd = ["bitbake", "e1"] 27708902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 27808902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 27908902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 28008902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene'] 28108902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 28208902b01SBrad Bishop 28308902b01SBrad Bishop 284*a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 28508902b01SBrad Bishop def test_hashserv_multiple_setscene(self): 28608902b01SBrad Bishop # Runs e1:do_package_setscene twice 28708902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 28808902b01SBrad Bishop extraenv = { 289*a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 29008902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 29108902b01SBrad Bishop } 29208902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "e1"] 29308902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 29408902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 29508902b01SBrad Bishop sstatevalid = "" 29608902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 29708902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks] 29808902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 29908902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"] 30008902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 30108902b01SBrad Bishop cmd = ["bitbake", "e1"] 30208902b01SBrad Bishop sstatevalid = "e1:do_package" 30308902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True, slowtasks="a1:populate_sysroot b1:populate_sysroot") 30408902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 30508902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 30608902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene', 30708902b01SBrad Bishop 'e1:package_setscene'] 30808902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 30908902b01SBrad Bishop for i in expected: 31008902b01SBrad Bishop if i in ["e1:package_setscene"]: 31108902b01SBrad Bishop self.assertEqual(tasks.count(i), 4, "%s not in task list four times" % i) 31208902b01SBrad Bishop else: 31308902b01SBrad Bishop self.assertEqual(tasks.count(i), 1, "%s not in task list once" % i) 31408902b01SBrad Bishop 315*a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 31608902b01SBrad Bishop def test_hashserv_partial_match(self): 31708902b01SBrad Bishop # e1:do_package matches initial built but not second hash value 31808902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 31908902b01SBrad Bishop extraenv = { 320*a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 32108902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 32208902b01SBrad Bishop } 32308902b01SBrad Bishop cmd = ["bitbake", "a1", "b1"] 32408902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 32508902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 32608902b01SBrad Bishop sstatevalid = "" 32708902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 32808902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] 32908902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 33008902b01SBrad Bishop with open(tempdir + "/stamps/a1.do_install.taint", "w") as f: 33108902b01SBrad Bishop f.write("d460a29e-903f-4b76-a96b-3bcc22a65994") 33208902b01SBrad Bishop with open(tempdir + "/stamps/b1.do_install.taint", "w") as f: 33308902b01SBrad Bishop f.write("ed36d46a-2977-458a-b3de-eef885bc1817") 33408902b01SBrad Bishop cmd = ["bitbake", "e1"] 33508902b01SBrad Bishop sstatevalid = "e1:do_package:685e69a026b2f029483fdefe6a11e1e06641dd2a0f6f86e27b9b550f8f21229d" 33608902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 33708902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 33808902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 33908902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene', 34008902b01SBrad Bishop 'e1:package_setscene'] + ['e1:' + x for x in self.alltasks] 34108902b01SBrad Bishop expected.remove('e1:package') 34208902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 34308902b01SBrad Bishop 344*a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 34508902b01SBrad Bishop def test_hashserv_partial_match2(self): 34608902b01SBrad Bishop # e1:do_package + e1:do_populate_sysroot matches initial built but not second hash value 34708902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 34808902b01SBrad Bishop extraenv = { 349*a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 35008902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 35108902b01SBrad Bishop } 35208902b01SBrad Bishop cmd = ["bitbake", "a1", "b1"] 35308902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 35408902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 35508902b01SBrad Bishop sstatevalid = "" 35608902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 35708902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] 35808902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 35908902b01SBrad Bishop with open(tempdir + "/stamps/a1.do_install.taint", "w") as f: 36008902b01SBrad Bishop f.write("d460a29e-903f-4b76-a96b-3bcc22a65994") 36108902b01SBrad Bishop with open(tempdir + "/stamps/b1.do_install.taint", "w") as f: 36208902b01SBrad Bishop f.write("ed36d46a-2977-458a-b3de-eef885bc1817") 36308902b01SBrad Bishop cmd = ["bitbake", "e1"] 36408902b01SBrad Bishop sstatevalid = "e1:do_package:685e69a026b2f029483fdefe6a11e1e06641dd2a0f6f86e27b9b550f8f21229d e1:do_populate_sysroot:ef7dc0e2dd55d0534e75cba50731ff42f949818b6f29a65d72bc05856e56711d" 36508902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 36608902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 36708902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 36808902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene', 36908902b01SBrad Bishop 'e1:package_setscene', 'e1:populate_sysroot_setscene', 'e1:build', 'e1:package_qa', 'e1:package_write_rpm', 'e1:package_write_ipk', 'e1:packagedata'] 37008902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 37108902b01SBrad Bishop 372*a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 37308902b01SBrad Bishop def test_hashserv_partial_match3(self): 37408902b01SBrad Bishop # e1:do_package is valid for a1 but not after b1 37508902b01SBrad Bishop # In former buggy code, this triggered e1:do_fetch, then e1:do_populate_sysroot to run 37608902b01SBrad Bishop # with none of the intermediate tasks which is a serious bug 37708902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 37808902b01SBrad Bishop extraenv = { 379*a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 38008902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 38108902b01SBrad Bishop } 38208902b01SBrad Bishop cmd = ["bitbake", "a1", "b1"] 38308902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 38408902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 38508902b01SBrad Bishop sstatevalid = "" 38608902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 38708902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] 38808902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 38908902b01SBrad Bishop with open(tempdir + "/stamps/a1.do_install.taint", "w") as f: 39008902b01SBrad Bishop f.write("d460a29e-903f-4b76-a96b-3bcc22a65994") 39108902b01SBrad Bishop with open(tempdir + "/stamps/b1.do_install.taint", "w") as f: 39208902b01SBrad Bishop f.write("ed36d46a-2977-458a-b3de-eef885bc1817") 39308902b01SBrad Bishop cmd = ["bitbake", "e1", "-DD"] 39408902b01SBrad Bishop sstatevalid = "e1:do_package:af056eae12a733a6a8c4f4da8c6757e588e13565852c94e2aad4d953a3989c13 e1:do_package:a3677703db82b22d28d57c1820a47851dd780104580863f5bd32e66e003a779d" 39508902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True, slowtasks="e1:fetch b1:install") 39608902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 39708902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 39808902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene', 39908902b01SBrad Bishop 'e1:package_setscene'] + ['e1:' + x for x in self.alltasks] 40008902b01SBrad Bishop expected.remove('e1:package') 40108902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 40208902b01SBrad Bishop 40308902b01SBrad Bishop 404