test_xxhash.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import os
  2. import infra.basetest
  3. class TestXxHash(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_PACKAGE_XXHASH=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. testfile = "data.bin"
  17. # Check we can run the program.
  18. self.assertRunOk("xxhsum --version")
  19. # We create a test data file with random data.
  20. cmd = f"dd if=/dev/urandom of={testfile} bs=1M count=1"
  21. self.assertRunOk(cmd)
  22. # For the three hash sizes, we compute the xxhash and check
  23. # the integrity of the file.
  24. for hsize in [32, 64, 128]:
  25. hashfile = f"{testfile}.xxh{hsize}"
  26. self.assertRunOk(f"xxh{hsize}sum {testfile} | tee {hashfile}")
  27. self.assertRunOk(f"xxh{hsize}sum -c {hashfile}")