summaryrefslogtreecommitdiff
path: root/poky/meta/lib/oeqa/selftest/cases/reproducible.py
diff options
context:
space:
mode:
Diffstat (limited to 'poky/meta/lib/oeqa/selftest/cases/reproducible.py')
-rw-r--r--poky/meta/lib/oeqa/selftest/cases/reproducible.py80
1 files changed, 51 insertions, 29 deletions
diff --git a/poky/meta/lib/oeqa/selftest/cases/reproducible.py b/poky/meta/lib/oeqa/selftest/cases/reproducible.py
index 6dc83d2847..eee09d3fb2 100644
--- a/poky/meta/lib/oeqa/selftest/cases/reproducible.py
+++ b/poky/meta/lib/oeqa/selftest/cases/reproducible.py
@@ -8,6 +8,7 @@ from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
import functools
import multiprocessing
import textwrap
+import json
import unittest
MISSING = 'MISSING'
@@ -81,14 +82,12 @@ class ReproducibleTests(OESelftestTestCase):
for v in needed_vars:
setattr(self, v.lower(), bb_vars[v])
- if not hasattr(self.tc, "extraresults"):
- self.tc.extraresults = {}
- self.extras = self.tc.extraresults
-
- self.extras.setdefault('reproducible.rawlogs', {})['log'] = ''
+ self.extrasresults = {}
+ self.extrasresults.setdefault('reproducible.rawlogs', {})['log'] = ''
+ self.extrasresults.setdefault('reproducible', {}).setdefault('files', {})
def append_to_log(self, msg):
- self.extras['reproducible.rawlogs']['log'] += msg
+ self.extrasresults['reproducible.rawlogs']['log'] += msg
def compare_packages(self, reference_dir, test_dir, diffutils_sysroot):
result = PackageCompareResults()
@@ -114,47 +113,70 @@ class ReproducibleTests(OESelftestTestCase):
result.sort()
return result
- @unittest.skip("Reproducible builds do not yet pass")
+ def write_package_list(self, package_class, name, packages):
+ self.extrasresults['reproducible']['files'].setdefault(package_class, {})[name] = [
+ {'reference': p.reference, 'test': p.test} for p in packages]
+
def test_reproducible_builds(self):
capture_vars = ['DEPLOY_DIR_' + c.upper() for c in self.package_classes]
+ # Build native utilities
+ self.write_config('')
+ bitbake("diffutils-native -c addto_recipe_sysroot")
+ diffutils_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffutils-native")
+
+ # Reproducible builds should not pull from sstate or mirrors, but
+ # sharing DL_DIR is fine
common_config = textwrap.dedent('''\
INHERIT += "reproducible_build"
PACKAGE_CLASSES = "%s"
+ SSTATE_DIR = "${TMPDIR}/sstate"
''') % (' '.join('package_%s' % c for c in self.package_classes))
- # Do an initial build. It's acceptable for this build to use sstate
- self.write_config(common_config)
- vars_reference = get_bb_vars(capture_vars)
+ # Perform a build.
+ reproducibleA_tmp = os.path.join(self.topdir, 'reproducibleA', 'tmp')
+ if os.path.exists(reproducibleA_tmp):
+ bb.utils.remove(reproducibleA_tmp, recurse=True)
+
+ self.write_config((textwrap.dedent('''\
+ TMPDIR = "%s"
+ ''') % reproducibleA_tmp) + common_config)
+ vars_A = get_bb_vars(capture_vars)
bitbake(' '.join(self.images))
- # Build native utilities
- bitbake("diffutils-native -c addto_recipe_sysroot")
- diffutils_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffutils-native")
+ # Perform another build.
+ reproducibleB_tmp = os.path.join(self.topdir, 'reproducibleB', 'tmp')
+ if os.path.exists(reproducibleB_tmp):
+ bb.utils.remove(reproducibleB_tmp, recurse=True)
- # Perform another build. This build should *not* share sstate or pull
- # from any mirrors, but sharing a DL_DIR is fine
- self.write_config(textwrap.dedent('''\
- TMPDIR = "${TOPDIR}/reproducible/tmp"
- SSTATE_DIR = "${TMPDIR}/sstate"
+ self.write_config((textwrap.dedent('''\
SSTATE_MIRROR = ""
- ''') + common_config)
- vars_test = get_bb_vars(capture_vars)
+ TMPDIR = "%s"
+ ''') % reproducibleB_tmp) + common_config)
+ vars_B = get_bb_vars(capture_vars)
bitbake(' '.join(self.images))
+ # NOTE: The temp directories from the reproducible build are purposely
+ # kept after the build so it can be diffed for debugging.
+
for c in self.package_classes:
- package_class = 'package_' + c
+ with self.subTest(package_class=c):
+ package_class = 'package_' + c
+
+ deploy_A = vars_A['DEPLOY_DIR_' + c.upper()]
+ deploy_B = vars_B['DEPLOY_DIR_' + c.upper()]
- deploy_reference = vars_reference['DEPLOY_DIR_' + c.upper()]
- deploy_test = vars_test['DEPLOY_DIR_' + c.upper()]
+ result = self.compare_packages(deploy_A, deploy_B, diffutils_sysroot)
- result = self.compare_packages(deploy_reference, deploy_test, diffutils_sysroot)
+ self.logger.info('Reproducibility summary for %s: %s' % (c, result))
- self.logger.info('Reproducibility summary for %s: %s' % (c, result))
+ self.append_to_log('\n'.join("%s: %s" % (r.status, r.test) for r in result.total))
- self.append_to_log('\n'.join("%s: %s" % (r.status, r.test) for r in result.total))
+ self.write_package_list(package_class, 'missing', result.missing)
+ self.write_package_list(package_class, 'different', result.different)
+ self.write_package_list(package_class, 'same', result.same)
- if result.missing or result.different:
- self.fail("The following %s packages are missing or different: %s" %
- (c, ' '.join(r.test for r in (result.missing + result.different))))
+ if result.missing or result.different:
+ self.fail("The following %s packages are missing or different: %s" %
+ (c, ' '.join(r.test for r in (result.missing + result.different))))