diff options
author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2017-05-12 14:40:21 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-06 19:02:43 +0100 |
commit | 157c3be2ca93f076033f725ec1ee912df91f7488 (patch) | |
tree | 8ef896ff7adf78d63b34059cd5b017a4f0a3419a /meta/lib/oeqa/selftest/cases/sstatetests.py | |
parent | 10c512b60d1167122b5fe778b93838dca3def717 (diff) | |
download | poky-157c3be2ca93f076033f725ec1ee912df91f7488.tar.gz |
oeqa/selftest/cases: Migrate test cases into the new oe-qa framework
New framework has different classes/decorators so adapt current test cases to
support these. Changes include changes on base classes and decorators.
Also include paths in selftest/__init__.py isn't needed because the
loader is the standard unittest one.
(From OE-Core rev: ddbbefdd124604d10bd47dd0266b55a764fcc0ab)
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/sstatetests.py')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/sstatetests.py | 479 |
1 files changed, 479 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py new file mode 100644 index 0000000000..8d05e30423 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/sstatetests.py | |||
@@ -0,0 +1,479 @@ | |||
1 | import os | ||
2 | import shutil | ||
3 | import glob | ||
4 | import subprocess | ||
5 | |||
6 | from oeqa.selftest.case import OESelftestTestCase | ||
7 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer | ||
8 | from oeqa.selftest.cases.sstate import SStateBase | ||
9 | from oeqa.core.decorator.oeid import OETestID | ||
10 | |||
11 | class SStateTests(SStateBase): | ||
12 | |||
13 | # Test sstate files creation and their location | ||
14 | def run_test_sstate_creation(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True, should_pass=True): | ||
15 | self.config_sstate(temp_sstate_location, [self.sstate_path]) | ||
16 | |||
17 | if self.temp_sstate_location: | ||
18 | bitbake(['-cclean'] + targets) | ||
19 | else: | ||
20 | bitbake(['-ccleansstate'] + targets) | ||
21 | |||
22 | bitbake(targets) | ||
23 | file_tracker = [] | ||
24 | results = self.search_sstate('|'.join(map(str, targets)), distro_specific, distro_nonspecific) | ||
25 | if distro_nonspecific: | ||
26 | for r in results: | ||
27 | if r.endswith(("_populate_lic.tgz", "_populate_lic.tgz.siginfo", "_fetch.tgz.siginfo", "_unpack.tgz.siginfo", "_patch.tgz.siginfo")): | ||
28 | continue | ||
29 | file_tracker.append(r) | ||
30 | else: | ||
31 | file_tracker = results | ||
32 | |||
33 | if should_pass: | ||
34 | self.assertTrue(file_tracker , msg="Could not find sstate files for: %s" % ', '.join(map(str, targets))) | ||
35 | else: | ||
36 | self.assertTrue(not file_tracker , msg="Found sstate files in the wrong place for: %s (found %s)" % (', '.join(map(str, targets)), str(file_tracker))) | ||
37 | |||
38 | @OETestID(975) | ||
39 | def test_sstate_creation_distro_specific_pass(self): | ||
40 | self.run_test_sstate_creation(['binutils-cross-'+ self.tune_arch, 'binutils-native'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True) | ||
41 | |||
42 | @OETestID(1374) | ||
43 | def test_sstate_creation_distro_specific_fail(self): | ||
44 | self.run_test_sstate_creation(['binutils-cross-'+ self.tune_arch, 'binutils-native'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True, should_pass=False) | ||
45 | |||
46 | @OETestID(976) | ||
47 | def test_sstate_creation_distro_nonspecific_pass(self): | ||
48 | self.run_test_sstate_creation(['linux-libc-headers'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True) | ||
49 | |||
50 | @OETestID(1375) | ||
51 | def test_sstate_creation_distro_nonspecific_fail(self): | ||
52 | self.run_test_sstate_creation(['linux-libc-headers'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True, should_pass=False) | ||
53 | |||
54 | # Test the sstate files deletion part of the do_cleansstate task | ||
55 | def run_test_cleansstate_task(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True): | ||
56 | self.config_sstate(temp_sstate_location, [self.sstate_path]) | ||
57 | |||
58 | bitbake(['-ccleansstate'] + targets) | ||
59 | |||
60 | bitbake(targets) | ||
61 | tgz_created = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific, distro_nonspecific) | ||
62 | self.assertTrue(tgz_created, msg="Could not find sstate .tgz files for: %s (%s)" % (', '.join(map(str, targets)), str(tgz_created))) | ||
63 | |||
64 | siginfo_created = self.search_sstate('|'.join(map(str, [s + '.*?\.siginfo$' for s in targets])), distro_specific, distro_nonspecific) | ||
65 | self.assertTrue(siginfo_created, msg="Could not find sstate .siginfo files for: %s (%s)" % (', '.join(map(str, targets)), str(siginfo_created))) | ||
66 | |||
67 | bitbake(['-ccleansstate'] + targets) | ||
68 | tgz_removed = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific, distro_nonspecific) | ||
69 | self.assertTrue(not tgz_removed, msg="do_cleansstate didn't remove .tgz sstate files for: %s (%s)" % (', '.join(map(str, targets)), str(tgz_removed))) | ||
70 | |||
71 | @OETestID(977) | ||
72 | def test_cleansstate_task_distro_specific_nonspecific(self): | ||
73 | targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native'] | ||
74 | targets.append('linux-libc-headers') | ||
75 | self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True) | ||
76 | |||
77 | @OETestID(1376) | ||
78 | def test_cleansstate_task_distro_nonspecific(self): | ||
79 | self.run_test_cleansstate_task(['linux-libc-headers'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True) | ||
80 | |||
81 | @OETestID(1377) | ||
82 | def test_cleansstate_task_distro_specific(self): | ||
83 | targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native'] | ||
84 | targets.append('linux-libc-headers') | ||
85 | self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=False, temp_sstate_location=True) | ||
86 | |||
87 | |||
88 | # Test rebuilding of distro-specific sstate files | ||
89 | def run_test_rebuild_distro_specific_sstate(self, targets, temp_sstate_location=True): | ||
90 | self.config_sstate(temp_sstate_location, [self.sstate_path]) | ||
91 | |||
92 | bitbake(['-ccleansstate'] + targets) | ||
93 | |||
94 | bitbake(targets) | ||
95 | results = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific=False, distro_nonspecific=True) | ||
96 | filtered_results = [] | ||
97 | for r in results: | ||
98 | if r.endswith(("_populate_lic.tgz", "_populate_lic.tgz.siginfo")): | ||
99 | continue | ||
100 | filtered_results.append(r) | ||
101 | self.assertTrue(filtered_results == [], msg="Found distro non-specific sstate for: %s (%s)" % (', '.join(map(str, targets)), str(filtered_results))) | ||
102 | file_tracker_1 = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific=True, distro_nonspecific=False) | ||
103 | self.assertTrue(len(file_tracker_1) >= len(targets), msg = "Not all sstate files ware created for: %s" % ', '.join(map(str, targets))) | ||
104 | |||
105 | self.track_for_cleanup(self.distro_specific_sstate + "_old") | ||
106 | shutil.copytree(self.distro_specific_sstate, self.distro_specific_sstate + "_old") | ||
107 | shutil.rmtree(self.distro_specific_sstate) | ||
108 | |||
109 | bitbake(['-cclean'] + targets) | ||
110 | bitbake(targets) | ||
111 | file_tracker_2 = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific=True, distro_nonspecific=False) | ||
112 | self.assertTrue(len(file_tracker_2) >= len(targets), msg = "Not all sstate files ware created for: %s" % ', '.join(map(str, targets))) | ||
113 | |||
114 | not_recreated = [x for x in file_tracker_1 if x not in file_tracker_2] | ||
115 | self.assertTrue(not_recreated == [], msg="The following sstate files ware not recreated: %s" % ', '.join(map(str, not_recreated))) | ||
116 | |||
117 | created_once = [x for x in file_tracker_2 if x not in file_tracker_1] | ||
118 | self.assertTrue(created_once == [], msg="The following sstate files ware created only in the second run: %s" % ', '.join(map(str, created_once))) | ||
119 | |||
120 | @OETestID(175) | ||
121 | def test_rebuild_distro_specific_sstate_cross_native_targets(self): | ||
122 | self.run_test_rebuild_distro_specific_sstate(['binutils-cross-' + self.tune_arch, 'binutils-native'], temp_sstate_location=True) | ||
123 | |||
124 | @OETestID(1372) | ||
125 | def test_rebuild_distro_specific_sstate_cross_target(self): | ||
126 | self.run_test_rebuild_distro_specific_sstate(['binutils-cross-' + self.tune_arch], temp_sstate_location=True) | ||
127 | |||
128 | @OETestID(1373) | ||
129 | def test_rebuild_distro_specific_sstate_native_target(self): | ||
130 | self.run_test_rebuild_distro_specific_sstate(['binutils-native'], temp_sstate_location=True) | ||
131 | |||
132 | |||
133 | # Test the sstate-cache-management script. Each element in the global_config list is used with the corresponding element in the target_config list | ||
134 | # global_config elements are expected to not generate any sstate files that would be removed by sstate-cache-management.sh (such as changing the value of MACHINE) | ||
135 | def run_test_sstate_cache_management_script(self, target, global_config=[''], target_config=[''], ignore_patterns=[]): | ||
136 | self.assertTrue(global_config) | ||
137 | self.assertTrue(target_config) | ||
138 | self.assertTrue(len(global_config) == len(target_config), msg='Lists global_config and target_config should have the same number of elements') | ||
139 | self.config_sstate(temp_sstate_location=True, add_local_mirrors=[self.sstate_path]) | ||
140 | |||
141 | # If buildhistory is enabled, we need to disable version-going-backwards | ||
142 | # QA checks for this test. It may report errors otherwise. | ||
143 | self.append_config('ERROR_QA_remove = "version-going-backwards"') | ||
144 | |||
145 | # For not this only checks if random sstate tasks are handled correctly as a group. | ||
146 | # In the future we should add control over what tasks we check for. | ||
147 | |||
148 | sstate_archs_list = [] | ||
149 | expected_remaining_sstate = [] | ||
150 | for idx in range(len(target_config)): | ||
151 | self.append_config(global_config[idx]) | ||
152 | self.append_recipeinc(target, target_config[idx]) | ||
153 | sstate_arch = get_bb_var('SSTATE_PKGARCH', target) | ||
154 | if not sstate_arch in sstate_archs_list: | ||
155 | sstate_archs_list.append(sstate_arch) | ||
156 | if target_config[idx] == target_config[-1]: | ||
157 | target_sstate_before_build = self.search_sstate(target + '.*?\.tgz$') | ||
158 | bitbake("-cclean %s" % target) | ||
159 | result = bitbake(target, ignore_status=True) | ||
160 | if target_config[idx] == target_config[-1]: | ||
161 | target_sstate_after_build = self.search_sstate(target + '.*?\.tgz$') | ||
162 | expected_remaining_sstate += [x for x in target_sstate_after_build if x not in target_sstate_before_build if not any(pattern in x for pattern in ignore_patterns)] | ||
163 | self.remove_config(global_config[idx]) | ||
164 | self.remove_recipeinc(target, target_config[idx]) | ||
165 | self.assertEqual(result.status, 0, msg = "build of %s failed with %s" % (target, result.output)) | ||
166 | |||
167 | runCmd("sstate-cache-management.sh -y --cache-dir=%s --remove-duplicated --extra-archs=%s" % (self.sstate_path, ','.join(map(str, sstate_archs_list)))) | ||
168 | actual_remaining_sstate = [x for x in self.search_sstate(target + '.*?\.tgz$') if not any(pattern in x for pattern in ignore_patterns)] | ||
169 | |||
170 | actual_not_expected = [x for x in actual_remaining_sstate if x not in expected_remaining_sstate] | ||
171 | self.assertFalse(actual_not_expected, msg="Files should have been removed but ware not: %s" % ', '.join(map(str, actual_not_expected))) | ||
172 | expected_not_actual = [x for x in expected_remaining_sstate if x not in actual_remaining_sstate] | ||
173 | self.assertFalse(expected_not_actual, msg="Extra files ware removed: %s" ', '.join(map(str, expected_not_actual))) | ||
174 | |||
175 | @OETestID(973) | ||
176 | def test_sstate_cache_management_script_using_pr_1(self): | ||
177 | global_config = [] | ||
178 | target_config = [] | ||
179 | global_config.append('') | ||
180 | target_config.append('PR = "0"') | ||
181 | self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) | ||
182 | |||
183 | @OETestID(978) | ||
184 | def test_sstate_cache_management_script_using_pr_2(self): | ||
185 | global_config = [] | ||
186 | target_config = [] | ||
187 | global_config.append('') | ||
188 | target_config.append('PR = "0"') | ||
189 | global_config.append('') | ||
190 | target_config.append('PR = "1"') | ||
191 | self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) | ||
192 | |||
193 | @OETestID(979) | ||
194 | def test_sstate_cache_management_script_using_pr_3(self): | ||
195 | global_config = [] | ||
196 | target_config = [] | ||
197 | global_config.append('MACHINE = "qemux86-64"') | ||
198 | target_config.append('PR = "0"') | ||
199 | global_config.append(global_config[0]) | ||
200 | target_config.append('PR = "1"') | ||
201 | global_config.append('MACHINE = "qemux86"') | ||
202 | target_config.append('PR = "1"') | ||
203 | self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) | ||
204 | |||
205 | @OETestID(974) | ||
206 | def test_sstate_cache_management_script_using_machine(self): | ||
207 | global_config = [] | ||
208 | target_config = [] | ||
209 | global_config.append('MACHINE = "qemux86-64"') | ||
210 | target_config.append('') | ||
211 | global_config.append('MACHINE = "qemux86"') | ||
212 | target_config.append('') | ||
213 | self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) | ||
214 | |||
215 | @OETestID(1270) | ||
216 | def test_sstate_32_64_same_hash(self): | ||
217 | """ | ||
218 | The sstate checksums for both native and target should not vary whether | ||
219 | they're built on a 32 or 64 bit system. Rather than requiring two different | ||
220 | build machines and running a builds, override the variables calling uname() | ||
221 | manually and check using bitbake -S. | ||
222 | """ | ||
223 | |||
224 | self.write_config(""" | ||
225 | MACHINE = "qemux86" | ||
226 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash" | ||
227 | BUILD_ARCH = "x86_64" | ||
228 | BUILD_OS = "linux" | ||
229 | SDKMACHINE = "x86_64" | ||
230 | PACKAGE_CLASSES = "package_rpm package_ipk package_deb" | ||
231 | """) | ||
232 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") | ||
233 | bitbake("core-image-sato -S none") | ||
234 | self.write_config(""" | ||
235 | MACHINE = "qemux86" | ||
236 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" | ||
237 | BUILD_ARCH = "i686" | ||
238 | BUILD_OS = "linux" | ||
239 | SDKMACHINE = "i686" | ||
240 | PACKAGE_CLASSES = "package_rpm package_ipk package_deb" | ||
241 | """) | ||
242 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") | ||
243 | bitbake("core-image-sato -S none") | ||
244 | |||
245 | def get_files(d): | ||
246 | f = [] | ||
247 | for root, dirs, files in os.walk(d): | ||
248 | if "core-image-sato" in root: | ||
249 | # SDKMACHINE changing will change | ||
250 | # do_rootfs/do_testimage/do_build stamps of images which | ||
251 | # is safe to ignore. | ||
252 | continue | ||
253 | f.extend(os.path.join(root, name) for name in files) | ||
254 | return f | ||
255 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps/") | ||
256 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps/") | ||
257 | files2 = [x.replace("tmp-sstatesamehash2", "tmp-sstatesamehash").replace("i686-linux", "x86_64-linux").replace("i686" + self.target_vendor + "-linux", "x86_64" + self.target_vendor + "-linux", ) for x in files2] | ||
258 | self.maxDiff = None | ||
259 | self.assertCountEqual(files1, files2) | ||
260 | |||
261 | |||
262 | @OETestID(1271) | ||
263 | def test_sstate_nativelsbstring_same_hash(self): | ||
264 | """ | ||
265 | The sstate checksums should be independent of whichever NATIVELSBSTRING is | ||
266 | detected. Rather than requiring two different build machines and running | ||
267 | builds, override the variables manually and check using bitbake -S. | ||
268 | """ | ||
269 | |||
270 | self.write_config(""" | ||
271 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" | ||
272 | NATIVELSBSTRING = \"DistroA\" | ||
273 | """) | ||
274 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") | ||
275 | bitbake("core-image-sato -S none") | ||
276 | self.write_config(""" | ||
277 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" | ||
278 | NATIVELSBSTRING = \"DistroB\" | ||
279 | """) | ||
280 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") | ||
281 | bitbake("core-image-sato -S none") | ||
282 | |||
283 | def get_files(d): | ||
284 | f = [] | ||
285 | for root, dirs, files in os.walk(d): | ||
286 | f.extend(os.path.join(root, name) for name in files) | ||
287 | return f | ||
288 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps/") | ||
289 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps/") | ||
290 | files2 = [x.replace("tmp-sstatesamehash2", "tmp-sstatesamehash") for x in files2] | ||
291 | self.maxDiff = None | ||
292 | self.assertCountEqual(files1, files2) | ||
293 | |||
294 | @OETestID(1368) | ||
295 | def test_sstate_allarch_samesigs(self): | ||
296 | """ | ||
297 | The sstate checksums of allarch packages should be independent of whichever | ||
298 | MACHINE is set. Check this using bitbake -S. | ||
299 | Also, rather than duplicate the test, check nativesdk stamps are the same between | ||
300 | the two MACHINE values. | ||
301 | """ | ||
302 | |||
303 | configA = """ | ||
304 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" | ||
305 | MACHINE = \"qemux86-64\" | ||
306 | """ | ||
307 | configB = """ | ||
308 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" | ||
309 | MACHINE = \"qemuarm\" | ||
310 | """ | ||
311 | self.sstate_allarch_samesigs(configA, configB) | ||
312 | |||
313 | def test_sstate_allarch_samesigs_multilib(self): | ||
314 | """ | ||
315 | The sstate checksums of allarch multilib packages should be independent of whichever | ||
316 | MACHINE is set. Check this using bitbake -S. | ||
317 | Also, rather than duplicate the test, check nativesdk stamps are the same between | ||
318 | the two MACHINE values. | ||
319 | """ | ||
320 | |||
321 | configA = """ | ||
322 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" | ||
323 | MACHINE = \"qemux86-64\" | ||
324 | require conf/multilib.conf | ||
325 | MULTILIBS = \"multilib:lib32\" | ||
326 | DEFAULTTUNE_virtclass-multilib-lib32 = \"x86\" | ||
327 | """ | ||
328 | configB = """ | ||
329 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" | ||
330 | MACHINE = \"qemuarm\" | ||
331 | require conf/multilib.conf | ||
332 | MULTILIBS = \"\" | ||
333 | """ | ||
334 | self.sstate_allarch_samesigs(configA, configB) | ||
335 | |||
336 | def sstate_allarch_samesigs(self, configA, configB): | ||
337 | |||
338 | self.write_config(configA) | ||
339 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") | ||
340 | bitbake("world meta-toolchain -S none") | ||
341 | self.write_config(configB) | ||
342 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") | ||
343 | bitbake("world meta-toolchain -S none") | ||
344 | |||
345 | def get_files(d): | ||
346 | f = {} | ||
347 | for root, dirs, files in os.walk(d): | ||
348 | for name in files: | ||
349 | if "meta-environment" in root or "cross-canadian" in root: | ||
350 | continue | ||
351 | if "do_build" not in name: | ||
352 | # 1.4.1+gitAUTOINC+302fca9f4c-r0.do_package_write_ipk.sigdata.f3a2a38697da743f0dbed8b56aafcf79 | ||
353 | (_, task, _, shash) = name.rsplit(".", 3) | ||
354 | f[os.path.join(os.path.basename(root), task)] = shash | ||
355 | return f | ||
356 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps/all" + self.target_vendor + "-" + self.target_os) | ||
357 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps/all" + self.target_vendor + "-" + self.target_os) | ||
358 | self.maxDiff = None | ||
359 | self.assertEqual(files1, files2) | ||
360 | |||
361 | nativesdkdir = os.path.basename(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/*-nativesdk*-linux")[0]) | ||
362 | |||
363 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps/" + nativesdkdir) | ||
364 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps/" + nativesdkdir) | ||
365 | self.maxDiff = None | ||
366 | self.assertEqual(files1, files2) | ||
367 | |||
368 | @OETestID(1369) | ||
369 | def test_sstate_sametune_samesigs(self): | ||
370 | """ | ||
371 | The sstate checksums of two identical machines (using the same tune) should be the | ||
372 | same, apart from changes within the machine specific stamps directory. We use the | ||
373 | qemux86copy machine to test this. Also include multilibs in the test. | ||
374 | """ | ||
375 | |||
376 | self.write_config(""" | ||
377 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" | ||
378 | MACHINE = \"qemux86\" | ||
379 | require conf/multilib.conf | ||
380 | MULTILIBS = "multilib:lib32" | ||
381 | DEFAULTTUNE_virtclass-multilib-lib32 = "x86" | ||
382 | """) | ||
383 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") | ||
384 | bitbake("world meta-toolchain -S none") | ||
385 | self.write_config(""" | ||
386 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" | ||
387 | MACHINE = \"qemux86copy\" | ||
388 | require conf/multilib.conf | ||
389 | MULTILIBS = "multilib:lib32" | ||
390 | DEFAULTTUNE_virtclass-multilib-lib32 = "x86" | ||
391 | """) | ||
392 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") | ||
393 | bitbake("world meta-toolchain -S none") | ||
394 | |||
395 | def get_files(d): | ||
396 | f = [] | ||
397 | for root, dirs, files in os.walk(d): | ||
398 | for name in files: | ||
399 | if "meta-environment" in root or "cross-canadian" in root: | ||
400 | continue | ||
401 | if "qemux86copy-" in root or "qemux86-" in root: | ||
402 | continue | ||
403 | if "do_build" not in name and "do_populate_sdk" not in name: | ||
404 | f.append(os.path.join(root, name)) | ||
405 | return f | ||
406 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps") | ||
407 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps") | ||
408 | files2 = [x.replace("tmp-sstatesamehash2", "tmp-sstatesamehash") for x in files2] | ||
409 | self.maxDiff = None | ||
410 | self.assertCountEqual(files1, files2) | ||
411 | |||
412 | |||
413 | def test_sstate_noop_samesigs(self): | ||
414 | """ | ||
415 | The sstate checksums of two builds with these variables changed or | ||
416 | classes inherits should be the same. | ||
417 | """ | ||
418 | |||
419 | self.write_config(""" | ||
420 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash" | ||
421 | BB_NUMBER_THREADS = "1" | ||
422 | PARALLEL_MAKE = "-j 1" | ||
423 | DL_DIR = "${TOPDIR}/download1" | ||
424 | TIME = "111111" | ||
425 | DATE = "20161111" | ||
426 | INHERIT_remove = "buildstats-summary buildhistory uninative" | ||
427 | http_proxy = "" | ||
428 | """) | ||
429 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") | ||
430 | self.track_for_cleanup(self.topdir + "/download1") | ||
431 | bitbake("world meta-toolchain -S none") | ||
432 | self.write_config(""" | ||
433 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" | ||
434 | BB_NUMBER_THREADS = "2" | ||
435 | PARALLEL_MAKE = "-j 2" | ||
436 | DL_DIR = "${TOPDIR}/download2" | ||
437 | TIME = "222222" | ||
438 | DATE = "20161212" | ||
439 | # Always remove uninative as we're changing proxies | ||
440 | INHERIT_remove = "uninative" | ||
441 | INHERIT += "buildstats-summary buildhistory" | ||
442 | http_proxy = "http://example.com/" | ||
443 | """) | ||
444 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") | ||
445 | self.track_for_cleanup(self.topdir + "/download2") | ||
446 | bitbake("world meta-toolchain -S none") | ||
447 | |||
448 | def get_files(d): | ||
449 | f = {} | ||
450 | for root, dirs, files in os.walk(d): | ||
451 | for name in files: | ||
452 | name, shash = name.rsplit('.', 1) | ||
453 | # Extract just the machine and recipe name | ||
454 | base = os.sep.join(root.rsplit(os.sep, 2)[-2:] + [name]) | ||
455 | f[base] = shash | ||
456 | return f | ||
457 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps/") | ||
458 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps/") | ||
459 | # Remove items that are identical in both sets | ||
460 | for k,v in files1.items() & files2.items(): | ||
461 | del files1[k] | ||
462 | del files2[k] | ||
463 | if not files1 and not files2: | ||
464 | # No changes, so we're done | ||
465 | return | ||
466 | |||
467 | for k in files1.keys() | files2.keys(): | ||
468 | if k in files1 and k in files2: | ||
469 | print("%s differs:" % k) | ||
470 | print(subprocess.check_output(("bitbake-diffsigs", | ||
471 | self.topdir + "/tmp-sstatesamehash/stamps/" + k + "." + files1[k], | ||
472 | self.topdir + "/tmp-sstatesamehash2/stamps/" + k + "." + files2[k]))) | ||
473 | elif k in files1 and k not in files2: | ||
474 | print("%s in files1" % k) | ||
475 | elif k not in files1 and k in files2: | ||
476 | print("%s in files2" % k) | ||
477 | else: | ||
478 | assert "shouldn't reach here" | ||
479 | self.fail("sstate hashes not identical.") | ||