test_dieharder.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import os
  2. import infra.basetest
  3. class TestDieharder(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_PACKAGE_DIEHARDER=y
  7. BR2_TARGET_ROOTFS_CPIO=y
  8. # BR2_TARGET_ROOTFS_TAR is not set
  9. """
  10. def test_run(self):
  11. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  12. self.emulator.boot(arch="armv5",
  13. kernel="builtin",
  14. options=["-initrd", cpio_file])
  15. self.emulator.login()
  16. # Check the program can run (by showing its version)
  17. self.assertRunOk("dieharder -V")
  18. # The birthdays randomness test on the mt19937 random number
  19. # generator with 25 sample is expected to always succeed.
  20. cmd = "dieharder -g mt19937 -d diehard_birthdays -t 25"
  21. output, exit_code = self.emulator.run(cmd, timeout=10)
  22. self.assertEqual(exit_code, 0)
  23. self.assertIn("PASSED", '\n'.join(output))
  24. # The birthdays randomness test on file /dev/zero is expected
  25. # to always fail.
  26. cmd = "dieharder -g file_input_raw -f /dev/zero -d diehard_birthdays -t 25"
  27. output, exit_code = self.emulator.run(cmd, timeout=40)
  28. self.assertEqual(exit_code, 0)
  29. self.assertIn("FAILED", '\n'.join(output))