test_f2fs.py 1.9 KB

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