Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 4 | # Copyright 2019-2020 by Garmin Ltd. or its subsidiaries |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 5 | |
| 6 | from oeqa.selftest.case import OESelftestTestCase |
| 7 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 8 | import bb.utils |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 9 | import functools |
| 10 | import multiprocessing |
| 11 | import textwrap |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 12 | import tempfile |
| 13 | import shutil |
| 14 | import stat |
| 15 | import os |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 16 | import datetime |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 17 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 18 | exclude_packages = [ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 19 | 'rust', |
| 20 | 'rust-dbg' |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 21 | ] |
| 22 | |
| 23 | def is_excluded(package): |
| 24 | package_name = os.path.basename(package) |
| 25 | for i in exclude_packages: |
| 26 | if package_name.startswith(i): |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame] | 27 | return i |
| 28 | return None |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 29 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 30 | MISSING = 'MISSING' |
| 31 | DIFFERENT = 'DIFFERENT' |
| 32 | SAME = 'SAME' |
| 33 | |
| 34 | @functools.total_ordering |
| 35 | class CompareResult(object): |
| 36 | def __init__(self): |
| 37 | self.reference = None |
| 38 | self.test = None |
| 39 | self.status = 'UNKNOWN' |
| 40 | |
| 41 | def __eq__(self, other): |
| 42 | return (self.status, self.test) == (other.status, other.test) |
| 43 | |
| 44 | def __lt__(self, other): |
| 45 | return (self.status, self.test) < (other.status, other.test) |
| 46 | |
| 47 | class PackageCompareResults(object): |
| 48 | def __init__(self): |
| 49 | self.total = [] |
| 50 | self.missing = [] |
| 51 | self.different = [] |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 52 | self.different_excluded = [] |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 53 | self.same = [] |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame] | 54 | self.active_exclusions = set() |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 55 | |
| 56 | def add_result(self, r): |
| 57 | self.total.append(r) |
| 58 | if r.status == MISSING: |
| 59 | self.missing.append(r) |
| 60 | elif r.status == DIFFERENT: |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame] | 61 | exclusion = is_excluded(r.reference) |
| 62 | if exclusion: |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 63 | self.different_excluded.append(r) |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame] | 64 | self.active_exclusions.add(exclusion) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 65 | else: |
| 66 | self.different.append(r) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 67 | else: |
| 68 | self.same.append(r) |
| 69 | |
| 70 | def sort(self): |
| 71 | self.total.sort() |
| 72 | self.missing.sort() |
| 73 | self.different.sort() |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 74 | self.different_excluded.sort() |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 75 | self.same.sort() |
| 76 | |
| 77 | def __str__(self): |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame] | 78 | return 'same=%i different=%i different_excluded=%i missing=%i total=%i\nunused_exclusions=%s' % (len(self.same), len(self.different), len(self.different_excluded), len(self.missing), len(self.total), self.unused_exclusions()) |
| 79 | |
| 80 | def unused_exclusions(self): |
| 81 | return sorted(set(exclude_packages) - self.active_exclusions) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 82 | |
| 83 | def compare_file(reference, test, diffutils_sysroot): |
| 84 | result = CompareResult() |
| 85 | result.reference = reference |
| 86 | result.test = test |
| 87 | |
| 88 | if not os.path.exists(reference): |
| 89 | result.status = MISSING |
| 90 | return result |
| 91 | |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 92 | r = runCmd(['cmp', '--quiet', reference, test], native_sysroot=diffutils_sysroot, ignore_status=True, sync=False) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 93 | |
| 94 | if r.status: |
| 95 | result.status = DIFFERENT |
| 96 | return result |
| 97 | |
| 98 | result.status = SAME |
| 99 | return result |
| 100 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 101 | def run_diffoscope(a_dir, b_dir, html_dir, max_report_size=0, **kwargs): |
| 102 | return runCmd(['diffoscope', '--no-default-limits', '--max-report-size', str(max_report_size), |
| 103 | '--exclude-directory-metadata', 'yes', '--html-dir', html_dir, a_dir, b_dir], |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 104 | **kwargs) |
| 105 | |
| 106 | class DiffoscopeTests(OESelftestTestCase): |
| 107 | diffoscope_test_files = os.path.join(os.path.dirname(os.path.abspath(__file__)), "diffoscope") |
| 108 | |
| 109 | def test_diffoscope(self): |
| 110 | bitbake("diffoscope-native -c addto_recipe_sysroot") |
| 111 | diffoscope_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffoscope-native") |
| 112 | |
| 113 | # Check that diffoscope doesn't return an error when the files compare |
| 114 | # the same (a general check that diffoscope is working) |
| 115 | with tempfile.TemporaryDirectory() as tmpdir: |
| 116 | run_diffoscope('A', 'A', tmpdir, |
| 117 | native_sysroot=diffoscope_sysroot, cwd=self.diffoscope_test_files) |
| 118 | |
| 119 | # Check that diffoscope generates an index.html file when the files are |
| 120 | # different |
| 121 | with tempfile.TemporaryDirectory() as tmpdir: |
| 122 | r = run_diffoscope('A', 'B', tmpdir, |
| 123 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=self.diffoscope_test_files) |
| 124 | |
| 125 | self.assertNotEqual(r.status, 0, msg="diffoscope was successful when an error was expected") |
| 126 | self.assertTrue(os.path.exists(os.path.join(tmpdir, 'index.html')), "HTML index not found!") |
| 127 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 128 | class ReproducibleTests(OESelftestTestCase): |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 129 | # Test the reproducibility of whatever is built between sstate_targets and targets |
| 130 | |
| 131 | package_classes = ['deb', 'ipk', 'rpm'] |
| 132 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 133 | # Maximum report size, in bytes |
| 134 | max_report_size = 250 * 1024 * 1024 |
| 135 | |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 136 | # targets are the things we want to test the reproducibility of |
| 137 | targets = ['core-image-minimal', 'core-image-sato', 'core-image-full-cmdline', 'core-image-weston', 'world'] |
| 138 | # sstate targets are things to pull from sstate to potentially cut build/debugging time |
| 139 | sstate_targets = [] |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 140 | save_results = False |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 141 | if 'OEQA_DEBUGGING_SAVED_OUTPUT' in os.environ: |
| 142 | save_results = os.environ['OEQA_DEBUGGING_SAVED_OUTPUT'] |
| 143 | |
| 144 | # This variable controls if one of the test builds is allowed to pull from |
| 145 | # an sstate cache/mirror. The other build is always done clean as a point of |
| 146 | # comparison. |
| 147 | # If you know that your sstate archives are reproducible, enabling this |
| 148 | # will test that and also make the test run faster. If your sstate is not |
| 149 | # reproducible, disable this in your derived test class |
| 150 | build_from_sstate = True |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 151 | |
| 152 | def setUpLocal(self): |
| 153 | super().setUpLocal() |
| 154 | needed_vars = ['TOPDIR', 'TARGET_PREFIX', 'BB_NUMBER_THREADS'] |
| 155 | bb_vars = get_bb_vars(needed_vars) |
| 156 | for v in needed_vars: |
| 157 | setattr(self, v.lower(), bb_vars[v]) |
| 158 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 159 | self.extraresults = {} |
| 160 | self.extraresults.setdefault('reproducible.rawlogs', {})['log'] = '' |
| 161 | self.extraresults.setdefault('reproducible', {}).setdefault('files', {}) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 162 | |
| 163 | def append_to_log(self, msg): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 164 | self.extraresults['reproducible.rawlogs']['log'] += msg |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 165 | |
| 166 | def compare_packages(self, reference_dir, test_dir, diffutils_sysroot): |
| 167 | result = PackageCompareResults() |
| 168 | |
| 169 | old_cwd = os.getcwd() |
| 170 | try: |
| 171 | file_result = {} |
| 172 | os.chdir(test_dir) |
| 173 | with multiprocessing.Pool(processes=int(self.bb_number_threads or 0)) as p: |
| 174 | for root, dirs, files in os.walk('.'): |
| 175 | async_result = [] |
| 176 | for f in files: |
| 177 | reference_path = os.path.join(reference_dir, root, f) |
| 178 | test_path = os.path.join(test_dir, root, f) |
| 179 | async_result.append(p.apply_async(compare_file, (reference_path, test_path, diffutils_sysroot))) |
| 180 | |
| 181 | for a in async_result: |
| 182 | result.add_result(a.get()) |
| 183 | |
| 184 | finally: |
| 185 | os.chdir(old_cwd) |
| 186 | |
| 187 | result.sort() |
| 188 | return result |
| 189 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 190 | def write_package_list(self, package_class, name, packages): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 191 | self.extraresults['reproducible']['files'].setdefault(package_class, {})[name] = [ |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 192 | {'reference': p.reference, 'test': p.test} for p in packages] |
| 193 | |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 194 | def copy_file(self, source, dest): |
| 195 | bb.utils.mkdirhier(os.path.dirname(dest)) |
| 196 | shutil.copyfile(source, dest) |
| 197 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 198 | def do_test_build(self, name, use_sstate): |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 199 | capture_vars = ['DEPLOY_DIR_' + c.upper() for c in self.package_classes] |
| 200 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 201 | tmpdir = os.path.join(self.topdir, name, 'tmp') |
| 202 | if os.path.exists(tmpdir): |
| 203 | bb.utils.remove(tmpdir, recurse=True) |
| 204 | |
| 205 | config = textwrap.dedent('''\ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 206 | PACKAGE_CLASSES = "{package_classes}" |
| 207 | INHIBIT_PACKAGE_STRIP = "1" |
| 208 | TMPDIR = "{tmpdir}" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 209 | LICENSE_FLAGS_ACCEPTED = "commercial" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 210 | DISTRO_FEATURES:append = ' systemd pam' |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 211 | USERADDEXTENSION = "useradd-staticids" |
| 212 | USERADD_ERROR_DYNAMIC = "skip" |
| 213 | USERADD_UID_TABLES += "files/static-passwd" |
| 214 | USERADD_GID_TABLES += "files/static-group" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 215 | ''').format(package_classes=' '.join('package_%s' % c for c in self.package_classes), |
| 216 | tmpdir=tmpdir) |
| 217 | |
| 218 | if not use_sstate: |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 219 | if self.sstate_targets: |
| 220 | self.logger.info("Building prebuild for %s (sstate allowed)..." % (name)) |
| 221 | self.write_config(config) |
| 222 | bitbake(' '.join(self.sstate_targets)) |
| 223 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 224 | # This config fragment will disable using shared and the sstate |
| 225 | # mirror, forcing a complete build from scratch |
| 226 | config += textwrap.dedent('''\ |
| 227 | SSTATE_DIR = "${TMPDIR}/sstate" |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame] | 228 | SSTATE_MIRRORS = "" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 229 | ''') |
| 230 | |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame] | 231 | self.logger.info("Building %s (sstate%s allowed)..." % (name, '' if use_sstate else ' NOT')) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 232 | self.write_config(config) |
| 233 | d = get_bb_vars(capture_vars) |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 234 | # targets used to be called images |
| 235 | bitbake(' '.join(getattr(self, 'images', self.targets))) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 236 | return d |
| 237 | |
| 238 | def test_reproducible_builds(self): |
| 239 | def strip_topdir(s): |
| 240 | if s.startswith(self.topdir): |
| 241 | return s[len(self.topdir):] |
| 242 | return s |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 243 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 244 | # Build native utilities |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 245 | self.write_config('') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 246 | bitbake("diffoscope-native diffutils-native jquery-native -c addto_recipe_sysroot") |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 247 | diffutils_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffutils-native") |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 248 | diffoscope_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffoscope-native") |
| 249 | jquery_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "jquery-native") |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 250 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 251 | if self.save_results: |
| 252 | os.makedirs(self.save_results, exist_ok=True) |
| 253 | datestr = datetime.datetime.now().strftime('%Y%m%d') |
| 254 | save_dir = tempfile.mkdtemp(prefix='oe-reproducible-%s-' % datestr, dir=self.save_results) |
| 255 | os.chmod(save_dir, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH) |
| 256 | self.logger.info('Non-reproducible packages will be copied to %s', save_dir) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 257 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 258 | vars_A = self.do_test_build('reproducibleA', self.build_from_sstate) |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame] | 259 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 260 | vars_B = self.do_test_build('reproducibleB', False) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 261 | |
| 262 | # NOTE: The temp directories from the reproducible build are purposely |
| 263 | # kept after the build so it can be diffed for debugging. |
| 264 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 265 | fails = [] |
| 266 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 267 | for c in self.package_classes: |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 268 | with self.subTest(package_class=c): |
| 269 | package_class = 'package_' + c |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 270 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 271 | deploy_A = vars_A['DEPLOY_DIR_' + c.upper()] |
| 272 | deploy_B = vars_B['DEPLOY_DIR_' + c.upper()] |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 273 | |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame] | 274 | self.logger.info('Checking %s packages for differences...' % c) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 275 | result = self.compare_packages(deploy_A, deploy_B, diffutils_sysroot) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 276 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 277 | self.logger.info('Reproducibility summary for %s: %s' % (c, result)) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 278 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 279 | self.append_to_log('\n'.join("%s: %s" % (r.status, r.test) for r in result.total)) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 280 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 281 | self.write_package_list(package_class, 'missing', result.missing) |
| 282 | self.write_package_list(package_class, 'different', result.different) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 283 | self.write_package_list(package_class, 'different_excluded', result.different_excluded) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 284 | self.write_package_list(package_class, 'same', result.same) |
| 285 | |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 286 | if self.save_results: |
| 287 | for d in result.different: |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 288 | self.copy_file(d.reference, '/'.join([save_dir, 'packages', strip_topdir(d.reference)])) |
| 289 | self.copy_file(d.test, '/'.join([save_dir, 'packages', strip_topdir(d.test)])) |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 290 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 291 | for d in result.different_excluded: |
| 292 | self.copy_file(d.reference, '/'.join([save_dir, 'packages-excluded', strip_topdir(d.reference)])) |
| 293 | self.copy_file(d.test, '/'.join([save_dir, 'packages-excluded', strip_topdir(d.test)])) |
| 294 | |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 295 | if result.different: |
| 296 | fails.append("The following %s packages are different and not in exclusion list:\n%s" % |
| 297 | (c, '\n'.join(r.test for r in (result.different)))) |
| 298 | |
| 299 | if result.missing and len(self.sstate_targets) == 0: |
| 300 | fails.append("The following %s packages are missing and not in exclusion list:\n%s" % |
| 301 | (c, '\n'.join(r.test for r in (result.missing)))) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 302 | |
| 303 | # Clean up empty directories |
| 304 | if self.save_results: |
| 305 | if not os.listdir(save_dir): |
| 306 | os.rmdir(save_dir) |
| 307 | else: |
| 308 | self.logger.info('Running diffoscope') |
| 309 | package_dir = os.path.join(save_dir, 'packages') |
| 310 | package_html_dir = os.path.join(package_dir, 'diff-html') |
| 311 | |
| 312 | # Copy jquery to improve the diffoscope output usability |
| 313 | self.copy_file(os.path.join(jquery_sysroot, 'usr/share/javascript/jquery/jquery.min.js'), os.path.join(package_html_dir, 'jquery.js')) |
| 314 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 315 | run_diffoscope('reproducibleA', 'reproducibleB', package_html_dir, max_report_size=self.max_report_size, |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 316 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=package_dir) |
| 317 | |
| 318 | if fails: |
| 319 | self.fail('\n'.join(fails)) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 320 | |