All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS
@ 2022-09-15  9:36 Petr Vorel
  2022-09-15  9:36 ` [LTP] [PATCH v6 1/8] tst_supported_fs: Implement skip list Petr Vorel
                   ` (8 more replies)
  0 siblings, 9 replies; 26+ messages in thread
From: Petr Vorel @ 2022-09-15  9:36 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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/70df29e7-0097-c698-b6ba-e3f87da3893f@suse.cz/
[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

-- 
2.37.3


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

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

* [LTP] [PATCH v6 1/8] tst_supported_fs: Implement skip list
  2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
@ 2022-09-15  9:36 ` Petr Vorel
  2022-09-15  9:36 ` [LTP] [PATCH v6 2/8] zram01.sh: Use tst_supported_fs -s tmpfs Petr Vorel
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 26+ messages in thread
From: Petr Vorel @ 2022-09-15  9:36 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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.

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
Reviewed-by: Li Wang <liwang@redhat.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 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(-)

diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
index 43eac194f..2b42d5bb3 100644
--- a/testcases/lib/tst_supported_fs.c
+++ b/testcases/lib/tst_supported_fs.c
@@ -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]);
 
diff --git a/testcases/misc/lvm/generate_lvm_runfile.sh b/testcases/misc/lvm/generate_lvm_runfile.sh
index 477aed116..7f7e149d9 100755
--- a/testcases/misc/lvm/generate_lvm_runfile.sh
+++ b/testcases/misc/lvm/generate_lvm_runfile.sh
@@ -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
diff --git a/testcases/misc/lvm/prepare_lvm.sh b/testcases/misc/lvm/prepare_lvm.sh
index d3ae4b23f..29f386df8 100755
--- a/testcases/misc/lvm/prepare_lvm.sh
+++ b/testcases/misc/lvm/prepare_lvm.sh
@@ -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"
-- 
2.37.3


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

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

* [LTP] [PATCH v6 2/8] zram01.sh: Use tst_supported_fs -s tmpfs
  2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
  2022-09-15  9:36 ` [LTP] [PATCH v6 1/8] tst_supported_fs: Implement skip list Petr Vorel
@ 2022-09-15  9:36 ` Petr Vorel
  2022-09-16 11:33   ` Cyril Hrubis
  2022-09-15  9:36 ` [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs Petr Vorel
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2022-09-15  9:36 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/device-drivers/zram/zram01.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh
index ad01291bf..8b92b699f 100755
--- a/testcases/kernel/device-drivers/zram/zram01.sh
+++ b/testcases/kernel/device-drivers/zram/zram01.sh
@@ -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
-- 
2.37.3


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

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

* [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs
  2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
  2022-09-15  9:36 ` [LTP] [PATCH v6 1/8] tst_supported_fs: Implement skip list Petr Vorel
  2022-09-15  9:36 ` [LTP] [PATCH v6 2/8] zram01.sh: Use tst_supported_fs -s tmpfs Petr Vorel
@ 2022-09-15  9:36 ` Petr Vorel
  2022-09-16 11:45   ` Cyril Hrubis
  2022-09-15  9:36 ` [LTP] [PATCH v6 4/8] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2022-09-15  9:36 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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).

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_supported_fs.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
index 2b42d5bb3..e2261244d 100644
--- a/testcases/lib/tst_supported_fs.c
+++ b/testcases/lib/tst_supported_fs.c
@@ -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]);
-- 
2.37.3


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

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

* [LTP] [PATCH v6 4/8] shell: Add $TST_SKIP_FILESYSTEMS + tests
  2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (2 preceding siblings ...)
  2022-09-15  9:36 ` [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs Petr Vorel
@ 2022-09-15  9:36 ` Petr Vorel
  2022-09-16 11:50   ` Cyril Hrubis
  2022-09-15  9:36 ` [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2022-09-15  9:36 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

C API struct tst_test skip_filesystems member equivalent.

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

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 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

diff --git a/doc/shell-test-api.txt b/doc/shell-test-api.txt
index 65444541e..18ed144a9 100644
--- a/doc/shell-test-api.txt
+++ b/doc/shell-test-api.txt
@@ -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.
diff --git a/lib/newlib_tests/shell/tst_skip_filesystems.sh b/lib/newlib_tests/shell/tst_skip_filesystems.sh
new file mode 100755
index 000000000..675d0ee5f
--- /dev/null
+++ b/lib/newlib_tests/shell/tst_skip_filesystems.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+
+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
diff --git a/lib/newlib_tests/shell/tst_skip_filesystems_skip.sh b/lib/newlib_tests/shell/tst_skip_filesystems_skip.sh
new file mode 100755
index 000000000..6748d021d
--- /dev/null
+++ b/lib/newlib_tests/shell/tst_skip_filesystems_skip.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+
+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
diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c
index 9726d193a..ce33beb98 100644
--- a/lib/tst_supported_fs_types.c
+++ b/lib/tst_supported_fs_types.c
@@ -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",
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 7c97b69fe..2937bd80c 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -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
-- 
2.37.3


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

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

* [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (3 preceding siblings ...)
  2022-09-15  9:36 ` [LTP] [PATCH v6 4/8] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
@ 2022-09-15  9:36 ` Petr Vorel
  2022-09-16 12:45   ` Cyril Hrubis
  2022-09-15  9:36 ` [LTP] [PATCH v6 6/8] tst_test.sh: Allow | after whitelisted variable Petr Vorel
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2022-09-15  9:36 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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

Improve also $TST_SKIP_FILESYSTEMS to behave like .skip_filesystems.

Reviewed-by: Li Wang <liwang@redhat.com>
Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 doc/shell-test-api.txt    |   9 ++-
 testcases/lib/tst_test.sh | 136 +++++++++++++++++++++++++-------------
 2 files changed, 98 insertions(+), 47 deletions(-)

diff --git a/doc/shell-test-api.txt b/doc/shell-test-api.txt
index 18ed144a9..73c9eff91 100644
--- a/doc/shell-test-api.txt
+++ b/doc/shell-test-api.txt
@@ -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
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 2937bd80c..55d96f17d 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -17,10 +17,6 @@ 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
 
@@ -33,17 +29,7 @@ _tst_do_exit()
 	local ret=0
 	TST_DO_EXIT=1
 
-	if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
-		if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then
-			$TST_CLEANUP
-		else
-			tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)"
-		fi
-	fi
-
-	if [ "$TST_MOUNT_FLAG" = 1 ]; then
-		tst_umount
-	fi
+	[ "$TST_MOUNT_FLAG" = 1 ] && tst_umount
 
 	if [ "$TST_NEEDS_DEVICE" = 1 -a "$TST_DEVICE_FLAG" = 1 ]; then
 		if ! tst_device release "$TST_DEVICE"; then
@@ -287,7 +273,7 @@ TST_CHECKPOINT_WAKE_AND_WAIT()
 
 tst_mount()
 {
-	local mnt_opt mnt_err
+	local mnt_opt mnt_err mnt_real
 
 	if [ -n "$TST_FS_TYPE" ]; then
 		mnt_opt="-t $TST_FS_TYPE"
@@ -478,6 +464,7 @@ LTPROOT              Prefix for installed LTP (default: /opt/ltp)
 LTP_COLORIZE_OUTPUT  Force colorized output behaviour (y/1 always, n/0: never)
 LTP_DEV              Path to the block device to be used (for .needs_device)
 LTP_DEV_FS_TYPE      Filesystem used for testing (default: ext2)
+LTP_SINGLE_FS_TYPE   Testing only - specifies filesystem instead all supported (for TST_ALL_FILESYSTEMS=1)
 LTP_TIMEOUT_MUL      Timeout multiplier (must be a number >=1, ceiled to int)
 TMPDIR               Base directory for template directory (for .needs_tmpdir, default: /tmp)
 EOF
@@ -619,10 +606,41 @@ _tst_init_checkpoints()
 	export LTP_IPC_PATH
 }
 
+_prepare_device()
+{
+	if [ "$TST_FORMAT_DEVICE" = 1 ]; then
+		tst_device clear "$TST_DEVICE"
+		tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS
+	fi
+
+	if [ "$TST_MOUNT_DEVICE" = 1 ]; then
+		tst_mount
+		TST_MOUNT_FLAG=1
+	fi
+}
+
+_tst_run_tcases_per_fs()
+{
+	local fs
+	local filesystems
+
+	filesystems="$(tst_supported_fs -s "$TST_SKIP_FILESYSTEMS")"
+	if [ $? -ne 0 ]; then
+		tst_brk TCONF "There are no supported filesystems or all skipped"
+	fi
+
+	for fs in $filesystems; do
+		tst_res TINFO "=== Testing on $fs ==="
+		TST_FS_TYPE="$fs"
+		_tst_run_iterations
+	done
+}
+
 tst_run()
 {
 	local _tst_i
 	local _tst_data
+	local _tst_fs
 	local _tst_max
 	local _tst_name
 	local _tst_pattern='[='\''"} \t\/:`$\;].*'
@@ -631,7 +649,7 @@ tst_run()
 	if [ -n "$TST_TEST_PATH" ]; then
 		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do
 			case "$_tst_i" in
-			DISABLE_APPARMOR|DISABLE_SELINUX);;
+			ALL_FILESYSTEMS|DISABLE_APPARMOR|DISABLE_SELINUX);;
 			SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
 			OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
 			NEEDS_ROOT|NEEDS_TMPDIR|TMPDIR|NEEDS_DEVICE|DEVICE);;
@@ -677,16 +695,33 @@ 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
+	[ -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_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"
+		fi
+	fi
+
+	if [ "$TST_NEEDS_DEVICE" = 1 ]; then
+		TST_DEVICE=$(tst_device acquire)
+
+		if [ ! -b "$TST_DEVICE" -o $? -ne 0 ]; then
+			unset TST_DEVICE
+			tst_brk TBROK "Failed to acquire device"
+		fi
+		TST_DEVICE_FLAG=1
+
+		if [ -z "$TST_FS_TYPE" ]; then
+			export TST_FS_TYPE="${LTP_DEV_FS_TYPE:-ext2}"
+		fi
+	fi
+
 	if [ "$TST_NEEDS_TMPDIR" = 1 ]; then
 		if [ -z "$TMPDIR" ]; then
 			export TMPDIR="/tmp"
@@ -697,35 +732,32 @@ tst_run()
 		chmod 777 "$TST_TMPDIR"
 
 		TST_STARTWD=$(pwd)
-
 		cd "$TST_TMPDIR"
 	fi
 
-	TST_MNTPOINT="${TST_MNTPOINT:-$PWD/mntpoint}"
-	if [ "$TST_NEEDS_DEVICE" = 1 ]; then
-
-		TST_DEVICE=$(tst_device acquire)
+	[ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints
 
-		if [ ! -b "$TST_DEVICE" -o $? -ne 0 ]; then
-			unset TST_DEVICE
-			tst_brk TBROK "Failed to acquire device"
-		fi
+	TST_MNTPOINT="${TST_MNTPOINT:-$PWD/mntpoint}"
 
-		TST_DEVICE_FLAG=1
+	if [ "$TST_ALL_FILESYSTEMS" = 1 ]; then
+		_tst_run_tcases_per_fs
+	else
+		_tst_run_iterations
 	fi
 
-	[ -n "$TST_NEEDS_MODULE" ] && tst_require_module "$TST_NEEDS_MODULE"
+	_tst_do_exit
+}
 
-	if [ "$TST_FORMAT_DEVICE" = 1 ]; then
-		tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS
-	fi
+_tst_run_iterations()
+{
+	local _tst_i=$TST_ITERATIONS
+	local _tst_j
 
-	if [ "$TST_MOUNT_DEVICE" = 1 ]; then
-		tst_mount
-		TST_MOUNT_FLAG=1
-	fi
+	[ "$TST_NEEDS_TMPDIR" = 1 ] && cd "$TST_TMPDIR"
 
-	[ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints
+	_prepare_device
+
+	_tst_setup_timer
 
 	if [ -n "$TST_SETUP" ]; then
 		if command -v $TST_SETUP >/dev/null 2>/dev/null; then
@@ -737,20 +769,32 @@ tst_run()
 	fi
 
 	#TODO check that test reports some results for each test function call
-	while [ $TST_ITERATIONS -gt 0 ]; do
+	while [ $_tst_i -gt 0 ]; do
 		if [ -n "$TST_TEST_DATA" ]; then
 			tst_require_cmds cut tr wc
 			_tst_max=$(( $(echo $TST_TEST_DATA | tr -cd "$TST_TEST_DATA_IFS" | wc -c) +1))
-			for _tst_i in $(seq $_tst_max); do
-				_tst_data="$(echo "$TST_TEST_DATA" | cut -d"$TST_TEST_DATA_IFS" -f$_tst_i)"
+			for _tst_j in $(seq $_tst_max); do
+				_tst_data="$(echo "$TST_TEST_DATA" | cut -d"$TST_TEST_DATA_IFS" -f$_tst_j)"
 				_tst_run_tests "$_tst_data"
 			done
 		else
 			_tst_run_tests
 		fi
-		TST_ITERATIONS=$((TST_ITERATIONS-1))
+		_tst_i=$((_tst_i-1))
 	done
-	_tst_do_exit
+
+	if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
+		if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then
+			$TST_CLEANUP
+		else
+			tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)"
+		fi
+	fi
+
+	if [ "$TST_MOUNT_FLAG" = 1 ]; then
+		tst_umount
+		TST_MOUNT_FLAG=
+	fi
 }
 
 _tst_run_tests()
-- 
2.37.3


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

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

* [LTP] [PATCH v6 6/8] tst_test.sh: Allow | after whitelisted variable
  2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (4 preceding siblings ...)
  2022-09-15  9:36 ` [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
@ 2022-09-15  9:36 ` Petr Vorel
  2022-09-16 13:02   ` Cyril Hrubis
  2022-09-15  9:36 ` [LTP] [PATCH v6 7/8] shell: Add tests for TST_ALL_FILESYSTEMS=1 Petr Vorel
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2022-09-15  9:36 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 55d96f17d..e92e0ce7f 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -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
-- 
2.37.3


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

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

* [LTP] [PATCH v6 7/8] shell: Add tests for TST_ALL_FILESYSTEMS=1
  2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (5 preceding siblings ...)
  2022-09-15  9:36 ` [LTP] [PATCH v6 6/8] tst_test.sh: Allow | after whitelisted variable Petr Vorel
@ 2022-09-15  9:36 ` Petr Vorel
  2022-09-15  9:36 ` [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 Petr Vorel
  2022-09-16 21:22 ` [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
  8 siblings, 0 replies; 26+ messages in thread
From: Petr Vorel @ 2022-09-15  9:36 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Li Wang <liwang@redhat.com>
Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 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

diff --git a/lib/newlib_tests/shell/tst_all_filesystems.sh b/lib/newlib_tests/shell/tst_all_filesystems.sh
new file mode 100755
index 000000000..61284f4f2
--- /dev/null
+++ b/lib/newlib_tests/shell/tst_all_filesystems.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+
+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
diff --git a/lib/newlib_tests/shell/tst_all_filesystems_skip.sh b/lib/newlib_tests/shell/tst_all_filesystems_skip.sh
new file mode 100755
index 000000000..c2e0ba9ff
--- /dev/null
+++ b/lib/newlib_tests/shell/tst_all_filesystems_skip.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+
+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
diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c
index ce33beb98..52824cce9 100644
--- a/lib/tst_supported_fs_types.c
+++ b/lib/tst_supported_fs_types.c
@@ -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",
-- 
2.37.3


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

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

* [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1
  2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (6 preceding siblings ...)
  2022-09-15  9:36 ` [LTP] [PATCH v6 7/8] shell: Add tests for TST_ALL_FILESYSTEMS=1 Petr Vorel
@ 2022-09-15  9:36 ` Petr Vorel
  2022-09-16 13:10   ` Cyril Hrubis
  2022-09-16 21:22 ` [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
  8 siblings, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2022-09-15  9:36 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 runtest/commands              |  8 +-------
 runtest/smoketest             |  2 +-
 testcases/commands/df/df01.sh | 28 +++++-----------------------
 3 files changed, 7 insertions(+), 31 deletions(-)

diff --git a/runtest/commands b/runtest/commands
index 8cfad0449..5ec2c3b69 100644
--- a/runtest/commands
+++ b/runtest/commands
@@ -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
diff --git a/runtest/smoketest b/runtest/smoketest
index 485f211fb..83eebfe7b 100644
--- a/runtest/smoketest
+++ b/runtest/smoketest
@@ -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
diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index 1e86d1c40..9527da214 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -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
-- 
2.37.3


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

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

* Re: [LTP] [PATCH v6 2/8] zram01.sh: Use tst_supported_fs -s tmpfs
  2022-09-15  9:36 ` [LTP] [PATCH v6 2/8] zram01.sh: Use tst_supported_fs -s tmpfs Petr Vorel
@ 2022-09-16 11:33   ` Cyril Hrubis
  0 siblings, 0 replies; 26+ messages in thread
From: Cyril Hrubis @ 2022-09-16 11:33 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs
  2022-09-15  9:36 ` [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs Petr Vorel
@ 2022-09-16 11:45   ` Cyril Hrubis
  2022-09-16 12:09     ` Petr Vorel
  2022-09-16 12:10     ` Petr Vorel
  0 siblings, 2 replies; 26+ messages in thread
From: Cyril Hrubis @ 2022-09-16 11:45 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> And use this feature in zram01.sh.

This looks like an leftover.

> Also print TINFO if test it supported by the test, quit with TCONF
> otherwise (code from do_test_setup() tst_test.c).
> 
> Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
> Reviewed-by: Li Wang <liwang@redhat.com>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/lib/tst_supported_fs.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
> index 2b42d5bb3..e2261244d 100644
> --- a/testcases/lib/tst_supported_fs.c
> +++ b/testcases/lib/tst_supported_fs.c
> @@ -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;
> +	}

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?

>  	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]);
> -- 
> 2.37.3
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 4/8] shell: Add $TST_SKIP_FILESYSTEMS + tests
  2022-09-15  9:36 ` [LTP] [PATCH v6 4/8] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
@ 2022-09-16 11:50   ` Cyril Hrubis
  0 siblings, 0 replies; 26+ messages in thread
From: Cyril Hrubis @ 2022-09-16 11:50 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs
  2022-09-16 11:45   ` Cyril Hrubis
@ 2022-09-16 12:09     ` Petr Vorel
  2022-09-16 12:28       ` Cyril Hrubis
  2022-09-16 12:10     ` Petr Vorel
  1 sibling, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2022-09-16 12:09 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > And use this feature in zram01.sh.

> This looks like an leftover.

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

> > Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
> > Reviewed-by: Li Wang <liwang@redhat.com>
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> >  testcases/lib/tst_supported_fs.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)

> > diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
> > index 2b42d5bb3..e2261244d 100644
> > --- a/testcases/lib/tst_supported_fs.c
> > +++ b/testcases/lib/tst_supported_fs.c
> > @@ -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;
> > +	}

> 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

> 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


> >  	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]);
> > -- 
> > 2.37.3

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

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

* Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs
  2022-09-16 11:45   ` Cyril Hrubis
  2022-09-16 12:09     ` Petr Vorel
@ 2022-09-16 12:10     ` Petr Vorel
  1 sibling, 0 replies; 26+ messages in thread
From: Petr Vorel @ 2022-09-16 12:10 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > And use this feature in zram01.sh.

> This looks like an leftover.
Thanks!

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs
  2022-09-16 12:09     ` Petr Vorel
@ 2022-09-16 12:28       ` Cyril Hrubis
  2022-09-16 12:39         ` Petr Vorel
  0 siblings, 1 reply; 26+ messages in thread
From: Cyril Hrubis @ 2022-09-16 12:28 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> 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?

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.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs
  2022-09-16 12:28       ` Cyril Hrubis
@ 2022-09-16 12:39         ` Petr Vorel
  0 siblings, 0 replies; 26+ messages in thread
From: Petr Vorel @ 2022-09-16 12:39 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > 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?

> 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.

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

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

* Re: [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-09-15  9:36 ` [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
@ 2022-09-16 12:45   ` Cyril Hrubis
  2022-09-16 13:09     ` Petr Vorel
  0 siblings, 1 reply; 26+ messages in thread
From: Cyril Hrubis @ 2022-09-16 12:45 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> +	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:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 6/8] tst_test.sh: Allow | after whitelisted variable
  2022-09-15  9:36 ` [LTP] [PATCH v6 6/8] tst_test.sh: Allow | after whitelisted variable Petr Vorel
@ 2022-09-16 13:02   ` Cyril Hrubis
  0 siblings, 0 replies; 26+ messages in thread
From: Cyril Hrubis @ 2022-09-16 13:02 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-09-16 12:45   ` Cyril Hrubis
@ 2022-09-16 13:09     ` Petr Vorel
  2022-09-16 13:17       ` Cyril Hrubis
  0 siblings, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2022-09-16 13:09 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > +	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

> Otherwise:

> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

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

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

* Re: [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1
  2022-09-15  9:36 ` [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 Petr Vorel
@ 2022-09-16 13:10   ` Cyril Hrubis
  2022-09-16 13:11     ` Cyril Hrubis
  2022-09-16 13:12     ` Petr Vorel
  0 siblings, 2 replies; 26+ messages in thread
From: Cyril Hrubis @ 2022-09-16 13:10 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> +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.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1
  2022-09-16 13:10   ` Cyril Hrubis
@ 2022-09-16 13:11     ` Cyril Hrubis
  2022-09-16 20:39       ` Petr Vorel
  2022-09-16 13:12     ` Petr Vorel
  1 sibling, 1 reply; 26+ messages in thread
From: Cyril Hrubis @ 2022-09-16 13:11 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > +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.

Also with that change:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1
  2022-09-16 13:10   ` Cyril Hrubis
  2022-09-16 13:11     ` Cyril Hrubis
@ 2022-09-16 13:12     ` Petr Vorel
  1 sibling, 0 replies; 26+ messages in thread
From: Petr Vorel @ 2022-09-16 13:12 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > +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

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

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

* Re: [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-09-16 13:09     ` Petr Vorel
@ 2022-09-16 13:17       ` Cyril Hrubis
  2022-09-16 20:27         ` Petr Vorel
  0 siblings, 1 reply; 26+ messages in thread
From: Cyril Hrubis @ 2022-09-16 13:17 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > 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?

> 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.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-09-16 13:17       ` Cyril Hrubis
@ 2022-09-16 20:27         ` Petr Vorel
  0 siblings, 0 replies; 26+ messages in thread
From: Petr Vorel @ 2022-09-16 20:27 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > > 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?

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.

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


> 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

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

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

* Re: [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1
  2022-09-16 13:11     ` Cyril Hrubis
@ 2022-09-16 20:39       ` Petr Vorel
  0 siblings, 0 replies; 26+ messages in thread
From: Petr Vorel @ 2022-09-16 20:39 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > > +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

> Also with that change:

> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

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

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

* Re: [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS
  2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (7 preceding siblings ...)
  2022-09-15  9:36 ` [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 Petr Vorel
@ 2022-09-16 21:22 ` Petr Vorel
  8 siblings, 0 replies; 26+ messages in thread
From: Petr Vorel @ 2022-09-16 21:22 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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
 

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

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

end of thread, other threads:[~2022-09-16 21:22 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15  9:36 [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel
2022-09-15  9:36 ` [LTP] [PATCH v6 1/8] tst_supported_fs: Implement skip list Petr Vorel
2022-09-15  9:36 ` [LTP] [PATCH v6 2/8] zram01.sh: Use tst_supported_fs -s tmpfs Petr Vorel
2022-09-16 11:33   ` Cyril Hrubis
2022-09-15  9:36 ` [LTP] [PATCH v6 3/8] tst_supported_fs: Support skip list when query single fs Petr Vorel
2022-09-16 11:45   ` Cyril Hrubis
2022-09-16 12:09     ` Petr Vorel
2022-09-16 12:28       ` Cyril Hrubis
2022-09-16 12:39         ` Petr Vorel
2022-09-16 12:10     ` Petr Vorel
2022-09-15  9:36 ` [LTP] [PATCH v6 4/8] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
2022-09-16 11:50   ` Cyril Hrubis
2022-09-15  9:36 ` [LTP] [PATCH v6 5/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
2022-09-16 12:45   ` Cyril Hrubis
2022-09-16 13:09     ` Petr Vorel
2022-09-16 13:17       ` Cyril Hrubis
2022-09-16 20:27         ` Petr Vorel
2022-09-15  9:36 ` [LTP] [PATCH v6 6/8] tst_test.sh: Allow | after whitelisted variable Petr Vorel
2022-09-16 13:02   ` Cyril Hrubis
2022-09-15  9:36 ` [LTP] [PATCH v6 7/8] shell: Add tests for TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-09-15  9:36 ` [LTP] [PATCH v6 8/8] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-09-16 13:10   ` Cyril Hrubis
2022-09-16 13:11     ` Cyril Hrubis
2022-09-16 20:39       ` Petr Vorel
2022-09-16 13:12     ` Petr Vorel
2022-09-16 21:22 ` [LTP] [PATCH v6 0/8] shell: df01.sh: $TST_ALL_FILESYSTEMS Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.