Browse Source

support/testing: new xxhash runtime test

Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit b118c9dcf344c489b3e78a325060f01540f03eb3)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Julien Olivain 7 months ago
parent
commit
5926391587
2 changed files with 36 additions and 0 deletions
  1. 1 0
      DEVELOPERS
  2. 35 0
      support/testing/tests/package/test_xxhash.py

+ 1 - 0
DEVELOPERS

@@ -2007,6 +2007,7 @@ F:	support/testing/tests/package/test_wine.py
 F:	support/testing/tests/package/test_xfsprogs.py
 F:	support/testing/tests/package/test_xfsprogs.py
 F:	support/testing/tests/package/test_xfsprogs/
 F:	support/testing/tests/package/test_xfsprogs/
 F:	support/testing/tests/package/test_xvisor.py
 F:	support/testing/tests/package/test_xvisor.py
+F:	support/testing/tests/package/test_xxhash.py
 F:	support/testing/tests/package/test_xz.py
 F:	support/testing/tests/package/test_xz.py
 F:	support/testing/tests/package/test_z3.py
 F:	support/testing/tests/package/test_z3.py
 F:	support/testing/tests/package/test_z3/
 F:	support/testing/tests/package/test_z3/

+ 35 - 0
support/testing/tests/package/test_xxhash.py

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