[LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS

Petr Vorel pvorel@suse.cz
Fri Sep 16 23:22:08 CEST 2022


Hi all,

I finally merged this, with diff below.
In case I overlooked something in eb47b4497 ("tst_supported_fs: Support skip
list when query single fs") or there is other problem needed to be fixed before
release, I'll try to address it next week.

Thanks a lot to all reviewers for their time and patience.

Kind regards,
Petr

diff --git lib/newlib_tests/shell/tst_all_filesystems.sh lib/newlib_tests/shell/tst_all_filesystems.sh
index 61284f4f2..7561579ff 100755
--- lib/newlib_tests/shell/tst_all_filesystems.sh
+++ lib/newlib_tests/shell/tst_all_filesystems.sh
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
 
 TST_ALL_FILESYSTEMS=1
+TST_MOUNT_DEVICE=1
 TST_NEEDS_ROOT=1
 TST_TESTFUNC=test
 TST_CNT=2
diff --git lib/newlib_tests/shell/tst_all_filesystems_skip.sh lib/newlib_tests/shell/tst_all_filesystems_skip.sh
index c2e0ba9ff..9516f38d9 100755
--- lib/newlib_tests/shell/tst_all_filesystems_skip.sh
+++ lib/newlib_tests/shell/tst_all_filesystems_skip.sh
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
 
 TST_ALL_FILESYSTEMS=1
+TST_MOUNT_DEVICE=1
 TST_NEEDS_ROOT=1
 TST_TESTFUNC=test
 TST_SKIP_FILESYSTEMS="btrfs,exfat,ext2,ext3,ext4,fuse,ntfs,vfat,tmpfs,xfs"
diff --git lib/tst_supported_fs_types.c lib/tst_supported_fs_types.c
index 52824cce9..7781f94c3 100644
--- lib/tst_supported_fs_types.c
+++ lib/tst_supported_fs_types.c
@@ -14,7 +14,10 @@
 #include "tst_test.h"
 #include "tst_fs.h"
 
-/* NOTE: new filesystem should be also added to tst_*skip*.sh */
+/*
+ * NOTE: new filesystem should be also added to
+ * lib/newlib_tests/shell/tst_{all_filesystems_skip,skip_filesystems}.sh
+ */
 static const char *const fs_type_whitelist[] = {
 	"ext2",
 	"ext3",
diff --git testcases/commands/df/df01.sh testcases/commands/df/df01.sh
index 9527da214..ae0449c3c 100755
--- testcases/commands/df/df01.sh
+++ testcases/commands/df/df01.sh
@@ -7,6 +7,7 @@
 # Test df command with some basic options.
 
 TST_ALL_FILESYSTEMS=1
+TST_MOUNT_DEVICE=1
 TST_CNT=12
 TST_SETUP=setup
 TST_TESTFUNC=test
diff --git testcases/lib/tst_supported_fs.c testcases/lib/tst_supported_fs.c
index e2261244d..70d4d38c7 100644
--- testcases/lib/tst_supported_fs.c
+++ testcases/lib/tst_supported_fs.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
+ * Copyright (c) Linux Test Project, 2019-2022
  * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
  * Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
  */
@@ -16,12 +17,23 @@
 
 static void usage(void)
 {
-	fprintf(stderr, "Usage: tst_supported_fs [-s skip_list] [fs_type]\n");
-	fprintf(stderr, "   If fs_type is supported, return 0\n");
-	fprintf(stderr, "   If fs_type isn't supported, return 1\n");
-	fprintf(stderr, "   If fs_type isn't specified, print the list of supported filesystems\n");
-	fprintf(stderr, "   fs_type - a specified filesystem type\n");
-	fprintf(stderr, "   skip_list - filesystems to skip, delimiter: '%c'\n",
+	fprintf(stderr, "Usage:\n");
+	fprintf(stderr, "* all filesystems\n");
+	fprintf(stderr, "tst_supported_fs [-s skip_list]\n");
+	fprintf(stderr, "   print the list of supported filesystems\n");
+	fprintf(stderr, "   if fs_type is supported and not in skip_list (optional),\n"
+			"   print list of supported filesystems and return 0\n");
+	fprintf(stderr, "   if fs_type isn't supported or in skip_list, return 1\n\n");
+
+	fprintf(stderr, "* single filesystem\n");
+	fprintf(stderr, "tst_supported_fs fs_type\n");
+	fprintf(stderr, "   if fs_type is supported, return 0 otherwise return 1\n\n");
+
+	fprintf(stderr, "tst_supported_fs -s skip_list fs_type\n");
+	fprintf(stderr, "   if fs_type is in skip_list, return 1 otherwise return 0\n\n");
+
+	fprintf(stderr, "fs_type - a specified filesystem type\n");
+	fprintf(stderr, "skip_list - filesystems to skip, delimiter: '%c'\n",
 			SKIP_DELIMITER);
 }
 
@@ -80,15 +92,29 @@ int main(int argc, char *argv[])
 		return 2;
 	}
 
+	/* fs_type */
 	if (optind < argc) {
-		if (tst_fs_in_skiplist(argv[optind], (const char * const*)skiplist))
-			tst_brk(TCONF, "%s is not supported by the test", argv[optind]);
+		if (argv[optind][0] == '\0')
+			tst_brk(TCONF, "fs_type is empty");
 
-		tst_res(TINFO, "%s is supported by the test", argv[optind]);
+		if (skiplist) {
+			if (tst_fs_in_skiplist(argv[optind], (const char * const*)skiplist))
+				tst_brk(TCONF, "%s is skipped", argv[optind]);
+			else
+				tst_res(TINFO, "%s is not skipped", argv[optind]);
+
+			return 0;
+		}
+
+		if (tst_fs_is_supported(argv[optind]) == TST_FS_UNSUPPORTED)
+			tst_brk(TCONF, "%s is not supported", argv[optind]);
+		else
+			tst_res(TINFO, "%s is supported", argv[optind]);
 
 		return 0;
 	}
 
+	/* all filesystems */
 	filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
 
 	if (!filesystems[0])
diff --git testcases/lib/tst_test.sh testcases/lib/tst_test.sh
index 5b2abb282..229317713 100644
--- testcases/lib/tst_test.sh
+++ testcases/lib/tst_test.sh
@@ -699,14 +699,13 @@ tst_run()
 
 	[ -n "$TST_NEEDS_MODULE" ] && tst_require_module "$TST_NEEDS_MODULE"
 
-	[ "$TST_ALL_FILESYSTEMS" = 1 ] && TST_MOUNT_DEVICE=1
 	[ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1
-	[ "$TST_FORMAT_DEVICE" = 1 ] && TST_NEEDS_DEVICE=1
+	[ "$TST_FORMAT_DEVICE" = 1 -o "$TST_ALL_FILESYSTEMS" = 1 ] && TST_NEEDS_DEVICE=1
 	[ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1
 
 	if [ "$TST_ALL_FILESYSTEMS" != 1 ]; then
 		if ! tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE > /dev/null; then
-			tst_brk TCONF "$TST_FS_TYPE is not supported"
+			tst_brk TCONF "$TST_FS_TYPE is skipped by the test"
 		fi
 	fi
 


More information about the ltp mailing list