diff mbox series

support/testing: add test for gzip

Message ID 20220717154213.6206-1-vincent.stehle@laposte.net
State Changes Requested
Headers show
Series support/testing: add test for gzip | expand

Commit Message

Vincent Stehlé July 17, 2022, 3:42 p.m. UTC
Add a simple compress-uncompress test to verify that gzip is working.

Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
---


Hi,

I have verified that this test runs fine both locally and on gitlab.

Best regards,
Vincent.


 DEVELOPERS                                 |  1 +
 support/testing/tests/package/test_gzip.py | 42 ++++++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 support/testing/tests/package/test_gzip.py
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 5c3c24ff7a..b1c21ff4a4 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2919,6 +2919,7 @@  F:	package/i7z/
 F:	package/msr-tools/
 F:	package/pixz/
 F:	package/zerofree/
+F:	support/testing/tests/package/test_gzip.py
 F:	support/testing/tests/package/test_msr_tools*
 F:	support/testing/tests/package/test_pixz.py
 F:	support/testing/tests/package/test_zerofree.py
diff --git a/support/testing/tests/package/test_gzip.py b/support/testing/tests/package/test_gzip.py
new file mode 100644
index 0000000000..4837786dad
--- /dev/null
+++ b/support/testing/tests/package/test_gzip.py
@@ -0,0 +1,42 @@ 
+import os
+
+import infra.basetest
+
+
+class TestGzip(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+        BR2_PACKAGE_GZIP=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()
+
+        # Prepare input file with random data and zeroes.
+        # We keep the size small (4 MB) for the sake of test time.
+        cmd = "dd if=/dev/urandom of=orig bs=1M count=2 && " \
+              "dd if=/dev/zero of=orig bs=1M count=2 seek=2"
+        self.assertRunOk(cmd)
+
+        # Compress.
+        cmd = "cp -v orig compressed && gzip -v compressed"
+        self.assertRunOk(cmd, timeout=60)
+
+        # Test.
+        self.assertRunOk("gzip -tv compressed.gz")
+
+        # Uncompress.
+        cmd = "cp -v compressed.gz uncompressed.gz && " \
+              "gunzip -v uncompressed.gz"
+        self.assertRunOk(cmd)
+
+        # Verify.
+        # The ls is there for debugging.
+        self.assertRunOk("ls -l && cmp orig uncompressed")