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 | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 12 | import json |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 13 | import unittest |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 14 | import tempfile |
| 15 | import shutil |
| 16 | import stat |
| 17 | import os |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 18 | import datetime |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 19 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 20 | # For sample packages, see: |
| 21 | # https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20201127-0t7wr_oo/ |
| 22 | # https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20201127-4s9ejwyp/ |
| 23 | # https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20201127-haiwdlbr/ |
| 24 | # https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20201127-hwds3mcl/ |
| 25 | # https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20201203-sua0pzvc/ |
| 26 | # (both packages/ and packages-excluded/) |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 27 | |
| 28 | # ruby-ri-docs, meson: |
| 29 | #https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20210215-0_td9la2/packages/diff-html/ |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 30 | exclude_packages = [ |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 31 | 'babeltrace2-ptest', |
| 32 | 'bootchart2-doc', |
| 33 | 'cups', |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 34 | 'efivar', |
| 35 | 'epiphany', |
| 36 | 'gcr', |
| 37 | 'git', |
| 38 | 'glide', |
| 39 | 'go-dep', |
| 40 | 'go-helloworld', |
| 41 | 'go-runtime', |
| 42 | 'go_', |
| 43 | 'groff', |
| 44 | 'gst-devtools', |
| 45 | 'gstreamer1.0-python', |
| 46 | 'gtk-doc', |
| 47 | 'igt-gpu-tools', |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 48 | 'libaprutil', |
| 49 | 'libcap-ng', |
| 50 | 'libhandy-1-src', |
| 51 | 'libid3tag', |
| 52 | 'libproxy', |
| 53 | 'libsecret-dev', |
| 54 | 'libsecret-src', |
| 55 | 'lttng-tools-dbg', |
| 56 | 'lttng-tools-ptest', |
| 57 | 'ltp', |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 58 | 'meson', |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 59 | 'ovmf-shell-efi', |
| 60 | 'parted-ptest', |
| 61 | 'perf', |
| 62 | 'python3-cython', |
| 63 | 'qemu', |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 64 | 'rsync', |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 65 | 'ruby-ri-docs', |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 66 | 'swig', |
| 67 | 'syslinux-misc', |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 68 | 'systemd-bootchart' |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 69 | ] |
| 70 | |
| 71 | def is_excluded(package): |
| 72 | package_name = os.path.basename(package) |
| 73 | for i in exclude_packages: |
| 74 | if package_name.startswith(i): |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 75 | return i |
| 76 | return None |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 77 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 78 | MISSING = 'MISSING' |
| 79 | DIFFERENT = 'DIFFERENT' |
| 80 | SAME = 'SAME' |
| 81 | |
| 82 | @functools.total_ordering |
| 83 | class CompareResult(object): |
| 84 | def __init__(self): |
| 85 | self.reference = None |
| 86 | self.test = None |
| 87 | self.status = 'UNKNOWN' |
| 88 | |
| 89 | def __eq__(self, other): |
| 90 | return (self.status, self.test) == (other.status, other.test) |
| 91 | |
| 92 | def __lt__(self, other): |
| 93 | return (self.status, self.test) < (other.status, other.test) |
| 94 | |
| 95 | class PackageCompareResults(object): |
| 96 | def __init__(self): |
| 97 | self.total = [] |
| 98 | self.missing = [] |
| 99 | self.different = [] |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 100 | self.different_excluded = [] |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 101 | self.same = [] |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 102 | self.active_exclusions = set() |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 103 | |
| 104 | def add_result(self, r): |
| 105 | self.total.append(r) |
| 106 | if r.status == MISSING: |
| 107 | self.missing.append(r) |
| 108 | elif r.status == DIFFERENT: |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 109 | exclusion = is_excluded(r.reference) |
| 110 | if exclusion: |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 111 | self.different_excluded.append(r) |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 112 | self.active_exclusions.add(exclusion) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 113 | else: |
| 114 | self.different.append(r) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 115 | else: |
| 116 | self.same.append(r) |
| 117 | |
| 118 | def sort(self): |
| 119 | self.total.sort() |
| 120 | self.missing.sort() |
| 121 | self.different.sort() |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 122 | self.different_excluded.sort() |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 123 | self.same.sort() |
| 124 | |
| 125 | def __str__(self): |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 126 | 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()) |
| 127 | |
| 128 | def unused_exclusions(self): |
| 129 | return sorted(set(exclude_packages) - self.active_exclusions) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 130 | |
| 131 | def compare_file(reference, test, diffutils_sysroot): |
| 132 | result = CompareResult() |
| 133 | result.reference = reference |
| 134 | result.test = test |
| 135 | |
| 136 | if not os.path.exists(reference): |
| 137 | result.status = MISSING |
| 138 | return result |
| 139 | |
| 140 | r = runCmd(['cmp', '--quiet', reference, test], native_sysroot=diffutils_sysroot, ignore_status=True) |
| 141 | |
| 142 | if r.status: |
| 143 | result.status = DIFFERENT |
| 144 | return result |
| 145 | |
| 146 | result.status = SAME |
| 147 | return result |
| 148 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 149 | def run_diffoscope(a_dir, b_dir, html_dir, **kwargs): |
| 150 | return runCmd(['diffoscope', '--no-default-limits', '--exclude-directory-metadata', 'yes', '--html-dir', html_dir, a_dir, b_dir], |
| 151 | **kwargs) |
| 152 | |
| 153 | class DiffoscopeTests(OESelftestTestCase): |
| 154 | diffoscope_test_files = os.path.join(os.path.dirname(os.path.abspath(__file__)), "diffoscope") |
| 155 | |
| 156 | def test_diffoscope(self): |
| 157 | bitbake("diffoscope-native -c addto_recipe_sysroot") |
| 158 | diffoscope_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffoscope-native") |
| 159 | |
| 160 | # Check that diffoscope doesn't return an error when the files compare |
| 161 | # the same (a general check that diffoscope is working) |
| 162 | with tempfile.TemporaryDirectory() as tmpdir: |
| 163 | run_diffoscope('A', 'A', tmpdir, |
| 164 | native_sysroot=diffoscope_sysroot, cwd=self.diffoscope_test_files) |
| 165 | |
| 166 | # Check that diffoscope generates an index.html file when the files are |
| 167 | # different |
| 168 | with tempfile.TemporaryDirectory() as tmpdir: |
| 169 | r = run_diffoscope('A', 'B', tmpdir, |
| 170 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=self.diffoscope_test_files) |
| 171 | |
| 172 | self.assertNotEqual(r.status, 0, msg="diffoscope was successful when an error was expected") |
| 173 | self.assertTrue(os.path.exists(os.path.join(tmpdir, 'index.html')), "HTML index not found!") |
| 174 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 175 | class ReproducibleTests(OESelftestTestCase): |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 176 | package_classes = ['deb', 'ipk'] |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 177 | images = ['core-image-minimal', 'core-image-sato', 'core-image-full-cmdline', 'world'] |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 178 | save_results = False |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 179 | if 'OEQA_DEBUGGING_SAVED_OUTPUT' in os.environ: |
| 180 | save_results = os.environ['OEQA_DEBUGGING_SAVED_OUTPUT'] |
| 181 | |
| 182 | # This variable controls if one of the test builds is allowed to pull from |
| 183 | # an sstate cache/mirror. The other build is always done clean as a point of |
| 184 | # comparison. |
| 185 | # If you know that your sstate archives are reproducible, enabling this |
| 186 | # will test that and also make the test run faster. If your sstate is not |
| 187 | # reproducible, disable this in your derived test class |
| 188 | build_from_sstate = True |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 189 | |
| 190 | def setUpLocal(self): |
| 191 | super().setUpLocal() |
| 192 | needed_vars = ['TOPDIR', 'TARGET_PREFIX', 'BB_NUMBER_THREADS'] |
| 193 | bb_vars = get_bb_vars(needed_vars) |
| 194 | for v in needed_vars: |
| 195 | setattr(self, v.lower(), bb_vars[v]) |
| 196 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 197 | self.extraresults = {} |
| 198 | self.extraresults.setdefault('reproducible.rawlogs', {})['log'] = '' |
| 199 | self.extraresults.setdefault('reproducible', {}).setdefault('files', {}) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 200 | |
| 201 | def append_to_log(self, msg): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 202 | self.extraresults['reproducible.rawlogs']['log'] += msg |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 203 | |
| 204 | def compare_packages(self, reference_dir, test_dir, diffutils_sysroot): |
| 205 | result = PackageCompareResults() |
| 206 | |
| 207 | old_cwd = os.getcwd() |
| 208 | try: |
| 209 | file_result = {} |
| 210 | os.chdir(test_dir) |
| 211 | with multiprocessing.Pool(processes=int(self.bb_number_threads or 0)) as p: |
| 212 | for root, dirs, files in os.walk('.'): |
| 213 | async_result = [] |
| 214 | for f in files: |
| 215 | reference_path = os.path.join(reference_dir, root, f) |
| 216 | test_path = os.path.join(test_dir, root, f) |
| 217 | async_result.append(p.apply_async(compare_file, (reference_path, test_path, diffutils_sysroot))) |
| 218 | |
| 219 | for a in async_result: |
| 220 | result.add_result(a.get()) |
| 221 | |
| 222 | finally: |
| 223 | os.chdir(old_cwd) |
| 224 | |
| 225 | result.sort() |
| 226 | return result |
| 227 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 228 | def write_package_list(self, package_class, name, packages): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 229 | self.extraresults['reproducible']['files'].setdefault(package_class, {})[name] = [ |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 230 | {'reference': p.reference, 'test': p.test} for p in packages] |
| 231 | |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 232 | def copy_file(self, source, dest): |
| 233 | bb.utils.mkdirhier(os.path.dirname(dest)) |
| 234 | shutil.copyfile(source, dest) |
| 235 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 236 | def do_test_build(self, name, use_sstate): |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 237 | capture_vars = ['DEPLOY_DIR_' + c.upper() for c in self.package_classes] |
| 238 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 239 | tmpdir = os.path.join(self.topdir, name, 'tmp') |
| 240 | if os.path.exists(tmpdir): |
| 241 | bb.utils.remove(tmpdir, recurse=True) |
| 242 | |
| 243 | config = textwrap.dedent('''\ |
| 244 | INHERIT += "reproducible_build" |
| 245 | PACKAGE_CLASSES = "{package_classes}" |
| 246 | INHIBIT_PACKAGE_STRIP = "1" |
| 247 | TMPDIR = "{tmpdir}" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 248 | LICENSE_FLAGS_WHITELIST = "commercial" |
| 249 | DISTRO_FEATURES_append = ' systemd pam' |
| 250 | USERADDEXTENSION = "useradd-staticids" |
| 251 | USERADD_ERROR_DYNAMIC = "skip" |
| 252 | USERADD_UID_TABLES += "files/static-passwd" |
| 253 | USERADD_GID_TABLES += "files/static-group" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 254 | ''').format(package_classes=' '.join('package_%s' % c for c in self.package_classes), |
| 255 | tmpdir=tmpdir) |
| 256 | |
| 257 | if not use_sstate: |
| 258 | # This config fragment will disable using shared and the sstate |
| 259 | # mirror, forcing a complete build from scratch |
| 260 | config += textwrap.dedent('''\ |
| 261 | SSTATE_DIR = "${TMPDIR}/sstate" |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 262 | SSTATE_MIRRORS = "" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 263 | ''') |
| 264 | |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 265 | 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] | 266 | self.write_config(config) |
| 267 | d = get_bb_vars(capture_vars) |
| 268 | bitbake(' '.join(self.images)) |
| 269 | return d |
| 270 | |
| 271 | def test_reproducible_builds(self): |
| 272 | def strip_topdir(s): |
| 273 | if s.startswith(self.topdir): |
| 274 | return s[len(self.topdir):] |
| 275 | return s |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 276 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 277 | # Build native utilities |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 278 | self.write_config('') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 279 | bitbake("diffoscope-native diffutils-native jquery-native -c addto_recipe_sysroot") |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 280 | diffutils_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffutils-native") |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 281 | diffoscope_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffoscope-native") |
| 282 | jquery_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "jquery-native") |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 283 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 284 | if self.save_results: |
| 285 | os.makedirs(self.save_results, exist_ok=True) |
| 286 | datestr = datetime.datetime.now().strftime('%Y%m%d') |
| 287 | save_dir = tempfile.mkdtemp(prefix='oe-reproducible-%s-' % datestr, dir=self.save_results) |
| 288 | os.chmod(save_dir, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH) |
| 289 | 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] | 290 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 291 | vars_A = self.do_test_build('reproducibleA', self.build_from_sstate) |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 292 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 293 | vars_B = self.do_test_build('reproducibleB', False) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 294 | |
| 295 | # NOTE: The temp directories from the reproducible build are purposely |
| 296 | # kept after the build so it can be diffed for debugging. |
| 297 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 298 | fails = [] |
| 299 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 300 | for c in self.package_classes: |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 301 | with self.subTest(package_class=c): |
| 302 | package_class = 'package_' + c |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 303 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 304 | deploy_A = vars_A['DEPLOY_DIR_' + c.upper()] |
| 305 | deploy_B = vars_B['DEPLOY_DIR_' + c.upper()] |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 306 | |
Andrew Geissler | 9b4d8b0 | 2021-02-19 12:26:16 -0600 | [diff] [blame^] | 307 | self.logger.info('Checking %s packages for differences...' % c) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 308 | result = self.compare_packages(deploy_A, deploy_B, diffutils_sysroot) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 309 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 310 | self.logger.info('Reproducibility summary for %s: %s' % (c, result)) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 311 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 312 | 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] | 313 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 314 | self.write_package_list(package_class, 'missing', result.missing) |
| 315 | self.write_package_list(package_class, 'different', result.different) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 316 | self.write_package_list(package_class, 'different_excluded', result.different_excluded) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 317 | self.write_package_list(package_class, 'same', result.same) |
| 318 | |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 319 | if self.save_results: |
| 320 | for d in result.different: |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 321 | self.copy_file(d.reference, '/'.join([save_dir, 'packages', strip_topdir(d.reference)])) |
| 322 | 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] | 323 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 324 | for d in result.different_excluded: |
| 325 | self.copy_file(d.reference, '/'.join([save_dir, 'packages-excluded', strip_topdir(d.reference)])) |
| 326 | self.copy_file(d.test, '/'.join([save_dir, 'packages-excluded', strip_topdir(d.test)])) |
| 327 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 328 | if result.missing or result.different: |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 329 | fails.append("The following %s packages are missing or different and not in exclusion list: %s" % |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 330 | (c, '\n'.join(r.test for r in (result.missing + result.different)))) |
| 331 | |
| 332 | # Clean up empty directories |
| 333 | if self.save_results: |
| 334 | if not os.listdir(save_dir): |
| 335 | os.rmdir(save_dir) |
| 336 | else: |
| 337 | self.logger.info('Running diffoscope') |
| 338 | package_dir = os.path.join(save_dir, 'packages') |
| 339 | package_html_dir = os.path.join(package_dir, 'diff-html') |
| 340 | |
| 341 | # Copy jquery to improve the diffoscope output usability |
| 342 | self.copy_file(os.path.join(jquery_sysroot, 'usr/share/javascript/jquery/jquery.min.js'), os.path.join(package_html_dir, 'jquery.js')) |
| 343 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 344 | run_diffoscope('reproducibleA', 'reproducibleB', package_html_dir, |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 345 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=package_dir) |
| 346 | |
| 347 | if fails: |
| 348 | self.fail('\n'.join(fails)) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 349 | |