From 73dbdac4267ba0d0b5fbaff695e0eaf029c87927 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Mon, 15 Jul 2024 19:38:22 +0200 Subject: [PATCH] support/testing: new dieharder runtime test Note: this test was not working in Buildroot test infrastructure before commit [1] was merged, because dieharder has the string "# " in its output. [1] https://gitlab.com/buildroot.org/buildroot/-/commit/0cad947b964be5612a182413da136fcf0dc5a1f2 Signed-off-by: Julien Olivain Signed-off-by: Arnout Vandecappelle (cherry picked from commit e9498b4faa28c494c064728d564b43c07b1b0689) Signed-off-by: Thomas Perale --- DEVELOPERS | 1 + .../testing/tests/package/test_dieharder.py | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 support/testing/tests/package/test_dieharder.py diff --git a/DEVELOPERS b/DEVELOPERS index 0eff5f3308..6a6e4e14a5 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1867,6 +1867,7 @@ F: support/testing/tests/package/test_cryptsetup.py F: support/testing/tests/package/test_cryptsetup/ F: support/testing/tests/package/test_ddrescue.py F: support/testing/tests/package/test_ddrescue/ +F: support/testing/tests/package/test_dieharder.py F: support/testing/tests/package/test_dmidecode.py F: support/testing/tests/package/test_dos2unix.py F: support/testing/tests/package/test_dosfstools.py diff --git a/support/testing/tests/package/test_dieharder.py b/support/testing/tests/package/test_dieharder.py new file mode 100644 index 0000000000..de09b383b4 --- /dev/null +++ b/support/testing/tests/package/test_dieharder.py @@ -0,0 +1,36 @@ +import os + +import infra.basetest + + +class TestDieharder(infra.basetest.BRTest): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_PACKAGE_DIEHARDER=y + BR2_TARGET_ROOTFS_CPIO=y + # BR2_TARGET_ROOTFS_TAR is not set + """ + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", cpio_file]) + self.emulator.login() + + # Check the program can run (by showing its version) + self.assertRunOk("dieharder -V") + + # The birthdays randomness test on the mt19937 random number + # generator with 25 sample is expected to always succeed. + cmd = "dieharder -g mt19937 -d diehard_birthdays -t 25" + output, exit_code = self.emulator.run(cmd, timeout=10) + self.assertEqual(exit_code, 0) + self.assertIn("PASSED", '\n'.join(output)) + + # The birthdays randomness test on file /dev/zero is expected + # to always fail. + cmd = "dieharder -g file_input_raw -f /dev/zero -d diehard_birthdays -t 25" + output, exit_code = self.emulator.run(cmd, timeout=40) + self.assertEqual(exit_code, 0) + self.assertIn("FAILED", '\n'.join(output))