[LTP] [PATCH v2 1/6] tst_test.sh: Properly init $TST_FS_TYPE

Petr Vorel pvorel@suse.cz
Thu Feb 10 17:27:34 CET 2022


to sync with C API init $TST_FS_TYPE with $LTP_DEV_FS_TYPE, when
defined. That's equivalent of the .dev_fs_type in the tst_test
structure:

    if (tst_test->dev_fs_type)
	    tdev.fs_type = tst_test->dev_fs_type;
    else
	    tdev.fs_type = tst_dev_fs_type();

    (And the tst_dev_fs_type() returns either $LTP_DEV_FS_TYPE or "ext2"
    if it's not defined.)

Now, when $TST_FS_TYPE properly defined, tst_mkfs() can rely on it
(thus define the check).

Also use the variable in df01.sh, mkfs01.sh (the only shell tests which
works with filesystems).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/commands/df/df01.sh     | 2 --
 testcases/commands/mkfs/mkfs01.sh | 2 +-
 testcases/lib/tst_test.sh         | 8 ++++----
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index b821452e60..e70f33c9b0 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -28,8 +28,6 @@ OPTIONS
 EOF
 }
 
-TST_FS_TYPE=ext2
-
 parse_args()
 {
 	TST_FS_TYPE="$2"
diff --git a/testcases/commands/mkfs/mkfs01.sh b/testcases/commands/mkfs/mkfs01.sh
index 17c7fb9e4a..a3ff027a6d 100755
--- a/testcases/commands/mkfs/mkfs01.sh
+++ b/testcases/commands/mkfs/mkfs01.sh
@@ -45,7 +45,7 @@ setup()
 mkfs_verify_type()
 {
 	if [ -z "$1" ]; then
-		blkid $2 -t TYPE="ext2" >/dev/null
+		blkid $2 -t TYPE="$TST_FS_TYPE" >/dev/null
 	else
 		if [ "$1" = "msdos" ]; then
 			blkid $2 -t TYPE="vfat" >/dev/null
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 30614974c3..fa4c90f787 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -17,6 +17,10 @@ export TST_ITERATIONS=1
 export TST_TMPDIR_RHOST=0
 export TST_LIB_LOADED=1
 
+if [ -z "$TST_FS_TYPE" ]; then
+	export TST_FS_TYPE="${LTP_DEV_FS_TYPE:-ext2}"
+fi
+
 . tst_ansi_color.sh
 . tst_security.sh
 
@@ -343,10 +347,6 @@ tst_mkfs()
 	[ $# -ge 1 ] && shift
 	local fs_opts="$@"
 
-	if [ -z "$fs_type" ]; then
-		tst_brk TBROK "No fs_type specified"
-	fi
-
 	if [ -z "$device" ]; then
 		tst_brk TBROK "No device specified"
 	fi
-- 
2.35.1



More information about the ltp mailing list