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 os 1196ff1984SBrad Bishopimport tempfile 1296ff1984SBrad Bishopimport subprocess 13a34c030eSBrad Bishopimport sys 1400e122a7SBrad Bishopimport time 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 236a34c030eSBrad 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 = { 240a34c030eSBrad 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', 257*82c905dcSAndrew Geissler 'a1:package_write_ipk_setscene', 'a1:package_qa_setscene', 'a1:build'] 25808902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 25908902b01SBrad Bishop 26000e122a7SBrad Bishop self.shutdown(tempdir) 26100e122a7SBrad Bishop 262a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 26308902b01SBrad Bishop def test_hashserv_double(self): 26408902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 26508902b01SBrad Bishop extraenv = { 266a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 26708902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 26808902b01SBrad Bishop } 26908902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "e1"] 27008902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 27108902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 27208902b01SBrad Bishop sstatevalid = "" 27308902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 27408902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks] 27508902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 27608902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"] 27708902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 27808902b01SBrad Bishop cmd = ["bitbake", "e1"] 27908902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 28008902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 28108902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 28208902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene'] 28308902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 28408902b01SBrad Bishop 28500e122a7SBrad Bishop self.shutdown(tempdir) 28608902b01SBrad Bishop 287a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 28808902b01SBrad Bishop def test_hashserv_multiple_setscene(self): 28908902b01SBrad Bishop # Runs e1:do_package_setscene twice 29008902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 29108902b01SBrad Bishop extraenv = { 292a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 29308902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 29408902b01SBrad Bishop } 29508902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "e1"] 29608902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 29708902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 29808902b01SBrad Bishop sstatevalid = "" 29908902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 30008902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks] 30108902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 30208902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"] 30308902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 30408902b01SBrad Bishop cmd = ["bitbake", "e1"] 30508902b01SBrad Bishop sstatevalid = "e1:do_package" 30608902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True, slowtasks="a1:populate_sysroot b1:populate_sysroot") 30708902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 30808902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 30908902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene', 31008902b01SBrad Bishop 'e1:package_setscene'] 31108902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 31208902b01SBrad Bishop for i in expected: 31308902b01SBrad Bishop self.assertEqual(tasks.count(i), 1, "%s not in task list once" % i) 31408902b01SBrad Bishop 31500e122a7SBrad Bishop self.shutdown(tempdir) 31608902b01SBrad Bishop 31700e122a7SBrad Bishop def shutdown(self, tempdir): 31800e122a7SBrad Bishop # Wait for the hashserve socket to disappear else we'll see races with the tempdir cleanup 31900e122a7SBrad Bishop while os.path.exists(tempdir + "/hashserve.sock"): 32000e122a7SBrad Bishop time.sleep(0.5) 32108902b01SBrad Bishop 32208902b01SBrad Bishop 323