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