ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
* [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems)
@ 2022-09-02 13:37 Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 1/9] shell: Print mount command in tst_mount() Petr Vorel
                   ` (9 more replies)
  0 siblings, 10 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Hi,

Note, I'm not sure if changes in commit "tst_supported_fs: Implement
skip list" in tst_supported_fs.c will not be heavily rewritten due
tracking minimal filesystem usage. But if the commit looks ok, it'd be
nice to get this merged first.

Kind regards,
Petr

change v3->v4:
* dropped NFS tests change for now (plan to get to this soon, as that
  is the motivation for whole work)
* convert df01.sh (to at least something is using it)
* new variable $TST_FS_TYPE_FUSE
* rebased (some commits were merged)

new commits
worth to review
* df01.sh: Convert to TST_ALL_FILESYSTEMS=1
* tst_test.sh: Introduce TST_FS_TYPE_FUSE
some minor cleanup
* shell: Print mount command in tst_mount()
* shell API/tests: Require root for TST_{FORMAT,MOUNT}_DEVICE

Petr Vorel (9):
  shell: Print mount command in tst_mount()
  shell API/tests: Require root for TST_{FORMAT,MOUNT}_DEVICE
  tst_supported_fs: Implement skip list
  tst_supported_fs: Support skip list when query single fs
  shell: Add $TST_SKIP_FILESYSTEMS + tests
  tst_test.sh: Introduce TST_FS_TYPE_FUSE
  tst_test.sh: Add $TST_ALL_FILESYSTEMS
  shell: Add test for TST_ALL_FILESYSTEMS=1
  df01.sh: Convert to TST_ALL_FILESYSTEMS=1

 doc/shell-test-api.txt                        |  13 +-
 include/tst_fs.h                              |  10 ++
 lib/newlib_tests/shell/tst_all_filesystems.sh |  27 ++++
 lib/newlib_tests/shell/tst_format_device.sh   |   1 +
 lib/newlib_tests/shell/tst_mount_device.sh    |   1 +
 .../shell/tst_mount_device_tmpfs.sh           |   1 +
 .../shell/tst_skip_filesystems.sh             |  35 +++++
 .../shell/tst_skip_filesystems_skip.sh        |  17 ++
 lib/tst_supported_fs_types.c                  |  18 +++
 runtest/commands                              |   8 +-
 runtest/smoketest                             |   2 +-
 testcases/commands/df/df01.sh                 |  32 ++--
 testcases/lib/tst_supported_fs.c              |  56 +++++--
 testcases/lib/tst_test.sh                     | 147 ++++++++++++------
 testcases/misc/lvm/generate_lvm_runfile.sh    |   2 +-
 testcases/misc/lvm/prepare_lvm.sh             |   2 +-
 16 files changed, 282 insertions(+), 90 deletions(-)
 create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.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.2


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

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

* [LTP] [PATCH v4 1/9] shell: Print mount command in tst_mount()
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
@ 2022-09-02 13:37 ` Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 2/9] shell API/tests: Require root for TST_{FORMAT, MOUNT}_DEVICE Petr Vorel
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index f884a278d..7c97b69fe 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -293,9 +293,11 @@ tst_mount()
 		mnt_opt="-t $TST_FS_TYPE"
 		mnt_err=" $TST_FS_TYPE type"
 	fi
+	local cmd="mount $mnt_opt $TST_DEVICE $TST_MNTPOINT $TST_MNT_PARAMS"
 
 	ROD_SILENT mkdir -p $TST_MNTPOINT
-	mount $mnt_opt $TST_DEVICE $TST_MNTPOINT $TST_MNT_PARAMS
+	tst_res TINFO "Mounting device: $cmd"
+	$cmd
 	local ret=$?
 
 	if [ $ret -eq 32 ]; then
-- 
2.37.2


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

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

* [LTP] [PATCH v4 2/9] shell API/tests: Require root for TST_{FORMAT, MOUNT}_DEVICE
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 1/9] shell: Print mount command in tst_mount() Petr Vorel
@ 2022-09-02 13:37 ` Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list Petr Vorel
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Although the warning is quite obvious:
tst_device.c:101: TINFO: Not allowed to open /dev/loop-control. Are you root?: EACCES (13)
tst_device.c:140: TINFO: No free devices found
TBROK: Failed to acquire device

it's safer to expect root to get valid result.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/newlib_tests/shell/tst_format_device.sh      | 1 +
 lib/newlib_tests/shell/tst_mount_device.sh       | 1 +
 lib/newlib_tests/shell/tst_mount_device_tmpfs.sh | 1 +
 3 files changed, 3 insertions(+)

diff --git a/lib/newlib_tests/shell/tst_format_device.sh b/lib/newlib_tests/shell/tst_format_device.sh
index 73a919086..dbe4ea9e7 100755
--- a/lib/newlib_tests/shell/tst_format_device.sh
+++ b/lib/newlib_tests/shell/tst_format_device.sh
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
 
 TST_FORMAT_DEVICE=1
+TST_NEEDS_ROOT=1
 TST_TESTFUNC=test
 TST_CNT=2
 TST_DEV_FS_OPTS="-b 1024"
diff --git a/lib/newlib_tests/shell/tst_mount_device.sh b/lib/newlib_tests/shell/tst_mount_device.sh
index 561f878d2..70f80f84a 100755
--- a/lib/newlib_tests/shell/tst_mount_device.sh
+++ b/lib/newlib_tests/shell/tst_mount_device.sh
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
 
 TST_MOUNT_DEVICE=1
+TST_NEEDS_ROOT=1
 TST_FS_TYPE=ext4
 TST_TESTFUNC=test
 TST_CNT=3
diff --git a/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh b/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh
index 36a78bc85..ed2ba8c50 100755
--- a/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh
+++ b/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
 
 TST_MOUNT_DEVICE=1
+TST_NEEDS_ROOT=1
 TST_FS_TYPE=tmpfs
 TST_TESTFUNC=test
 
-- 
2.37.2


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

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

* [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 1/9] shell: Print mount command in tst_mount() Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 2/9] shell API/tests: Require root for TST_{FORMAT, MOUNT}_DEVICE Petr Vorel
@ 2022-09-02 13:37 ` Petr Vorel
  2022-09-09  9:40   ` Cyril Hrubis
  2022-09-02 13:37 ` [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs Petr Vorel
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 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),
but allow to use zram01.sh with tmpfs as it works with it.

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Note, I'm not sure if changes in this commit in tst_supported_fs.c will
not be heavily rewritten due tracking minimal filesystem usage.

 testcases/lib/tst_supported_fs.c           | 56 +++++++++++++++++-----
 testcases/misc/lvm/generate_lvm_runfile.sh |  2 +-
 testcases/misc/lvm/prepare_lvm.sh          |  2 +-
 3 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
index 43eac194f..87be2b759 100644
--- a/testcases/lib/tst_supported_fs.c
+++ b/testcases/lib/tst_supported_fs.c
@@ -5,42 +5,74 @@
  */
 
 #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);
 }
 
 int main(int argc, char *argv[])
 {
-	const char *skiplist[] = {"tmpfs", NULL};
 	const char *const *filesystems;
-	int i;
+	int i, ret, cnt = 1;
+	char **skiplist = NULL;
+	char *fs;
 
-	if (argc > 2) {
-		fprintf(stderr, "Can't specify multiple fs_type\n");
-		usage();
-		return 2;
+	while ((ret = getopt(argc, argv, "hs:"))) {
+		if (ret < 0)
+			break;
+
+		switch (ret) {
+		case '?':
+			return 1;
+
+		case 'h':
+			usage();
+			return 0;
+
+		case 's':
+			fs = optarg;
+			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 1;
+			}
+
+			fs = optarg;
+			for (i = 0; i < cnt; i++)
+				skiplist[i] = strtok_r(fs, TST_TO_STR(SKIP_DELIMITER), &fs);
+			break;
+		}
 	}
 
-	if (argv[1] && !strcmp(argv[1], "-h")) {
+	if (argc - optind > 1) {
+		fprintf(stderr, "Can't specify multiple fs_type\n");
 		usage();
-		return 0;
+		return 2;
 	}
 
-	if (argv[1])
-		return !tst_fs_is_supported(argv[1]);
+	if (optind < argc)
+		return !tst_fs_is_supported(argv[optind]);
 
-	filesystems = tst_get_supported_fs_types(skiplist);
+	filesystems = tst_get_supported_fs_types((const char * const*)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.2


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

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

* [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (2 preceding siblings ...)
  2022-09-02 13:37 ` [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list Petr Vorel
@ 2022-09-02 13:37 ` Petr Vorel
  2022-09-09  9:43   ` Cyril Hrubis
  2022-09-02 13:37 ` [LTP] [PATCH v4 5/9] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 include/tst_fs.h                 | 10 ++++++++++
 lib/tst_supported_fs_types.c     | 18 ++++++++++++++++++
 testcases/lib/tst_supported_fs.c |  2 +-
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/include/tst_fs.h b/include/tst_fs.h
index cc6d9b547..e399aef54 100644
--- a/include/tst_fs.h
+++ b/include/tst_fs.h
@@ -183,6 +183,16 @@ enum tst_fs_impl {
  */
 enum tst_fs_impl tst_fs_is_supported(const char *fs_type);
 
+/*
+ * Check filesystem support (@see tst_fs_is_supported()), but consider also
+ * filesystems to skip.
+ *
+ * @fs_type A filesystem name to check the support for.
+ * @skiplist A NULL terminated array of filesystems to skip.
+ */
+enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
+					      *const *skiplist);
+
 /*
  * Returns NULL-terminated array of kernel-supported filesystems.
  *
diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c
index 9726d193a..8c9379c1b 100644
--- a/lib/tst_supported_fs_types.c
+++ b/lib/tst_supported_fs_types.c
@@ -134,6 +134,24 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
 	return TST_FS_UNSUPPORTED;
 }
 
+enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
+					      *const *skiplist)
+{
+	int ret;
+
+	ret = tst_fs_is_supported(fs_type);
+
+	if (!ret)
+		return ret;
+
+	if (tst_fs_in_skiplist(fs_type, skiplist)) {
+		tst_brk(TCONF, "%s is not supported by the test",
+			fs_type);
+	}
+
+	return ret;
+}
+
 const char **tst_get_supported_fs_types(const char *const *skiplist)
 {
 	unsigned int i, j = 0;
diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
index 87be2b759..75945c809 100644
--- a/testcases/lib/tst_supported_fs.c
+++ b/testcases/lib/tst_supported_fs.c
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
 	}
 
 	if (optind < argc)
-		return !tst_fs_is_supported(argv[optind]);
+		return !tst_fs_is_supported_skiplist(argv[optind], (const char * const*)skiplist);
 
 	filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
 	for (i = 0; filesystems[i]; i++)
-- 
2.37.2


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

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

* [LTP] [PATCH v4 5/9] shell: Add $TST_SKIP_FILESYSTEMS + tests
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (3 preceding siblings ...)
  2022-09-02 13:37 ` [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs Petr Vorel
@ 2022-09-02 13:37 ` Petr Vorel
  2022-09-02 22:14   ` Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 6/9] tst_test.sh: Introduce TST_FS_TYPE_FUSE Petr Vorel
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 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>
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 +++++++++
 testcases/lib/tst_test.sh                     |  6 ++++
 4 files changed, 60 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..d7ce1c202
--- /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,ext2,ext3,xfs,vfat,exfat,ntfs,tmpfs"
+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/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.2


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

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

* [LTP] [PATCH v4 6/9] tst_test.sh: Introduce TST_FS_TYPE_FUSE
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (4 preceding siblings ...)
  2022-09-02 13:37 ` [LTP] [PATCH v4 5/9] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
@ 2022-09-02 13:37 ` Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 7/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Useful if tests need to grep on mount output (there is fuseblk instead
of expected filesystem).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 doc/shell-test-api.txt    |  2 ++
 testcases/lib/tst_test.sh | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/shell-test-api.txt b/doc/shell-test-api.txt
index 18ed144a9..e16080061 100644
--- a/doc/shell-test-api.txt
+++ b/doc/shell-test-api.txt
@@ -210,6 +210,8 @@ simply by setting right '$TST_FOO'.
 | '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_FUSE'       | 1 if mounted 'TST_FS_TYPE' filesystem on
+                             'TST_DEVICE' device is FUSE.
 | '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..78dbfc1ce 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -307,6 +307,18 @@ tst_mount()
 	if [ $ret -ne 0 ]; then
 		tst_brk TBROK "Failed to mount device${mnt_err}: mount exit = $ret"
 	fi
+
+	mnt_real="$(grep -E "$TST_MNTPOINT ($TST_FS_TYPE|fuseblk)" /proc/mounts | awk 'NR==1{print $3}')"
+	case $mnt_real in
+		'') tst_brk TBROK 'Failed to found filesystem type in /proc/mounts';;
+		'fuseblk') TST_FS_TYPE_FUSE=1;;
+		*)
+			if [ "$mnt_real" != "$TST_FS_TYPE" ]; then
+				tst_brk TBROK "$mnt_real: unsupported type in /proc/mounts"
+			fi
+			TST_FS_TYPE_FUSE=
+		;;
+		esac
 }
 
 tst_umount()
@@ -636,7 +648,7 @@ tst_run()
 			OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
 			NEEDS_ROOT|NEEDS_TMPDIR|TMPDIR|NEEDS_DEVICE|DEVICE);;
 			NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);;
-			NEEDS_DRIVERS|FS_TYPE|MNTPOINT|MNT_PARAMS);;
+			NEEDS_DRIVERS|FS_TYPE|FS_TYPE_FUSE|MNTPOINT|MNT_PARAMS);;
 			NEEDS_KCONFIGS|NEEDS_KCONFIGS_IFS);;
 			IPV6|IPV6_FLAG|IPVER|TEST_DATA|TEST_DATA_IFS);;
 			RETRY_FUNC|RETRY_FN_EXP_BACKOFF|TIMEOUT);;
-- 
2.37.2


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

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

* [LTP] [PATCH v4 7/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (5 preceding siblings ...)
  2022-09-02 13:37 ` [LTP] [PATCH v4 6/9] tst_test.sh: Introduce TST_FS_TYPE_FUSE Petr Vorel
@ 2022-09-02 13:37 ` Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 8/9] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 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 | 131 +++++++++++++++++++++++++-------------
 2 files changed, 93 insertions(+), 47 deletions(-)

diff --git a/doc/shell-test-api.txt b/doc/shell-test-api.txt
index e16080061..c92d7f4b4 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_FS_TYPE_FUSE'       | 1 if mounted 'TST_FS_TYPE' filesystem on
                              'TST_DEVICE' device is FUSE.
 | 'TST_MNTPOINT'           | Holds path to mountpoint used in 'tst_mount', see
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 78dbfc1ce..65b30b658 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"
@@ -490,6 +476,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
@@ -631,10 +618,36 @@ _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()
+{
+	for _tst_fs in $(tst_supported_fs -s "$TST_SKIP_FILESYSTEMS"); do
+		tst_res TINFO "=== Testing on $_tst_fs ==="
+		TST_FS_TYPE="$_tst_fs"
+		if [ "$TST_FS_TYPE" != "$TST_FS_TYPE_FUSE" ]; then
+			 tst_res TINFO "filesystem type in /proc/mounts: '$TST_FS_TYPE_FUSE'"
+		fi
+		_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\/:`$\;].*'
@@ -643,7 +656,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);;
@@ -689,16 +702,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
+		tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE > /dev/null
+		ret=$?
+		[ $ret -ne 0 ] && return $ret
+	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"
@@ -709,35 +739,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
@@ -749,20 +776,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.2


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

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

* [LTP] [PATCH v4 8/9] shell: Add test for TST_ALL_FILESYSTEMS=1
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (6 preceding siblings ...)
  2022-09-02 13:37 ` [LTP] [PATCH v4 7/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
@ 2022-09-02 13:37 ` Petr Vorel
  2022-09-02 13:37 ` [LTP] [PATCH v4 9/9] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 Petr Vorel
  2022-09-05  6:47 ` [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Li Wang
  9 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 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 | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.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..0ee1ab240
--- /dev/null
+++ b/lib/newlib_tests/shell/tst_all_filesystems.sh
@@ -0,0 +1,27 @@
+#!/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()
+{
+	local pattern="$TST_FS_TYPE"
+
+	if [ "$TST_FS_TYPE_FUSE" = 1 ]; then
+		pattern="fuseblk"
+	fi
+
+	EXPECT_PASS "grep -E '$TST_MNTPOINT ($pattern)' /proc/mounts"
+}
+
+. tst_test.sh
+tst_run
-- 
2.37.2


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

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

* [LTP] [PATCH v4 9/9] df01.sh: Convert to TST_ALL_FILESYSTEMS=1
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (7 preceding siblings ...)
  2022-09-02 13:37 ` [LTP] [PATCH v4 8/9] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
@ 2022-09-02 13:37 ` Petr Vorel
  2022-09-05  6:47 ` [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Li Wang
  9 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 13:37 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 runtest/commands              |  8 +-------
 runtest/smoketest             |  2 +-
 testcases/commands/df/df01.sh | 32 +++++++++-----------------------
 3 files changed, 11 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..ddfa9d9a7 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -6,35 +6,19 @@
 #
 # 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="$TST_FS_TYPE"
+
+	if [ "$TST_FS_TYPE_FUSE" = 1 ]; then
+		DF_FS_TYPE="fuseblk"
+	fi
 }
 
 df_test()
@@ -180,7 +164,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.2


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

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

* Re: [LTP] [PATCH v4 5/9] shell: Add $TST_SKIP_FILESYSTEMS + tests
  2022-09-02 13:37 ` [LTP] [PATCH v4 5/9] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
@ 2022-09-02 22:14   ` Petr Vorel
  0 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-02 22:14 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Hi all,

> 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 +++++++++
>  testcases/lib/tst_test.sh                     |  6 ++++
>  4 files changed, 60 insertions(+)
>  create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems.sh
>  create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems_skip.sh

...
> +++ 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,ext2,ext3,xfs,vfat,exfat,ntfs,tmpfs"

I suppose I should move this commit after following commit "tst_test.sh:
Introduce TST_FS_TYPE_FUSE" (swap them) so that I can here add "fuse" into
TST_SKIP_FILESYSTEMS.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems)
  2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (8 preceding siblings ...)
  2022-09-02 13:37 ` [LTP] [PATCH v4 9/9] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 Petr Vorel
@ 2022-09-05  6:47 ` Li Wang
  2022-09-05  7:04   ` Petr Vorel
  9 siblings, 1 reply; 28+ messages in thread
From: Li Wang @ 2022-09-05  6:47 UTC (permalink / raw)
  To: Petr Vorel; +Cc: LTP List, Richard Palethorpe


[-- Attachment #1.1: Type: text/plain, Size: 263 bytes --]

Hi Petr,

The whole patch set looks nice!

Btw, it might be great to wait for the series patch set of
"Track minimal size per filesystem" and merge together
in case this can't complete test on XFS.

Reviewed-by: Li Wang <liwang@redhat.com>


-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 1070 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


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

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

* Re: [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems)
  2022-09-05  6:47 ` [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Li Wang
@ 2022-09-05  7:04   ` Petr Vorel
  2022-09-05  7:35     ` Li Wang
  0 siblings, 1 reply; 28+ messages in thread
From: Petr Vorel @ 2022-09-05  7:04 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List, Richard Palethorpe

Hi Li,

> Hi Petr,

> The whole patch set looks nice!
Thanks a lot for your time to review!

> Btw, it might be great to wait for the series patch set of
> "Track minimal size per filesystem" and merge together
> in case this can't complete test on XFS.

FYI I marked patchset "Track minimal size per filesystem" [1] to changes requested,
I have WIP version which will track set size for .all_filesystems based on
max of all supported filesystems (as we discussed).

Because these two patchsets
modify the same files: lib/tst_supported_fs_types.c,
testcases/lib/tst_supported_fs.c modified in this patchset in commit
"tst_supported_fs: Support skip list when query single fs" in will likely be
changed in "Track minimal size per filesystem", I can either merge this now
(probably simpler) or sent big patchset which implements both.

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/list/?series=315621&state=*

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

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

* Re: [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems)
  2022-09-05  7:04   ` Petr Vorel
@ 2022-09-05  7:35     ` Li Wang
  0 siblings, 0 replies; 28+ messages in thread
From: Li Wang @ 2022-09-05  7:35 UTC (permalink / raw)
  To: Petr Vorel; +Cc: LTP List, Richard Palethorpe


[-- Attachment #1.1: Type: text/plain, Size: 1104 bytes --]

On Mon, Sep 5, 2022 at 3:05 PM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Li,
>
> > Hi Petr,
>
> > The whole patch set looks nice!
> Thanks a lot for your time to review!
>
> > Btw, it might be great to wait for the series patch set of
> > "Track minimal size per filesystem" and merge together
> > in case this can't complete test on XFS.
>
> FYI I marked patchset "Track minimal size per filesystem" [1] to changes
> requested,
> I have WIP version which will track set size for .all_filesystems based on
> max of all supported filesystems (as we discussed).
>
> Because these two patchsets
> modify the same files: lib/tst_supported_fs_types.c,
> testcases/lib/tst_supported_fs.c modified in this patchset in commit
> "tst_supported_fs: Support skip list when query single fs" in will likely
> be
> changed in "Track minimal size per filesystem", I can either merge this now
> (probably simpler) or sent big patchset which implements both.
>

Ok understand, feel free to merge first for convinent
or post the latest [1] based on this patch set.

I will help to test them as well.


-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 1960 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


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

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

* Re: [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list
  2022-09-02 13:37 ` [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list Petr Vorel
@ 2022-09-09  9:40   ` Cyril Hrubis
  2022-09-09  9:41     ` Petr Vorel
  2022-09-09 10:02     ` Petr Vorel
  0 siblings, 2 replies; 28+ messages in thread
From: Cyril Hrubis @ 2022-09-09  9:40 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> as it will be needed for $ALL_FILESYSTEMS shell implementation in the
> next commit. Pass tmpfs to LVM scripts (as it was required there),
> but allow to use zram01.sh with tmpfs as it works with it.
> 
> Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Note, I'm not sure if changes in this commit in tst_supported_fs.c will
> not be heavily rewritten due tracking minimal filesystem usage.
> 
>  testcases/lib/tst_supported_fs.c           | 56 +++++++++++++++++-----
>  testcases/misc/lvm/generate_lvm_runfile.sh |  2 +-
>  testcases/misc/lvm/prepare_lvm.sh          |  2 +-
>  3 files changed, 46 insertions(+), 14 deletions(-)
> 
> diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
> index 43eac194f..87be2b759 100644
> --- a/testcases/lib/tst_supported_fs.c
> +++ b/testcases/lib/tst_supported_fs.c
> @@ -5,42 +5,74 @@
>   */
>  
>  #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);
>  }
>  
>  int main(int argc, char *argv[])
>  {
> -	const char *skiplist[] = {"tmpfs", NULL};
>  	const char *const *filesystems;
> -	int i;
> +	int i, ret, cnt = 1;
> +	char **skiplist = NULL;
> +	char *fs;
>  
> -	if (argc > 2) {
> -		fprintf(stderr, "Can't specify multiple fs_type\n");
> -		usage();
> -		return 2;
> +	while ((ret = getopt(argc, argv, "hs:"))) {
> +		if (ret < 0)
> +			break;
> +
> +		switch (ret) {
> +		case '?':

No usage?

> +			return 1;
> +
> +		case 'h':
> +			usage();
> +			return 0;
> +
> +		case 's':
> +			fs = optarg;
> +			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 1;
> +			}
> +
> +			fs = optarg;
> +			for (i = 0; i < cnt; i++)
> +				skiplist[i] = strtok_r(fs, TST_TO_STR(SKIP_DELIMITER), &fs);
> +			break;

It may be a bit cleaner to put this part into a function i.e.

	skiplist = parse_skiplist(optarg);


-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list
  2022-09-09  9:40   ` Cyril Hrubis
@ 2022-09-09  9:41     ` Petr Vorel
  2022-09-09  9:47       ` Petr Vorel
  2022-09-09 10:02     ` Petr Vorel
  1 sibling, 1 reply; 28+ messages in thread
From: Petr Vorel @ 2022-09-09  9:41 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

Hi all,

> > -	if (argc > 2) {
> > -		fprintf(stderr, "Can't specify multiple fs_type\n");
> > -		usage();
> > -		return 2;
> > +	while ((ret = getopt(argc, argv, "hs:"))) {
> > +		if (ret < 0)
> > +			break;
> > +
> > +		switch (ret) {
> > +		case '?':

> No usage?
Ah, make sense to -? be alias of -h.

> > +			return 1;
> > +
> > +		case 'h':
> > +			usage();
> > +			return 0;
> > +
> > +		case 's':
> > +			fs = optarg;
> > +			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 1;
> > +			}
> > +
> > +			fs = optarg;
> > +			for (i = 0; i < cnt; i++)
> > +				skiplist[i] = strtok_r(fs, TST_TO_STR(SKIP_DELIMITER), &fs);
> > +			break;

> It may be a bit cleaner to put this part into a function i.e.

> 	skiplist = parse_skiplist(optarg);

+1, I'll post next version.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-02 13:37 ` [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs Petr Vorel
@ 2022-09-09  9:43   ` Cyril Hrubis
  2022-09-09 10:55     ` Petr Vorel
  0 siblings, 1 reply; 28+ messages in thread
From: Cyril Hrubis @ 2022-09-09  9:43 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  include/tst_fs.h                 | 10 ++++++++++
>  lib/tst_supported_fs_types.c     | 18 ++++++++++++++++++
>  testcases/lib/tst_supported_fs.c |  2 +-
>  3 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/include/tst_fs.h b/include/tst_fs.h
> index cc6d9b547..e399aef54 100644
> --- a/include/tst_fs.h
> +++ b/include/tst_fs.h
> @@ -183,6 +183,16 @@ enum tst_fs_impl {
>   */
>  enum tst_fs_impl tst_fs_is_supported(const char *fs_type);
>  
> +/*
> + * Check filesystem support (@see tst_fs_is_supported()), but consider also
> + * filesystems to skip.
> + *
> + * @fs_type A filesystem name to check the support for.
> + * @skiplist A NULL terminated array of filesystems to skip.
> + */
> +enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
> +					      *const *skiplist);
> +
>  /*
>   * Returns NULL-terminated array of kernel-supported filesystems.
>   *
> diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c
> index 9726d193a..8c9379c1b 100644
> --- a/lib/tst_supported_fs_types.c
> +++ b/lib/tst_supported_fs_types.c
> @@ -134,6 +134,24 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
>  	return TST_FS_UNSUPPORTED;
>  }
>  
> +enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
> +					      *const *skiplist)
> +{
> +	int ret;
> +
> +	ret = tst_fs_is_supported(fs_type);
> +
> +	if (!ret)
> +		return ret;
> +
> +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
> +		tst_brk(TCONF, "%s is not supported by the test",
> +			fs_type);

I would expect to return TST_FS_UNSUPPORTED here. It's a bit hacky
solution to exit a library call with tst_brk(TCONF, "");

> +	}
> +
> +	return ret;
> +}
> +
>  const char **tst_get_supported_fs_types(const char *const *skiplist)
>  {
>  	unsigned int i, j = 0;
> diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
> index 87be2b759..75945c809 100644
> --- a/testcases/lib/tst_supported_fs.c
> +++ b/testcases/lib/tst_supported_fs.c
> @@ -70,7 +70,7 @@ int main(int argc, char *argv[])
>  	}
>  
>  	if (optind < argc)
> -		return !tst_fs_is_supported(argv[optind]);
> +		return !tst_fs_is_supported_skiplist(argv[optind], (const char * const*)skiplist);
>  
>  	filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
>  	for (i = 0; filesystems[i]; i++)
> -- 
> 2.37.2
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list
  2022-09-09  9:41     ` Petr Vorel
@ 2022-09-09  9:47       ` Petr Vorel
  0 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-09  9:47 UTC (permalink / raw)
  To: Cyril Hrubis, ltp, Li Wang, Richard Palethorpe, Martin Doucha, Yang Xu

...
> > > +		switch (ret) {
> > > +		case '?':

> > No usage?
> Ah, make sense to -? be alias of -h.
I mean to call usage() before return 1.

Kind regards,
Petr

> > > +			return 1;
> > > +
> > > +		case 'h':
> > > +			usage();
> > > +			return 0;

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

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

* Re: [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list
  2022-09-09  9:40   ` Cyril Hrubis
  2022-09-09  9:41     ` Petr Vorel
@ 2022-09-09 10:02     ` Petr Vorel
  1 sibling, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-09 10:02 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> > +			fs = optarg;
> > +			for (i = 0; i < cnt; i++)
> > +				skiplist[i] = strtok_r(fs, TST_TO_STR(SKIP_DELIMITER), &fs);
> > +			break;

> It may be a bit cleaner to put this part into a function i.e.

> 	skiplist = parse_skiplist(optarg);

Suppose code below is good enough (will be in v5).
Thanks for your review!

Kind regards,
Petr

char **parse_skiplist(char *fs)
{
	char **skiplist = NULL;
	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 *const *filesystems;
	int i, ret;
	char **skiplist = NULL;

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

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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-09  9:43   ` Cyril Hrubis
@ 2022-09-09 10:55     ` Petr Vorel
  2022-09-09 11:16       ` Cyril Hrubis
  0 siblings, 1 reply; 28+ messages in thread
From: Petr Vorel @ 2022-09-09 10:55 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

Hi all,

> > +++ b/lib/tst_supported_fs_types.c
> > @@ -134,6 +134,24 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
> >  	return TST_FS_UNSUPPORTED;
> >  }

> > +enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
> > +					      *const *skiplist)
> > +{
> > +	int ret;
> > +
> > +	ret = tst_fs_is_supported(fs_type);
> > +
> > +	if (!ret)
> > +		return ret;
> > +
> > +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
> > +		tst_brk(TCONF, "%s is not supported by the test",
> > +			fs_type);

> I would expect to return TST_FS_UNSUPPORTED here. It's a bit hacky
> solution to exit a library call with tst_brk(TCONF, "");
Understand. There are 2 cases of not supported filesystems: 1) filesystem not
supported 2) filesystem skipped. Therefore I'd like to introduce
TST_FS_SKIPPED_BY_TEST (that would be 1 (therefore exit code
will have to be tested against the constants. That's IMHO better than
reinventing a wheel to detect this in testcases/lib/tst_supported_fs.c.

e.g.:

+++ b/include/tst_fs.h
@@ -171,7 +171,8 @@ int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount);
 int tst_prealloc_file(const char *path, size_t bs, size_t bcount);
 
 enum tst_fs_impl {
-       TST_FS_UNSUPPORTED = 0,
+       TST_FS_UNSUPPORTED = -2,
+       TST_FS_SKIPPED_BY_TEST = -1,
        TST_FS_KERNEL = 1,
        TST_FS_FUSE = 2,
 };

I also wonder if testcases/lib/tst_supported_fs.c should print TCONF in case of
error or just exit 0 or 1 (that's done now).

check for all filesystems (tst_supported_fs without params) is run in:
* zram01.sh - it handles no suitable filesystem, but the check could be based
  on tst_supported_fs return code
* generate_lvm_runfile.sh - does handle no suitable filesystem, but with
  'set -e' and trap - adding TCONF info would make things more clear
* prepare_lvm.sh (in prepare_lvm()) - does *not* handle no suitable filesystem.
  Although it's unlikely there is no supported filesystem it'd be better to
  print the message (it'd be more clear when testing with $LTP_SINGLE_FS_TYPE)

check for particular filesystem (tst_supported_fs foo) is run in:
* prepare_lvm.sh (in create_volume) - it check for unsupported filesystem and
  just quietly skip creating LVM. IMHO have here TCONF message would not harm.

=> Unless anybody objects I'll add TCONF messages in v5.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-09 10:55     ` Petr Vorel
@ 2022-09-09 11:16       ` Cyril Hrubis
  2022-09-09 11:33         ` Petr Vorel
  0 siblings, 1 reply; 28+ messages in thread
From: Cyril Hrubis @ 2022-09-09 11:16 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > > +++ b/lib/tst_supported_fs_types.c
> > > @@ -134,6 +134,24 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
> > >  	return TST_FS_UNSUPPORTED;
> > >  }
> 
> > > +enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
> > > +					      *const *skiplist)
> > > +{
> > > +	int ret;
> > > +
> > > +	ret = tst_fs_is_supported(fs_type);
> > > +
> > > +	if (!ret)
> > > +		return ret;
> > > +
> > > +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
> > > +		tst_brk(TCONF, "%s is not supported by the test",
> > > +			fs_type);
> 
> > I would expect to return TST_FS_UNSUPPORTED here. It's a bit hacky
> > solution to exit a library call with tst_brk(TCONF, "");
> Understand. There are 2 cases of not supported filesystems: 1) filesystem not
> supported 2) filesystem skipped. Therefore I'd like to introduce
> TST_FS_SKIPPED_BY_TEST (that would be 1 (therefore exit code
> will have to be tested against the constants. That's IMHO better than
> reinventing a wheel to detect this in testcases/lib/tst_supported_fs.c.
> 
> e.g.:
> 
> +++ b/include/tst_fs.h
> @@ -171,7 +171,8 @@ int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount);
>  int tst_prealloc_file(const char *path, size_t bs, size_t bcount);
>  
>  enum tst_fs_impl {
> -       TST_FS_UNSUPPORTED = 0,
> +       TST_FS_UNSUPPORTED = -2,
> +       TST_FS_SKIPPED_BY_TEST = -1,

Maybe just TST_FS_SKIPPED

>         TST_FS_KERNEL = 1,
>         TST_FS_FUSE = 2,
>  };

I wonder though if we really care about the difference between
unsupported and skipped. Maybe just print TINFO message in case of the
skipped filesystem and return zero in both cases? And maybe rename
TST_FS_UNSUPPORTED to TST_FSNOT_USED.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-09 11:16       ` Cyril Hrubis
@ 2022-09-09 11:33         ` Petr Vorel
  2022-09-09 14:15           ` Martin Doucha
  0 siblings, 1 reply; 28+ messages in thread
From: Petr Vorel @ 2022-09-09 11:33 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > > > +++ b/lib/tst_supported_fs_types.c
> > > > @@ -134,6 +134,24 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
> > > >  	return TST_FS_UNSUPPORTED;
> > > >  }

> > > > +enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
> > > > +					      *const *skiplist)
> > > > +{
> > > > +	int ret;
> > > > +
> > > > +	ret = tst_fs_is_supported(fs_type);
> > > > +
> > > > +	if (!ret)
> > > > +		return ret;
> > > > +
> > > > +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
> > > > +		tst_brk(TCONF, "%s is not supported by the test",
> > > > +			fs_type);

> > > I would expect to return TST_FS_UNSUPPORTED here. It's a bit hacky
> > > solution to exit a library call with tst_brk(TCONF, "");
> > Understand. There are 2 cases of not supported filesystems: 1) filesystem not
> > supported 2) filesystem skipped. Therefore I'd like to introduce
> > TST_FS_SKIPPED_BY_TEST (that would be 1 (therefore exit code
> > will have to be tested against the constants. That's IMHO better than
> > reinventing a wheel to detect this in testcases/lib/tst_supported_fs.c.

> > e.g.:

> > +++ b/include/tst_fs.h
> > @@ -171,7 +171,8 @@ int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount);
> >  int tst_prealloc_file(const char *path, size_t bs, size_t bcount);

> >  enum tst_fs_impl {
> > -       TST_FS_UNSUPPORTED = 0,
> > +       TST_FS_UNSUPPORTED = -2,
> > +       TST_FS_SKIPPED_BY_TEST = -1,

> Maybe just TST_FS_SKIPPED

> >         TST_FS_KERNEL = 1,
> >         TST_FS_FUSE = 2,
> >  };

> I wonder though if we really care about the difference between
> unsupported and skipped. Maybe just print TINFO message in case of the
> skipped filesystem and return zero in both cases? And maybe rename
> TST_FS_UNSUPPORTED to TST_FSNOT_USED.

I thought being precise why there is TCONF would help, but users will just read
previous TINFO messages.

Having just single "error" enum constant, I'm OK to keep TST_FS_UNSUPPORTED
(unless anybody really think renaming it to TST_FS_NOT_USED would be better).

So, there can be just single message "foo is not supported or skipped by
test" (in case of asking for particular fs support) and "no supported
filesystem" (in case of list of all supported fs).
I'd use tst_brk(TCONF, ...) here, because the binary exits 1 on "error", thus
here would be exit 32 on "error".

Thanks for your input!

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-09 11:33         ` Petr Vorel
@ 2022-09-09 14:15           ` Martin Doucha
  2022-09-09 14:22             ` Petr Vorel
  0 siblings, 1 reply; 28+ messages in thread
From: Martin Doucha @ 2022-09-09 14:15 UTC (permalink / raw)
  To: Petr Vorel, Cyril Hrubis; +Cc: Richard Palethorpe, ltp

On 09. 09. 22 13:33, Petr Vorel wrote:
>> Hi!
>>>>> +++ b/lib/tst_supported_fs_types.c
>>>>> @@ -134,6 +134,24 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
>>>>>   	return TST_FS_UNSUPPORTED;
>>>>>   }
> 
>>>>> +enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
>>>>> +					      *const *skiplist)
>>>>> +{
>>>>> +	int ret;
>>>>> +
>>>>> +	ret = tst_fs_is_supported(fs_type);
>>>>> +
>>>>> +	if (!ret)
>>>>> +		return ret;
>>>>> +
>>>>> +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
>>>>> +		tst_brk(TCONF, "%s is not supported by the test",
>>>>> +			fs_type);
> 
>>>> I would expect to return TST_FS_UNSUPPORTED here. It's a bit hacky
>>>> solution to exit a library call with tst_brk(TCONF, "");

I agree with that. Return a status code from 
tst_fs_is_supported_skiplist() and raise TCONF somewhere higher in the 
call chain.

>>> +++ b/include/tst_fs.h
>>> @@ -171,7 +171,8 @@ int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount);
>>>   int tst_prealloc_file(const char *path, size_t bs, size_t bcount);
> 
>>>   enum tst_fs_impl {
>>> -       TST_FS_UNSUPPORTED = 0,
>>> +       TST_FS_UNSUPPORTED = -2,
>>> +       TST_FS_SKIPPED_BY_TEST = -1,
> 
>> Maybe just TST_FS_SKIPPED
> 
>>>          TST_FS_KERNEL = 1,
>>>          TST_FS_FUSE = 2,
>>>   };
> 
>> I wonder though if we really care about the difference between
>> unsupported and skipped. Maybe just print TINFO message in case of the
>> skipped filesystem and return zero in both cases? And maybe rename
>> TST_FS_UNSUPPORTED to TST_FSNOT_USED.
> 
> I thought being precise why there is TCONF would help, but users will just read
> previous TINFO messages.
> 
> Having just single "error" enum constant, I'm OK to keep TST_FS_UNSUPPORTED
> (unless anybody really think renaming it to TST_FS_NOT_USED would be better).

I'd like to see why exactly a filesystem was skipped so I prefer two 
enum values. Though I'd name them TST_FS_UNAVAILABLE (missing mkfs or 
kernel support) and TST_FS_UNSUPPORTED (disabled by test skiplist).

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-09 14:15           ` Martin Doucha
@ 2022-09-09 14:22             ` Petr Vorel
  2022-09-09 14:39               ` Martin Doucha
  0 siblings, 1 reply; 28+ messages in thread
From: Petr Vorel @ 2022-09-09 14:22 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp, Richard Palethorpe

> On 09. 09. 22 13:33, Petr Vorel wrote:
> > > Hi!
> > > > > > +++ b/lib/tst_supported_fs_types.c
> > > > > > @@ -134,6 +134,24 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
> > > > > >   	return TST_FS_UNSUPPORTED;
> > > > > >   }

> > > > > > +enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
> > > > > > +					      *const *skiplist)
> > > > > > +{
> > > > > > +	int ret;
> > > > > > +
> > > > > > +	ret = tst_fs_is_supported(fs_type);
> > > > > > +
> > > > > > +	if (!ret)
> > > > > > +		return ret;
> > > > > > +
> > > > > > +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
> > > > > > +		tst_brk(TCONF, "%s is not supported by the test",
> > > > > > +			fs_type);

> > > > > I would expect to return TST_FS_UNSUPPORTED here. It's a bit hacky
> > > > > solution to exit a library call with tst_brk(TCONF, "");

> I agree with that. Return a status code from tst_fs_is_supported_skiplist()
> and raise TCONF somewhere higher in the call chain.

Martin, thanks for your input! Done in v5 (just sent).

> > > > +++ b/include/tst_fs.h
> > > > @@ -171,7 +171,8 @@ int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount);
> > > >   int tst_prealloc_file(const char *path, size_t bs, size_t bcount);

> > > >   enum tst_fs_impl {
> > > > -       TST_FS_UNSUPPORTED = 0,
> > > > +       TST_FS_UNSUPPORTED = -2,
> > > > +       TST_FS_SKIPPED_BY_TEST = -1,

> > > Maybe just TST_FS_SKIPPED

> > > >          TST_FS_KERNEL = 1,
> > > >          TST_FS_FUSE = 2,
> > > >   };

> > > I wonder though if we really care about the difference between
> > > unsupported and skipped. Maybe just print TINFO message in case of the
> > > skipped filesystem and return zero in both cases? And maybe rename
> > > TST_FS_UNSUPPORTED to TST_FSNOT_USED.

> > I thought being precise why there is TCONF would help, but users will just read
> > previous TINFO messages.

> > Having just single "error" enum constant, I'm OK to keep TST_FS_UNSUPPORTED
> > (unless anybody really think renaming it to TST_FS_NOT_USED would be better).

> I'd like to see why exactly a filesystem was skipped so I prefer two enum
> values. Though I'd name them TST_FS_UNAVAILABLE (missing mkfs or kernel
> support) and TST_FS_UNSUPPORTED (disabled by test skiplist).

OK, this is not in v5. I don't mind to send v6 on Monday, if we agree this
is wanted. Implementation detail: should I use for -2 and -1 for these two values?
(code < 0 would be error, code > 0 would be OK, 0 itself skipped)

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-09 14:22             ` Petr Vorel
@ 2022-09-09 14:39               ` Martin Doucha
  2022-09-09 14:47                 ` Petr Vorel
  0 siblings, 1 reply; 28+ messages in thread
From: Martin Doucha @ 2022-09-09 14:39 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp, Richard Palethorpe

On 09. 09. 22 16:22, Petr Vorel wrote:
> OK, this is not in v5. I don't mind to send v6 on Monday, if we agree this
> is wanted. Implementation detail: should I use for -2 and -1 for these two values?
> (code < 0 would be error, code > 0 would be OK, 0 itself skipped)

One more thing, the skiplist check should be done before availability 
check. It's faster and it'll save you work when you're trying to fix 
tests that shouldn't be skipped.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-09 14:39               ` Martin Doucha
@ 2022-09-09 14:47                 ` Petr Vorel
  2022-09-09 14:49                   ` Martin Doucha
  0 siblings, 1 reply; 28+ messages in thread
From: Petr Vorel @ 2022-09-09 14:47 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp, Richard Palethorpe

> On 09. 09. 22 16:22, Petr Vorel wrote:
> > OK, this is not in v5. I don't mind to send v6 on Monday, if we agree this
> > is wanted. Implementation detail: should I use for -2 and -1 for these two values?
> > (code < 0 would be error, code > 0 would be OK, 0 itself skipped)

> One more thing, the skiplist check should be done before availability check.
> It's faster and it'll save you work when you're trying to fix tests that
> shouldn't be skipped.
Good point. I guess you mean just to reverse order in
tst_fs_is_supported_skiplist(), right?

Kind regards,
Petr

+++ lib/tst_supported_fs_types.c
@@ -137,17 +137,10 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
 enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
 					      *const *skiplist)
 {
-	int ret;
-
-	ret = tst_fs_is_supported(fs_type);
-
-	if (!ret)
-		return ret;
-
 	if (tst_fs_in_skiplist(fs_type, skiplist))
 		return TST_FS_UNSUPPORTED;
 
-	return ret;
+	return tst_fs_is_supported(fs_type);
 }
 
 const char **tst_get_supported_fs_types(const char *const *skiplist)

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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-09 14:47                 ` Petr Vorel
@ 2022-09-09 14:49                   ` Martin Doucha
  2022-09-12  5:40                     ` Petr Vorel
  0 siblings, 1 reply; 28+ messages in thread
From: Martin Doucha @ 2022-09-09 14:49 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On 09. 09. 22 16:47, Petr Vorel wrote:
>> One more thing, the skiplist check should be done before availability check.
>> It's faster and it'll save you work when you're trying to fix tests that
>> shouldn't be skipped.
> Good point. I guess you mean just to reverse order in
> tst_fs_is_supported_skiplist(), right?

Exactly.

> +++ lib/tst_supported_fs_types.c
> @@ -137,17 +137,10 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
>   enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
>   					      *const *skiplist)
>   {
> -	int ret;
> -
> -	ret = tst_fs_is_supported(fs_type);
> -
> -	if (!ret)
> -		return ret;
> -
>   	if (tst_fs_in_skiplist(fs_type, skiplist))
>   		return TST_FS_UNSUPPORTED;
>   
> -	return ret;
> +	return tst_fs_is_supported(fs_type);
>   }
>   
>   const char **tst_get_supported_fs_types(const char *const *skiplist)

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


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

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

* Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs
  2022-09-09 14:49                   ` Martin Doucha
@ 2022-09-12  5:40                     ` Petr Vorel
  0 siblings, 0 replies; 28+ messages in thread
From: Petr Vorel @ 2022-09-12  5:40 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp, Richard Palethorpe

> On 09. 09. 22 16:47, Petr Vorel wrote:
> > > One more thing, the skiplist check should be done before availability check.
> > > It's faster and it'll save you work when you're trying to fix tests that
> > > shouldn't be skipped.
> > Good point. I guess you mean just to reverse order in
> > tst_fs_is_supported_skiplist(), right?

> Exactly.
+1

> > +++ lib/tst_supported_fs_types.c
> > @@ -137,17 +137,10 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
> >   enum tst_fs_impl tst_fs_is_supported_skiplist(const char *fs_type, const char
> >   					      *const *skiplist)
> >   {
> > -	int ret;
> > -
> > -	ret = tst_fs_is_supported(fs_type);
> > -
> > -	if (!ret)
> > -		return ret;
> > -
> >   	if (tst_fs_in_skiplist(fs_type, skiplist))
> >   		return TST_FS_UNSUPPORTED;
> > -	return ret;
> > +	return tst_fs_is_supported(fs_type);
> >   }
> >   const char **tst_get_supported_fs_types(const char *const *skiplist)

FYI if anybody wants to test v5 with this fix, it's in my fork in branch
shell/all_filesystems.v5.fixes

https://github.com/pevik/ltp/commits/shell/all_filesystems.v5.fixes

Kind regards,
Petr

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

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

end of thread, other threads:[~2022-09-12  5:40 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 13:37 [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
2022-09-02 13:37 ` [LTP] [PATCH v4 1/9] shell: Print mount command in tst_mount() Petr Vorel
2022-09-02 13:37 ` [LTP] [PATCH v4 2/9] shell API/tests: Require root for TST_{FORMAT, MOUNT}_DEVICE Petr Vorel
2022-09-02 13:37 ` [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list Petr Vorel
2022-09-09  9:40   ` Cyril Hrubis
2022-09-09  9:41     ` Petr Vorel
2022-09-09  9:47       ` Petr Vorel
2022-09-09 10:02     ` Petr Vorel
2022-09-02 13:37 ` [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs Petr Vorel
2022-09-09  9:43   ` Cyril Hrubis
2022-09-09 10:55     ` Petr Vorel
2022-09-09 11:16       ` Cyril Hrubis
2022-09-09 11:33         ` Petr Vorel
2022-09-09 14:15           ` Martin Doucha
2022-09-09 14:22             ` Petr Vorel
2022-09-09 14:39               ` Martin Doucha
2022-09-09 14:47                 ` Petr Vorel
2022-09-09 14:49                   ` Martin Doucha
2022-09-12  5:40                     ` Petr Vorel
2022-09-02 13:37 ` [LTP] [PATCH v4 5/9] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
2022-09-02 22:14   ` Petr Vorel
2022-09-02 13:37 ` [LTP] [PATCH v4 6/9] tst_test.sh: Introduce TST_FS_TYPE_FUSE Petr Vorel
2022-09-02 13:37 ` [LTP] [PATCH v4 7/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
2022-09-02 13:37 ` [LTP] [PATCH v4 8/9] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-09-02 13:37 ` [LTP] [PATCH v4 9/9] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-09-05  6:47 ` [LTP] [PATCH v4 0/9] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Li Wang
2022-09-05  7:04   ` Petr Vorel
2022-09-05  7:35     ` Li Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).