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