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 14a34c030eSBrad Bishopimport sys 15*00e122a7SBrad Bishopimport time 1696ff1984SBrad Bishop 1796ff1984SBrad Bishop# 1896ff1984SBrad Bishop# TODO: 1996ff1984SBrad Bishop# Add tests on task ordering (X happens before Y after Z) 2096ff1984SBrad Bishop# 2196ff1984SBrad Bishop 2296ff1984SBrad Bishopclass RunQueueTests(unittest.TestCase): 2396ff1984SBrad Bishop 2496ff1984SBrad Bishop alltasks = ['package', 'fetch', 'unpack', 'patch', 'prepare_recipe_sysroot', 'configure', 2596ff1984SBrad Bishop 'compile', 'install', 'packagedata', 'package_qa', 'package_write_rpm', 'package_write_ipk', 2696ff1984SBrad Bishop 'populate_sysroot', 'build'] 2796ff1984SBrad 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" 2896ff1984SBrad 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" 2996ff1984SBrad Bishop 3008902b01SBrad Bishop def run_bitbakecmd(self, cmd, builddir, sstatevalid="", slowtasks="", extraenv=None, cleanup=False): 3196ff1984SBrad Bishop env = os.environ.copy() 3296ff1984SBrad Bishop env["BBPATH"] = os.path.realpath(os.path.join(os.path.dirname(__file__), "runqueue-tests")) 3396ff1984SBrad Bishop env["BB_ENV_EXTRAWHITE"] = "SSTATEVALID SLOWTASKS" 3496ff1984SBrad Bishop env["SSTATEVALID"] = sstatevalid 3596ff1984SBrad Bishop env["SLOWTASKS"] = slowtasks 3696ff1984SBrad Bishop if extraenv: 3796ff1984SBrad Bishop for k in extraenv: 3896ff1984SBrad Bishop env[k] = extraenv[k] 3996ff1984SBrad Bishop env["BB_ENV_EXTRAWHITE"] = env["BB_ENV_EXTRAWHITE"] + " " + k 4096ff1984SBrad Bishop try: 4196ff1984SBrad Bishop output = subprocess.check_output(cmd, env=env, stderr=subprocess.STDOUT,universal_newlines=True, cwd=builddir) 4208902b01SBrad Bishop print(output) 4396ff1984SBrad Bishop except subprocess.CalledProcessError as e: 4496ff1984SBrad Bishop self.fail("Command %s failed with %s" % (cmd, e.output)) 4596ff1984SBrad Bishop tasks = [] 4608902b01SBrad Bishop tasklog = builddir + "/task.log" 4708902b01SBrad Bishop if os.path.exists(tasklog): 4808902b01SBrad Bishop with open(tasklog, "r") as f: 4996ff1984SBrad Bishop tasks = [line.rstrip() for line in f] 5008902b01SBrad Bishop if cleanup: 5108902b01SBrad Bishop os.remove(tasklog) 5296ff1984SBrad Bishop return tasks 5396ff1984SBrad Bishop 5496ff1984SBrad Bishop def test_no_setscenevalid(self): 5596ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 5696ff1984SBrad Bishop cmd = ["bitbake", "a1"] 5796ff1984SBrad Bishop sstatevalid = "" 5896ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 5996ff1984SBrad Bishop expected = ['a1:' + x for x in self.alltasks] 6096ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 6196ff1984SBrad Bishop 6296ff1984SBrad Bishop def test_single_setscenevalid(self): 6396ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 6496ff1984SBrad Bishop cmd = ["bitbake", "a1"] 6596ff1984SBrad Bishop sstatevalid = "a1:do_package" 6696ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 6796ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 6896ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk', 6996ff1984SBrad Bishop 'a1:populate_sysroot', 'a1:build'] 7096ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 7196ff1984SBrad Bishop 7296ff1984SBrad Bishop def test_intermediate_setscenevalid(self): 7396ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 7496ff1984SBrad Bishop cmd = ["bitbake", "a1"] 7596ff1984SBrad Bishop sstatevalid = "a1:do_package a1:do_populate_sysroot" 7696ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 7796ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk', 7896ff1984SBrad Bishop 'a1:populate_sysroot_setscene', 'a1:build'] 7996ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 8096ff1984SBrad Bishop 8196ff1984SBrad Bishop def test_intermediate_notcovered(self): 8296ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 8396ff1984SBrad Bishop cmd = ["bitbake", "a1"] 8496ff1984SBrad 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" 8596ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 8696ff1984SBrad Bishop expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 8796ff1984SBrad Bishop 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene'] 8896ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 8996ff1984SBrad Bishop 9096ff1984SBrad Bishop def test_all_setscenevalid(self): 9196ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 9296ff1984SBrad Bishop cmd = ["bitbake", "a1"] 9396ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 9496ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 9596ff1984SBrad Bishop expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 9696ff1984SBrad Bishop 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene'] 9796ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 9896ff1984SBrad Bishop 9996ff1984SBrad Bishop def test_no_settasks(self): 10096ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 10196ff1984SBrad Bishop cmd = ["bitbake", "a1", "-c", "patch"] 10296ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 10396ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 10496ff1984SBrad Bishop expected = ['a1:fetch', 'a1:unpack', 'a1:patch'] 10596ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 10696ff1984SBrad Bishop 10796ff1984SBrad Bishop def test_mix_covered_notcovered(self): 10896ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 10996ff1984SBrad Bishop cmd = ["bitbake", "a1:do_patch", "a1:do_populate_sysroot"] 11096ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 11196ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 11296ff1984SBrad Bishop expected = ['a1:fetch', 'a1:unpack', 'a1:patch', 'a1:populate_sysroot_setscene'] 11396ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 11496ff1984SBrad Bishop 11596ff1984SBrad Bishop 11696ff1984SBrad Bishop # Test targets with intermediate setscene tasks alongside a target with no intermediate setscene tasks 11796ff1984SBrad Bishop def test_mixed_direct_tasks_setscene_tasks(self): 11896ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 11996ff1984SBrad Bishop cmd = ["bitbake", "c1:do_patch", "a1"] 12096ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 12196ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 12296ff1984SBrad Bishop expected = ['c1:fetch', 'c1:unpack', 'c1:patch', 'a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 12396ff1984SBrad Bishop 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene'] 12496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 12596ff1984SBrad Bishop 12696ff1984SBrad Bishop # This test slows down the execution of do_package_setscene until after other real tasks have 12796ff1984SBrad Bishop # started running which tests for a bug where tasks were being lost from the buildable list of real 12896ff1984SBrad Bishop # tasks if they weren't in tasks_covered or tasks_notcovered 12996ff1984SBrad Bishop def test_slow_setscene(self): 13096ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 13196ff1984SBrad Bishop cmd = ["bitbake", "a1"] 13296ff1984SBrad Bishop sstatevalid = "a1:do_package" 13396ff1984SBrad Bishop slowtasks = "a1:package_setscene" 13496ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, slowtasks) 13596ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 13696ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk', 13796ff1984SBrad Bishop 'a1:populate_sysroot', 'a1:build'] 13896ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 13996ff1984SBrad Bishop 14096ff1984SBrad Bishop def test_setscenewhitelist(self): 14196ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 14296ff1984SBrad Bishop cmd = ["bitbake", "a1"] 14396ff1984SBrad Bishop extraenv = { 14496ff1984SBrad Bishop "BB_SETSCENE_ENFORCE" : "1", 14596ff1984SBrad Bishop "BB_SETSCENE_ENFORCE_WHITELIST" : "a1:do_package_write_rpm a1:do_build" 14696ff1984SBrad Bishop } 14796ff1984SBrad 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" 14896ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv) 14996ff1984SBrad Bishop expected = ['a1:packagedata_setscene', 'a1:package_qa_setscene', 'a1:package_write_ipk_setscene', 15096ff1984SBrad Bishop 'a1:populate_sysroot_setscene', 'a1:package_setscene'] 15196ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 15296ff1984SBrad Bishop 15396ff1984SBrad Bishop # Tests for problems with dependencies between setscene tasks 15496ff1984SBrad Bishop def test_no_setscenevalid_harddeps(self): 15596ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 15696ff1984SBrad Bishop cmd = ["bitbake", "d1"] 15796ff1984SBrad Bishop sstatevalid = "" 15896ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 15996ff1984SBrad Bishop expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 16096ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 16196ff1984SBrad Bishop 'a1:populate_sysroot', 'd1:package', 'd1:fetch', 'd1:unpack', 'd1:patch', 'd1:prepare_recipe_sysroot', 'd1:configure', 16296ff1984SBrad Bishop 'd1:compile', 'd1:install', 'd1:packagedata', 'd1:package_qa', 'd1:package_write_rpm', 'd1:package_write_ipk', 16396ff1984SBrad Bishop 'd1:populate_sysroot', 'd1:build'] 16496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 16596ff1984SBrad Bishop 16696ff1984SBrad Bishop def test_no_setscenevalid_withdeps(self): 16796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 16896ff1984SBrad Bishop cmd = ["bitbake", "b1"] 16996ff1984SBrad Bishop sstatevalid = "" 17096ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 17196ff1984SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] 17296ff1984SBrad Bishop expected.remove('a1:build') 17396ff1984SBrad Bishop expected.remove('a1:package_qa') 17496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 17596ff1984SBrad Bishop 17696ff1984SBrad Bishop def test_single_a1_setscenevalid_withdeps(self): 17796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 17896ff1984SBrad Bishop cmd = ["bitbake", "b1"] 17996ff1984SBrad Bishop sstatevalid = "a1:do_package" 18096ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 18196ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 18296ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 18396ff1984SBrad Bishop 'a1:populate_sysroot'] + ['b1:' + x for x in self.alltasks] 18496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 18596ff1984SBrad Bishop 18696ff1984SBrad Bishop def test_single_b1_setscenevalid_withdeps(self): 18796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 18896ff1984SBrad Bishop cmd = ["bitbake", "b1"] 18996ff1984SBrad Bishop sstatevalid = "b1:do_package" 19096ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 19196ff1984SBrad Bishop expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 19296ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 19396ff1984SBrad Bishop 'a1:populate_sysroot', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks] 19496ff1984SBrad Bishop expected.remove('b1:package') 19596ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 19696ff1984SBrad Bishop 19796ff1984SBrad Bishop def test_intermediate_setscenevalid_withdeps(self): 19896ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 19996ff1984SBrad Bishop cmd = ["bitbake", "b1"] 20096ff1984SBrad Bishop sstatevalid = "a1:do_package a1:do_populate_sysroot b1:do_package" 20196ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 20296ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 20396ff1984SBrad Bishop 'a1:populate_sysroot_setscene', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks] 20496ff1984SBrad Bishop expected.remove('b1:package') 20596ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 20696ff1984SBrad Bishop 20796ff1984SBrad Bishop def test_all_setscenevalid_withdeps(self): 20896ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 20996ff1984SBrad Bishop cmd = ["bitbake", "b1"] 21096ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid + " " + self.b1_sstatevalid 21196ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 21296ff1984SBrad Bishop expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 21396ff1984SBrad Bishop 'b1:build', 'a1:populate_sysroot_setscene', 'b1:package_write_ipk_setscene', 'b1:package_write_rpm_setscene', 21496ff1984SBrad Bishop 'b1:packagedata_setscene', 'b1:package_qa_setscene', 'b1:populate_sysroot_setscene'] 21596ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 21696ff1984SBrad Bishop 21796ff1984SBrad Bishop def test_multiconfig_setscene_optimise(self): 21896ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 21996ff1984SBrad Bishop extraenv = { 22096ff1984SBrad Bishop "BBMULTICONFIG" : "mc1 mc2", 22196ff1984SBrad Bishop "BB_SIGNATURE_HANDLER" : "basic" 22296ff1984SBrad Bishop } 22396ff1984SBrad Bishop cmd = ["bitbake", "b1", "mc:mc1:b1", "mc:mc2:b1"] 22496ff1984SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 22596ff1984SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 22696ff1984SBrad Bishop sstatevalid = "" 22796ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv) 22896ff1984SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + \ 22996ff1984SBrad Bishop ['mc1:b1:' + x for x in setscenetasks] + ['mc1:a1:' + x for x in setscenetasks] + \ 23096ff1984SBrad Bishop ['mc2:b1:' + x for x in setscenetasks] + ['mc2:a1:' + x for x in setscenetasks] + \ 23196ff1984SBrad Bishop ['mc1:b1:build', 'mc2:b1:build'] 23296ff1984SBrad Bishop for x in ['mc1:a1:package_qa_setscene', 'mc2:a1:package_qa_setscene', 'a1:build', 'a1:package_qa']: 23396ff1984SBrad Bishop expected.remove(x) 23496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 23596ff1984SBrad Bishop 23608902b01SBrad Bishop 237a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 23808902b01SBrad Bishop def test_hashserv_single(self): 23908902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 24008902b01SBrad Bishop extraenv = { 241a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 24208902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 24308902b01SBrad Bishop } 24408902b01SBrad Bishop cmd = ["bitbake", "a1", "b1"] 24508902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 24608902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 24708902b01SBrad Bishop sstatevalid = "" 24808902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 24908902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] 25008902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 25108902b01SBrad Bishop cmd = ["bitbake", "a1", "-c", "install", "-f"] 25208902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 25308902b01SBrad Bishop expected = ['a1:install'] 25408902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 25508902b01SBrad Bishop cmd = ["bitbake", "a1", "b1"] 25608902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 25708902b01SBrad Bishop expected = ['a1:populate_sysroot', 'a1:package', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 25808902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'a1:package_qa_setscene'] 25908902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 26008902b01SBrad Bishop 261*00e122a7SBrad Bishop self.shutdown(tempdir) 262*00e122a7SBrad Bishop 263a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 26408902b01SBrad Bishop def test_hashserv_double(self): 26508902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 26608902b01SBrad Bishop extraenv = { 267a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 26808902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 26908902b01SBrad Bishop } 27008902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "e1"] 27108902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 27208902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 27308902b01SBrad Bishop sstatevalid = "" 27408902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 27508902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks] 27608902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 27708902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"] 27808902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 27908902b01SBrad Bishop cmd = ["bitbake", "e1"] 28008902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 28108902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 28208902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 28308902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene'] 28408902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 28508902b01SBrad Bishop 286*00e122a7SBrad Bishop self.shutdown(tempdir) 28708902b01SBrad Bishop 288a34c030eSBrad Bishop @unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required') 28908902b01SBrad Bishop def test_hashserv_multiple_setscene(self): 29008902b01SBrad Bishop # Runs e1:do_package_setscene twice 29108902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 29208902b01SBrad Bishop extraenv = { 293a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 29408902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 29508902b01SBrad Bishop } 29608902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "e1"] 29708902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 29808902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 29908902b01SBrad Bishop sstatevalid = "" 30008902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 30108902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks] 30208902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 30308902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"] 30408902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 30508902b01SBrad Bishop cmd = ["bitbake", "e1"] 30608902b01SBrad Bishop sstatevalid = "e1:do_package" 30708902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True, slowtasks="a1:populate_sysroot b1:populate_sysroot") 30808902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 30908902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 31008902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene', 31108902b01SBrad Bishop 'e1:package_setscene'] 31208902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 31308902b01SBrad Bishop for i in expected: 31408902b01SBrad Bishop self.assertEqual(tasks.count(i), 1, "%s not in task list once" % i) 31508902b01SBrad Bishop 316*00e122a7SBrad Bishop self.shutdown(tempdir) 31708902b01SBrad Bishop 318*00e122a7SBrad Bishop def shutdown(self, tempdir): 319*00e122a7SBrad Bishop # Wait for the hashserve socket to disappear else we'll see races with the tempdir cleanup 320*00e122a7SBrad Bishop while os.path.exists(tempdir + "/hashserve.sock"): 321*00e122a7SBrad Bishop time.sleep(0.5) 32208902b01SBrad Bishop 32308902b01SBrad Bishop 324