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 5bca9d741d)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
This commit is contained in:
El Mehdi YOUNES
2025-04-24 13:22:02 +02:00
committed by Arnout Vandecappelle
parent 672f99bdce
commit 901f6e1cb4

View File

@@ -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))