[LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported

Petr Vorel pvorel@suse.cz
Fri Sep 9 16:18:33 CEST 2022


Although this is unlikely, it can happen.
This means 32 (TCONF) instead of 0 exit code when searching for all
filesystems and 32 instead of 1 when searching for a particular
filesystem.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
New in v5

NOTE:

Although this will later leads to duplicating message (see below) it's
IMHO better because LVM scripts and zram01.sh use this helper directly.

Tests added in later commits which demonstrates TCONF:

# ./tst_skip_filesystems_skip.sh
tst_supported_fs_types.c:90: TINFO: Kernel supports ext4
tst_supported_fs_types.c:52: TINFO: mkfs.ext4 does exist
tst_supported_fs.c:88: TCONF: ext4 is skipped or not supported
tst_skip_filesystems_skip 1 TCONF: ext4 is not supported

Summary:
passed   0
failed   0
broken   0
skipped  1
warnings 0

# ./tst_all_filesystems_skip.sh
tst_device.c:89: TINFO: Found free device 0 '/dev/loop0'
tst_supported_fs_types.c:173: TINFO: Skipping ext2 as requested by the test
tst_supported_fs_types.c:173: TINFO: Skipping ext3 as requested by the test
tst_supported_fs_types.c:173: TINFO: Skipping ext4 as requested by the test
tst_supported_fs_types.c:173: TINFO: Skipping xfs as requested by the test
tst_supported_fs_types.c:173: TINFO: Skipping btrfs as requested by the test
tst_supported_fs_types.c:173: TINFO: Skipping vfat as requested by the test
tst_supported_fs_types.c:173: TINFO: Skipping exfat as requested by the test
tst_supported_fs_types.c:173: TINFO: Skipping ntfs as requested by the test
tst_supported_fs_types.c:173: TINFO: Skipping tmpfs as requested by the test
tst_supported_fs.c:96: TCONF: There are no supported filesystems or all skipped
tst_all_filesystems_skip 1 TCONF: There are no supported filesystems or all skipped

Summary:
passed   0
failed   0
broken   0
skipped  1
warnings 0

 testcases/lib/tst_supported_fs.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
index 43eac194f..6e544070c 100644
--- a/testcases/lib/tst_supported_fs.c
+++ b/testcases/lib/tst_supported_fs.c
@@ -24,7 +24,7 @@ int main(int argc, char *argv[])
 {
 	const char *skiplist[] = {"tmpfs", NULL};
 	const char *const *filesystems;
-	int i;
+	int i, ret;
 
 	if (argc > 2) {
 		fprintf(stderr, "Can't specify multiple fs_type\n");
@@ -37,10 +37,20 @@ int main(int argc, char *argv[])
 		return 0;
 	}
 
-	if (argv[1])
-		return !tst_fs_is_supported(argv[1]);
+	if (argv[1]) {
+		ret = tst_fs_is_supported(argv[1]);
+
+		if (ret == TST_FS_UNSUPPORTED)
+			tst_brk(TCONF, "%s is not supported", argv[optind]);
+
+		return !ret;
+	}
 
 	filesystems = tst_get_supported_fs_types(skiplist);
+
+	if (!filesystems[0])
+		tst_brk(TCONF, "There are no supported filesystems");
+
 	for (i = 0; filesystems[i]; i++)
 		printf("%s\n", filesystems[i]);
 
-- 
2.37.3



More information about the ltp mailing list