Jelajahi Sumber

support/test: new dust runtime test

Add a runtime test for the 'dust' package to verify that the binary
executes correctly in a minimal buildroot rootfs. The test checks that:
- 'dust --version' runs without error
- 'dust' can analyze a directory structure with files
- The output includes the expected directory names

Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit 5bca9d741d8dce703c678872b0d61052e23b53a2)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
El Mehdi YOUNES 3 bulan lalu
induk
melakukan
901f6e1cb4
1 mengubah file dengan 32 tambahan dan 0 penghapusan
  1. 32 0
      support/testing/tests/package/test_dust.py

+ 32 - 0
support/testing/tests/package/test_dust.py

@@ -0,0 +1,32 @@
+import os
+import infra.basetest
+
+
+class TestDust(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_DUST=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="armv7",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        # Check that dust is installed and can be executed
+        self.assertRunOk("dust --version")
+
+        # Create a test directory structure with some files
+        self.assertRunOk("mkdir -p testdir/subdir")
+        self.assertRunOk("dd if=/dev/zero of=testdir/a bs=1K count=10")
+        self.assertRunOk("dd if=/dev/zero of=testdir/subdir/b bs=1K count=5")
+
+        # Run dust on the test directory and capture the output
+        output, exit_code = self.emulator.run("dust testdir", timeout=10)
+        self.assertEqual(exit_code, 0)
+        self.assertIn("testdir", "\n".join(output))
+        self.assertIn("subdir", "\n".join(output))