Skip to contentSkip to conversation

shell: df01.sh: $TST_ALL_FILESYSTEMS

PATCH In review Petr Vorel 2 participants 26 messages Sep 15, 2022 – Sep 16, 2022 Library code

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

v6 cover shell: df01.sh: $TST_ALL_FILESYSTEMS

Hi,

Note, I give up on some duplicity in the code, i.e. instead adding tst_fs_is_current_fs_supported() I proposed in [1], I just make duplicity:

    if (tst_fs_in_skiplist(fs_type, skiplist))
        tst_brk(TCONF, "%s is not supported by the test", fs_type);

	if (!filesystems[0])
		tst_brk(TCONF, "There are no supported filesystems");

I also didn't implement different exit code for test not supported and test being skipped TST_FS_UNAVAILABLE and TST_FS_UNSUPPORTED (Martin [2]). It should be obvious from previous messages or we can easily implement it after the release.

changes v5->v6
* Remove TST_FS_TYPE_FUSE (put the code just to df01.sh and tst_all_filesystems.sh test (Cyril [3])
* Remove tst_fs_is_supported_skiplist(), implement tst_fs_in_skiplist() instead.
* new commit to whitelist | in filtering variables

[1] https://lore.kernel.org/ltp/YyCJnQR7ORn3phVn@pevik/
[2] https://lore.kernel.org/ltp/[email protected]/
[3] https://lore.kernel.org/ltp/Yx9QFWuRMjDUAafp@yuki/

Petr Vorel (8):
tst_supported_fs: Implement skip list zram01.sh: Use tst_supported_fs -s tmpfs
tst_supported_fs: Support skip list when query single fs
shell: Add $TST_SKIP_FILESYSTEMS + tests tst_test.sh: Add $TST_ALL_FILESYSTEMS tst_test.sh: Allow | after whitelisted variable
shell: Add tests for TST_ALL_FILESYSTEMS=1 df01.sh: Convert to TST_ALL_FILESYSTEMS=1

 doc/shell-test-api.txt                        |  11 +-
 lib/newlib_tests/shell/tst_all_filesystems.sh |  21 +++
 .../shell/tst_all_filesystems_skip.sh         |  16 +++
 .../shell/tst_skip_filesystems.sh             |  35 +++++
 .../shell/tst_skip_filesystems_skip.sh        |  17 +++
 lib/tst_supported_fs_types.c                  |   1 +
 runtest/commands                              |   8 +-
 runtest/smoketest                             |   2 +-
 testcases/commands/df/df01.sh                 |  28 +---
 .../kernel/device-drivers/zram/zram01.sh      |   3 +-
 testcases/lib/tst_supported_fs.c              |  71 +++++++--
 testcases/lib/tst_test.sh                     | 136 ++++++++++++------
 testcases/misc/lvm/generate_lvm_runfile.sh    |   2 +-
 testcases/misc/lvm/prepare_lvm.sh             |   2 +-
 14 files changed, 265 insertions(+), 88 deletions(-)
 create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh
 create mode 100755 lib/newlib_tests/shell/tst_all_filesystems_skip.sh
 create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems.sh
 create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems_skip.sh
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH v6 1/8 tst_supported_fs: Implement skip list

as it will be needed for $ALL_FILESYSTEMS shell implementation in the next commit. Pass tmpfs to LVM scripts (as it was required there).

Also print TCONF if there are not supported filesystems.

---
 testcases/lib/tst_supported_fs.c           | 70 ++++++++++++++++++----
 testcases/misc/lvm/generate_lvm_runfile.sh |  2 +-
 testcases/misc/lvm/prepare_lvm.sh          |  2 +-
 3 files changed, 61 insertions(+), 13 deletions(-)
testcases/lib/tst_supported_fs.c +59 -11
index 43eac194f..2b42d5bb3 100644
@@ -5,42 +5,90 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
+#define SKIP_DELIMITER ','
+
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 #include "tst_fs.h"
 
 static void usage(void)
 {
-	fprintf(stderr, "Usage: tst_supported_fs [fs_type]\n");
+	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",
+			SKIP_DELIMITER);
+}
+
+static char **parse_skiplist(char *fs)
+{
+	char **skiplist;
+	int i, cnt = 1;
+
+	for (i = 0; fs[i]; i++) {
+		if (optarg[i] == SKIP_DELIMITER)
+			cnt++;
+	}
+
+	skiplist = malloc(++cnt * sizeof(char *));
+	if (!skiplist) {
+		fprintf(stderr, "malloc() failed\n");
+		return NULL;
+	}
+
+	for (i = 0; i < cnt; i++)
+		skiplist[i] = strtok_r(fs, TST_TO_STR(SKIP_DELIMITER), &fs);
+
+	return skiplist;
 }
 
 int main(int argc, char *argv[])
 {
-	const char *skiplist[] = {"tmpfs", NULL};
 	const char *const *filesystems;
-	int i;
+	int i, ret;
+	char **skiplist = NULL;
 
-	if (argc > 2) {
+	while ((ret = getopt(argc, argv, "hs:"))) {
+		if (ret < 0)
+			break;
+
+		switch (ret) {
+		case '?':
+			usage();
+			return 1;
+
+		case 'h':
+			usage();
+			return 0;
+
+		case 's':
+			skiplist = parse_skiplist(optarg);
+			if (!skiplist)
+				return 1;
+			break;
+		}
+	}
+
+	if (argc - optind > 1) {
 		fprintf(stderr, "Can't specify multiple fs_type\n");
 		usage();
 		return 2;
 	}
 
-	if (argv[1] && !strcmp(argv[1], "-h")) {
-		usage();
-		return 0;
-	}
+	if (optind < argc)
+		return !tst_fs_is_supported(argv[optind]);
+
+
+	filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
 
-	if (argv[1])
-		return !tst_fs_is_supported(argv[1]);
+	if (!filesystems[0])
+		tst_brk(TCONF, "There are no supported filesystems");
 
-	filesystems = tst_get_supported_fs_types(skiplist);
 	for (i = 0; filesystems[i]; i++)
 		printf("%s\n", filesystems[i]);
 
testcases/misc/lvm/generate_lvm_runfile.sh +1 -1
index 477aed116..7f7e149d9 100755
@@ -17,7 +17,7 @@ generate_runfile()
 	trap '[ $? -eq 0 ] || tst_brk TBROK "Cannot create LVM runfile"' EXIT
 	INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl"
 	OUTFILE="$LTPROOT/runtest/lvm.local"
-	FS_LIST=`tst_supported_fs`
+	FS_LIST=$(tst_supported_fs -s tmpfs)
 	echo -n "" >"$OUTFILE"
 
 	for fsname in $FS_LIST; do
testcases/misc/lvm/prepare_lvm.sh +1 -1
index d3ae4b23f..29f386df8 100755
@@ -70,7 +70,7 @@ prepare_mounts()
 
 prepare_lvm()
 {
-	FS_LIST=`tst_supported_fs | sort -u`
+	FS_LIST=$(tst_supported_fs -s tmpfs | sort -u)
 	ROD mkdir -p "$LVM_TMPDIR"
 	ROD mkdir -p "$LVM_IMGDIR"
 	chmod 777 "$LVM_TMPDIR"
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#2 lore raw

PATCH v6 2/8 zram01.sh: Use tst_supported_fs -s tmpfs

In reply to Petr Vorel
---
 testcases/kernel/device-drivers/zram/zram01.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
testcases/kernel/device-drivers/zram/zram01.sh +1 -2
index ad01291bf..8b92b699f 100755
@@ -38,8 +38,7 @@ initialize_vars()
 	local fs limit size stream=-1
 	dev_num=0
 
-	for fs in $(tst_supported_fs); do
-		[ "$fs" = "tmpfs" ] && continue
+	for fs in $(tst_supported_fs -s tmpfs); do
 		size="26214400"
 		limit="25M"
 		if [ "$fs" = "btrfs" ]; then
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#4 lore raw

PATCH v6 3/8 tst_supported_fs: Support skip list when query single fs

In reply to Petr Vorel

And use this feature in zram01.sh.

Also print TINFO if test it supported by the test, quit with TCONF otherwise (code from do_test_setup() tst_test.c).

---
 testcases/lib/tst_supported_fs.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
testcases/lib/tst_supported_fs.c +8 -3
index 2b42d5bb3..e2261244d 100644
@@ -80,14 +80,19 @@ int main(int argc, char *argv[])
 		return 2;
 	}
 
-	if (optind < argc)
-		return !tst_fs_is_supported(argv[optind]);
+	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]);
 
+		tst_res(TINFO, "%s is supported by the test", argv[optind]);
+
+		return 0;
+	}
 
 	filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
 
 	if (!filesystems[0])
-		tst_brk(TCONF, "There are no supported filesystems");
+		tst_brk(TCONF, "There are no supported filesystems or all skipped");
 
 	for (i = 0; filesystems[i]; i++)
 		printf("%s\n", filesystems[i]);
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs

Hi!

Quoted 1 line

And use this feature in zram01.sh.

This looks like an leftover.

Quoted 18 lines

Also print TINFO if test it supported by the test, quit with TCONF otherwise (code from do_test_setup() tst_test.c).

---
 testcases/lib/tst_supported_fs.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
testcases/lib/tst_supported_fs.c +0 -0
index 2b42d5bb3..e2261244d 100644
@@ -80,14 +80,19 @@ int main(int argc, char *argv[])
 		return 2;
 	}
 

testcases/lib/tst_supported_fs.c int main(int argc, char *argv[]) · line 90

Quoted 10 lines
testcases/lib/tst_supported_fs.c +7 -2
-	if (optind < argc)
-		return !tst_fs_is_supported(argv[optind]);
+	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]);
 
+		tst_res(TINFO, "%s is supported by the test", argv[optind]);
+
+		return 0;
+	}

So we now do not check if filesystem is supported just check against the skiplist?

I guess that it would mqake sense if -s option was present, but shouldn't we check for mkfs and kernel support without -s if filesystem was specified?

Quoted 11 lines
testcases/lib/tst_supported_fs.c +1 -1
 	filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
 
 	if (!filesystems[0])
-		tst_brk(TCONF, "There are no supported filesystems");
+		tst_brk(TCONF, "There are no supported filesystems or all skipped");
 
 	for (i = 0; filesystems[i]; i++)
 		printf("%s\n", filesystems[i]);
Signature · 1 line
2.37.3
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#6 lore raw

Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs

Quoted 29 lines

Hi!

Quoted 1 line

And use this feature in zram01.sh.

This looks like an leftover.

Quoted 23 lines

Also print TINFO if test it supported by the test, quit with TCONF otherwise (code from do_test_setup() tst_test.c).

---
 testcases/lib/tst_supported_fs.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
testcases/lib/tst_supported_fs.c +3 -2
index 2b42d5bb3..e2261244d 100644
@@ -80,14 +80,19 @@ int main(int argc, char *argv[])
 		return 2;
 	}
 
-	if (optind < argc)
-		return !tst_fs_is_supported(argv[optind]);
+	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]);
Quoted 7 lines

testcases/lib/tst_supported_fs.c int main(int argc, char *argv[]) · line 90

Quoted 4 lines
testcases/lib/tst_supported_fs.c +4 -0
+		tst_res(TINFO, "%s is supported by the test", argv[optind]);
+
+		return 0;
+	}

So we now do not check if filesystem is supported just check against the skiplist?

Good catch, before there was check for mkfs.foo even for single filesystem (via. tst_fs_is_supported()). Now I removed it when checking single filesystem (It's still being checked for all filesystems in code below:
filesystems = tst_get_supported_fs_types((const char * const*)skiplist); ).

FYI skip list without mkfs is needed for $TST_SKIP_FILESYSTEMS used without TST_ALL_FILESYSTEMS=1, i.e. in tst_test.sh:

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"
fi
fi

Quoted 3 lines

I guess that it would make sense if -s option was present, but shouldn't we check for mkfs and kernel support without -s if filesystem was specified?

This would solve problem for prepare_lvm.sh, where code:
if ! tst_supported_fs $fsname; then
checks just for mkfs.foo (no skip list). The problem is with certain inconsistency of mkfs check: because when checking skip list for all filesystems, both mkfs and skip list are being addressed (i.e. check for mkfs even -s is passed). Also it might be useful in the future to check both skip list and mkfs even for single filesystem.

Shouldn't there be an getopt option to decide?
e.g. by default both skip list and mkfs (no matter if -s is passed) and with option (e.g. -o) check only for a list? This is not needed when checking all filesystems, only for testing single filesystem, so I wonder if I should implement it for all filesystems mode.

But as this is not needed I'm ok to implement what you suggest:
tst_supported_fs -s skiplist foo would check only if the used filesystem is not filtered by skip list (used in tst_test.sh).

tst_supported_fs foo would check only for mkfs.foo (used in prepare_lvm.sh).

What do you prefer?

Kind regards,
Petr

Quoted 10 lines
Quoted 10 lines
testcases/lib/tst_supported_fs.c +1 -1
 	filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
 
 	if (!filesystems[0])
-		tst_brk(TCONF, "There are no supported filesystems");
+		tst_brk(TCONF, "There are no supported filesystems or all skipped");
 
 	for (i = 0; filesystems[i]; i++)
 		printf("%s\n", filesystems[i]);
Signature · 1 line
2.37.3
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs

Hi!

Quoted 6 lines

Shouldn't there be an getopt option to decide?
e.g. by default both skip list and mkfs (no matter if -s is passed) and with option (e.g. -o) check only for a list? This is not needed when checking all filesystems, only for testing single filesystem, so I wonder if I should implement it for all filesystems mode.

Quoted 7 lines

But as this is not needed I'm ok to implement what you suggest:
tst_supported_fs -s skiplist foo would check only if the used filesystem is not filtered by skip list (used in tst_test.sh).

tst_supported_fs foo would check only for mkfs.foo (used in prepare_lvm.sh).

What do you prefer?

I guess that I do not care that much what exact API we do have here as long was we can check for just skiplist or just support separatelly.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#8 lore raw

Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs

Quoted 11 lines

Hi!

Quoted 9 lines

Shouldn't there be an getopt option to decide?
e.g. by default both skip list and mkfs (no matter if -s is passed) and with option (e.g. -o) check only for a list? This is not needed when checking all filesystems, only for testing single filesystem, so I wonder if I should implement it for all filesystems mode.

But as this is not needed I'm ok to implement what you suggest:
tst_supported_fs -s skiplist foo would check only if the used filesystem is not filtered by skip list (used in tst_test.sh).

Quoted 6 lines
Quoted 3 lines

tst_supported_fs foo would check only for mkfs.foo (used in prepare_lvm.sh).

What do you prefer?

I guess that I do not care that much what exact API we do have here as long was we can check for just skiplist or just support separatelly.

OK, atm we don't need the third option (skip list + both), so that I will not care about it.

I might do this only for mode when single fs is being queried (haven't decided yet) as that's IMHO not needed atm.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#9 lore raw

Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs

In reply to Cyril Hrubis
Quoted 4 lines

Hi!

Quoted 1 line

And use this feature in zram01.sh.

This looks like an leftover.

Thanks!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#10 lore raw

PATCH v6 4/8 shell: Add $TST_SKIP_FILESYSTEMS + tests

In reply to Petr Vorel

C API struct tst_test skip_filesystems member equivalent.

Now only running on single filesystem (will be improved in the next commit)

---
 doc/shell-test-api.txt                        |  2 ++
 .../shell/tst_skip_filesystems.sh             | 35 +++++++++++++++++++
 .../shell/tst_skip_filesystems_skip.sh        | 17 +++++++++
 lib/tst_supported_fs_types.c                  |  1 +
 testcases/lib/tst_test.sh                     |  6 ++++
 5 files changed, 61 insertions(+)
 create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems.sh
 create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems_skip.sh
doc/shell-test-api.txt +2 -0
index 65444541e..18ed144a9 100644
@@ -229,6 +229,8 @@ simply by setting right '$TST_FOO'.
 | 'TST_NEEDS_KCONFIGS'     | Checks kernel kconfigs support for the test (see below).
 | 'TST_NEEDS_KCONFIGS_IFS' | Used for splitting '$TST_NEEDS_KCONFIGS' variable,
                              default value is comma, it only supports single character.
+| 'TST_SKIP_FILESYSTEMS'   | Comma separated list of filesystems on which test will be skipped
+                             (tst_test.skip_filesystems equivalent).
 | 'TST_TIMEOUT'            | Maximum timeout set for the test in sec. Must be int >= 1,
                              or -1 (special value to disable timeout), default is 300.
                              Variable is meant be set in tests, not by user.
lib/newlib_tests/shell/tst_skip_filesystems.sh new file +35 -0
new file mode 100755
index 000000000..675d0ee5f
@@ -0,0 +1,35 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
+
+TST_MOUNT_DEVICE=1
+TST_NEEDS_ROOT=1
+TST_FS_TYPE=ext4
+TST_TESTFUNC=test
+TST_SKIP_FILESYSTEMS="btrfs,exfat,ext2,ext3,fuse,ntfs,vfat,tmpfs,xfs"
+TST_CNT=3
+
+test1()
+{
+	EXPECT_PASS "cd $TST_MNTPOINT"
+}
+
+test2()
+{
+	EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts"
+}
+
+test3()
+{
+	local fs fs_skip
+
+	fs=$(grep "$TST_MNTPOINT $TST_FS_TYPE" /proc/mounts | cut -d ' ' -f3)
+	EXPECT_PASS "[ '$fs' = '$TST_FS_TYPE' ]"
+
+	for fs_skip in $TST_SKIP_FILESYSTEMS; do
+		EXPECT_FAIL "[ $fs = $fs_skip ]"
+	done
+}
+
+. tst_test.sh
+tst_run
lib/newlib_tests/shell/tst_skip_filesystems_skip.sh new file +17 -0
new file mode 100755
index 000000000..6748d021d
@@ -0,0 +1,17 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
+
+TST_MOUNT_DEVICE=1
+TST_NEEDS_ROOT=1
+TST_FS_TYPE=ext4
+TST_TESTFUNC=test
+TST_SKIP_FILESYSTEMS="ext4"
+
+test()
+{
+	tst_res TFAIL "test should be skipped with TCONF"
+}
+
+. tst_test.sh
+tst_run
lib/tst_supported_fs_types.c +1 -0
index 9726d193a..ce33beb98 100644
@@ -14,6 +14,7 @@
 #include "tst_test.h"
 #include "tst_fs.h"
 
+/* NOTE: new filesystem should be also added to tst_skip_filesystems.sh */
 static const char *const fs_type_whitelist[] = {
 	"ext2",
 	"ext3",
testcases/lib/tst_test.sh +6 -0
index 7c97b69fe..2937bd80c 100644
@@ -626,6 +626,7 @@ tst_run()
 	local _tst_max
 	local _tst_name
 	local _tst_pattern='[='\''"} \t\/:`$\;].*'
+	local ret
 
 	if [ -n "$TST_TEST_PATH" ]; then
 		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do
@@ -644,6 +645,7 @@ tst_run()
 			CHECKPOINT_WAIT|CHECKPOINT_WAKE);;
 			CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);;
 			DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);;
+			SKIP_FILESYSTEMS);;
 			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
 			esac
 		done
@@ -675,6 +677,10 @@ tst_run()
 			tst_brk TCONF "test requires kernel $TST_MIN_KVER+"
 	fi
 
+	tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE
+	ret=$?
+	[ $ret -ne 0 ] && return $ret
+
 	_tst_setup_timer
 
 	[ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#12 lore raw

PATCH v6 5/8 tst_test.sh: Add $TST_ALL_FILESYSTEMS

In reply to Petr Vorel

$TST_ALL_FILESYSTEMS is shell API equivalent of .all_filesystems from C API.

Improve also $TST_SKIP_FILESYSTEMS to behave like .skip_filesystems.

---
 doc/shell-test-api.txt    |   9 ++-
 testcases/lib/tst_test.sh | 136 +++++++++++++++++++++++++-------------
 2 files changed, 98 insertions(+), 47 deletions(-)
doc/shell-test-api.txt +8 -1
index 18ed144a9..73c9eff91 100644
@@ -199,6 +199,10 @@ simply by setting right '$TST_FOO'.
 [options="header"]
 |=============================================================================
 | Variable name            | Action done
+| 'TST_ALL_FILESYSTEMS'    | Testing on all available filesystems
+                             ('tst_test.all_filesystems' equivalent).
+                             When 'TST_SKIP_FILESYSTEMS' any listed filesystem is not
+                             included in the resulting list of supported filesystems.
 | 'TST_DEV_EXTRA_OPTS'     | Pass extra 'mkfs' options _after_ device name,
                              to 'tst_mkfs', use with 'TST_FORMAT_DEVICE=1'.
 | 'TST_DEV_FS_OPTS'        | Pass 'mkfs' options _before_ the device name,
@@ -209,7 +213,10 @@ simply by setting right '$TST_FOO'.
                              Implies 'TST_NEEDS_DEVICE=1' (no need to set it).
 | 'TST_DEVICE'             | Block device name for 'tst_mount' and 'tst_mkfs', see
                              https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#formatting-device-with-a-filesystem[Formatting device with a filesystem].
-| 'TST_FS_TYPE'            | Override the default filesystem to be used.
+| 'TST_FS_TYPE'            | Override the default filesystem to be used. Also
+                             contains currently used filesystem during looping
+                             filesystems in 'TST_ALL_FILESYSTEMS=1'
+                             ('tst_device->fs_type' equivalent).
 | 'TST_MNTPOINT'           | Holds path to mountpoint used in 'tst_mount', see
                              https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#formatting-device-with-a-filesystem[Formatting device with a filesystem].
 | 'TST_MNT_PARAMS'         | Extra mount params for 'tst_mount', see
testcases/lib/tst_test.sh +90 -46

218 lines not on this page · raw message

Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v6 5/8
#13 lore raw

Re: [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS

Hi!

testcases/lib/tst_test.sh tst_run() · line 706

Quoted 2 lines
testcases/lib/tst_test.sh +2 -0
+	if [ "$TST_ALL_FILESYSTEMS" != 1 ]; then
+		if ! tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE > /dev/null; then

Whatever the API ends up I guess that we should check the support and mkfs here as well in order to TCONF early before we create a device and attempt to format/mount it.

Otherwise:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#14 lore raw

Re: [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS

Quoted 7 lines

Hi!

testcases/lib/tst_test.sh tst_run() · line 706

Quoted 2 lines
testcases/lib/tst_test.sh +2 -0
+	if [ "$TST_ALL_FILESYSTEMS" != 1 ]; then
+		if ! tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE > /dev/null; then

Whatever the API ends up I guess that we should check the support and mkfs here as well in order to TCONF early before we create a device and attempt to format/mount it.

I was worried to add mkfs.foo dependency unless there is a requirement for it (i.e. TST_NEEDS_DEVICE=1). Do you really want to add this dependency for *all* tests? (I'd prefer no, i.e. to keep here check only for test not being skipped, because check for mkfs.foo is in tst_mkfs which does the job, thus not only we'd add an extra unneeded dependency but also duplicity in the check).

But if you want it, i.e. if we require mkfs.$TST_FS_TYPE (unless tmpfs of course, which is handled properly) here, then we don't need to separate checks for mkfs.foo and skip list in testcases/lib/tst_supported_fs.c.

Kind regards,
Petr

Quoted 3 lines

Otherwise:

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw

Re: [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS

Hi!

Quoted 8 lines
Quoted 3 lines

Whatever the API ends up I guess that we should check the support and mkfs here as well in order to TCONF early before we create a device and attempt to format/mount it.

I was worried to add mkfs.foo dependency unless there is a requirement for it (i.e. TST_NEEDS_DEVICE=1). Do you really want to add this dependency for *all* tests? (I'd prefer no, i.e. to keep here check only for test not being skipped, because check for mkfs.foo is in tst_mkfs which does the job, thus not only we'd add an extra unneeded dependency but also duplicity in the check).

Isn't this mostly theoretical problem? I mean how common it would be to have test that tests different filesystem but does not need corresponding mkfs?

Quoted 3 lines

But if you want it, i.e. if we require mkfs.$TST_FS_TYPE (unless tmpfs of course, which is handled properly) here, then we don't need to separate checks for mkfs.foo and skip list in testcases/lib/tst_supported_fs.c.

I would go that way for now.

I guess that the cleanest solution would be keeping the funcionality really orthogonal, i.e. separating the kernel and mkfs checks so that we would have -m to enable mkfs check -k to enable kernel check and -s to enable skiplist. But that is something that can and should be done after the relase.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#16 lore raw

Re: [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS

Quoted 10 lines

Hi!

Quoted 8 lines
Quoted 3 lines

Whatever the API ends up I guess that we should check the support and mkfs here as well in order to TCONF early before we create a device and attempt to format/mount it.

I was worried to add mkfs.foo dependency unless there is a requirement for it (i.e. TST_NEEDS_DEVICE=1). Do you really want to add this dependency for *all* tests? (I'd prefer no, i.e. to keep here check only for test not being skipped, because check for mkfs.foo is in tst_mkfs which does the job, thus not only we'd add an extra unneeded dependency but also duplicity in the check).

Quoted 3 lines

Isn't this mostly theoretical problem? I mean how common it would be to have test that tests different filesystem but does not need corresponding mkfs?

Have you noticed !=, i.e.:
if [ "$TST_ALL_FILESYSTEMS" != 1 ]; then
The check here is for single filesystem testing, just with disabled on some filesystems (i.e. skip on tmpfs). Equivalent of fcntl33.c (skips on tmpfs, ramfs - BTW not in fs_type_whitelist, thus not being checked, nfs; but not using .all_filesystems).

That's why I'm not going to add check for kernel support and mkfs.foo (hope I was correct you overlooked !=, or did I miss something?)

For testing on all filesystems (TST_ALL_FILESYSTEMS=1) there is obviously check for kernel and mkfs support in testcases/lib/tst_supported_fs.c.

Quoted 5 lines
Quoted 3 lines

But if you want it, i.e. if we require mkfs.$TST_FS_TYPE (unless tmpfs of course, which is handled properly) here, then we don't need to separate checks for mkfs.foo and skip list in testcases/lib/tst_supported_fs.c.

I would go that way for now.

I dare to merge this approach:

* all filesystems
tst_supported_fs [-s skip_list]
print the list of supported filesystems
if fs_type is supported and not in skip_list (optional), print list of supported filesystems and return 0 if fs_type isn't supported or in skip_list, return 1

* single filesystem
tst_supported_fs fs_type
if fs_type is supported, return 0 otherwise return 1

tst_supported_fs -s skip_list fs_type
if fs_type is in skip_list, return 1 otherwise return 0

Quoted 5 lines

I guess that the cleanest solution would be keeping the funcionality really orthogonal, i.e. separating the kernel and mkfs checks so that we would have -m to enable mkfs check -k to enable kernel check and -s to enable skiplist. But that is something that can and should be done after the relase.

If really needed, sure.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#17 lore raw

PATCH v6 6/8 tst_test.sh: Allow | after whitelisted variable

In reply to Petr Vorel

Variable followed by other variable was not whitelisted:
e.g.:
TST_FS_TYPE|fuseblk
TWARN: Reserved variable TST_FS_TYPE$ used!

---
 testcases/lib/tst_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/tst_test.sh +1 -1
index 55d96f17d..e92e0ce7f 100644
@@ -643,7 +643,7 @@ tst_run()
 	local _tst_fs
 	local _tst_max
 	local _tst_name
-	local _tst_pattern='[='\''"} \t\/:`$\;].*'
+	local _tst_pattern='[='\''"} \t\/:`$\;|].*'
 	local ret
 
 	if [ -n "$TST_TEST_PATH" ]; then
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#19 lore raw

PATCH v6 7/8 shell: Add tests for TST_ALL_FILESYSTEMS=1

In reply to Petr Vorel

Unfortunately GitHub Actions don't have loop devices, thus cannot be run in CI:

tst_format_device 1 TINFO: timeout per run is 0h 5m 0s /__w/ltp/ltp/lib/tst_device.c:139: TINFO: No free devices found

---
 lib/newlib_tests/shell/tst_all_filesystems.sh | 21 +++++++++++++++++++
 .../shell/tst_all_filesystems_skip.sh         | 16 ++++++++++++++
 lib/tst_supported_fs_types.c                  |  2 +-
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh
 create mode 100755 lib/newlib_tests/shell/tst_all_filesystems_skip.sh
lib/newlib_tests/shell/tst_all_filesystems.sh new file +21 -0
new file mode 100755
index 000000000..61284f4f2
@@ -0,0 +1,21 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
+
+TST_ALL_FILESYSTEMS=1
+TST_NEEDS_ROOT=1
+TST_TESTFUNC=test
+TST_CNT=2
+
+test1()
+{
+	tst_res TPASS "device using filesystem"
+}
+
+test2()
+{
+	EXPECT_PASS "grep -E '$TST_MNTPOINT ($TST_FS_TYPE|fuseblk)' /proc/mounts"
+}
+
+. tst_test.sh
+tst_run
lib/newlib_tests/shell/tst_all_filesystems_skip.sh new file +16 -0
new file mode 100755
index 000000000..c2e0ba9ff
@@ -0,0 +1,16 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
+
+TST_ALL_FILESYSTEMS=1
+TST_NEEDS_ROOT=1
+TST_TESTFUNC=test
+TST_SKIP_FILESYSTEMS="btrfs,exfat,ext2,ext3,ext4,fuse,ntfs,vfat,tmpfs,xfs"
+
+test1()
+{
+	tst_res TFAIL "test should be skipped with TCONF"
+}
+
+. tst_test.sh
+tst_run
lib/tst_supported_fs_types.c +1 -1
index ce33beb98..52824cce9 100644
@@ -14,7 +14,7 @@
 #include "tst_test.h"
 #include "tst_fs.h"
 
-/* NOTE: new filesystem should be also added to tst_skip_filesystems.sh */
+/* NOTE: new filesystem should be also added to tst_*skip*.sh */
 static const char *const fs_type_whitelist[] = {
 	"ext2",
 	"ext3",
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#20 lore raw

PATCH v6 8/8 df01.sh: Convert to TST_ALL_FILESYSTEMS=1

In reply to Petr Vorel
---
 runtest/commands              |  8 +-------
 runtest/smoketest             |  2 +-
 testcases/commands/df/df01.sh | 28 +++++-----------------------
 3 files changed, 7 insertions(+), 31 deletions(-)
runtest/commands +1 -7
index 8cfad0449..5ec2c3b69 100644
@@ -14,13 +14,7 @@ ln01_sh ln_tests.sh
 mkdir01_sh mkdir_tests.sh
 mv01_sh mv_tests.sh
 du01_sh du01.sh
-df01_ext2_sh df01.sh -f ext2
-df01_ext3_sh df01.sh -f ext3
-df01_ext4_sh df01.sh -f ext4
-df01_xfs_sh df01.sh -f xfs
-df01_vfat_sh df01.sh -f vfat
-df01_exfat_sh df01.sh -f exfat
-df01_ntfs_sh df01.sh -f ntfs
+df01_sh df01.sh
 mkfs01_sh mkfs01.sh
 mkfs01_ext2_sh mkfs01.sh -f ext2
 mkfs01_ext3_sh mkfs01.sh -f ext3
runtest/smoketest +1 -1
index 485f211fb..83eebfe7b 100644
@@ -12,7 +12,7 @@ stat04 symlink01 -T stat04
 utime01A symlink01 -T utime01
 rename01A symlink01 -T rename01
 splice02 splice02 -s 20
-df01_ext4_sh df01.sh -f ext4
+df01_sh df01.sh
 shell_test01 echo "SUCCESS" | shell_pipe01.sh
 ping602 ping02.sh -6
 macsec02 macsec02.sh
testcases/commands/df/df01.sh +5 -23
index 1e86d1c40..9527da214 100755
@@ -6,35 +6,15 @@
 #
 # Test df command with some basic options.
 
+TST_ALL_FILESYSTEMS=1
 TST_CNT=12
 TST_SETUP=setup
 TST_TESTFUNC=test
-TST_OPTS="f:"
-TST_USAGE=usage
-TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
-TST_MOUNT_DEVICE=1
-
-usage()
-{
-	cat << EOF
-usage: $0 [-f <ext2|ext3|ext4|vfat|...>]
-
-OPTIONS
--f	Specify the type of filesystem to be built.  If not
-	specified, the default filesystem type (currently ext2)
-	is used.
-EOF
-}
-
-parse_args()
-{
-	TST_FS_TYPE="$2"
-}
 
 setup()
 {
-	DF_FS_TYPE=$(mount | grep "$TST_DEVICE" | awk 'NR==1{print $5}')
+	DF_FS_TYPE="$(grep -E "$TST_MNTPOINT ($TST_FS_TYPE|fuseblk)" /proc/mounts | awk 'NR==1{print $3}')"
 }
 
 df_test()
@@ -180,7 +160,9 @@ test11()
 
 test12()
 {
-	local cmd="df -x $DF_FS_TYPE -P"
+	local fs="$DF_FS_TYPE"
+
+	local cmd="df -x $fs -P"
 
 	df_verify $cmd
 	if [ $? -ne 0 ]; then
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#21 lore raw

Re: [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1

Hi!

testcases/commands/df/df01.sh line 16

Quoted 9 lines
testcases/commands/df/df01.sh +1 -4
+TST_ALL_FILESYSTEMS=1
 TST_CNT=12
 TST_SETUP=setup
 TST_TESTFUNC=test
-TST_OPTS="f:"
-TST_USAGE=usage
-TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
-TST_MOUNT_DEVICE=1

Just looking at this made me realize that for C API ALL_FILESYTEMST does not imply TST_MOUNT_DEVICE since these functionalities are orthogonal. I think that it would be better if we had the C API and shell API as close as possible, hence ALL_FILESYSTEMS should imply only NEEDS_DEVICE and the MOUNT_DEVICE would stay here.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by
#22 lore raw

Re: [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1

Hi!

Quoted 7 lines
Quoted 7 lines
testcases/commands/df/df01.sh +1 -3
+TST_ALL_FILESYSTEMS=1
 TST_CNT=12
 TST_SETUP=setup
 TST_TESTFUNC=test
-TST_OPTS="f:"
-TST_USAGE=usage
-TST_PARSE_ARGS=parse_args
Quoted 8 lines
Quoted 2 lines

TST_NEEDS_ROOT=1
-TST_MOUNT_DEVICE=1

Just looking at this made me realize that for C API ALL_FILESYTEMST does not imply TST_MOUNT_DEVICE since these functionalities are orthogonal. I think that it would be better if we had the C API and shell API as close as possible, hence ALL_FILESYSTEMS should imply only NEEDS_DEVICE and the MOUNT_DEVICE would stay here.

Also with that change:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#23 lore raw

Re: [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1

Quoted 16 lines

Hi!

Quoted 15 lines

testcases/commands/df/df01.sh line 16

Quoted 9 lines
testcases/commands/df/df01.sh +1 -4
+TST_ALL_FILESYSTEMS=1
 TST_CNT=12
 TST_SETUP=setup
 TST_TESTFUNC=test
-TST_OPTS="f:"
-TST_USAGE=usage
-TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
-TST_MOUNT_DEVICE=1

Just looking at this made me realize that for C API ALL_FILESYTEMST does not imply TST_MOUNT_DEVICE since these functionalities are orthogonal. I think that it would be better if we had the C API and shell API as close as possible, hence ALL_FILESYSTEMS should imply only NEEDS_DEVICE and the MOUNT_DEVICE would stay here.

Good point, thanks! Another reason is that With ALL_FILESYSTEMS implying TST_MOUNT_DEVICE mkfs01.sh could not use ALL_FILESYSTEMS=1.

Kind regards,
Petr

Quoted 3 lines

Also with that change:

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#24 lore raw

Re: [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1

In reply to Cyril Hrubis
Quoted 16 lines

Hi!

testcases/commands/df/df01.sh line 16

Quoted 9 lines
testcases/commands/df/df01.sh +1 -4
+TST_ALL_FILESYSTEMS=1
 TST_CNT=12
 TST_SETUP=setup
 TST_TESTFUNC=test
-TST_OPTS="f:"
-TST_USAGE=usage
-TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
-TST_MOUNT_DEVICE=1

Just looking at this made me realize that for C API ALL_FILESYTEMST does not imply TST_MOUNT_DEVICE since these functionalities are orthogonal. I think that it would be better if we had the C API and shell API as close as possible, hence ALL_FILESYSTEMS should imply only NEEDS_DEVICE and the MOUNT_DEVICE would stay here.

OK, I'll keep MOUNT_DEVICE=1 here and we can change it later for both.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#25 lore raw
In reply to Petr Vorel

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

newlib_tests/shell/tst_all_filesystems.sh +1 -0
index 61284f4f2..7561579ff 100755
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <[email protected]>
 
 TST_ALL_FILESYSTEMS=1
+TST_MOUNT_DEVICE=1
 TST_NEEDS_ROOT=1
 TST_TESTFUNC=test
 TST_CNT=2
newlib_tests/shell/tst_all_filesystems_skip.sh +1 -0
index c2e0ba9ff..9516f38d9 100755
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <[email protected]>
 
 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"
tst_supported_fs_types.c +4 -1
index 52824cce9..7781f94c3 100644
@@ -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",
commands/df/df01.sh +1 -0
index 9527da214..ae0449c3c 100755
@@ -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
lib/tst_supported_fs.c +35 -9

67 lines not on this page · raw message

lib/tst_test.sh +2 -3
index 5b2abb282..229317713 100644
@@ -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
 
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp