public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] zram/zram_lib.sh: Check fielsystem support more throughly
@ 2018-07-11  8:55 Xiao Yang
  2018-07-18 12:46 ` Cyril Hrubis
  0 siblings, 1 reply; 10+ messages in thread
From: Xiao Yang @ 2018-07-11  8:55 UTC (permalink / raw)
  To: ltp

When mkfs command supports a specified filesystem and kernel doesn't support it,
mkfs can format zram device to the filesystem successfully, but mount will fail
with "unknown filesystem type".

For example, running zram01 got the following error when only mkfs supported btrfs
filesystem:
---------------------------------------------------------------------------------
mount: /tmp/ltp-aJSv2PMZGl/zram01.46mBiYaa3M/zram3: unknown filesystem type 'btrfs'.
---------------------------------------------------------------------------------

We should add a fielsystem support check for both kernel and mkfs command, and use
ext2 fielsystem by default if either of them doesn't support a specified filesystem.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/kernel/device-drivers/zram/zram_lib.sh | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh
index 224b407..d6ce74a 100755
--- a/testcases/kernel/device-drivers/zram/zram_lib.sh
+++ b/testcases/kernel/device-drivers/zram/zram_lib.sh
@@ -193,13 +193,27 @@ zram_swapoff()
 	tst_resm TPASS "swapoff completed"
 }
 
+zram_check_fs_support()
+{
+	tst_check_cmds which modprobe
+	local filesystem=$1
+
+	# Check if mkfs command supports fs
+	which mkfs.$filesystem > /dev/null 2>&1 || return 1
+
+	# Check if kernel supports fs
+	if ! grep -qw $filesystem /proc/filesystems; then
+		modprobe $filesystem > /dev/null 2>&1 || return 1
+	fi
+}
+
 zram_makefs()
 {
-	tst_check_cmds mkfs which
+	tst_check_cmds mkfs
 	local i=0
 	for fs in $zram_filesystems; do
 		# if requested fs not supported default it to ext2
-		which mkfs.$fs > /dev/null 2>&1 || fs=ext2
+		zram_check_fs_support $fs || fs=ext2
 
 		tst_resm TINFO "make $fs filesystem on /dev/zram$i"
 		mkfs.$fs /dev/zram$i > err.log 2>&1
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-07-23 14:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-11  8:55 [LTP] [PATCH] zram/zram_lib.sh: Check fielsystem support more throughly Xiao Yang
2018-07-18 12:46 ` Cyril Hrubis
2018-07-19  7:31   ` [LTP] [PATCH v2 1/2] lib: Factor out is_supported() && Add tst_supported_fs for shell Xiao Yang
2018-07-19  7:31     ` [LTP] [PATCH v2 2/2] zram/zram_lib.sh: Apply " Xiao Yang
2018-07-19 12:27       ` Cyril Hrubis
2018-07-19 12:21     ` [LTP] [PATCH v2 1/2] lib: Factor out is_supported() && Add " Cyril Hrubis
2018-07-20 10:40       ` [LTP] [PATCH v3 1/2] lib: Factor out is_supported() && Add tst_supported_fs Xiao Yang
2018-07-20 10:40         ` [LTP] [PATCH v3 2/2] zram/zram_lib.sh: Apply tst_supported_fs for shell Xiao Yang
2018-07-23 14:52         ` [LTP] [PATCH v3 1/2] lib: Factor out is_supported() && Add tst_supported_fs Cyril Hrubis
2018-07-19 12:27     ` [LTP] [PATCH v2 1/2] lib: Factor out is_supported() && Add tst_supported_fs for shell Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox