diff options
| author | Joshua Watt <JPEWhacker@gmail.com> | 2020-08-29 22:00:34 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-15 11:53:55 +0000 |
| commit | 25cf12590903e0313b4c8fbd3cf6526bdc22a22d (patch) | |
| tree | 86d25d4f2cd6f251fce4b480b3f5e82079a50bba | |
| parent | 76c841d8a8386c0170b0317a12188cd945214c6d (diff) | |
| download | poky-25cf12590903e0313b4c8fbd3cf6526bdc22a22d.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: a1087756221b8fcfe9c6903e678920f96e12292e)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit ea8fbcb7978ce48d7a9a83143d09402329535f86)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -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 c8604a2054..60ddc76340 100644 --- a/meta/lib/oeqa/selftest/cases/reproducible.py +++ b/meta/lib/oeqa/selftest/cases/reproducible.py | |||
| @@ -139,6 +139,32 @@ def compare_file(reference, test, diffutils_sysroot): | |||
| 139 | result.status = SAME | 139 | result.status = SAME |
| 140 | return result | 140 | return result |
| 141 | 141 | ||
| 142 | def run_diffoscope(a_dir, b_dir, html_dir, **kwargs): | ||
| 143 | return runCmd(['diffoscope', '--no-default-limits', '--exclude-directory-metadata', 'yes', '--html-dir', html_dir, a_dir, b_dir], | ||
| 144 | **kwargs) | ||
| 145 | |||
| 146 | class DiffoscopeTests(OESelftestTestCase): | ||
| 147 | diffoscope_test_files = os.path.join(os.path.dirname(os.path.abspath(__file__)), "diffoscope") | ||
| 148 | |||
| 149 | def test_diffoscope(self): | ||
| 150 | bitbake("diffoscope-native -c addto_recipe_sysroot") | ||
| 151 | diffoscope_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "diffoscope-native") | ||
| 152 | |||
| 153 | # Check that diffoscope doesn't return an error when the files compare | ||
| 154 | # the same (a general check that diffoscope is working) | ||
| 155 | with tempfile.TemporaryDirectory() as tmpdir: | ||
| 156 | run_diffoscope('A', 'A', tmpdir, | ||
| 157 | native_sysroot=diffoscope_sysroot, cwd=self.diffoscope_test_files) | ||
| 158 | |||
| 159 | # Check that diffoscope generates an index.html file when the files are | ||
| 160 | # different | ||
| 161 | with tempfile.TemporaryDirectory() as tmpdir: | ||
| 162 | r = run_diffoscope('A', 'B', tmpdir, | ||
| 163 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=self.diffoscope_test_files) | ||
| 164 | |||
| 165 | self.assertNotEqual(r.status, 0, msg="diffoscope was successful when an error was expected") | ||
| 166 | self.assertTrue(os.path.exists(os.path.join(tmpdir, 'index.html')), "HTML index not found!") | ||
| 167 | |||
| 142 | class ReproducibleTests(OESelftestTestCase): | 168 | class ReproducibleTests(OESelftestTestCase): |
| 143 | # Test the reproducibility of whatever is built between sstate_targets and targets | 169 | # Test the reproducibility of whatever is built between sstate_targets and targets |
| 144 | 170 | ||
| @@ -316,7 +342,7 @@ class ReproducibleTests(OESelftestTestCase): | |||
| 316 | # Copy jquery to improve the diffoscope output usability | 342 | # Copy jquery to improve the diffoscope output usability |
| 317 | self.copy_file(os.path.join(jquery_sysroot, 'usr/share/javascript/jquery/jquery.min.js'), os.path.join(package_html_dir, 'jquery.js')) | 343 | self.copy_file(os.path.join(jquery_sysroot, 'usr/share/javascript/jquery/jquery.min.js'), os.path.join(package_html_dir, 'jquery.js')) |
| 318 | 344 | ||
| 319 | runCmd(['diffoscope', '--no-default-limits', '--exclude-directory-metadata', '--html-dir', package_html_dir, 'reproducibleA', 'reproducibleB'], | 345 | run_diffoscope('reproducibleA', 'reproducibleB', package_html_dir, |
| 320 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=package_dir) | 346 | native_sysroot=diffoscope_sysroot, ignore_status=True, cwd=package_dir) |
| 321 | 347 | ||
| 322 | if fails: | 348 | if fails: |
