test_f2fs.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import os
  2. import infra.basetest
  3. def dumpf2fs_getprop(out, prop):
  4. for line in out:
  5. fields = line.split(" = ")
  6. if fields[0] == prop:
  7. return fields[1].strip()
  8. class TestF2FS(infra.basetest.BRTest):
  9. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  10. """
  11. BR2_TARGET_ROOTFS_F2FS=y
  12. BR2_TARGET_ROOTFS_F2FS_SIZE="128M"
  13. BR2_TARGET_ROOTFS_F2FS_OVERPROVISION=0
  14. BR2_TARGET_ROOTFS_F2FS_DISCARD=y
  15. # BR2_TARGET_ROOTFS_TAR is not set
  16. BR2_LINUX_KERNEL=y
  17. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  18. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.27"
  19. BR2_LINUX_KERNEL_USE_DEFCONFIG=y
  20. BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
  21. BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{}"
  22. """.format(infra.filepath("conf/f2fs-kernel-fragment.config"))
  23. def test_run(self):
  24. img = os.path.join(self.builddir, "images", "rootfs.f2fs")
  25. out = infra.run_cmd_on_host(self.builddir, ["host/sbin/dump.f2fs", img])
  26. out = out.splitlines()
  27. prop = dumpf2fs_getprop(out, "Info: total FS sectors")
  28. self.assertEqual(prop, "262144 (128 MB)")
  29. kernel = os.path.join(self.builddir, "images", "zImage")
  30. kernel_cmdline = ["root=/dev/mmcblk0", "rootfstype=f2fs",
  31. "console=ttyAMA0"]
  32. dtb = infra.download(self.downloaddir, "vexpress-v2p-ca9.dtb")
  33. options = ["-M", "vexpress-a9", "-dtb", dtb,
  34. "-drive", "file={},if=sd,format=raw".format(img)]
  35. self.emulator.boot(arch="armv7", kernel=kernel,
  36. kernel_cmdline=kernel_cmdline,
  37. options=options)
  38. self.emulator.login()
  39. cmd = "mount | grep '/dev/root on / type f2fs'"
  40. self.assertRunOk(cmd)