Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | import datetime |
| 2 | import unittest |
| 3 | import os |
| 4 | import re |
| 5 | import shutil |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 6 | import glob |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7 | import subprocess |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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) |
| 20 | |
| 21 | if self.temp_sstate_location: |
| 22 | bitbake(['-cclean'] + targets) |
| 23 | else: |
| 24 | bitbake(['-ccleansstate'] + targets) |
| 25 | |
| 26 | bitbake(targets) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 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 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 37 | if should_pass: |
| 38 | self.assertTrue(file_tracker , msg="Could not find sstate files for: %s" % ', '.join(map(str, targets))) |
| 39 | else: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 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))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | |
| 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 47 | @testcase(1374) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 56 | @testcase(1375) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 69 | self.assertTrue(tgz_created, msg="Could not find sstate .tgz files for: %s (%s)" % (', '.join(map(str, targets)), str(tgz_created))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 70 | |
| 71 | siginfo_created = self.search_sstate('|'.join(map(str, [s + '.*?\.siginfo$' for s in targets])), distro_specific, distro_nonspecific) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 72 | self.assertTrue(siginfo_created, msg="Could not find sstate .siginfo files for: %s (%s)" % (', '.join(map(str, targets)), str(siginfo_created))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | |
| 74 | bitbake(['-ccleansstate'] + targets) |
| 75 | tgz_removed = self.search_sstate('|'.join(map(str, [s + '.*?\.tgz$' for s in targets])), distro_specific, distro_nonspecific) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 76 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 77 | |
| 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 83 | @testcase(1376) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 87 | @testcase(1377) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 100 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 130 | @testcase(1372) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 131 | 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 135 | @testcase(1373) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 136 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 227 | they're built on a 32 or 64 bit system. Rather than requiring two different |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 228 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 235 | MACHINE = "qemux86" |
| 236 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash" |
| 237 | BUILD_ARCH = "x86_64" |
| 238 | BUILD_OS = "linux" |
| 239 | SDKMACHINE = "x86_64" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 240 | """) |
| 241 | self.track_for_cleanup(topdir + "/tmp-sstatesamehash") |
| 242 | bitbake("core-image-sato -S none") |
| 243 | self.write_config(""" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 244 | MACHINE = "qemux86" |
| 245 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" |
| 246 | BUILD_ARCH = "i686" |
| 247 | BUILD_OS = "linux" |
| 248 | SDKMACHINE = "i686" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 249 | """) |
| 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 256 | if "core-image-sato" in root: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 257 | # SDKMACHINE changing will change |
| 258 | # do_rootfs/do_testimage/do_build stamps of images which |
| 259 | # is safe to ignore. |
| 260 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 261 | 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 266 | self.maxDiff = None |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 267 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 274 | detected. Rather than requiring two different build machines and running |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 275 | builds, override the variables manually and check using bitbake -S. |
| 276 | """ |
| 277 | |
| 278 | topdir = get_bb_var('TOPDIR') |
| 279 | self.write_config(""" |
| 280 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" |
| 281 | NATIVELSBSTRING = \"DistroA\" |
| 282 | """) |
| 283 | self.track_for_cleanup(topdir + "/tmp-sstatesamehash") |
| 284 | bitbake("core-image-sato -S none") |
| 285 | self.write_config(""" |
| 286 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" |
| 287 | NATIVELSBSTRING = \"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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 300 | self.maxDiff = None |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 301 | self.assertItemsEqual(files1, files2) |
| 302 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 303 | @testcase(1368) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 304 | def test_sstate_allarch_samesigs(self): |
| 305 | """ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 306 | The sstate checksums of allarch packages should be independent of whichever |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 307 | MACHINE is set. Check this using bitbake -S. |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 308 | Also, rather than duplicate the test, check nativesdk stamps are the same between |
| 309 | the two MACHINE values. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 310 | """ |
| 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(""" |
| 316 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" |
| 317 | MACHINE = \"qemux86\" |
| 318 | """) |
| 319 | self.track_for_cleanup(topdir + "/tmp-sstatesamehash") |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 320 | bitbake("world meta-toolchain -S none") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 321 | self.write_config(""" |
| 322 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" |
| 323 | MACHINE = \"qemuarm\" |
| 324 | """) |
| 325 | self.track_for_cleanup(topdir + "/tmp-sstatesamehash2") |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 326 | bitbake("world meta-toolchain -S none") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 327 | |
| 328 | def get_files(d): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 329 | f = {} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 330 | for root, dirs, files in os.walk(d): |
| 331 | for name in files: |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 332 | if "meta-environment" in root or "cross-canadian" in root: |
| 333 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 334 | if "do_build" not in name: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 335 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 338 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 341 | self.maxDiff = None |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 342 | self.assertEqual(files1, files2) |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 343 | |
| 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 Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 348 | self.maxDiff = None |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 349 | self.assertEqual(files1, files2) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 350 | |
| 351 | @testcase(1369) |
| 352 | def test_sstate_sametune_samesigs(self): |
| 353 | """ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 354 | The sstate checksums of two identical machines (using the same tune) should be the |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 355 | 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(""" |
| 363 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" |
| 364 | MACHINE = \"qemux86\" |
| 365 | require conf/multilib.conf |
| 366 | MULTILIBS = "multilib:lib32" |
| 367 | DEFAULTTUNE_virtclass-multilib-lib32 = "x86" |
| 368 | """) |
| 369 | self.track_for_cleanup(topdir + "/tmp-sstatesamehash") |
| 370 | bitbake("world meta-toolchain -S none") |
| 371 | self.write_config(""" |
| 372 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" |
| 373 | MACHINE = \"qemux86copy\" |
| 374 | require conf/multilib.conf |
| 375 | MULTILIBS = "multilib:lib32" |
| 376 | DEFAULTTUNE_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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 397 | |
| 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(""" |
| 408 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash" |
| 409 | BB_NUMBER_THREADS = "1" |
| 410 | PARALLEL_MAKE = "-j 1" |
| 411 | DL_DIR = "${TOPDIR}/download1" |
| 412 | TIME = "111111" |
| 413 | DATE = "20161111" |
| 414 | INHERIT_remove = "buildstats-summary buildhistory" |
| 415 | """) |
| 416 | self.track_for_cleanup(topdir + "/tmp-sstatesamehash") |
| 417 | bitbake("world meta-toolchain -S none") |
| 418 | self.write_config(""" |
| 419 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" |
| 420 | BB_NUMBER_THREADS = "2" |
| 421 | PARALLEL_MAKE = "-j 2" |
| 422 | DL_DIR = "${TOPDIR}/download2" |
| 423 | TIME = "222222" |
| 424 | DATE = "20161212" |
| 425 | INHERIT += "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.") |