]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/testing/tests/fs/test_jffs2.py
support/testing: standardize defconfig fragments style
[coffee/buildroot.git] / support / testing / tests / fs / test_jffs2.py
1 import os
2 import subprocess
3
4 import infra.basetest
5
6 def 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 class TestJffs2(infra.basetest.BRTest):
14     config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
15         """
16         BR2_TARGET_ROOTFS_JFFS2=y
17         BR2_TARGET_ROOTFS_JFFS2_CUSTOM=y
18         BR2_TARGET_ROOTFS_JFFS2_CUSTOM_EBSIZE=0x80000
19         BR2_TARGET_ROOTFS_JFFS2_NOCLEANMARKER=y
20         BR2_TARGET_ROOTFS_JFFS2_PAD=y
21         BR2_TARGET_ROOTFS_JFFS2_PADSIZE=0x4000000
22         # BR2_TARGET_ROOTFS_TAR is not set
23         """
24
25     # TODO: there are some scary JFFS2 messages when one starts to
26     # write files in the rootfs: "jffs2: Newly-erased block contained
27     # word 0x0 at offset 0x046c0000". To be investigated.
28
29     def test_run(self):
30         img = os.path.join(self.builddir, "images", "rootfs.jffs2")
31         out = subprocess.check_output(["host/sbin/jffs2dump", "-c", img],
32                                       cwd=self.builddir,
33                                       env={"LANG": "C"})
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         _, exit_code = self.emulator.run(cmd)
45         self.assertEqual(exit_code, 0)