Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7 | import os |
| 8 | import shutil |
| 9 | import glob |
| 10 | import subprocess |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11 | import tempfile |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12 | |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 13 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 14 | from oeqa.selftest.cases.sstate import SStateBase |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 15 | import oe |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | |
| 17 | import bb.siggen |
| 18 | |
| 19 | class SStateTests(SStateBase): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | def test_autorev_sstate_works(self): |
| 21 | # Test that a git repository which changes is correctly handled by SRCREV = ${AUTOREV} |
| 22 | # when PV does not contain SRCPV |
| 23 | |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 24 | tempdir = tempfile.mkdtemp(prefix='sstate_autorev') |
| 25 | tempdldir = tempfile.mkdtemp(prefix='sstate_autorev_dldir') |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 26 | self.track_for_cleanup(tempdir) |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 27 | self.track_for_cleanup(tempdldir) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 28 | create_temp_layer(tempdir, 'selftestrecipetool') |
| 29 | self.add_command_to_tearDown('bitbake-layers remove-layer %s' % tempdir) |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 30 | self.append_config("DL_DIR = \"%s\"" % tempdldir) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | runCmd('bitbake-layers add-layer %s' % tempdir) |
| 32 | |
| 33 | # Use dbus-wait as a local git repo we can add a commit between two builds in |
| 34 | pn = 'dbus-wait' |
| 35 | srcrev = '6cc6077a36fe2648a5f993fe7c16c9632f946517' |
| 36 | url = 'git://git.yoctoproject.org/dbus-wait' |
| 37 | result = runCmd('git clone %s noname' % url, cwd=tempdir) |
| 38 | srcdir = os.path.join(tempdir, 'noname') |
| 39 | result = runCmd('git reset --hard %s' % srcrev, cwd=srcdir) |
| 40 | self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure.ac')), 'Unable to find configure script in source directory') |
| 41 | |
| 42 | recipefile = os.path.join(tempdir, "recipes-test", "dbus-wait-test", 'dbus-wait-test_git.bb') |
| 43 | os.makedirs(os.path.dirname(recipefile)) |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 44 | srcuri = 'git://' + srcdir + ';protocol=file;branch=master' |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 45 | result = runCmd(['recipetool', 'create', '-o', recipefile, srcuri]) |
| 46 | self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output) |
| 47 | |
| 48 | with open(recipefile, 'a') as f: |
| 49 | f.write('SRCREV = "${AUTOREV}"\n') |
| 50 | f.write('PV = "1.0"\n') |
| 51 | |
| 52 | bitbake("dbus-wait-test -c fetch") |
| 53 | with open(os.path.join(srcdir, "bar.txt"), "w") as f: |
| 54 | f.write("foo") |
| 55 | result = runCmd('git add bar.txt; git commit -asm "add bar"', cwd=srcdir) |
| 56 | bitbake("dbus-wait-test -c unpack") |
| 57 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 58 | |
| 59 | # Test sstate files creation and their location |
| 60 | def run_test_sstate_creation(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True, should_pass=True): |
| 61 | self.config_sstate(temp_sstate_location, [self.sstate_path]) |
| 62 | |
| 63 | if self.temp_sstate_location: |
| 64 | bitbake(['-cclean'] + targets) |
| 65 | else: |
| 66 | bitbake(['-ccleansstate'] + targets) |
| 67 | |
| 68 | bitbake(targets) |
| 69 | file_tracker = [] |
| 70 | results = self.search_sstate('|'.join(map(str, targets)), distro_specific, distro_nonspecific) |
| 71 | if distro_nonspecific: |
| 72 | for r in results: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 73 | if r.endswith(("_populate_lic.tar.zst", "_populate_lic.tar.zst.siginfo", "_fetch.tar.zst.siginfo", "_unpack.tar.zst.siginfo", "_patch.tar.zst.siginfo")): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 74 | continue |
| 75 | file_tracker.append(r) |
| 76 | else: |
| 77 | file_tracker = results |
| 78 | |
| 79 | if should_pass: |
| 80 | self.assertTrue(file_tracker , msg="Could not find sstate files for: %s" % ', '.join(map(str, targets))) |
| 81 | else: |
| 82 | self.assertTrue(not file_tracker , msg="Found sstate files in the wrong place for: %s (found %s)" % (', '.join(map(str, targets)), str(file_tracker))) |
| 83 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 84 | def test_sstate_creation_distro_specific_pass(self): |
| 85 | self.run_test_sstate_creation(['binutils-cross-'+ self.tune_arch, 'binutils-native'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True) |
| 86 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 87 | def test_sstate_creation_distro_specific_fail(self): |
| 88 | 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) |
| 89 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 90 | def test_sstate_creation_distro_nonspecific_pass(self): |
| 91 | self.run_test_sstate_creation(['linux-libc-headers'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True) |
| 92 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 93 | def test_sstate_creation_distro_nonspecific_fail(self): |
| 94 | self.run_test_sstate_creation(['linux-libc-headers'], distro_specific=True, distro_nonspecific=False, temp_sstate_location=True, should_pass=False) |
| 95 | |
| 96 | # Test the sstate files deletion part of the do_cleansstate task |
| 97 | def run_test_cleansstate_task(self, targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True): |
| 98 | self.config_sstate(temp_sstate_location, [self.sstate_path]) |
| 99 | |
| 100 | bitbake(['-ccleansstate'] + targets) |
| 101 | |
| 102 | bitbake(targets) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 103 | archives_created = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific, distro_nonspecific) |
| 104 | self.assertTrue(archives_created, msg="Could not find sstate .tar.zst files for: %s (%s)" % (', '.join(map(str, targets)), str(archives_created))) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 105 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 106 | siginfo_created = self.search_sstate('|'.join(map(str, [s + r'.*?\.siginfo$' for s in targets])), distro_specific, distro_nonspecific) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 107 | self.assertTrue(siginfo_created, msg="Could not find sstate .siginfo files for: %s (%s)" % (', '.join(map(str, targets)), str(siginfo_created))) |
| 108 | |
| 109 | bitbake(['-ccleansstate'] + targets) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 110 | archives_removed = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific, distro_nonspecific) |
| 111 | self.assertTrue(not archives_removed, msg="do_cleansstate didn't remove .tar.zst sstate files for: %s (%s)" % (', '.join(map(str, targets)), str(archives_removed))) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 112 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 113 | def test_cleansstate_task_distro_specific_nonspecific(self): |
| 114 | targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native'] |
| 115 | targets.append('linux-libc-headers') |
| 116 | self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=True, temp_sstate_location=True) |
| 117 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 118 | def test_cleansstate_task_distro_nonspecific(self): |
| 119 | self.run_test_cleansstate_task(['linux-libc-headers'], distro_specific=False, distro_nonspecific=True, temp_sstate_location=True) |
| 120 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 121 | def test_cleansstate_task_distro_specific(self): |
| 122 | targets = ['binutils-cross-'+ self.tune_arch, 'binutils-native'] |
| 123 | targets.append('linux-libc-headers') |
| 124 | self.run_test_cleansstate_task(targets, distro_specific=True, distro_nonspecific=False, temp_sstate_location=True) |
| 125 | |
| 126 | |
| 127 | # Test rebuilding of distro-specific sstate files |
| 128 | def run_test_rebuild_distro_specific_sstate(self, targets, temp_sstate_location=True): |
| 129 | self.config_sstate(temp_sstate_location, [self.sstate_path]) |
| 130 | |
| 131 | bitbake(['-ccleansstate'] + targets) |
| 132 | |
| 133 | bitbake(targets) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 134 | results = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=False, distro_nonspecific=True) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 135 | filtered_results = [] |
| 136 | for r in results: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 137 | if r.endswith(("_populate_lic.tar.zst", "_populate_lic.tar.zst.siginfo")): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 138 | continue |
| 139 | filtered_results.append(r) |
| 140 | self.assertTrue(filtered_results == [], msg="Found distro non-specific sstate for: %s (%s)" % (', '.join(map(str, targets)), str(filtered_results))) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 141 | file_tracker_1 = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=True, distro_nonspecific=False) |
| 142 | self.assertTrue(len(file_tracker_1) >= len(targets), msg = "Not all sstate files were created for: %s" % ', '.join(map(str, targets))) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 143 | |
| 144 | self.track_for_cleanup(self.distro_specific_sstate + "_old") |
| 145 | shutil.copytree(self.distro_specific_sstate, self.distro_specific_sstate + "_old") |
| 146 | shutil.rmtree(self.distro_specific_sstate) |
| 147 | |
| 148 | bitbake(['-cclean'] + targets) |
| 149 | bitbake(targets) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 150 | file_tracker_2 = self.search_sstate('|'.join(map(str, [s + r'.*?\.tar.zst$' for s in targets])), distro_specific=True, distro_nonspecific=False) |
| 151 | self.assertTrue(len(file_tracker_2) >= len(targets), msg = "Not all sstate files were created for: %s" % ', '.join(map(str, targets))) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 152 | |
| 153 | not_recreated = [x for x in file_tracker_1 if x not in file_tracker_2] |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 154 | self.assertTrue(not_recreated == [], msg="The following sstate files were not recreated: %s" % ', '.join(map(str, not_recreated))) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 155 | |
| 156 | created_once = [x for x in file_tracker_2 if x not in file_tracker_1] |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 157 | self.assertTrue(created_once == [], msg="The following sstate files were created only in the second run: %s" % ', '.join(map(str, created_once))) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 158 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 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 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 162 | def test_rebuild_distro_specific_sstate_cross_target(self): |
| 163 | self.run_test_rebuild_distro_specific_sstate(['binutils-cross-' + self.tune_arch], temp_sstate_location=True) |
| 164 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 165 | def test_rebuild_distro_specific_sstate_native_target(self): |
| 166 | self.run_test_rebuild_distro_specific_sstate(['binutils-native'], temp_sstate_location=True) |
| 167 | |
| 168 | |
| 169 | # Test the sstate-cache-management script. Each element in the global_config list is used with the corresponding element in the target_config list |
| 170 | # 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) |
| 171 | def run_test_sstate_cache_management_script(self, target, global_config=[''], target_config=[''], ignore_patterns=[]): |
| 172 | self.assertTrue(global_config) |
| 173 | self.assertTrue(target_config) |
| 174 | self.assertTrue(len(global_config) == len(target_config), msg='Lists global_config and target_config should have the same number of elements') |
| 175 | self.config_sstate(temp_sstate_location=True, add_local_mirrors=[self.sstate_path]) |
| 176 | |
| 177 | # If buildhistory is enabled, we need to disable version-going-backwards |
| 178 | # QA checks for this test. It may report errors otherwise. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 179 | self.append_config('ERROR_QA:remove = "version-going-backwards"') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 180 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 181 | # For now this only checks if random sstate tasks are handled correctly as a group. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 182 | # In the future we should add control over what tasks we check for. |
| 183 | |
| 184 | sstate_archs_list = [] |
| 185 | expected_remaining_sstate = [] |
| 186 | for idx in range(len(target_config)): |
| 187 | self.append_config(global_config[idx]) |
| 188 | self.append_recipeinc(target, target_config[idx]) |
| 189 | sstate_arch = get_bb_var('SSTATE_PKGARCH', target) |
| 190 | if not sstate_arch in sstate_archs_list: |
| 191 | sstate_archs_list.append(sstate_arch) |
| 192 | if target_config[idx] == target_config[-1]: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 193 | target_sstate_before_build = self.search_sstate(target + r'.*?\.tar.zst$') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 194 | bitbake("-cclean %s" % target) |
| 195 | result = bitbake(target, ignore_status=True) |
| 196 | if target_config[idx] == target_config[-1]: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 197 | target_sstate_after_build = self.search_sstate(target + r'.*?\.tar.zst$') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 198 | 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)] |
| 199 | self.remove_config(global_config[idx]) |
| 200 | self.remove_recipeinc(target, target_config[idx]) |
| 201 | self.assertEqual(result.status, 0, msg = "build of %s failed with %s" % (target, result.output)) |
| 202 | |
| 203 | runCmd("sstate-cache-management.sh -y --cache-dir=%s --remove-duplicated --extra-archs=%s" % (self.sstate_path, ','.join(map(str, sstate_archs_list)))) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 204 | actual_remaining_sstate = [x for x in self.search_sstate(target + r'.*?\.tar.zst$') if not any(pattern in x for pattern in ignore_patterns)] |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 205 | |
| 206 | actual_not_expected = [x for x in actual_remaining_sstate if x not in expected_remaining_sstate] |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 207 | self.assertFalse(actual_not_expected, msg="Files should have been removed but were not: %s" % ', '.join(map(str, actual_not_expected))) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 208 | expected_not_actual = [x for x in expected_remaining_sstate if x not in actual_remaining_sstate] |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 209 | self.assertFalse(expected_not_actual, msg="Extra files were removed: %s" ', '.join(map(str, expected_not_actual))) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 210 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 211 | def test_sstate_cache_management_script_using_pr_1(self): |
| 212 | global_config = [] |
| 213 | target_config = [] |
| 214 | global_config.append('') |
| 215 | target_config.append('PR = "0"') |
| 216 | self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) |
| 217 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 218 | def test_sstate_cache_management_script_using_pr_2(self): |
| 219 | global_config = [] |
| 220 | target_config = [] |
| 221 | global_config.append('') |
| 222 | target_config.append('PR = "0"') |
| 223 | global_config.append('') |
| 224 | target_config.append('PR = "1"') |
| 225 | self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) |
| 226 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 227 | def test_sstate_cache_management_script_using_pr_3(self): |
| 228 | global_config = [] |
| 229 | target_config = [] |
| 230 | global_config.append('MACHINE = "qemux86-64"') |
| 231 | target_config.append('PR = "0"') |
| 232 | global_config.append(global_config[0]) |
| 233 | target_config.append('PR = "1"') |
| 234 | global_config.append('MACHINE = "qemux86"') |
| 235 | target_config.append('PR = "1"') |
| 236 | self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) |
| 237 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 238 | def test_sstate_cache_management_script_using_machine(self): |
| 239 | global_config = [] |
| 240 | target_config = [] |
| 241 | global_config.append('MACHINE = "qemux86-64"') |
| 242 | target_config.append('') |
| 243 | global_config.append('MACHINE = "qemux86"') |
| 244 | target_config.append('') |
| 245 | self.run_test_sstate_cache_management_script('m4', global_config, target_config, ignore_patterns=['populate_lic']) |
| 246 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 247 | def test_sstate_32_64_same_hash(self): |
| 248 | """ |
| 249 | The sstate checksums for both native and target should not vary whether |
| 250 | they're built on a 32 or 64 bit system. Rather than requiring two different |
| 251 | build machines and running a builds, override the variables calling uname() |
| 252 | manually and check using bitbake -S. |
| 253 | """ |
| 254 | |
| 255 | self.write_config(""" |
| 256 | MACHINE = "qemux86" |
| 257 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 258 | TCLIBCAPPEND = "" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 259 | BUILD_ARCH = "x86_64" |
| 260 | BUILD_OS = "linux" |
| 261 | SDKMACHINE = "x86_64" |
| 262 | PACKAGE_CLASSES = "package_rpm package_ipk package_deb" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 263 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 264 | """) |
| 265 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 266 | bitbake("core-image-weston -S none") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 267 | self.write_config(""" |
| 268 | MACHINE = "qemux86" |
| 269 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 270 | TCLIBCAPPEND = "" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 271 | BUILD_ARCH = "i686" |
| 272 | BUILD_OS = "linux" |
| 273 | SDKMACHINE = "i686" |
| 274 | PACKAGE_CLASSES = "package_rpm package_ipk package_deb" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 275 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 276 | """) |
| 277 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 278 | bitbake("core-image-weston -S none") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 279 | |
| 280 | def get_files(d): |
| 281 | f = [] |
| 282 | for root, dirs, files in os.walk(d): |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 283 | if "core-image-weston" in root: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 284 | # SDKMACHINE changing will change |
| 285 | # do_rootfs/do_testimage/do_build stamps of images which |
| 286 | # is safe to ignore. |
| 287 | continue |
| 288 | f.extend(os.path.join(root, name) for name in files) |
| 289 | return f |
| 290 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps/") |
| 291 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps/") |
| 292 | 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] |
| 293 | self.maxDiff = None |
| 294 | self.assertCountEqual(files1, files2) |
| 295 | |
| 296 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 297 | def test_sstate_nativelsbstring_same_hash(self): |
| 298 | """ |
| 299 | The sstate checksums should be independent of whichever NATIVELSBSTRING is |
| 300 | detected. Rather than requiring two different build machines and running |
| 301 | builds, override the variables manually and check using bitbake -S. |
| 302 | """ |
| 303 | |
| 304 | self.write_config(""" |
| 305 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 306 | TCLIBCAPPEND = \"\" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 307 | NATIVELSBSTRING = \"DistroA\" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 308 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 309 | """) |
| 310 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 311 | bitbake("core-image-weston -S none") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 312 | self.write_config(""" |
| 313 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 314 | TCLIBCAPPEND = \"\" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 315 | NATIVELSBSTRING = \"DistroB\" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 316 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 317 | """) |
| 318 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 319 | bitbake("core-image-weston -S none") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 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 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 332 | def test_sstate_allarch_samesigs(self): |
| 333 | """ |
| 334 | The sstate checksums of allarch packages should be independent of whichever |
| 335 | MACHINE is set. Check this using bitbake -S. |
| 336 | Also, rather than duplicate the test, check nativesdk stamps are the same between |
| 337 | the two MACHINE values. |
| 338 | """ |
| 339 | |
| 340 | configA = """ |
| 341 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 342 | TCLIBCAPPEND = \"\" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 343 | MACHINE = \"qemux86-64\" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 344 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 345 | """ |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 346 | #OLDEST_KERNEL is arch specific so set to a different value here for testing |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 347 | configB = """ |
| 348 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 349 | TCLIBCAPPEND = \"\" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 350 | MACHINE = \"qemuarm\" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 351 | OLDEST_KERNEL = \"3.3.0\" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 352 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 353 | """ |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 354 | self.sstate_common_samesigs(configA, configB, allarch=True) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 355 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 356 | def test_sstate_nativesdk_samesigs_multilib(self): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 357 | """ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 358 | check nativesdk stamps are the same between the two MACHINE values. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 359 | """ |
| 360 | |
| 361 | configA = """ |
| 362 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 363 | TCLIBCAPPEND = \"\" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 364 | MACHINE = \"qemux86-64\" |
| 365 | require conf/multilib.conf |
| 366 | MULTILIBS = \"multilib:lib32\" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 367 | DEFAULTTUNE:virtclass-multilib-lib32 = \"x86\" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 368 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 369 | """ |
| 370 | configB = """ |
| 371 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 372 | TCLIBCAPPEND = \"\" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 373 | MACHINE = \"qemuarm\" |
| 374 | require conf/multilib.conf |
| 375 | MULTILIBS = \"\" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 376 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 377 | """ |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 378 | self.sstate_common_samesigs(configA, configB) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 379 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 380 | def sstate_common_samesigs(self, configA, configB, allarch=False): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 381 | |
| 382 | self.write_config(configA) |
| 383 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") |
| 384 | bitbake("world meta-toolchain -S none") |
| 385 | self.write_config(configB) |
| 386 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") |
| 387 | bitbake("world meta-toolchain -S none") |
| 388 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 389 | def get_files(d, result): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 390 | for root, dirs, files in os.walk(d): |
| 391 | for name in files: |
| 392 | if "meta-environment" in root or "cross-canadian" in root: |
| 393 | continue |
| 394 | if "do_build" not in name: |
| 395 | # 1.4.1+gitAUTOINC+302fca9f4c-r0.do_package_write_ipk.sigdata.f3a2a38697da743f0dbed8b56aafcf79 |
| 396 | (_, task, _, shash) = name.rsplit(".", 3) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 397 | result[os.path.join(os.path.basename(root), task)] = shash |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 398 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 399 | files1 = {} |
| 400 | files2 = {} |
| 401 | subdirs = sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/*-nativesdk*-linux")) |
| 402 | if allarch: |
| 403 | subdirs.extend(sorted(glob.glob(self.topdir + "/tmp-sstatesamehash/stamps/all-*-linux"))) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 404 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 405 | for subdir in subdirs: |
| 406 | nativesdkdir = os.path.basename(subdir) |
| 407 | get_files(self.topdir + "/tmp-sstatesamehash/stamps/" + nativesdkdir, files1) |
| 408 | get_files(self.topdir + "/tmp-sstatesamehash2/stamps/" + nativesdkdir, files2) |
| 409 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 410 | self.maxDiff = None |
| 411 | self.assertEqual(files1, files2) |
| 412 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 413 | def test_sstate_sametune_samesigs(self): |
| 414 | """ |
| 415 | The sstate checksums of two identical machines (using the same tune) should be the |
| 416 | same, apart from changes within the machine specific stamps directory. We use the |
| 417 | qemux86copy machine to test this. Also include multilibs in the test. |
| 418 | """ |
| 419 | |
| 420 | self.write_config(""" |
| 421 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 422 | TCLIBCAPPEND = \"\" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 423 | MACHINE = \"qemux86\" |
| 424 | require conf/multilib.conf |
| 425 | MULTILIBS = "multilib:lib32" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 426 | DEFAULTTUNE:virtclass-multilib-lib32 = "x86" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 427 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 428 | """) |
| 429 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") |
| 430 | bitbake("world meta-toolchain -S none") |
| 431 | self.write_config(""" |
| 432 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 433 | TCLIBCAPPEND = \"\" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 434 | MACHINE = \"qemux86copy\" |
| 435 | require conf/multilib.conf |
| 436 | MULTILIBS = "multilib:lib32" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 437 | DEFAULTTUNE:virtclass-multilib-lib32 = "x86" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 438 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 439 | """) |
| 440 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") |
| 441 | bitbake("world meta-toolchain -S none") |
| 442 | |
| 443 | def get_files(d): |
| 444 | f = [] |
| 445 | for root, dirs, files in os.walk(d): |
| 446 | for name in files: |
Patrick Williams | db4c27e | 2022-08-05 08:10:29 -0500 | [diff] [blame] | 447 | if "meta-environment" in root or "cross-canadian" in root or 'meta-ide-support' in root: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 448 | continue |
| 449 | if "qemux86copy-" in root or "qemux86-" in root: |
| 450 | continue |
| 451 | if "do_build" not in name and "do_populate_sdk" not in name: |
| 452 | f.append(os.path.join(root, name)) |
| 453 | return f |
| 454 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps") |
| 455 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps") |
| 456 | files2 = [x.replace("tmp-sstatesamehash2", "tmp-sstatesamehash") for x in files2] |
| 457 | self.maxDiff = None |
| 458 | self.assertCountEqual(files1, files2) |
| 459 | |
| 460 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 461 | def test_sstate_multilib_or_not_native_samesigs(self): |
| 462 | """The sstate checksums of two native recipes (and their dependencies) |
| 463 | where the target is using multilib in one but not the other |
| 464 | should be the same. We use the qemux86copy machine to test |
| 465 | this. |
| 466 | """ |
| 467 | |
| 468 | self.write_config(""" |
| 469 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash\" |
| 470 | TCLIBCAPPEND = \"\" |
| 471 | MACHINE = \"qemux86\" |
| 472 | require conf/multilib.conf |
| 473 | MULTILIBS = "multilib:lib32" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 474 | DEFAULTTUNE:virtclass-multilib-lib32 = "x86" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 475 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
| 476 | """) |
| 477 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") |
| 478 | bitbake("binutils-native -S none") |
| 479 | self.write_config(""" |
| 480 | TMPDIR = \"${TOPDIR}/tmp-sstatesamehash2\" |
| 481 | TCLIBCAPPEND = \"\" |
| 482 | MACHINE = \"qemux86copy\" |
| 483 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
| 484 | """) |
| 485 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") |
| 486 | bitbake("binutils-native -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 | f.append(os.path.join(root, name)) |
| 493 | return f |
| 494 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps") |
| 495 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps") |
| 496 | files2 = [x.replace("tmp-sstatesamehash2", "tmp-sstatesamehash") for x in files2] |
| 497 | self.maxDiff = None |
| 498 | self.assertCountEqual(files1, files2) |
| 499 | |
| 500 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 501 | def test_sstate_noop_samesigs(self): |
| 502 | """ |
| 503 | The sstate checksums of two builds with these variables changed or |
| 504 | classes inherits should be the same. |
| 505 | """ |
| 506 | |
| 507 | self.write_config(""" |
| 508 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 509 | TCLIBCAPPEND = "" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 510 | BB_NUMBER_THREADS = "${@oe.utils.cpu_count()}" |
| 511 | PARALLEL_MAKE = "-j 1" |
| 512 | DL_DIR = "${TOPDIR}/download1" |
| 513 | TIME = "111111" |
| 514 | DATE = "20161111" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 515 | INHERIT:remove = "buildstats-summary buildhistory uninative" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 516 | http_proxy = "" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 517 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 518 | """) |
| 519 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") |
| 520 | self.track_for_cleanup(self.topdir + "/download1") |
| 521 | bitbake("world meta-toolchain -S none") |
| 522 | self.write_config(""" |
| 523 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 524 | TCLIBCAPPEND = "" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 525 | BB_NUMBER_THREADS = "${@oe.utils.cpu_count()+1}" |
| 526 | PARALLEL_MAKE = "-j 2" |
| 527 | DL_DIR = "${TOPDIR}/download2" |
| 528 | TIME = "222222" |
| 529 | DATE = "20161212" |
| 530 | # Always remove uninative as we're changing proxies |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 531 | INHERIT:remove = "uninative" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 532 | INHERIT += "buildstats-summary buildhistory" |
| 533 | http_proxy = "http://example.com/" |
Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 534 | BB_SIGNATURE_HANDLER = "OEBasicHash" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 535 | """) |
| 536 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") |
| 537 | self.track_for_cleanup(self.topdir + "/download2") |
| 538 | bitbake("world meta-toolchain -S none") |
| 539 | |
| 540 | def get_files(d): |
| 541 | f = {} |
| 542 | for root, dirs, files in os.walk(d): |
| 543 | for name in files: |
| 544 | name, shash = name.rsplit('.', 1) |
| 545 | # Extract just the machine and recipe name |
| 546 | base = os.sep.join(root.rsplit(os.sep, 2)[-2:] + [name]) |
| 547 | f[base] = shash |
| 548 | return f |
| 549 | |
| 550 | def compare_sigfiles(files, files1, files2, compare=False): |
| 551 | for k in files: |
| 552 | if k in files1 and k in files2: |
| 553 | print("%s differs:" % k) |
| 554 | if compare: |
| 555 | sigdatafile1 = self.topdir + "/tmp-sstatesamehash/stamps/" + k + "." + files1[k] |
| 556 | sigdatafile2 = self.topdir + "/tmp-sstatesamehash2/stamps/" + k + "." + files2[k] |
| 557 | output = bb.siggen.compare_sigfiles(sigdatafile1, sigdatafile2) |
| 558 | if output: |
| 559 | print('\n'.join(output)) |
| 560 | elif k in files1 and k not in files2: |
| 561 | print("%s in files1" % k) |
| 562 | elif k not in files1 and k in files2: |
| 563 | print("%s in files2" % k) |
| 564 | else: |
| 565 | assert "shouldn't reach here" |
| 566 | |
| 567 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps/") |
| 568 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps/") |
| 569 | # Remove items that are identical in both sets |
| 570 | for k,v in files1.items() & files2.items(): |
| 571 | del files1[k] |
| 572 | del files2[k] |
| 573 | if not files1 and not files2: |
| 574 | # No changes, so we're done |
| 575 | return |
| 576 | |
| 577 | files = list(files1.keys() | files2.keys()) |
| 578 | # this is an expensive computation, thus just compare the first 'max_sigfiles_to_compare' k files |
| 579 | max_sigfiles_to_compare = 20 |
| 580 | first, rest = files[:max_sigfiles_to_compare], files[max_sigfiles_to_compare:] |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 581 | compare_sigfiles(first, files1, files2, compare=True) |
| 582 | compare_sigfiles(rest, files1, files2, compare=False) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 583 | |
| 584 | self.fail("sstate hashes not identical.") |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 585 | |
| 586 | def test_sstate_movelayer_samesigs(self): |
| 587 | """ |
| 588 | The sstate checksums of two builds with the same oe-core layer in two |
| 589 | different locations should be the same. |
| 590 | """ |
| 591 | core_layer = os.path.join( |
| 592 | self.tc.td["COREBASE"], 'meta') |
| 593 | copy_layer_1 = self.topdir + "/meta-copy1/meta" |
| 594 | copy_layer_2 = self.topdir + "/meta-copy2/meta" |
| 595 | |
| 596 | oe.path.copytree(core_layer, copy_layer_1) |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 597 | os.symlink(os.path.dirname(core_layer) + "/scripts", self.topdir + "/meta-copy1/scripts") |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 598 | self.write_config(""" |
| 599 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash" |
| 600 | """) |
| 601 | bblayers_conf = 'BBLAYERS += "%s"\nBBLAYERS:remove = "%s"' % (copy_layer_1, core_layer) |
| 602 | self.write_bblayers_config(bblayers_conf) |
| 603 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash") |
| 604 | bitbake("bash -S none") |
| 605 | |
| 606 | oe.path.copytree(core_layer, copy_layer_2) |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 607 | os.symlink(os.path.dirname(core_layer) + "/scripts", self.topdir + "/meta-copy2/scripts") |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 608 | self.write_config(""" |
| 609 | TMPDIR = "${TOPDIR}/tmp-sstatesamehash2" |
| 610 | """) |
| 611 | bblayers_conf = 'BBLAYERS += "%s"\nBBLAYERS:remove = "%s"' % (copy_layer_2, core_layer) |
| 612 | self.write_bblayers_config(bblayers_conf) |
| 613 | self.track_for_cleanup(self.topdir + "/tmp-sstatesamehash2") |
| 614 | bitbake("bash -S none") |
| 615 | |
| 616 | def get_files(d): |
| 617 | f = [] |
| 618 | for root, dirs, files in os.walk(d): |
| 619 | for name in files: |
| 620 | f.append(os.path.join(root, name)) |
| 621 | return f |
| 622 | files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps") |
| 623 | files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps") |
| 624 | files2 = [x.replace("tmp-sstatesamehash2", "tmp-sstatesamehash") for x in files2] |
| 625 | self.maxDiff = None |
| 626 | self.assertCountEqual(files1, files2) |
| 627 | |