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