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")) 327e0e3c0cSAndrew Geissler env["BB_ENV_PASSTHROUGH_ADDITIONS"] = "SSTATEVALID SLOWTASKS TOPDIR" 3396ff1984SBrad Bishop env["SSTATEVALID"] = sstatevalid 3496ff1984SBrad Bishop env["SLOWTASKS"] = slowtasks 35595f6308SAndrew Geissler env["TOPDIR"] = builddir 3696ff1984SBrad Bishop if extraenv: 3796ff1984SBrad Bishop for k in extraenv: 3896ff1984SBrad Bishop env[k] = extraenv[k] 397e0e3c0cSAndrew Geissler env["BB_ENV_PASSTHROUGH_ADDITIONS"] = env["BB_ENV_PASSTHROUGH_ADDITIONS"] + " " + 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 62595f6308SAndrew Geissler self.shutdown(tempdir) 63595f6308SAndrew Geissler 6496ff1984SBrad Bishop def test_single_setscenevalid(self): 6596ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 6696ff1984SBrad Bishop cmd = ["bitbake", "a1"] 6796ff1984SBrad Bishop sstatevalid = "a1:do_package" 6896ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 6996ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 7096ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk', 7196ff1984SBrad Bishop 'a1:populate_sysroot', 'a1:build'] 7296ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 7396ff1984SBrad Bishop 74595f6308SAndrew Geissler self.shutdown(tempdir) 75595f6308SAndrew Geissler 7696ff1984SBrad Bishop def test_intermediate_setscenevalid(self): 7796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 7896ff1984SBrad Bishop cmd = ["bitbake", "a1"] 7996ff1984SBrad Bishop sstatevalid = "a1:do_package a1:do_populate_sysroot" 8096ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 8196ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk', 8296ff1984SBrad Bishop 'a1:populate_sysroot_setscene', 'a1:build'] 8396ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 8496ff1984SBrad Bishop 85595f6308SAndrew Geissler self.shutdown(tempdir) 86595f6308SAndrew Geissler 8796ff1984SBrad Bishop def test_intermediate_notcovered(self): 8896ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 8996ff1984SBrad Bishop cmd = ["bitbake", "a1"] 9096ff1984SBrad 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" 9196ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 9296ff1984SBrad Bishop expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 9396ff1984SBrad Bishop 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene'] 9496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 9596ff1984SBrad Bishop 96595f6308SAndrew Geissler self.shutdown(tempdir) 97595f6308SAndrew Geissler 9896ff1984SBrad Bishop def test_all_setscenevalid(self): 9996ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 10096ff1984SBrad Bishop cmd = ["bitbake", "a1"] 10196ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 10296ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 10396ff1984SBrad Bishop expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 10496ff1984SBrad Bishop 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene'] 10596ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 10696ff1984SBrad Bishop 107595f6308SAndrew Geissler self.shutdown(tempdir) 108595f6308SAndrew Geissler 10996ff1984SBrad Bishop def test_no_settasks(self): 11096ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 11196ff1984SBrad Bishop cmd = ["bitbake", "a1", "-c", "patch"] 11296ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 11396ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 11496ff1984SBrad Bishop expected = ['a1:fetch', 'a1:unpack', 'a1:patch'] 11596ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 11696ff1984SBrad Bishop 117595f6308SAndrew Geissler self.shutdown(tempdir) 118595f6308SAndrew Geissler 11996ff1984SBrad Bishop def test_mix_covered_notcovered(self): 12096ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 12196ff1984SBrad Bishop cmd = ["bitbake", "a1:do_patch", "a1:do_populate_sysroot"] 12296ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 12396ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 12496ff1984SBrad Bishop expected = ['a1:fetch', 'a1:unpack', 'a1:patch', 'a1:populate_sysroot_setscene'] 12596ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 12696ff1984SBrad Bishop 127595f6308SAndrew Geissler self.shutdown(tempdir) 12896ff1984SBrad Bishop 12996ff1984SBrad Bishop # Test targets with intermediate setscene tasks alongside a target with no intermediate setscene tasks 13096ff1984SBrad Bishop def test_mixed_direct_tasks_setscene_tasks(self): 13196ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 13296ff1984SBrad Bishop cmd = ["bitbake", "c1:do_patch", "a1"] 13396ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid 13496ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 13596ff1984SBrad Bishop expected = ['c1:fetch', 'c1:unpack', 'c1:patch', 'a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 13696ff1984SBrad Bishop 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene'] 13796ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 13896ff1984SBrad Bishop 139595f6308SAndrew Geissler self.shutdown(tempdir) 140595f6308SAndrew Geissler 14196ff1984SBrad Bishop # This test slows down the execution of do_package_setscene until after other real tasks have 14296ff1984SBrad Bishop # started running which tests for a bug where tasks were being lost from the buildable list of real 14396ff1984SBrad Bishop # tasks if they weren't in tasks_covered or tasks_notcovered 14496ff1984SBrad Bishop def test_slow_setscene(self): 14596ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 14696ff1984SBrad Bishop cmd = ["bitbake", "a1"] 14796ff1984SBrad Bishop sstatevalid = "a1:do_package" 14896ff1984SBrad Bishop slowtasks = "a1:package_setscene" 14996ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, slowtasks) 15096ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 15196ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk', 15296ff1984SBrad Bishop 'a1:populate_sysroot', 'a1:build'] 15396ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 15496ff1984SBrad Bishop 155595f6308SAndrew Geissler self.shutdown(tempdir) 156595f6308SAndrew Geissler 1577e0e3c0cSAndrew Geissler def test_setscene_ignore_tasks(self): 15896ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 15996ff1984SBrad Bishop cmd = ["bitbake", "a1"] 16096ff1984SBrad Bishop extraenv = { 16196ff1984SBrad Bishop "BB_SETSCENE_ENFORCE" : "1", 1627e0e3c0cSAndrew Geissler "BB_SETSCENE_ENFORCE_IGNORE_TASKS" : "a1:do_package_write_rpm a1:do_build" 16396ff1984SBrad Bishop } 16496ff1984SBrad 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" 16596ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv) 16696ff1984SBrad Bishop expected = ['a1:packagedata_setscene', 'a1:package_qa_setscene', 'a1:package_write_ipk_setscene', 16796ff1984SBrad Bishop 'a1:populate_sysroot_setscene', 'a1:package_setscene'] 16896ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 16996ff1984SBrad Bishop 170595f6308SAndrew Geissler self.shutdown(tempdir) 171595f6308SAndrew Geissler 17296ff1984SBrad Bishop # Tests for problems with dependencies between setscene tasks 17396ff1984SBrad Bishop def test_no_setscenevalid_harddeps(self): 17496ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 17596ff1984SBrad Bishop cmd = ["bitbake", "d1"] 17696ff1984SBrad Bishop sstatevalid = "" 17796ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 17896ff1984SBrad Bishop expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 17996ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 18096ff1984SBrad Bishop 'a1:populate_sysroot', 'd1:package', 'd1:fetch', 'd1:unpack', 'd1:patch', 'd1:prepare_recipe_sysroot', 'd1:configure', 18196ff1984SBrad Bishop 'd1:compile', 'd1:install', 'd1:packagedata', 'd1:package_qa', 'd1:package_write_rpm', 'd1:package_write_ipk', 18296ff1984SBrad Bishop 'd1:populate_sysroot', 'd1:build'] 18396ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 18496ff1984SBrad Bishop 185595f6308SAndrew Geissler self.shutdown(tempdir) 186595f6308SAndrew Geissler 18796ff1984SBrad Bishop def test_no_setscenevalid_withdeps(self): 18896ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 18996ff1984SBrad Bishop cmd = ["bitbake", "b1"] 19096ff1984SBrad Bishop sstatevalid = "" 19196ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 19296ff1984SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] 19396ff1984SBrad Bishop expected.remove('a1:build') 19496ff1984SBrad Bishop expected.remove('a1:package_qa') 19596ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 19696ff1984SBrad Bishop 197595f6308SAndrew Geissler self.shutdown(tempdir) 198595f6308SAndrew Geissler 19996ff1984SBrad Bishop def test_single_a1_setscenevalid_withdeps(self): 20096ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 20196ff1984SBrad Bishop cmd = ["bitbake", "b1"] 20296ff1984SBrad Bishop sstatevalid = "a1:do_package" 20396ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 20496ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 20596ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 20696ff1984SBrad Bishop 'a1:populate_sysroot'] + ['b1:' + x for x in self.alltasks] 20796ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 20896ff1984SBrad Bishop 209595f6308SAndrew Geissler self.shutdown(tempdir) 210595f6308SAndrew Geissler 21196ff1984SBrad Bishop def test_single_b1_setscenevalid_withdeps(self): 21296ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 21396ff1984SBrad Bishop cmd = ["bitbake", "b1"] 21496ff1984SBrad Bishop sstatevalid = "b1:do_package" 21596ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 21696ff1984SBrad Bishop expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure', 21796ff1984SBrad Bishop 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 21896ff1984SBrad Bishop 'a1:populate_sysroot', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks] 21996ff1984SBrad Bishop expected.remove('b1:package') 22096ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 22196ff1984SBrad Bishop 222595f6308SAndrew Geissler self.shutdown(tempdir) 223595f6308SAndrew Geissler 22496ff1984SBrad Bishop def test_intermediate_setscenevalid_withdeps(self): 22596ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 22696ff1984SBrad Bishop cmd = ["bitbake", "b1"] 22796ff1984SBrad Bishop sstatevalid = "a1:do_package a1:do_populate_sysroot b1:do_package" 22896ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 22996ff1984SBrad Bishop expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk', 23096ff1984SBrad Bishop 'a1:populate_sysroot_setscene', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks] 23196ff1984SBrad Bishop expected.remove('b1:package') 23296ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 23396ff1984SBrad Bishop 234595f6308SAndrew Geissler self.shutdown(tempdir) 235595f6308SAndrew Geissler 23696ff1984SBrad Bishop def test_all_setscenevalid_withdeps(self): 23796ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 23896ff1984SBrad Bishop cmd = ["bitbake", "b1"] 23996ff1984SBrad Bishop sstatevalid = self.a1_sstatevalid + " " + self.b1_sstatevalid 24096ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid) 24196ff1984SBrad Bishop expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 24296ff1984SBrad Bishop 'b1:build', 'a1:populate_sysroot_setscene', 'b1:package_write_ipk_setscene', 'b1:package_write_rpm_setscene', 24396ff1984SBrad Bishop 'b1:packagedata_setscene', 'b1:package_qa_setscene', 'b1:populate_sysroot_setscene'] 24496ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 24596ff1984SBrad Bishop 246595f6308SAndrew Geissler self.shutdown(tempdir) 247595f6308SAndrew Geissler 24896ff1984SBrad Bishop def test_multiconfig_setscene_optimise(self): 24996ff1984SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 25096ff1984SBrad Bishop extraenv = { 25190fd73cbSAndrew Geissler "BBMULTICONFIG" : "mc-1 mc_2", 25296ff1984SBrad Bishop "BB_SIGNATURE_HANDLER" : "basic" 25396ff1984SBrad Bishop } 25490fd73cbSAndrew Geissler cmd = ["bitbake", "b1", "mc:mc-1:b1", "mc:mc_2:b1"] 25596ff1984SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 25696ff1984SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 25796ff1984SBrad Bishop sstatevalid = "" 25896ff1984SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv) 25996ff1984SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + \ 26090fd73cbSAndrew Geissler ['mc-1:b1:' + x for x in setscenetasks] + ['mc-1:a1:' + x for x in setscenetasks] + \ 26190fd73cbSAndrew Geissler ['mc_2:b1:' + x for x in setscenetasks] + ['mc_2:a1:' + x for x in setscenetasks] + \ 26290fd73cbSAndrew Geissler ['mc-1:b1:build', 'mc_2:b1:build'] 26390fd73cbSAndrew Geissler for x in ['mc-1:a1:package_qa_setscene', 'mc_2:a1:package_qa_setscene', 'a1:build', 'a1:package_qa']: 26496ff1984SBrad Bishop expected.remove(x) 26596ff1984SBrad Bishop self.assertEqual(set(tasks), set(expected)) 26696ff1984SBrad Bishop 267595f6308SAndrew Geissler self.shutdown(tempdir) 268595f6308SAndrew Geissler 2695a43b434SAndrew Geissler def test_multiconfig_bbmask(self): 2705a43b434SAndrew Geissler # This test validates that multiconfigs can independently mask off 2715a43b434SAndrew Geissler # recipes they do not want with BBMASK. It works by having recipes 27290fd73cbSAndrew Geissler # that will fail to parse for mc-1 and mc_2, then making each multiconfig 2735a43b434SAndrew Geissler # build the one that does parse. This ensures that the recipes are in 2745a43b434SAndrew Geissler # each multiconfigs BBFILES, but each is masking only the one that 2755a43b434SAndrew Geissler # doesn't parse 2765a43b434SAndrew Geissler with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 2775a43b434SAndrew Geissler extraenv = { 27890fd73cbSAndrew Geissler "BBMULTICONFIG" : "mc-1 mc_2", 2795a43b434SAndrew Geissler "BB_SIGNATURE_HANDLER" : "basic", 2805a43b434SAndrew Geissler "EXTRA_BBFILES": "${COREBASE}/recipes/fails-mc/*.bb", 2815a43b434SAndrew Geissler } 28290fd73cbSAndrew Geissler cmd = ["bitbake", "mc:mc-1:fails-mc2", "mc:mc_2:fails-mc1"] 2835a43b434SAndrew Geissler self.run_bitbakecmd(cmd, tempdir, "", extraenv=extraenv) 2845a43b434SAndrew Geissler 285595f6308SAndrew Geissler self.shutdown(tempdir) 286595f6308SAndrew Geissler 2875a43b434SAndrew Geissler def test_multiconfig_mcdepends(self): 2885a43b434SAndrew Geissler with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 2895a43b434SAndrew Geissler extraenv = { 29090fd73cbSAndrew Geissler "BBMULTICONFIG" : "mc-1 mc_2", 291*517393d9SAndrew Geissler "BB_SIGNATURE_HANDLER" : "basichash", 2925a43b434SAndrew Geissler "EXTRA_BBFILES": "${COREBASE}/recipes/fails-mc/*.bb", 2935a43b434SAndrew Geissler } 29490fd73cbSAndrew Geissler tasks = self.run_bitbakecmd(["bitbake", "mc:mc-1:f1"], tempdir, "", extraenv=extraenv, cleanup=True) 29590fd73cbSAndrew Geissler expected = ["mc-1:f1:%s" % t for t in self.alltasks] + \ 29690fd73cbSAndrew Geissler ["mc_2:a1:%s" % t for t in self.alltasks] 2975a43b434SAndrew Geissler self.assertEqual(set(tasks), set(expected)) 2985a43b434SAndrew Geissler 2995a43b434SAndrew Geissler # A rebuild does nothing 30090fd73cbSAndrew Geissler tasks = self.run_bitbakecmd(["bitbake", "mc:mc-1:f1"], tempdir, "", extraenv=extraenv, cleanup=True) 3015a43b434SAndrew Geissler self.assertEqual(set(tasks), set()) 3025a43b434SAndrew Geissler 3035a43b434SAndrew Geissler # Test that a signature change in the dependent task causes 3045a43b434SAndrew Geissler # mcdepends to rebuild 30590fd73cbSAndrew Geissler tasks = self.run_bitbakecmd(["bitbake", "mc:mc_2:a1", "-c", "compile", "-f"], tempdir, "", extraenv=extraenv, cleanup=True) 30690fd73cbSAndrew Geissler expected = ["mc_2:a1:compile"] 3075a43b434SAndrew Geissler self.assertEqual(set(tasks), set(expected)) 3085a43b434SAndrew Geissler 3095a43b434SAndrew Geissler rerun_tasks = self.alltasks[:] 3105a43b434SAndrew Geissler for x in ("fetch", "unpack", "patch", "prepare_recipe_sysroot", "configure", "compile"): 3115a43b434SAndrew Geissler rerun_tasks.remove(x) 31290fd73cbSAndrew Geissler tasks = self.run_bitbakecmd(["bitbake", "mc:mc-1:f1"], tempdir, "", extraenv=extraenv, cleanup=True) 31390fd73cbSAndrew Geissler expected = ["mc-1:f1:%s" % t for t in rerun_tasks] + \ 31490fd73cbSAndrew Geissler ["mc_2:a1:%s" % t for t in rerun_tasks] 3155a43b434SAndrew Geissler self.assertEqual(set(tasks), set(expected)) 31608902b01SBrad Bishop 317595f6308SAndrew Geissler self.shutdown(tempdir) 318595f6308SAndrew Geissler 31908902b01SBrad Bishop def test_hashserv_single(self): 32008902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 32108902b01SBrad Bishop extraenv = { 322a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 32308902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 32408902b01SBrad Bishop } 32508902b01SBrad Bishop cmd = ["bitbake", "a1", "b1"] 32608902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 32708902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 32808902b01SBrad Bishop sstatevalid = "" 32908902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 33008902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] 33108902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 33208902b01SBrad Bishop cmd = ["bitbake", "a1", "-c", "install", "-f"] 33308902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 33408902b01SBrad Bishop expected = ['a1:install'] 33508902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 33608902b01SBrad Bishop cmd = ["bitbake", "a1", "b1"] 33708902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 33808902b01SBrad Bishop expected = ['a1:populate_sysroot', 'a1:package', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene', 33982c905dcSAndrew Geissler 'a1:package_write_ipk_setscene', 'a1:package_qa_setscene', 'a1:build'] 34008902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 34108902b01SBrad Bishop 34200e122a7SBrad Bishop self.shutdown(tempdir) 34300e122a7SBrad Bishop 34408902b01SBrad Bishop def test_hashserv_double(self): 34508902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 34608902b01SBrad Bishop extraenv = { 347a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 34808902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 34908902b01SBrad Bishop } 35008902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "e1"] 35108902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 35208902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 35308902b01SBrad Bishop sstatevalid = "" 35408902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 35508902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks] 35608902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 35708902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"] 35808902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 35908902b01SBrad Bishop cmd = ["bitbake", "e1"] 36008902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 36108902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 36208902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 36308902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene'] 36408902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 36508902b01SBrad Bishop 36600e122a7SBrad Bishop self.shutdown(tempdir) 36708902b01SBrad Bishop 36808902b01SBrad Bishop def test_hashserv_multiple_setscene(self): 36908902b01SBrad Bishop # Runs e1:do_package_setscene twice 37008902b01SBrad Bishop with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir: 37108902b01SBrad Bishop extraenv = { 372a34c030eSBrad Bishop "BB_HASHSERVE" : "auto", 37308902b01SBrad Bishop "BB_SIGNATURE_HANDLER" : "TestEquivHash" 37408902b01SBrad Bishop } 37508902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "e1"] 37608902b01SBrad Bishop setscenetasks = ['package_write_ipk_setscene', 'package_write_rpm_setscene', 'packagedata_setscene', 37708902b01SBrad Bishop 'populate_sysroot_setscene', 'package_qa_setscene'] 37808902b01SBrad Bishop sstatevalid = "" 37908902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 38008902b01SBrad Bishop expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks] + ['e1:' + x for x in self.alltasks] 38108902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 38208902b01SBrad Bishop cmd = ["bitbake", "a1", "b1", "-c", "install", "-fn"] 38308902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True) 38408902b01SBrad Bishop cmd = ["bitbake", "e1"] 38508902b01SBrad Bishop sstatevalid = "e1:do_package" 38608902b01SBrad Bishop tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv, cleanup=True, slowtasks="a1:populate_sysroot b1:populate_sysroot") 38708902b01SBrad Bishop expected = ['a1:package', 'a1:install', 'b1:package', 'b1:install', 'a1:populate_sysroot', 'b1:populate_sysroot', 38808902b01SBrad Bishop 'a1:package_write_ipk_setscene', 'b1:packagedata_setscene', 'b1:package_write_rpm_setscene', 38908902b01SBrad Bishop 'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene', 39008902b01SBrad Bishop 'e1:package_setscene'] 39108902b01SBrad Bishop self.assertEqual(set(tasks), set(expected)) 39208902b01SBrad Bishop for i in expected: 39308902b01SBrad Bishop self.assertEqual(tasks.count(i), 1, "%s not in task list once" % i) 39408902b01SBrad Bishop 39500e122a7SBrad Bishop self.shutdown(tempdir) 39608902b01SBrad Bishop 39700e122a7SBrad Bishop def shutdown(self, tempdir): 39800e122a7SBrad Bishop # Wait for the hashserve socket to disappear else we'll see races with the tempdir cleanup 399595f6308SAndrew Geissler while (os.path.exists(tempdir + "/hashserve.sock") or os.path.exists(tempdir + "cache/hashserv.db-wal") or os.path.exists(tempdir + "/bitbake.lock")): 40000e122a7SBrad Bishop time.sleep(0.5) 40108902b01SBrad Bishop 402