From 901f6e1cb413df12330cd81dcf150d2c4b3ca87a Mon Sep 17 00:00:00 2001 From: El Mehdi YOUNES Date: Thu, 24 Apr 2025 13:22:02 +0200 Subject: [PATCH] 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 Signed-off-by: Julien Olivain (cherry picked from commit 5bca9d741d8dce703c678872b0d61052e23b53a2) Signed-off-by: Thomas Perale --- support/testing/tests/package/test_dust.py | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 support/testing/tests/package/test_dust.py diff --git a/support/testing/tests/package/test_dust.py b/support/testing/tests/package/test_dust.py new file mode 100644 index 0000000000..8243024981 --- /dev/null +++ b/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))