summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/runqueue.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-10 14:26:37 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-15 10:28:12 +0100
commit7484fb49a4fb2e84729ce11c4c8c0433a8365dc3 (patch)
tree0e481bb23c29983e597985445b01a3d296636012 /bitbake/lib/bb/tests/runqueue.py
parent39ef064da5998b1bf1d47d10a9622e9fe4107796 (diff)
downloadpoky-7484fb49a4fb2e84729ce11c4c8c0433a8365dc3.tar.gz
bitbake: tests: Add initial scenario based test for runqueue
We need some tests for runqueue, its been something which has been hard to test for a long time. Add some dummy metadata to allow this, mirroring the OE structure in spirit. (Bitbake rev: 37564d7440c5d7aa05ec537f3b79026b1c83bb68) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/runqueue.py')
-rw-r--r--bitbake/lib/bb/tests/runqueue.py200
1 files changed, 200 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/runqueue.py b/bitbake/lib/bb/tests/runqueue.py
new file mode 100644
index 0000000000..4a65b5b6e7
--- /dev/null
+++ b/bitbake/lib/bb/tests/runqueue.py
@@ -0,0 +1,200 @@
1#
2# BitBake Tests for runqueue task processing
3#
4# Copyright (C) 2019 Richard Purdie
5#
6# SPDX-License-Identifier: GPL-2.0-only
7#
8
9import unittest
10import bb
11import os
12import tempfile
13import subprocess
14
15#
16# TODO:
17# Add tests on task ordering (X happens before Y after Z)
18#
19
20class RunQueueTests(unittest.TestCase):
21
22 alltasks = ['package', 'fetch', 'unpack', 'patch', 'prepare_recipe_sysroot', 'configure',
23 'compile', 'install', 'packagedata', 'package_qa', 'package_write_rpm', 'package_write_ipk',
24 'populate_sysroot', 'build']
25 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"
26 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"
27
28 def run_bitbakecmd(self, cmd, builddir, sstatevalid="", slowtasks="", extraenv=None):
29 env = os.environ.copy()
30 env["BBPATH"] = os.path.realpath(os.path.join(os.path.dirname(__file__), "runqueue-tests"))
31 env["BB_ENV_EXTRAWHITE"] = "SSTATEVALID SLOWTASKS"
32 env["SSTATEVALID"] = sstatevalid
33 env["SLOWTASKS"] = slowtasks
34 if extraenv:
35 for k in extraenv:
36 env[k] = extraenv[k]
37 env["BB_ENV_EXTRAWHITE"] = env["BB_ENV_EXTRAWHITE"] + " " + k
38 try:
39 output = subprocess.check_output(cmd, env=env, stderr=subprocess.STDOUT,universal_newlines=True, cwd=builddir)
40 except subprocess.CalledProcessError as e:
41 self.fail("Command %s failed with %s" % (cmd, e.output))
42 tasks = []
43 with open(builddir + "/task.log", "r") as f:
44 tasks = [line.rstrip() for line in f]
45 return tasks
46
47 def test_no_setscenevalid(self):
48 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
49 cmd = ["bitbake", "a1"]
50 sstatevalid = ""
51 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
52 expected = ['a1:' + x for x in self.alltasks]
53 self.assertEqual(set(tasks), set(expected))
54
55 def test_single_setscenevalid(self):
56 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
57 cmd = ["bitbake", "a1"]
58 sstatevalid = "a1:do_package"
59 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
60 expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
61 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk',
62 'a1:populate_sysroot', 'a1:build']
63 self.assertEqual(set(tasks), set(expected))
64
65 def test_intermediate_setscenevalid(self):
66 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
67 cmd = ["bitbake", "a1"]
68 sstatevalid = "a1:do_package a1:do_populate_sysroot"
69 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
70 expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk',
71 'a1:populate_sysroot_setscene', 'a1:build']
72 self.assertEqual(set(tasks), set(expected))
73
74 def test_intermediate_notcovered(self):
75 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
76 cmd = ["bitbake", "a1"]
77 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"
78 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
79 expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
80 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene']
81 self.assertEqual(set(tasks), set(expected))
82
83 def test_all_setscenevalid(self):
84 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
85 cmd = ["bitbake", "a1"]
86 sstatevalid = self.a1_sstatevalid
87 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
88 expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
89 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene']
90 self.assertEqual(set(tasks), set(expected))
91
92 def test_no_settasks(self):
93 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
94 cmd = ["bitbake", "a1", "-c", "patch"]
95 sstatevalid = self.a1_sstatevalid
96 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
97 expected = ['a1:fetch', 'a1:unpack', 'a1:patch']
98 self.assertEqual(set(tasks), set(expected))
99
100 # Test targets with intermediate setscene tasks alongside a target with no intermediate setscene tasks
101 def test_mixed_direct_tasks_setscene_tasks(self):
102 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
103 cmd = ["bitbake", "c1:do_patch", "a1"]
104 sstatevalid = self.a1_sstatevalid
105 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
106 expected = ['c1:fetch', 'c1:unpack', 'c1:patch', 'a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
107 'a1:package_qa_setscene', 'a1:build', 'a1:populate_sysroot_setscene']
108 self.assertEqual(set(tasks), set(expected))
109
110 # This test slows down the execution of do_package_setscene until after other real tasks have
111 # started running which tests for a bug where tasks were being lost from the buildable list of real
112 # tasks if they weren't in tasks_covered or tasks_notcovered
113 def test_slow_setscene(self):
114 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
115 cmd = ["bitbake", "a1"]
116 sstatevalid = "a1:do_package"
117 slowtasks = "a1:package_setscene"
118 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, slowtasks)
119 expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
120 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_qa', 'a1:package_write_rpm', 'a1:package_write_ipk',
121 'a1:populate_sysroot', 'a1:build']
122 self.assertEqual(set(tasks), set(expected))
123
124 def test_setscenewhitelist(self):
125 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
126 cmd = ["bitbake", "a1"]
127 extraenv = {
128 "BB_SETSCENE_ENFORCE" : "1",
129 "BB_SETSCENE_ENFORCE_WHITELIST" : "a1:do_package_write_rpm a1:do_build"
130 }
131 sstatevalid = "a1:do_package a1:do_package_qa a1:do_packagedata a1:do_package_write_ipk a1:do_populate_lic a1:do_populate_sysroot"
132 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid, extraenv=extraenv)
133 expected = ['a1:packagedata_setscene', 'a1:package_qa_setscene', 'a1:package_write_ipk_setscene',
134 'a1:populate_sysroot_setscene', 'a1:package_setscene']
135 self.assertEqual(set(tasks), set(expected))
136
137 # Tests for problems with dependencies between setscene tasks
138 def test_no_setscenevalid_harddeps(self):
139 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
140 cmd = ["bitbake", "d1"]
141 sstatevalid = ""
142 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
143 expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
144 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
145 'a1:populate_sysroot', 'd1:package', 'd1:fetch', 'd1:unpack', 'd1:patch', 'd1:prepare_recipe_sysroot', 'd1:configure',
146 'd1:compile', 'd1:install', 'd1:packagedata', 'd1:package_qa', 'd1:package_write_rpm', 'd1:package_write_ipk',
147 'd1:populate_sysroot', 'd1:build']
148 self.assertEqual(set(tasks), set(expected))
149
150 def test_no_setscenevalid_withdeps(self):
151 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
152 cmd = ["bitbake", "b1"]
153 sstatevalid = ""
154 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
155 expected = ['a1:' + x for x in self.alltasks] + ['b1:' + x for x in self.alltasks]
156 expected.remove('a1:build')
157 expected.remove('a1:package_qa')
158 self.assertEqual(set(tasks), set(expected))
159
160 def test_single_a1_setscenevalid_withdeps(self):
161 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
162 cmd = ["bitbake", "b1"]
163 sstatevalid = "a1:do_package"
164 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
165 expected = ['a1:package_setscene', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
166 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
167 'a1:populate_sysroot'] + ['b1:' + x for x in self.alltasks]
168 self.assertEqual(set(tasks), set(expected))
169
170 def test_single_b1_setscenevalid_withdeps(self):
171 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
172 cmd = ["bitbake", "b1"]
173 sstatevalid = "b1:do_package"
174 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
175 expected = ['a1:package', 'a1:fetch', 'a1:unpack', 'a1:patch', 'a1:prepare_recipe_sysroot', 'a1:configure',
176 'a1:compile', 'a1:install', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
177 'a1:populate_sysroot', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks]
178 expected.remove('b1:package')
179 self.assertEqual(set(tasks), set(expected))
180
181 def test_intermediate_setscenevalid_withdeps(self):
182 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
183 cmd = ["bitbake", "b1"]
184 sstatevalid = "a1:do_package a1:do_populate_sysroot b1:do_package"
185 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
186 expected = ['a1:package_setscene', 'a1:packagedata', 'a1:package_write_rpm', 'a1:package_write_ipk',
187 'a1:populate_sysroot_setscene', 'b1:package_setscene'] + ['b1:' + x for x in self.alltasks]
188 expected.remove('b1:package')
189 self.assertEqual(set(tasks), set(expected))
190
191 def test_all_setscenevalid_withdeps(self):
192 with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
193 cmd = ["bitbake", "b1"]
194 sstatevalid = self.a1_sstatevalid + " " + self.b1_sstatevalid
195 tasks = self.run_bitbakecmd(cmd, tempdir, sstatevalid)
196 expected = ['a1:package_write_ipk_setscene', 'a1:package_write_rpm_setscene', 'a1:packagedata_setscene',
197 'b1:build', 'a1:populate_sysroot_setscene', 'b1:package_write_ipk_setscene', 'b1:package_write_rpm_setscene',
198 'b1:packagedata_setscene', 'b1:package_qa_setscene', 'b1:populate_sysroot_setscene']
199 self.assertEqual(set(tasks), set(expected))
200