diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2020-08-29 22:00:34 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-09-02 16:00:46 +0100 |
commit | d7aec2f4a3e612d4b360c1a52f4dadd75c1e6b53 (patch) | |
tree | dc78961df9ae8b566be22bb6420eae7cde0bca31 /meta/lib | |
parent | 8633b278ef6168352e3074965a82b14093c783fb (diff) | |
download | poky-d7aec2f4a3e612d4b360c1a52f4dadd75c1e6b53.tar.gz |
oeqa: reproducible: Fix test not producing diffs
Diffoscope changed the --exclude-directory-metadata option to require an
argument.
Add a test to validate that diffoscope is functioning as
expected to ensure that future upgrades do not unintentionally break
the reproducibility tests.
[YOCTO #14025]
(From OE-Core rev: ea8fbcb7978ce48d7a9a83143d09402329535f86)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/diffoscope/A/file.txt | 1 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/diffoscope/B/file.txt | 1 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/reproducible.py | 28 |
3 files changed, 29 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/cases/diffoscope/A/file.txt b/meta/lib/oeqa/selftest/cases/diffoscope/A/file.txt new file mode 100644 index 0000000000..f70f10e4db --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/diffoscope/A/file.txt | |||
@@ -0,0 +1 @@ | |||
A | |||
diff --git a/meta/lib/oeqa/selftest/cases/diffoscope/B/file.txt b/meta/lib/oeqa/selftest/cases/diffoscope/B/file.txt new file mode 100644 index 0000000000..223b7836fb --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/diffoscope/B/file.txt | |||
@@ -0,0 +1 @@ | |||
B | |||
diff --git a/meta/lib/oeqa/selftest/cases/reproducible.py b/meta/lib/oeqa/selftest/cases/reproducible.py index 5d3959be77..a7ef336143 100644 --- a/meta/lib/oeqa/selftest/cases/reproducible.py +++ b/meta/lib/oeqa/selftest/cases/reproducible.py | |||
@@ -77,6 +77,32 @@ def compare_file(reference, test, diffutils_sysroot): | |||
77 | result.status = SAME | 77 | result.status = SAME |
78 | return result | 78 | return result |
79 | 79 | ||
80 | def run_diffoscope(a_dir, b_dir, html_dir, **kwargs): | ||
81 | return runCmd(['diffoscope', '--no-default-limits', '--exclude-directory-metadata', 'yes', '--html-dir', html_dir, a_dir, b_dir], | ||
82 | **kwargs) | ||
83 | |||
84 | class DiffoscopeTests(OESelftestTestCase): | ||
85 | diffoscope_test_files = os.path.join(os.path.dirname(os.path.abspath(__file__)), "diffoscope") | ||
86 | |||
87 | def test_diffoscope(self): | ||
88 | bitbake("diffoscope-native -c addto_recipe_sysroot") | ||
89 | diffoscope_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffoscope-native") | ||
90 | |||
91 | # Check that diffoscope doesn't return an error when the files compare | ||
92 | # the same (a general check that diffoscope is working) | ||
93 | with tempfile.TemporaryDirectory() as tmpdir: | ||
94 | run_diffoscope('A', 'A', tmpdir, | ||
95 | native_sysroot=diffoscope_sysroot, cwd=self.diffoscope_test_files) | ||
96 | |||
97 | # Check that diffoscope generates an index.html file when the files are | ||
98 | # different | ||
99 | with tempfile.TemporaryDirectory() as tmpdir: | ||
100 | r = run_diffoscope('A', 'B', tmpdir, | ||
101 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=self.diffoscope_test_files) | ||
102 | |||
103 | self.assertNotEqual(r.status, 0, msg="diffoscope was successful when an error was expected") | ||
104 | self.assertTrue(os.path.exists(os.path.join(tmpdir, 'index.html')), "HTML index not found!") | ||
105 | |||
80 | class ReproducibleTests(OESelftestTestCase): | 106 | class ReproducibleTests(OESelftestTestCase): |
81 | package_classes = ['deb', 'ipk'] | 107 | package_classes = ['deb', 'ipk'] |
82 | images = ['core-image-minimal', 'core-image-sato', 'core-image-full-cmdline'] | 108 | images = ['core-image-minimal', 'core-image-sato', 'core-image-full-cmdline'] |
@@ -232,7 +258,7 @@ class ReproducibleTests(OESelftestTestCase): | |||
232 | # Copy jquery to improve the diffoscope output usability | 258 | # Copy jquery to improve the diffoscope output usability |
233 | self.copy_file(os.path.join(jquery_sysroot, 'usr/share/javascript/jquery/jquery.min.js'), os.path.join(package_html_dir, 'jquery.js')) | 259 | self.copy_file(os.path.join(jquery_sysroot, 'usr/share/javascript/jquery/jquery.min.js'), os.path.join(package_html_dir, 'jquery.js')) |
234 | 260 | ||
235 | runCmd(['diffoscope', '--no-default-limits', '--exclude-directory-metadata', '--html-dir', package_html_dir, 'reproducibleA', 'reproducibleB'], | 261 | run_diffoscope('reproducibleA', 'reproducibleB', package_html_dir, |
236 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=package_dir) | 262 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=package_dir) |
237 | 263 | ||
238 | if fails: | 264 | if fails: |