summaryrefslogtreecommitdiffstats
path: root/support/testing/tests/fs/test_ext.py
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-03-20 21:36:52 +0100
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-05-07 22:04:54 +0200
commitbf4a6490e4ee70f0a46e588602995ba34e6c872a (patch)
treeea72b284a2039582c29f4e8e5f4bf59b3d6fa516 /support/testing/tests/fs/test_ext.py
parent96e21b617d72fc94445e18b6fb1e653850e0885e (diff)
downloadbuildroot-bf4a6490e4ee70f0a46e588602995ba34e6c872a.tar.gz
buildroot-bf4a6490e4ee70f0a46e588602995ba34e6c872a.zip
support/testing: add fs tests
This commit adds a number of test cases for various filesystem formats: ext2/3/4, iso9660, jffs2, squashfs, ubi/ubifs and yaffs2. All of them except yaffs2 are runtime tested. The iso9660 set of test cases is particularly rich, testing the proper operation of the iso9660 support with all of grub, grub2 and isolinux. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'support/testing/tests/fs/test_ext.py')
-rw-r--r--support/testing/tests/fs/test_ext.py119
1 files changed, 119 insertions, 0 deletions
diff --git a/support/testing/tests/fs/test_ext.py b/support/testing/tests/fs/test_ext.py
new file mode 100644
index 0000000000..f7e2e85055
--- /dev/null
+++ b/support/testing/tests/fs/test_ext.py
@@ -0,0 +1,119 @@
+import os
+import subprocess
+
+import infra.basetest
+
+VOLNAME_PROP = "Filesystem volume name"
+REVISION_PROP = "Filesystem revision #"
+FEATURES_PROP = "Filesystem features"
+BLOCKCNT_PROP = "Block count"
+INODECNT_PROP = "Inode count"
+RESBLKCNT_PROP = "Reserved block count"
+
+CHECK_FS_TYPE_CMD = "mount | grep '/dev/root on / type {}'"
+
+def dumpe2fs_run(builddir, image):
+ cmd = ["host/usr/sbin/dumpe2fs", os.path.join("images", image)]
+ ret = subprocess.check_output(cmd,
+ stderr=open(os.devnull, "w"),
+ cwd=builddir,
+ env={"LANG": "C"})
+ return ret.strip().splitlines()
+
+def dumpe2fs_getprop(out, prop):
+ for lines in out:
+ lines = lines.split(": ")
+ if lines[0] == prop:
+ return lines[1].strip()
+
+def boot_img_and_check_fs_type(emulator, builddir, fs_type):
+ img = os.path.join(builddir, "images", "rootfs.{}".format(fs_type))
+ emulator.boot(arch="armv7",
+ kernel="builtin",
+ kernel_cmdline=["root=/dev/mmcblk0",
+ "rootfstype={}".format(fs_type)],
+ options=["-drive", "file={},if=sd".format(img)])
+ emulator.login()
+ _, exit_code = emulator.run(CHECK_FS_TYPE_CMD.format(fs_type))
+ return exit_code
+
+class TestExt2(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+"""
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_2r0=y
+BR2_TARGET_ROOTFS_EXT2_LABEL="foobaz"
+# BR2_TARGET_ROOTFS_TAR is not set
+"""
+
+ def test_run(self):
+ out = dumpe2fs_run(self.builddir, "rootfs.ext2")
+ self.assertEqual(dumpe2fs_getprop(out, VOLNAME_PROP), "foobaz")
+ self.assertEqual(dumpe2fs_getprop(out, REVISION_PROP), "0 (original)")
+
+ exit_code = boot_img_and_check_fs_type(self.emulator,
+ self.builddir, "ext2")
+ self.assertEqual(exit_code, 0)
+
+class TestExt2r1(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+"""
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_2r1=y
+BR2_TARGET_ROOTFS_EXT2_LABEL="foobar"
+# BR2_TARGET_ROOTFS_TAR is not set
+"""
+
+ def test_run(self):
+ out = dumpe2fs_run(self.builddir, "rootfs.ext2")
+ self.assertEqual(dumpe2fs_getprop(out, VOLNAME_PROP), "foobar")
+ self.assertEqual(dumpe2fs_getprop(out, REVISION_PROP), "1 (dynamic)")
+ self.assertNotIn("has_journal", dumpe2fs_getprop(out, FEATURES_PROP))
+
+ exit_code = boot_img_and_check_fs_type(self.emulator,
+ self.builddir, "ext2")
+ self.assertEqual(exit_code, 0)
+
+class TestExt3(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+"""
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_3=y
+# BR2_TARGET_ROOTFS_TAR is not set
+"""
+
+ def test_run(self):
+ out = dumpe2fs_run(self.builddir, "rootfs.ext3")
+ self.assertEqual(dumpe2fs_getprop(out, REVISION_PROP), "1 (dynamic)")
+ self.assertIn("has_journal", dumpe2fs_getprop(out, FEATURES_PROP))
+
+ exit_code = boot_img_and_check_fs_type(self.emulator,
+ self.builddir, "ext3")
+ self.assertEqual(exit_code, 0)
+
+class TestExt4(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+"""
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_TARGET_ROOTFS_EXT2_BLOCKS=16384
+BR2_TARGET_ROOTFS_EXT2_INODES=3000
+BR2_TARGET_ROOTFS_EXT2_RESBLKS=10
+# BR2_TARGET_ROOTFS_TAR is not set
+"""
+
+ def test_run(self):
+ out = dumpe2fs_run(self.builddir, "rootfs.ext4")
+ self.assertEqual(dumpe2fs_getprop(out, REVISION_PROP), "1 (dynamic)")
+ self.assertEqual(dumpe2fs_getprop(out, BLOCKCNT_PROP), "16384")
+ # Yes there are 8 more inodes than requested
+ self.assertEqual(dumpe2fs_getprop(out, INODECNT_PROP), "3008")
+ self.assertEqual(dumpe2fs_getprop(out, RESBLKCNT_PROP), "1638")
+ self.assertIn("has_journal", dumpe2fs_getprop(out, FEATURES_PROP))
+ self.assertIn("extent", dumpe2fs_getprop(out, FEATURES_PROP))
+
+ exit_code = boot_img_and_check_fs_type(self.emulator,
+ self.builddir, "ext4")
+ self.assertEqual(exit_code, 0)
+
+
OpenPOWER on IntegriCloud