xref: /OK3568_Linux_fs/buildroot/support/testing/tests/fs/test_jffs2.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1import os
2
3import infra.basetest
4
5
6def jffs2dump_find_file(files_list, fname):
7    for file_name in files_list:
8        file_name = file_name.strip()
9        if file_name.startswith("Dirent") and file_name.endswith(fname):
10            return True
11    return False
12
13
14class TestJffs2(infra.basetest.BRTest):
15    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
16        """
17        BR2_TARGET_ROOTFS_JFFS2=y
18        BR2_TARGET_ROOTFS_JFFS2_CUSTOM=y
19        BR2_TARGET_ROOTFS_JFFS2_CUSTOM_EBSIZE=0x40000
20        BR2_TARGET_ROOTFS_JFFS2_NOCLEANMARKER=y
21        BR2_TARGET_ROOTFS_JFFS2_PAD=y
22        BR2_TARGET_ROOTFS_JFFS2_PADSIZE=0x4000000
23        # BR2_TARGET_ROOTFS_TAR is not set
24        """
25
26    # TODO: there are some scary JFFS2 messages when one starts to
27    # write files in the rootfs: "jffs2: Newly-erased block contained
28    # word 0x0 at offset 0x046c0000". To be investigated.
29
30    def test_run(self):
31        img = os.path.join(self.builddir, "images", "rootfs.jffs2")
32        cmd = ["host/sbin/jffs2dump", "-c", img]
33        out = infra.run_cmd_on_host(self.builddir, cmd)
34        out = out.splitlines()
35        self.assertTrue(jffs2dump_find_file(out, "busybox"))
36
37        self.emulator.boot(arch="armv7",
38                           kernel="builtin",
39                           kernel_cmdline=["root=/dev/mtdblock0",
40                                           "rootfstype=jffs2"],
41                           options=["-drive", "file={},if=pflash".format(img)])
42        self.emulator.login()
43        cmd = "mount | grep '/dev/root on / type jffs2'"
44        self.assertRunOk(cmd)
45