public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] tst_supported_fs: Implement checking paths against skiplist
@ 2022-09-21 15:50 Martin Doucha
  2022-09-22  4:16 ` Li Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Martin Doucha @ 2022-09-21 15:50 UTC (permalink / raw)
  To: pvorel, ltp

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Implement tst_supported_fs feature suggested by pvorel in his patch:
tst_test.sh: Fix filesystem support detection

Although the tst_fs_type_name() functions could use some improvements,
e.g. ext4 must be specified in skiplist as "ext2/ext3/ext4" to get properly
skipped and vfat is missing from the list of known filesystems.

 testcases/lib/tst_supported_fs.c | 49 ++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 8 deletions(-)

diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
index 70d4d38c7..5873d0ba1 100644
--- a/testcases/lib/tst_supported_fs.c
+++ b/testcases/lib/tst_supported_fs.c
@@ -32,9 +32,13 @@ static void usage(void)
 	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, "tst_supported_fs -s skip_list -d path\n");
+	fprintf(stderr, "   if filesystem mounted on path 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);
+	fprintf(stderr, "path - any valid file or directory\n");
 }
 
 static char **parse_skiplist(char *fs)
@@ -62,10 +66,11 @@ static char **parse_skiplist(char *fs)
 int main(int argc, char *argv[])
 {
 	const char *const *filesystems;
+	const char *fsname = NULL;
 	int i, ret;
 	char **skiplist = NULL;
 
-	while ((ret = getopt(argc, argv, "hs:"))) {
+	while ((ret = getopt(argc, argv, "hs:d:"))) {
 		if (ret < 0)
 			break;
 
@@ -83,9 +88,26 @@ int main(int argc, char *argv[])
 			if (!skiplist)
 				return 1;
 			break;
+
+		case 'd':
+			if (fsname) {
+				fprintf(stderr,
+					"Can't specify multiple paths\n");
+				usage();
+				return 2;
+			}
+
+			fsname = tst_fs_type_name(tst_fs_type(optarg));
+			break;
 		}
 	}
 
+	if (fsname && !skiplist) {
+		fprintf(stderr, "Parameter -d requires skiplist\n");
+		usage();
+		return 2;
+	}
+
 	if (argc - optind > 1) {
 		fprintf(stderr, "Can't specify multiple fs_type\n");
 		usage();
@@ -94,22 +116,33 @@ int main(int argc, char *argv[])
 
 	/* fs_type */
 	if (optind < argc) {
-		if (argv[optind][0] == '\0')
+		if (fsname) {
+			fprintf(stderr, "Can't specify fs_type and -d together\n");
+			usage();
+			return 2;
+
+		}
+
+		fsname = argv[optind];
+	}
+
+	if (fsname) {
+		if (fsname[0] == '\0')
 			tst_brk(TCONF, "fs_type is empty");
 
 		if (skiplist) {
-			if (tst_fs_in_skiplist(argv[optind], (const char * const*)skiplist))
-				tst_brk(TCONF, "%s is skipped", argv[optind]);
+			if (tst_fs_in_skiplist(fsname, (const char * const*)skiplist))
+				tst_brk(TCONF, "%s is skipped", fsname);
 			else
-				tst_res(TINFO, "%s is not skipped", argv[optind]);
+				tst_res(TINFO, "%s is not skipped", fsname);
 
 			return 0;
 		}
 
-		if (tst_fs_is_supported(argv[optind]) == TST_FS_UNSUPPORTED)
-			tst_brk(TCONF, "%s is not supported", argv[optind]);
+		if (tst_fs_is_supported(fsname) == TST_FS_UNSUPPORTED)
+			tst_brk(TCONF, "%s is not supported", fsname);
 		else
-			tst_res(TINFO, "%s is supported", argv[optind]);
+			tst_res(TINFO, "%s is supported", fsname);
 
 		return 0;
 	}
-- 
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2022-09-26  7:48 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-21 15:50 [LTP] [PATCH] tst_supported_fs: Implement checking paths against skiplist Martin Doucha
2022-09-22  4:16 ` Li Wang
2022-09-22  8:14   ` Martin Doucha
2022-09-22  8:43     ` Petr Vorel
2022-09-22  9:08       ` Li Wang
2022-09-22  9:56         ` Petr Vorel
2022-09-22  9:02   ` Petr Vorel
2022-09-22  9:24     ` Li Wang
2022-09-22 10:40       ` Petr Vorel
2022-09-22 10:55         ` Cyril Hrubis
2022-09-22 10:57           ` Martin Doucha
2022-09-22 11:20             ` Petr Vorel
2022-09-22 14:42               ` Cyril Hrubis
2022-09-22 20:22                 ` Petr Vorel
2022-09-22  8:56 ` Petr Vorel
2022-09-22 20:26 ` Petr Vorel
2022-09-23 10:00 ` Petr Vorel
2022-09-26  7:48   ` Petr Vorel
2022-09-23 15:17 ` Cyril Hrubis

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