blob: acaf405acb1b4fbb1648dc657a6306aeb86a1c94 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001import datetime
2import unittest
3import os
4import re
5import shutil
Patrick Williamsd7e96312015-09-22 08:09:05 -05006import glob
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05007import subprocess
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008
9import oeqa.utils.ftools as ftools
10from oeqa.selftest.base import oeSelfTest
11from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
12from oeqa.selftest.sstate import SStateBase
13from oeqa.utils.decorators import testcase
14
15class 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)
20
21 if self.temp_sstate_location:
22 bitbake(['-cclean'] + targets)
23 else:
24 bitbake(['-ccleansstate'] + targets)
25
26 bitbake(targets)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050027 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
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 if should_pass:
38 self.assertTrue(file_tracker , msg="Could not find sstate files for: %s" % ', '.join(map(str, targets)))
39 else:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050040 self.assertTrue(not file_tracker , msg="Found sstate files in the wrong place for: %s (found %s)" % (', '.join(map(str, targets)), str(file_tracker)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041
42 @testcase(975)
43 def test_sstate_creation_distro_specific_pass(self):
44 targetarch = get_bb_var('TUNE_ARCH')
45 self.run_test_sstate_creation(['binutils-cross-'+ targetarch, 'binutils-native'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True)
46
Patrick Williamsf1e5d692016-03-30 15:21:19 -050047 @testcase(1374)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 def test_sstate_creation_distro_specific_fail(self):
49 targetarch = get_bb_var('TUNE_ARCH')
50 self.run_test_sstate_creation(['binutils-cross-'+ targetarch, 'binutils-native'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True, should_pass=False)
51
52 @testcase(976)
53 def test_sstate_creation_distro_nonspecific_pass(self):
54 self.run_test_sstate_creation(['glibc-initial'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True)
55
Patrick Williamsf1e5d692016-03-30 15:21:19 -050056 @testcase(1375)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057 def test_sstate_creation_distro_nonspecific_fail(self):
58 self.run_test_sstate_creation(['glibc-initial'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True, should_pass=False)
59
60
61 # Test the sstate files deletion part of the do_cleansstate task
62 def run_test_cleansstate_task(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True):
63 self.config_sstate(temp_sstate_location)
64
65 bitbake(['-ccleansstate'] + targets)
66
67 bitbake(targets)
68 tgz_created = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific, distro_nonspecific)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050069 self.assertTrue(tgz_created, msg="Could not find sstate .tgz files for: %s (%s)" % (', '.join(map(str, targets)), str(tgz_created)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070
71 siginfo_created = self.search_sstate('|'.join(map(str, [s + '.*?\.siginfo$' for s in targets])), distro_specific, distro_nonspecific)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050072 self.assertTrue(siginfo_created, msg="Could not find sstate .siginfo files for: %s (%s)" % (', '.join(map(str, targets)), str(siginfo_created)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073
74 bitbake(['-ccleansstate'] + targets)
75 tgz_removed = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific, distro_nonspecific)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050076 self.assertTrue(not tgz_removed, msg="do_cleansstate didn't remove .tgz sstate files for: %s (%s)" % (', '.join(map(str, targets)), str(tgz_removed)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077
78 @testcase(977)
79 def test_cleansstate_task_distro_specific_nonspecific(self):
80 targetarch = get_bb_var('TUNE_ARCH')
81 self.run_test_cleansstate_task(['binutils-cross-' + targetarch, 'binutils-native', 'glibc-initial'], distro_specific=True, distro_nonspecific=True, temp_sstate_location=True)
82
Patrick Williamsf1e5d692016-03-30 15:21:19 -050083 @testcase(1376)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 def test_cleansstate_task_distro_nonspecific(self):
85 self.run_test_cleansstate_task(['glibc-initial'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True)
86
Patrick Williamsf1e5d692016-03-30 15:21:19 -050087 @testcase(1377)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 def test_cleansstate_task_distro_specific(self):
89 targetarch = get_bb_var('TUNE_ARCH')
90 self.run_test_cleansstate_task(['binutils-cross-'+ targetarch, 'binutils-native', 'glibc-initial'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True)
91
92
93 # Test rebuilding of distro-specific sstate files
94 def run_test_rebuild_distro_specific_sstate(self, targets, temp_sstate_location=True):
95 self.config_sstate(temp_sstate_location)
96
97 bitbake(['-ccleansstate'] + targets)
98
99 bitbake(targets)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500100 results = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific=False, distro_nonspecific=True)
101 filtered_results = []
102 for r in results:
103 if r.endswith(("_populate_lic.tgz", "_populate_lic.tgz.siginfo")):
104 continue
105 filtered_results.append(r)
106 self.assertTrue(filtered_results == [], msg="Found distro non-specific sstate for: %s (%s)" % (', '.join(map(str, targets)), str(filtered_results)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107 file_tracker_1 = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific=True, distro_nonspecific=False)
108 self.assertTrue(len(file_tracker_1) >= len(targets), msg = "Not all sstate files ware created for: %s" % ', '.join(map(str, targets)))
109
110 self.track_for_cleanup(self.distro_specific_sstate + "_old")
111 shutil.copytree(self.distro_specific_sstate, self.distro_specific_sstate + "_old")
112 shutil.rmtree(self.distro_specific_sstate)
113
114 bitbake(['-cclean'] + targets)
115 bitbake(targets)
116 file_tracker_2 = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific=True, distro_nonspecific=False)
117 self.assertTrue(len(file_tracker_2) >= len(targets), msg = "Not all sstate files ware created for: %s" % ', '.join(map(str, targets)))
118
119 not_recreated = [x for x in file_tracker_1 if x not in file_tracker_2]
120 self.assertTrue(not_recreated == [], msg="The following sstate files ware not recreated: %s" % ', '.join(map(str, not_recreated)))
121
122 created_once = [x for x in file_tracker_2 if x not in file_tracker_1]
123 self.assertTrue(created_once == [], msg="The following sstate files ware created only in the second run: %s" % ', '.join(map(str, created_once)))
124
125 @testcase(175)
126 def test_rebuild_distro_specific_sstate_cross_native_targets(self):
127 targetarch = get_bb_var('TUNE_ARCH')
128 self.run_test_rebuild_distro_specific_sstate(['binutils-cross-' + targetarch, 'binutils-native'], temp_sstate_location=True)
129
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500130 @testcase(1372)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500131 def test_rebuild_distro_specific_sstate_cross_target(self):
132 targetarch = get_bb_var('TUNE_ARCH')
133 self.run_test_rebuild_distro_specific_sstate(['binutils-cross-' + targetarch], temp_sstate_location=True)
134
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500135 @testcase(1373)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136 def test_rebuild_distro_specific_sstate_native_target(self):
137 self.run_test_rebuild_distro_specific_sstate(['binutils-native'], temp_sstate_location=True)
138
139
140 # Test the sstate-cache-management script. Each element in the global_config list is used with the corresponding element in the target_config list
141 # 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)
142 def run_test_sstate_cache_management_script(self, target, global_config=[''], target_config=[''], ignore_patterns=[]):
143 self.assertTrue(global_config)
144 self.assertTrue(target_config)
145 self.assertTrue(len(global_config) == len(target_config), msg='Lists global_config and target_config should have the same number of elements')
146 self.config_sstate(temp_sstate_location=True, add_local_mirrors=[self.sstate_path])
147
148 # If buildhistory is enabled, we need to disable version-going-backwards QA checks for this test. It may report errors otherwise.
149 if ('buildhistory' in get_bb_var('USER_CLASSES')) or ('buildhistory' in get_bb_var('INHERIT')):
150 remove_errors_config = 'ERROR_QA_remove = "version-going-backwards"'
151 self.append_config(remove_errors_config)
152
153 # For not this only checks if random sstate tasks are handled correctly as a group.
154 # In the future we should add control over what tasks we check for.
155
156 sstate_archs_list = []
157 expected_remaining_sstate = []
158 for idx in range(len(target_config)):
159 self.append_config(global_config[idx])
160 self.append_recipeinc(target, target_config[idx])
161 sstate_arch = get_bb_var('SSTATE_PKGARCH', target)
162 if not sstate_arch in sstate_archs_list:
163 sstate_archs_list.append(sstate_arch)
164 if target_config[idx] == target_config[-1]:
165 target_sstate_before_build = self.search_sstate(target + '.*?\.tgz$')
166 bitbake("-cclean %s" % target)
167 result = bitbake(target, ignore_status=True)
168 if target_config[idx] == target_config[-1]:
169 target_sstate_after_build = self.search_sstate(target + '.*?\.tgz$')
170 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)]
171 self.remove_config(global_config[idx])
172 self.remove_recipeinc(target, target_config[idx])
173 self.assertEqual(result.status, 0, msg = "build of %s failed with %s" % (target, result.output))
174
175 runCmd("sstate-cache-management.sh -y --cache-dir=%s --remove-duplicated --extra-archs=%s" % (self.sstate_path, ','.join(map(str, sstate_archs_list))))
176 actual_remaining_sstate = [x for x in self.search_sstate(target + '.*?\.tgz$') if not any(pattern in x for pattern in ignore_patterns)]
177
178 actual_not_expected = [x for x in actual_remaining_sstate if x not in expected_remaining_sstate]
179 self.assertFalse(actual_not_expected, msg="Files should have been removed but ware not: %s" % ', '.join(map(str, actual_not_expected)))
180 expected_not_actual = [x for x in expected_remaining_sstate if x not in actual_remaining_sstate]
181 self.assertFalse(expected_not_actual, msg="Extra files ware removed: %s" ', '.join(map(str, expected_not_actual)))
182
183 @testcase(973)
184 def test_sstate_cache_management_script_using_pr_1(self):
185 global_config = []
186 target_config = []
187 global_config.append('')
188 target_config.append('PR = "0"')
189 self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic'])
190
191 @testcase(978)
192 def test_sstate_cache_management_script_using_pr_2(self):
193 global_config = []
194 target_config = []
195 global_config.append('')
196 target_config.append('PR = "0"')
197 global_config.append('')
198 target_config.append('PR = "1"')
199 self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic'])
200
201 @testcase(979)
202 def test_sstate_cache_management_script_using_pr_3(self):
203 global_config = []
204 target_config = []
205 global_config.append('MACHINE = "qemux86-64"')
206 target_config.append('PR = "0"')
207 global_config.append(global_config[0])
208 target_config.append('PR = "1"')
209 global_config.append('MACHINE = "qemux86"')
210 target_config.append('PR = "1"')
211 self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic'])
212
213 @testcase(974)
214 def test_sstate_cache_management_script_using_machine(self):
215 global_config = []
216 target_config = []
217 global_config.append('MACHINE = "qemux86-64"')
218 target_config.append('')
219 global_config.append('MACHINE = "qemux86"')
220 target_config.append('')
221 self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic'])
222
223 @testcase(1270)
224 def test_sstate_32_64_same_hash(self):
225 """
226 The sstate checksums for both native and target should not vary whether
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500227 they're built on a 32 or 64 bit system. Rather than requiring two different
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500228 build machines and running a builds, override the variables calling uname()
229 manually and check using bitbake -S.
230 """
231
232 topdir = get_bb_var('TOPDIR')
233 targetvendor = get_bb_var('TARGET_VENDOR')
234 self.write_config("""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500235MACHINE = "qemux86"
236TMPDIR = "${TOPDIR}/tmp-sstatesamehash"
237BUILD_ARCH = "x86_64"
238BUILD_OS = "linux"
239SDKMACHINE = "x86_64"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500240""")
241 self.track_for_cleanup(topdir + "/tmp-sstatesamehash")
242 bitbake("core-image-sato -S none")
243 self.write_config("""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500244MACHINE = "qemux86"
245TMPDIR = "${TOPDIR}/tmp-sstatesamehash2"
246BUILD_ARCH = "i686"
247BUILD_OS = "linux"
248SDKMACHINE = "i686"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500249""")
250 self.track_for_cleanup(topdir + "/tmp-sstatesamehash2")
251 bitbake("core-image-sato -S none")
252
253 def get_files(d):
254 f = []
255 for root, dirs, files in os.walk(d):
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500256 if "core-image-sato" in root:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500257 # SDKMACHINE changing will change
258 # do_rootfs/do_testimage/do_build stamps of images which
259 # is safe to ignore.
260 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500261 f.extend(os.path.join(root, name) for name in files)
262 return f
263 files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/")
264 files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/")
265 files2 = [x.replace("tmp-sstatesamehash2", "tmp-sstatesamehash").replace("i686-linux", "x86_64-linux").replace("i686" + targetvendor + "-linux", "x86_64" + targetvendor + "-linux", ) for x in files2]
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500266 self.maxDiff = None
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500267 self.assertItemsEqual(files1, files2)
268
269
270 @testcase(1271)
271 def test_sstate_nativelsbstring_same_hash(self):
272 """
273 The sstate checksums should be independent of whichever NATIVELSBSTRING is
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500274 detected. Rather than requiring two different build machines and running
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500275 builds, override the variables manually and check using bitbake -S.
276 """
277
278 topdir = get_bb_var('TOPDIR')
279 self.write_config("""
280TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\"
281NATIVELSBSTRING = \"DistroA\"
282""")
283 self.track_for_cleanup(topdir + "/tmp-sstatesamehash")
284 bitbake("core-image-sato -S none")
285 self.write_config("""
286TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\"
287NATIVELSBSTRING = \"DistroB\"
288""")
289 self.track_for_cleanup(topdir + "/tmp-sstatesamehash2")
290 bitbake("core-image-sato -S none")
291
292 def get_files(d):
293 f = []
294 for root, dirs, files in os.walk(d):
295 f.extend(os.path.join(root, name) for name in files)
296 return f
297 files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/")
298 files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/")
299 files2 = [x.replace("tmp-sstatesamehash2", "tmp-sstatesamehash") for x in files2]
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500300 self.maxDiff = None
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500301 self.assertItemsEqual(files1, files2)
302
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500303 @testcase(1368)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500304 def test_sstate_allarch_samesigs(self):
305 """
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500306 The sstate checksums of allarch packages should be independent of whichever
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500307 MACHINE is set. Check this using bitbake -S.
Patrick Williamsd7e96312015-09-22 08:09:05 -0500308 Also, rather than duplicate the test, check nativesdk stamps are the same between
309 the two MACHINE values.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500310 """
311
312 topdir = get_bb_var('TOPDIR')
313 targetos = get_bb_var('TARGET_OS')
314 targetvendor = get_bb_var('TARGET_VENDOR')
315 self.write_config("""
316TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\"
317MACHINE = \"qemux86\"
318""")
319 self.track_for_cleanup(topdir + "/tmp-sstatesamehash")
Patrick Williamsd7e96312015-09-22 08:09:05 -0500320 bitbake("world meta-toolchain -S none")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500321 self.write_config("""
322TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\"
323MACHINE = \"qemuarm\"
324""")
325 self.track_for_cleanup(topdir + "/tmp-sstatesamehash2")
Patrick Williamsd7e96312015-09-22 08:09:05 -0500326 bitbake("world meta-toolchain -S none")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500327
328 def get_files(d):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500329 f = {}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500330 for root, dirs, files in os.walk(d):
331 for name in files:
Patrick Williamsd7e96312015-09-22 08:09:05 -0500332 if "meta-environment" in root or "cross-canadian" in root:
333 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500334 if "do_build" not in name:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500335 # 1.4.1+gitAUTOINC+302fca9f4c-r0.do_package_write_ipk.sigdata.f3a2a38697da743f0dbed8b56aafcf79
336 (_, task, _, shash) = name.rsplit(".", 3)
337 f[os.path.join(os.path.basename(root), task)] = shash
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500338 return f
339 files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/all" + targetvendor + "-" + targetos)
340 files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/all" + targetvendor + "-" + targetos)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500341 self.maxDiff = None
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500342 self.assertEqual(files1, files2)
Patrick Williamsd7e96312015-09-22 08:09:05 -0500343
344 nativesdkdir = os.path.basename(glob.glob(topdir + "/tmp-sstatesamehash/stamps/*-nativesdk*-linux")[0])
345
346 files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/" + nativesdkdir)
347 files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/" + nativesdkdir)
Patrick Williamsd7e96312015-09-22 08:09:05 -0500348 self.maxDiff = None
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500349 self.assertEqual(files1, files2)
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500350
351 @testcase(1369)
352 def test_sstate_sametune_samesigs(self):
353 """
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500354 The sstate checksums of two identical machines (using the same tune) should be the
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500355 same, apart from changes within the machine specific stamps directory. We use the
356 qemux86copy machine to test this. Also include multilibs in the test.
357 """
358
359 topdir = get_bb_var('TOPDIR')
360 targetos = get_bb_var('TARGET_OS')
361 targetvendor = get_bb_var('TARGET_VENDOR')
362 self.write_config("""
363TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\"
364MACHINE = \"qemux86\"
365require conf/multilib.conf
366MULTILIBS = "multilib:lib32"
367DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
368""")
369 self.track_for_cleanup(topdir + "/tmp-sstatesamehash")
370 bitbake("world meta-toolchain -S none")
371 self.write_config("""
372TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\"
373MACHINE = \"qemux86copy\"
374require conf/multilib.conf
375MULTILIBS = "multilib:lib32"
376DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
377""")
378 self.track_for_cleanup(topdir + "/tmp-sstatesamehash2")
379 bitbake("world meta-toolchain -S none")
380
381 def get_files(d):
382 f = []
383 for root, dirs, files in os.walk(d):
384 for name in files:
385 if "meta-environment" in root or "cross-canadian" in root:
386 continue
387 if "qemux86copy-" in root or "qemux86-" in root:
388 continue
389 if "do_build" not in name and "do_populate_sdk" not in name:
390 f.append(os.path.join(root, name))
391 return f
392 files1 = get_files(topdir + "/tmp-sstatesamehash/stamps")
393 files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps")
394 files2 = [x.replace("tmp-sstatesamehash2", "tmp-sstatesamehash") for x in files2]
395 self.maxDiff = None
396 self.assertItemsEqual(files1, files2)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500397
398
399 def test_sstate_noop_samesigs(self):
400 """
401 The sstate checksums of two builds with these variables changed or
402 classes inherits should be the same.
403 """
404
405 topdir = get_bb_var('TOPDIR')
406 targetvendor = get_bb_var('TARGET_VENDOR')
407 self.write_config("""
408TMPDIR = "${TOPDIR}/tmp-sstatesamehash"
409BB_NUMBER_THREADS = "1"
410PARALLEL_MAKE = "-j 1"
411DL_DIR = "${TOPDIR}/download1"
412TIME = "111111"
413DATE = "20161111"
414INHERIT_remove = "buildstats-summary buildhistory"
415""")
416 self.track_for_cleanup(topdir + "/tmp-sstatesamehash")
417 bitbake("world meta-toolchain -S none")
418 self.write_config("""
419TMPDIR = "${TOPDIR}/tmp-sstatesamehash2"
420BB_NUMBER_THREADS = "2"
421PARALLEL_MAKE = "-j 2"
422DL_DIR = "${TOPDIR}/download2"
423TIME = "222222"
424DATE = "20161212"
425INHERIT += "buildstats-summary buildhistory"
426""")
427 self.track_for_cleanup(topdir + "/tmp-sstatesamehash2")
428 bitbake("world meta-toolchain -S none")
429
430 def get_files(d):
431 f = {}
432 for root, dirs, files in os.walk(d):
433 for name in files:
434 name, shash = name.rsplit('.', 1)
435 # Extract just the machine and recipe name
436 base = os.sep.join(root.rsplit(os.sep, 2)[-2:] + [name])
437 f[base] = shash
438 return f
439 files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/")
440 files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/")
441 # Remove items that are identical in both sets
442 for k,v in files1.viewitems() & files2.viewitems():
443 del files1[k]
444 del files2[k]
445 if not files1 and not files2:
446 # No changes, so we're done
447 return
448
449 for k in files1.viewkeys() | files2.viewkeys():
450 if k in files1 and k in files2:
451 print "%s differs:" % k
452 print subprocess.check_output(("bitbake-diffsigs",
453 topdir + "/tmp-sstatesamehash/stamps/" + k + "." + files1[k],
454 topdir + "/tmp-sstatesamehash2/stamps/" + k + "." + files2[k]))
455 elif k in files1 and k not in files2:
456 print "%s in files1" % k
457 elif k not in files1 and k in files2:
458 print "%s in files2" % k
459 else:
460 assert "shouldn't reach here"
461 self.fail("sstate hashes not identical.")