From c68d24a71839c82e55a0d46ce7f5db5973387473 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sun, 18 Aug 2024 13:26:52 +0200 Subject: [PATCH] support/testing: fs: new erofs runtime test Signed-off-by: Julien Olivain Signed-off-by: Arnout Vandecappelle (cherry picked from commit 21e9bb0967a6534e73138a8e645a5c80fc442b0d) Signed-off-by: Peter Korsgaard --- DEVELOPERS | 2 + support/testing/tests/fs/test_erofs.py | 51 +++++++++++++++++++ .../tests/fs/test_erofs/linux-erofs.fragment | 1 + 3 files changed, 54 insertions(+) create mode 100644 support/testing/tests/fs/test_erofs.py create mode 100644 support/testing/tests/fs/test_erofs/linux-erofs.fragment diff --git a/DEVELOPERS b/DEVELOPERS index 5e9cd77abe..4422e9dc18 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1753,6 +1753,8 @@ F: support/testing/tests/boot/test_optee_os.py F: support/testing/tests/boot/test_optee_os/ F: support/testing/tests/fs/test_btrfs.py F: support/testing/tests/fs/test_btrfs/ +F: support/testing/tests/fs/test_erofs.py +F: support/testing/tests/fs/test_erofs/ F: support/testing/tests/package/sample_python_distro.py F: support/testing/tests/package/sample_python_gnupg.py F: support/testing/tests/package/sample_python_hwdata.py diff --git a/support/testing/tests/fs/test_erofs.py b/support/testing/tests/fs/test_erofs.py new file mode 100644 index 0000000000..47c75262e0 --- /dev/null +++ b/support/testing/tests/fs/test_erofs.py @@ -0,0 +1,51 @@ +import os + +import infra.basetest + + +class TestErofs(infra.basetest.BRTest): + kern_frag = \ + infra.filepath("tests/fs/test_erofs/linux-erofs.fragment") + config = \ + f""" + BR2_aarch64=y + BR2_TOOLCHAIN_EXTERNAL=y + BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" + BR2_LINUX_KERNEL=y + BR2_LINUX_KERNEL_CUSTOM_VERSION=y + BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.46" + BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y + BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config" + BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kern_frag}" + BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y + BR2_PACKAGE_EROFS_UTILS=y + BR2_TARGET_ROOTFS_EROFS=y + # BR2_TARGET_ROOTFS_TAR is not set + """ + + def test_run(self): + root_dev = "/dev/vda" + disk = os.path.join(self.builddir, "images", "rootfs.erofs") + kern = os.path.join(self.builddir, "images", "Image") + bootargs = [f"root={root_dev}", "console=ttyAMA0"] + qemu_opts = ["-M", "virt", "-cpu", "cortex-a57", "-m", "256M", + "-drive", f"file={disk},if=virtio,format=raw"] + self.emulator.boot(arch="aarch64", + kernel=kern, + kernel_cmdline=bootargs, + options=qemu_opts) + self.emulator.login() + + # We check our root filesystem is in erofs format. + cmd = "mount | grep '/dev/root on / type erofs'" + self.assertRunOk(cmd) + + # Since we are on a read-only mounted filesystem, we can run a + # check... + self.assertRunOk(f"fsck.erofs {root_dev}") + + # We check we can dump the superblock. + self.assertRunOk(f"dump.erofs -s {root_dev}") + + # We check we can dump statistics on the image. + self.assertRunOk(f"dump.erofs -S {root_dev}") diff --git a/support/testing/tests/fs/test_erofs/linux-erofs.fragment b/support/testing/tests/fs/test_erofs/linux-erofs.fragment new file mode 100644 index 0000000000..e14017aae4 --- /dev/null +++ b/support/testing/tests/fs/test_erofs/linux-erofs.fragment @@ -0,0 +1 @@ +CONFIG_EROFS_FS=y