test_erofs.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import os
  2. import infra.basetest
  3. class TestErofs(infra.basetest.BRTest):
  4. kern_frag = \
  5. infra.filepath("tests/fs/test_erofs/linux-erofs.fragment")
  6. config = \
  7. f"""
  8. BR2_aarch64=y
  9. BR2_TOOLCHAIN_EXTERNAL=y
  10. BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
  11. BR2_LINUX_KERNEL=y
  12. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  13. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.46"
  14. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  15. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
  16. BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kern_frag}"
  17. BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
  18. BR2_PACKAGE_EROFS_UTILS=y
  19. BR2_TARGET_ROOTFS_EROFS=y
  20. # BR2_TARGET_ROOTFS_TAR is not set
  21. """
  22. def test_run(self):
  23. root_dev = "/dev/vda"
  24. disk = os.path.join(self.builddir, "images", "rootfs.erofs")
  25. kern = os.path.join(self.builddir, "images", "Image")
  26. bootargs = [f"root={root_dev}", "console=ttyAMA0"]
  27. qemu_opts = ["-M", "virt", "-cpu", "cortex-a57", "-m", "256M",
  28. "-drive", f"file={disk},if=virtio,format=raw"]
  29. self.emulator.boot(arch="aarch64",
  30. kernel=kern,
  31. kernel_cmdline=bootargs,
  32. options=qemu_opts)
  33. self.emulator.login()
  34. # We check our root filesystem is in erofs format.
  35. cmd = "mount | grep '/dev/root on / type erofs'"
  36. self.assertRunOk(cmd)
  37. # Since we are on a read-only mounted filesystem, we can run a
  38. # check...
  39. self.assertRunOk(f"fsck.erofs {root_dev}")
  40. # We check we can dump the superblock.
  41. self.assertRunOk(f"dump.erofs -s {root_dev}")
  42. # We check we can dump statistics on the image.
  43. self.assertRunOk(f"dump.erofs -S {root_dev}")