All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems)
@ 2022-09-09 14:18 Petr Vorel
  2022-09-09 14:18 ` [LTP] [PATCH v5 01/10] shell: Print mount command in tst_mount() Petr Vorel
                   ` (9 more replies)
  0 siblings, 10 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Hi,

changes v4->v5:
* tst_fs_is_supported_skiplist() returns TST_FS_UNSUPPORTED,
  errors handled in testcases/lib/tst_supported_fs.c (Cyril)
* testcases/lib/tst_supported_fs.c: put parsing code to separate
  function parse_skiplist() (Cyril)
* testcases/lib/tst_supported_fs.c: Print usage on getopts error (Cyril)
* print TCONF when filesystem is not supported
* tst_test.sh: fix quiting test when no filesystem supported
* zram01.sh: use -f tmpfs in tst_supported_fs call
* new test lib/newlib_tests/shell/tst_all_filesystems_skip.sh
* add fuse to lib/newlib_tests/shell/tst_skip_filesystems.sh

new commits:
*  tst_supported_fs: Print TCONF if no filesystem supported

Petr Vorel (10):
  shell: Print mount command in tst_mount()
  shell API/tests: Require root for format/mount tests
  tst_supported_fs: Print TCONF if no filesystem supported
  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 tests 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 +++
 .../shell/tst_all_filesystems_skip.sh         |  16 ++
 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                  |  17 ++
 runtest/commands                              |   8 +-
 runtest/smoketest                             |   2 +-
 testcases/commands/df/df01.sh                 |  32 +---
 .../kernel/device-drivers/zram/zram01.sh      |   3 +-
 testcases/lib/tst_supported_fs.c              |  74 +++++++--
 testcases/lib/tst_test.sh                     | 155 +++++++++++++-----
 testcases/misc/lvm/generate_lvm_runfile.sh    |   2 +-
 testcases/misc/lvm/prepare_lvm.sh             |   2 +-
 18 files changed, 326 insertions(+), 90 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] 38+ messages in thread

* [LTP] [PATCH v5 01/10] shell: Print mount command in tst_mount()
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  2022-09-12 10:02   ` Cyril Hrubis
  2022-09-09 14:18 ` [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests Petr Vorel
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
The same as in v4

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


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

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

* [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
  2022-09-09 14:18 ` [LTP] [PATCH v5 01/10] shell: Print mount command in tst_mount() Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  2022-09-12 10:03   ` Cyril Hrubis
  2022-09-13 13:52   ` Petr Vorel
  2022-09-09 14:18 ` [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported Petr Vorel
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

i.e. for TST_{FORMAT,MOUNT}_DEVICE=1.

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.

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
The same as in v4

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


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

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

* [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
  2022-09-09 14:18 ` [LTP] [PATCH v5 01/10] shell: Print mount command in tst_mount() Petr Vorel
  2022-09-09 14:18 ` [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  2022-09-12 14:42   ` Cyril Hrubis
  2022-09-09 14:18 ` [LTP] [PATCH v5 04/10] tst_supported_fs: Implement skip list Petr Vorel
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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

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

NOTE:

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

Tests added in later commits which demonstrates TCONF:

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

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

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

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

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

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


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

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

* [LTP] [PATCH v5 04/10] tst_supported_fs: Implement skip list
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (2 preceding siblings ...)
  2022-09-09 14:18 ` [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  2022-09-12 14:39   ` Cyril Hrubis
  2022-09-09 14:18 ` [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs Petr Vorel
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 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).

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
changes v4->v5:
* testcases/lib/tst_supported_fs.c: put parsing code to separate
  function parse_skiplist() (Cyril)

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

diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
index 6e544070c..1c259e62a 100644
--- a/testcases/lib/tst_supported_fs.c
+++ b/testcases/lib/tst_supported_fs.c
@@ -5,40 +5,83 @@
  */
 
 #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 = 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 *skiplist[] = {"tmpfs", NULL};
 	const char *const *filesystems;
 	int i, ret;
+	char **skiplist = NULL;
 
-	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 '?':
+			usage();
+			return 1;
+
+		case 'h':
+			usage();
+			return 0;
+
+		case 's':
+			skiplist = parse_skiplist(optarg);
+			if (!skiplist)
+				return 1;
+			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]) {
-		ret = tst_fs_is_supported(argv[1]);
+	if (optind < argc) {
+		ret = tst_fs_is_supported(argv[optind]);
 
 		if (ret == TST_FS_UNSUPPORTED)
 			tst_brk(TCONF, "%s is not supported", argv[optind]);
@@ -46,7 +89,7 @@ int main(int argc, char *argv[])
 		return !ret;
 	}
 
-	filesystems = tst_get_supported_fs_types(skiplist);
+	filesystems = tst_get_supported_fs_types((const char * const*)skiplist);
 
 	if (!filesystems[0])
 		tst_brk(TCONF, "There are no supported filesystems");
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] 38+ messages in thread

* [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (3 preceding siblings ...)
  2022-09-09 14:18 ` [LTP] [PATCH v5 04/10] tst_supported_fs: Implement skip list Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  2022-09-12 11:21   ` Petr Vorel
                     ` (2 more replies)
  2022-09-09 14:18 ` [LTP] [PATCH v5 06/10] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
                   ` (4 subsequent siblings)
  9 siblings, 3 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

And use this feature in zram01.sh

Acked-by: Richard Palethorpe <rpalethorpe@suse.com>
Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
changes v4->v5:
* tst_fs_is_supported_skiplist() returns TST_FS_UNSUPPORTED,
  errors handled in testcases/lib/tst_supported_fs.c (Cyril)
* testcases/lib/tst_supported_fs.c: put parsing code to separate
  function parse_skiplist() (Cyril)
* testcases/lib/tst_supported_fs.c: Print usage on getopts error (Cyril)
* zram01.sh: use -f tmpfs in tst_supported_fs call

 include/tst_fs.h                               | 10 ++++++++++
 lib/tst_supported_fs_types.c                   | 16 ++++++++++++++++
 testcases/kernel/device-drivers/zram/zram01.sh |  3 +--
 testcases/lib/tst_supported_fs.c               |  7 ++++---
 4 files changed, 31 insertions(+), 5 deletions(-)

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..cde162555 100644
--- a/lib/tst_supported_fs_types.c
+++ b/lib/tst_supported_fs_types.c
@@ -134,6 +134,22 @@ 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))
+		return TST_FS_UNSUPPORTED;
+
+	return ret;
+}
+
 const char **tst_get_supported_fs_types(const char *const *skiplist)
 {
 	unsigned int i, j = 0;
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
diff --git a/testcases/lib/tst_supported_fs.c b/testcases/lib/tst_supported_fs.c
index 1c259e62a..032b9d10b 100644
--- a/testcases/lib/tst_supported_fs.c
+++ b/testcases/lib/tst_supported_fs.c
@@ -81,10 +81,11 @@ int main(int argc, char *argv[])
 	}
 
 	if (optind < argc) {
-		ret = tst_fs_is_supported(argv[optind]);
+		ret = tst_fs_is_supported_skiplist(argv[optind],
+						   (const char * const*)skiplist);
 
 		if (ret == TST_FS_UNSUPPORTED)
-			tst_brk(TCONF, "%s is not supported", argv[optind]);
+			tst_brk(TCONF, "%s is skipped or not supported", argv[optind]);
 
 		return !ret;
 	}
@@ -92,7 +93,7 @@ int main(int argc, char *argv[])
 	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] 38+ messages in thread

* [LTP] [PATCH v5 06/10] shell: Add $TST_SKIP_FILESYSTEMS + tests
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (4 preceding siblings ...)
  2022-09-09 14:18 ` [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  2022-09-12 15:10   ` Cyril Hrubis
  2022-09-09 14:18 ` [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE Petr Vorel
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 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>
---
changes v4->v5:
* add fuse to lib/newlib_tests/shell/tst_skip_filesystems.sh

 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 cde162555..41d9bcd27 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] 38+ messages in thread

* [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (5 preceding siblings ...)
  2022-09-09 14:18 ` [LTP] [PATCH v5 06/10] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  2022-09-12 15:28   ` Cyril Hrubis
  2022-09-09 14:18 ` [LTP] [PATCH v5 08/10] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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

Reviewed-by: Li Wang <liwang@redhat.com>
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.3


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

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

* [LTP] [PATCH v5 08/10] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (6 preceding siblings ...)
  2022-09-09 14:18 ` [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  2022-09-09 14:18 ` [LTP] [PATCH v5 09/10] shell: Add tests for TST_ALL_FILESYSTEMS=1 Petr Vorel
  2022-09-09 14:18 ` [LTP] [PATCH v5 10/10] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 Petr Vorel
  9 siblings, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 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>
---
changes v4->v5:
* tst_test.sh: fix quiting test when no filesystem supported

 doc/shell-test-api.txt    |   9 ++-
 testcases/lib/tst_test.sh | 139 +++++++++++++++++++++++++-------------
 2 files changed, 101 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..de4599625 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,44 @@ _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"
+		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 +664,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 +710,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"
@@ -709,35 +747,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 +784,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] 38+ messages in thread

* [LTP] [PATCH v5 09/10] shell: Add tests for TST_ALL_FILESYSTEMS=1
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (7 preceding siblings ...)
  2022-09-09 14:18 ` [LTP] [PATCH v5 08/10] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  2022-09-09 14:18 ` [LTP] [PATCH v5 10/10] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 Petr Vorel
  9 siblings, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 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>
---
changes v4->v5:
* new test lib/newlib_tests/shell/tst_all_filesystems_skip.sh

 lib/newlib_tests/shell/tst_all_filesystems.sh | 27 +++++++++++++++++++
 .../shell/tst_all_filesystems_skip.sh         | 16 +++++++++++
 lib/tst_supported_fs_types.c                  |  2 +-
 3 files changed, 44 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..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
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 41d9bcd27..35ec82071 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] 38+ messages in thread

* [LTP] [PATCH v5 10/10] df01.sh: Convert to TST_ALL_FILESYSTEMS=1
  2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (8 preceding siblings ...)
  2022-09-09 14:18 ` [LTP] [PATCH v5 09/10] shell: Add tests for TST_ALL_FILESYSTEMS=1 Petr Vorel
@ 2022-09-09 14:18 ` Petr Vorel
  9 siblings, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-09 14:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Reviewed-by: Li Wang <liwang@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
The same as in v4

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


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

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

* Re: [LTP] [PATCH v5 01/10] shell: Print mount command in tst_mount()
  2022-09-09 14:18 ` [LTP] [PATCH v5 01/10] shell: Print mount command in tst_mount() Petr Vorel
@ 2022-09-12 10:02   ` Cyril Hrubis
  0 siblings, 0 replies; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-12 10: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] 38+ messages in thread

* Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
  2022-09-09 14:18 ` [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests Petr Vorel
@ 2022-09-12 10:03   ` Cyril Hrubis
  2022-09-12 10:12     ` Petr Vorel
  2022-09-13 13:52   ` Petr Vorel
  1 sibling, 1 reply; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-12 10:03 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

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

Another option would actually be to make the TST_NEED_DEVICE flag imply
TST_NEEDS_ROOT flag, but I do not think that we have that for the C
library either.

Either way this is fine as well:

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

> Reviewed-by: Li Wang <liwang@redhat.com>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> The same as in v4
> 
>  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.3
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
  2022-09-12 10:03   ` Cyril Hrubis
@ 2022-09-12 10:12     ` Petr Vorel
  2022-09-12 10:24       ` Cyril Hrubis
  0 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-12 10:12 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

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

> Another option would actually be to make the TST_NEED_DEVICE flag imply
> TST_NEEDS_ROOT flag, but I do not think that we have that for the C
> library either.
No, it does not imply in C API either. Yes, that would make sense for both API.
But I'd keep it as it is now and I'll do this change after the release,
Because I have other small fixes on API I'd like to post before the release.

BTW I always wondered why it was not done from the start, I thought there is a
reason for that (i.e. some special user with approved permissions).

> Either way this is fine as well:

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

Thanks!

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
  2022-09-12 10:12     ` Petr Vorel
@ 2022-09-12 10:24       ` Cyril Hrubis
  2022-09-12 11:15         ` Petr Vorel
  0 siblings, 1 reply; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-12 10:24 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > > 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.
> 
> > Another option would actually be to make the TST_NEED_DEVICE flag imply
> > TST_NEEDS_ROOT flag, but I do not think that we have that for the C
> > library either.
> No, it does not imply in C API either. Yes, that would make sense for both API.
> But I'd keep it as it is now and I'll do this change after the release,
> Because I have other small fixes on API I'd like to post before the release.
> 
> BTW I always wondered why it was not done from the start, I thought there is a
> reason for that (i.e. some special user with approved permissions).

Well technically you can be added into whatever group is set to
/dev/loop-control e.g. disk group and then you can create devices
without a need to be a root.

So the most correct solution would be checking if we can access
/dev/loop-control if tst_test.needs_device is set and if not we would
imply needs_root. However this would need to be rethinked properly so
that we do not end up creating something complex and not really
required.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
  2022-09-12 10:24       ` Cyril Hrubis
@ 2022-09-12 11:15         ` Petr Vorel
  0 siblings, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-12 11:15 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

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

> > > Another option would actually be to make the TST_NEED_DEVICE flag imply
> > > TST_NEEDS_ROOT flag, but I do not think that we have that for the C
> > > library either.
> > No, it does not imply in C API either. Yes, that would make sense for both API.
> > But I'd keep it as it is now and I'll do this change after the release,
> > Because I have other small fixes on API I'd like to post before the release.

> > BTW I always wondered why it was not done from the start, I thought there is a
> > reason for that (i.e. some special user with approved permissions).

> Well technically you can be added into whatever group is set to
> /dev/loop-control e.g. disk group and then you can create devices
> without a need to be a root.

> So the most correct solution would be checking if we can access
> /dev/loop-control if tst_test.needs_device is set and if not we would
> imply needs_root. However this would need to be rethinked properly so
> that we do not end up creating something complex and not really
> required.
Agree. I wonder if anybody tests with this setup.
I guess people just test with root (which is the reason why some tests have to
switch to nobody).

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
  2022-09-09 14:18 ` [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs Petr Vorel
@ 2022-09-12 11:21   ` Petr Vorel
  2022-09-12 14:59   ` Cyril Hrubis
  2022-09-13 13:46   ` Petr Vorel
  2 siblings, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-12 11:21 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Hi all,

thread for v4 [1] [2] should have been for v5.

Therefore repeat here there will be diff below:
FYI if anybody wants to test v5 with this fix, it's in my fork in branch
shell/all_filesystems.v5.fixes [3]

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/5e01e854-7cc6-7b08-d1f8-7f0709fbc07d@suse.cz/
[2] https://lore.kernel.org/ltp/Yx7GPOsudkoRn5Nd@pevik/
[3] https://github.com/pevik/ltp/commits/shell/all_filesystems.v5.fixes

diff --git lib/tst_supported_fs_types.c lib/tst_supported_fs_types.c
index 35ec82071..80d0d163a 100644
--- lib/tst_supported_fs_types.c
+++ lib/tst_supported_fs_types.c
@@ -138,17 +138,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 related	[flat|nested] 38+ messages in thread

* Re: [LTP] [PATCH v5 04/10] tst_supported_fs: Implement skip list
  2022-09-09 14:18 ` [LTP] [PATCH v5 04/10] tst_supported_fs: Implement skip list Petr Vorel
@ 2022-09-12 14:39   ` Cyril Hrubis
  2022-09-12 20:15     ` Petr Vorel
  0 siblings, 1 reply; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-12 14:39 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> +static char **parse_skiplist(char *fs)
> +{
> +	char **skiplist = NULL;

There is no point in initializing variables that are not read before
they are assigned.

Other than that:

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] 38+ messages in thread

* Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
  2022-09-09 14:18 ` [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported Petr Vorel
@ 2022-09-12 14:42   ` Cyril Hrubis
  2022-09-12 20:29     ` Petr Vorel
  0 siblings, 1 reply; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-12 14:42 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> Although this is unlikely, it can happen.
> This means 32 (TCONF) instead of 0 exit code when searching for all
> filesystems and 32 instead of 1 when searching for a particular
> filesystem.
> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> New in v5
> 
> NOTE:
> 
> Although this will later leads to duplicating message (see below) it's
> IMHO better because LVM scripts and zram01.sh use this helper directly.
> 
> Tests added in later commits which demonstrates TCONF:

Shouldn't we rather than this add tst_res(TCONF, "...") messages to the
lib/tst_supported_fs_types.c so that we get consistent messages between
C and shell?

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
  2022-09-09 14:18 ` [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs Petr Vorel
  2022-09-12 11:21   ` Petr Vorel
@ 2022-09-12 14:59   ` Cyril Hrubis
  2022-09-12 20:38     ` Petr Vorel
  2022-09-13 13:46   ` Petr Vorel
  2 siblings, 1 reply; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-12 14:59 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
Shouldn't this one go before the addition of the functionality to the wrapper used by shell?

Other than that:

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] 38+ messages in thread

* Re: [LTP] [PATCH v5 06/10] shell: Add $TST_SKIP_FILESYSTEMS + tests
  2022-09-09 14:18 ` [LTP] [PATCH v5 06/10] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
@ 2022-09-12 15:10   ` Cyril Hrubis
  2022-09-12 20:43     ` Petr Vorel
  0 siblings, 1 reply; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-12 15:10 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> 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>
> ---
> changes v4->v5:
> * add fuse to lib/newlib_tests/shell/tst_skip_filesystems.sh
> 
>  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 cde162555..41d9bcd27 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

So we actually depend here on the tst_supported_fs return value. So at
least we have to do return TCONF in the helper binary even if ve move
the messages into the library.

>  	_tst_setup_timer
>  
>  	[ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1
> -- 
> 2.37.3
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
  2022-09-09 14:18 ` [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE Petr Vorel
@ 2022-09-12 15:28   ` Cyril Hrubis
  2022-09-12 20:04     ` Petr Vorel
  0 siblings, 1 reply; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-12 15:28 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> @@ -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
>  }

I just wonder if this is worth being added to the test library just for
a single test. Or do you expect this to be usable in more than df01.sh?

Also maybe it would be a better as a function so that the code does not
run unconditionally on each tst_mount() call?

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
  2022-09-12 15:28   ` Cyril Hrubis
@ 2022-09-12 20:04     ` Petr Vorel
  2022-09-13  8:15       ` Cyril Hrubis
  0 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-12 20:04 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > @@ -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
> >  }

> I just wonder if this is worth being added to the test library just for
> a single test. Or do you expect this to be usable in more than df01.sh?
Well, the inspiration was the C API, which also allows to skip fuse.
But sure, I can handle it just in df01.sh, just let me know the result.

> Also maybe it would be a better as a function so that the code does not
> run unconditionally on each tst_mount() call?
Do you mean e.g. tst_is_fuse() and df01.sh would call it?

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 04/10] tst_supported_fs: Implement skip list
  2022-09-12 14:39   ` Cyril Hrubis
@ 2022-09-12 20:15     ` Petr Vorel
  0 siblings, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-12 20:15 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > +static char **parse_skiplist(char *fs)
> > +{
> > +	char **skiplist = NULL;

> There is no point in initializing variables that are not read before
> they are assigned.
Good catch, thanks!
I'll fix it in next version or before pushing.

Kind regards,
Petr

> Other than that:

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

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

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

* Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
  2022-09-12 14:42   ` Cyril Hrubis
@ 2022-09-12 20:29     ` Petr Vorel
  2022-09-13  8:11       ` Cyril Hrubis
  0 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-12 20:29 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

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

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

> > NOTE:

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

> > Tests added in later commits which demonstrates TCONF:

> Shouldn't we rather than this add tst_res(TCONF, "...") messages to the
> lib/tst_supported_fs_types.c so that we get consistent messages between
> C and shell?

Well, in v4 I add TCONF in tst_fs_is_supported_skiplist()
(lib/tst_supported_fs_types.c), but you asked for TST_FS_UNSUPPORTED [1].

This function is used only in testcases/lib/tst_supported_fs.c, i.e. in shell.
C API handles skip list in do_test_setup() (lib/tst_test.c). I don't like this
inconsistency either, but not sure now how to put common code to
lib/tst_supported_fs_types.c (new function).

There is also inconsistency in "There are no supported filesystems"
(run_tcases_per_fs in lib/tst_test.c) and "There are no supported filesystems or
all skipped" in testcases/lib/tst_supported_fs.c. I'm not sure if it's worth to
add function tst_loop_per_fs (or macro in kernel style TST_FOR_EACH_FS()), so
that check and TCONF would be on single place.

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/YxsKz9j1mVHIhcfw@yuki/

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

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

* Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
  2022-09-12 14:59   ` Cyril Hrubis
@ 2022-09-12 20:38     ` Petr Vorel
  2022-09-13  8:14       ` Cyril Hrubis
  0 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-12 20:38 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> Shouldn't this one go before the addition of the functionality to the wrapper used by shell?
Do you mean to put this ("tst_supported_fs: Support skip list when query single
fs") before the previous ("tst_supported_fs: Implement skip list")?

Originally I had these 2 commits in squashed in single commit. But it was quite
big, thus I implemented skip list just for all filesystems and then for
particular filesystem.

Maybe "tst_supported_fs: Implement skip list" should be "tst_supported_fs:
Implement skip list for all fs".

Or did you mean something else?

Kind regards,
Petr

> Other than that:

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

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

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

* Re: [LTP] [PATCH v5 06/10] shell: Add $TST_SKIP_FILESYSTEMS + tests
  2022-09-12 15:10   ` Cyril Hrubis
@ 2022-09-12 20:43     ` Petr Vorel
  0 siblings, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-12 20:43 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

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

> So we actually depend here on the tst_supported_fs return value. So at
> least we have to do return TCONF in the helper binary even if ve move
> the messages into the library.

Yes. This is the equivalent of code in do_test_setup() (i.e. handling skipped
filesystems when testing single filesystem - *not* doing all filesystems loop).

Again, have C API function for looping filesystems and for single
filesystem would help avoiding duplicity, but not sure how to keep things simple
and readable. I'll try to think about it, but hints are welcome :).

Kind regards,
Petr

> >  	_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	[flat|nested] 38+ messages in thread

* Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
  2022-09-12 20:29     ` Petr Vorel
@ 2022-09-13  8:11       ` Cyril Hrubis
  2022-09-13  9:29         ` Petr Vorel
  0 siblings, 1 reply; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-13  8:11 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > Shouldn't we rather than this add tst_res(TCONF, "...") messages to the
> > lib/tst_supported_fs_types.c so that we get consistent messages between
> > C and shell?
> 
> Well, in v4 I add TCONF in tst_fs_is_supported_skiplist()
> (lib/tst_supported_fs_types.c), but you asked for TST_FS_UNSUPPORTED [1].

I guess that we misunderstand each other. I'm fine with the library
printing messages, what I didn't like was the tst_brk() which made the
whole program execution flow obscured.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
  2022-09-12 20:38     ` Petr Vorel
@ 2022-09-13  8:14       ` Cyril Hrubis
  2022-09-13  9:36         ` Petr Vorel
  0 siblings, 1 reply; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-13  8:14 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > Shouldn't this one go before the addition of the functionality to the wrapper used by shell?
> Do you mean to put this ("tst_supported_fs: Support skip list when query single
> fs") before the previous ("tst_supported_fs: Implement skip list")?

Yes, as far as I can tell this commit implement function that is called
from the previous patch.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
  2022-09-12 20:04     ` Petr Vorel
@ 2022-09-13  8:15       ` Cyril Hrubis
  2022-09-13  8:37         ` Petr Vorel
  2022-09-13 14:30         ` Petr Vorel
  0 siblings, 2 replies; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-13  8:15 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > Also maybe it would be a better as a function so that the code does not
> > run unconditionally on each tst_mount() call?
> Do you mean e.g. tst_is_fuse() and df01.sh would call it?

Yes that looks slightly cleaner than adding another variable.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
  2022-09-13  8:15       ` Cyril Hrubis
@ 2022-09-13  8:37         ` Petr Vorel
  2022-09-13 14:30         ` Petr Vorel
  1 sibling, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-13  8:37 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > > Also maybe it would be a better as a function so that the code does not
> > > run unconditionally on each tst_mount() call?
> > Do you mean e.g. tst_is_fuse() and df01.sh would call it?

> Yes that looks slightly cleaner than adding another variable.
OK, I'll fix it in v7. I put it into tst_test.sh, but if you prefer to have this
function just in df01.sh (called as is_fuse) until anything else needs it that
would work for me as well.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
  2022-09-13  8:11       ` Cyril Hrubis
@ 2022-09-13  9:29         ` Petr Vorel
  2022-09-13 13:08           ` Petr Vorel
  0 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-13  9:29 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > > Shouldn't we rather than this add tst_res(TCONF, "...") messages to the
> > > lib/tst_supported_fs_types.c so that we get consistent messages between
> > > C and shell?

> > Well, in v4 I add TCONF in tst_fs_is_supported_skiplist()
> > (lib/tst_supported_fs_types.c), but you asked for TST_FS_UNSUPPORTED [1].

> I guess that we misunderstand each other. I'm fine with the library
> printing messages, what I didn't like was the tst_brk() which made the
> whole program execution flow obscured.

OK, instead of this from v4:
> +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
> +		tst_brk(TCONF, "%s is not supported by the test",
> +			fs_type);

I'll add in v6:
> +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
> +		tst_res(TCONF, "%s is not supported by the test",
> +			fs_type);
> +		return TST_FS_UNSUPPORTED;
> +	}

I'll add tst_res(TINFO, "%s is supported by the test", fs_name);
from do_test_setup() tst_fs_is_supported_skiplist() and call
tst_fs_is_supported_skiplist() in do_test_setup().

But not sure if there can be a cleanup of duplicity of:
if (!filesystems[0])
	tst_brk(TCONF, "There are no supported filesystems")

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
  2022-09-13  8:14       ` Cyril Hrubis
@ 2022-09-13  9:36         ` Petr Vorel
  2022-09-13 10:53           ` Cyril Hrubis
  0 siblings, 1 reply; 38+ messages in thread
From: Petr Vorel @ 2022-09-13  9:36 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > > Shouldn't this one go before the addition of the functionality to the wrapper used by shell?
> > Do you mean to put this ("tst_supported_fs: Support skip list when query single
> > fs") before the previous ("tst_supported_fs: Implement skip list")?

> Yes, as far as I can tell this commit implement function that is called
> from the previous patch.
I'm really slow on this. Which function do you mean please?

"[v5,05/10] tst_supported_fs: Support skip list when query single fs" implements
just tst_fs_is_supported_skiplist() which is not used in "[v5,04/10]
tst_supported_fs: Implement skip list".

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
  2022-09-13  9:36         ` Petr Vorel
@ 2022-09-13 10:53           ` Cyril Hrubis
  0 siblings, 0 replies; 38+ messages in thread
From: Cyril Hrubis @ 2022-09-13 10:53 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > Yes, as far as I can tell this commit implement function that is called
> > from the previous patch.
> I'm really slow on this. Which function do you mean please?
> 
> "[v5,05/10] tst_supported_fs: Support skip list when query single fs" implements
> just tst_fs_is_supported_skiplist() which is not used in "[v5,04/10]
> tst_supported_fs: Implement skip list".

My bad, I confused the tst_fs_is_suppored() and
tst_fs_is_supported_skiplist() yesterday.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
  2022-09-13  9:29         ` Petr Vorel
@ 2022-09-13 13:08           ` Petr Vorel
  0 siblings, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-13 13:08 UTC (permalink / raw)
  To: Cyril Hrubis, ltp, Li Wang, Richard Palethorpe, Martin Doucha, Yang Xu

> > Hi!
> > > > Shouldn't we rather than this add tst_res(TCONF, "...") messages to the
> > > > lib/tst_supported_fs_types.c so that we get consistent messages between
> > > > C and shell?

> > > Well, in v4 I add TCONF in tst_fs_is_supported_skiplist()
> > > (lib/tst_supported_fs_types.c), but you asked for TST_FS_UNSUPPORTED [1].

> > I guess that we misunderstand each other. I'm fine with the library
> > printing messages, what I didn't like was the tst_brk() which made the
> > whole program execution flow obscured.

> OK, instead of this from v4:
> > +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
> > +		tst_brk(TCONF, "%s is not supported by the test",
> > +			fs_type);

> I'll add in v6:
> > +	if (tst_fs_in_skiplist(fs_type, skiplist)) {
> > +		tst_res(TCONF, "%s is not supported by the test",
> > +			fs_type);
> > +		return TST_FS_UNSUPPORTED;
> > +	}

> I'll add tst_res(TINFO, "%s is supported by the test", fs_name);
> from do_test_setup() tst_fs_is_supported_skiplist() and call
> tst_fs_is_supported_skiplist() in do_test_setup().

> But not sure if there can be a cleanup of duplicity of:
> if (!filesystems[0])
> 	tst_brk(TCONF, "There are no supported filesystems")

In order to unify the API I suggest to move the check above to
tst_get_supported_fs_types() in lib/tst_supported_fs_types.c.
This function is used only on lib/tst_test.c (and will be now in
testcases/lib/tst_supported_fs.c) and uses static array fs_types.
I see no point to add wrapper which would contain this check just to keep
tst_get_supported_fs_types() without tst_brk().
@Cyril WDYT?

Kind regards,
Petr

> Kind regards,
> Petr

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

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

* Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
  2022-09-09 14:18 ` [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs Petr Vorel
  2022-09-12 11:21   ` Petr Vorel
  2022-09-12 14:59   ` Cyril Hrubis
@ 2022-09-13 13:46   ` Petr Vorel
  2 siblings, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-13 13:46 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Hi,

there are 2 errors, 2) needs more thinking.

> And use this feature in zram01.sh
1) zram01.sh check in "all_filesystem" mode, thus it should not be changed here,
but in the separate commit.

> +/*
> + * 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..cde162555 100644
> --- a/lib/tst_supported_fs_types.c
> +++ b/lib/tst_supported_fs_types.c
> @@ -134,6 +134,22 @@ 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);
2) while this function might be useful in the future, now it's not what is
needed... Because for single filesystem does not need check for mkfs.foo.
> +
> +	if (!ret)
> +		return ret;
> +
> +	if (tst_fs_in_skiplist(fs_type, skiplist))
> +		return TST_FS_UNSUPPORTED;
> +
> +	return ret;
> +}

There should be new function with code moved from do_test_setup():

void tst_fs_is_current_fs_supported(const char *fs_name, const char *const *skiplist)
{
	if (tst_fs_in_skiplist(fs_name, skiplist))
		tst_brk(TCONF, "%s is not supported by the test", fs_name);

	tst_res(TINFO, "%s is supported by the test", fs_name);
}

I know you want tst_res(TCONF) in the library, that means I'd have to
call tst_vbrk_(), right? Because we have message already printed.
Maybe different function prefix could help.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
  2022-09-09 14:18 ` [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests Petr Vorel
  2022-09-12 10:03   ` Cyril Hrubis
@ 2022-09-13 13:52   ` Petr Vorel
  1 sibling, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-13 13:52 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Hi all,

merged this and previous commit.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
  2022-09-13  8:15       ` Cyril Hrubis
  2022-09-13  8:37         ` Petr Vorel
@ 2022-09-13 14:30         ` Petr Vorel
  1 sibling, 0 replies; 38+ messages in thread
From: Petr Vorel @ 2022-09-13 14:30 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > > Also maybe it would be a better as a function so that the code does not
> > > run unconditionally on each tst_mount() call?
> > Do you mean e.g. tst_is_fuse() and df01.sh would call it?

> Yes that looks slightly cleaner than adding another variable.
In the end I add custom code to df01.sh, that's really better until some other
test needs to detects fuse.

Kind regards,
Petr

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

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

end of thread, other threads:[~2022-09-13 14:31 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09 14:18 [LTP] [PATCH v5 00/10] shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
2022-09-09 14:18 ` [LTP] [PATCH v5 01/10] shell: Print mount command in tst_mount() Petr Vorel
2022-09-12 10:02   ` Cyril Hrubis
2022-09-09 14:18 ` [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests Petr Vorel
2022-09-12 10:03   ` Cyril Hrubis
2022-09-12 10:12     ` Petr Vorel
2022-09-12 10:24       ` Cyril Hrubis
2022-09-12 11:15         ` Petr Vorel
2022-09-13 13:52   ` Petr Vorel
2022-09-09 14:18 ` [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported Petr Vorel
2022-09-12 14:42   ` Cyril Hrubis
2022-09-12 20:29     ` Petr Vorel
2022-09-13  8:11       ` Cyril Hrubis
2022-09-13  9:29         ` Petr Vorel
2022-09-13 13:08           ` Petr Vorel
2022-09-09 14:18 ` [LTP] [PATCH v5 04/10] tst_supported_fs: Implement skip list Petr Vorel
2022-09-12 14:39   ` Cyril Hrubis
2022-09-12 20:15     ` Petr Vorel
2022-09-09 14:18 ` [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs Petr Vorel
2022-09-12 11:21   ` Petr Vorel
2022-09-12 14:59   ` Cyril Hrubis
2022-09-12 20:38     ` Petr Vorel
2022-09-13  8:14       ` Cyril Hrubis
2022-09-13  9:36         ` Petr Vorel
2022-09-13 10:53           ` Cyril Hrubis
2022-09-13 13:46   ` Petr Vorel
2022-09-09 14:18 ` [LTP] [PATCH v5 06/10] shell: Add $TST_SKIP_FILESYSTEMS + tests Petr Vorel
2022-09-12 15:10   ` Cyril Hrubis
2022-09-12 20:43     ` Petr Vorel
2022-09-09 14:18 ` [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE Petr Vorel
2022-09-12 15:28   ` Cyril Hrubis
2022-09-12 20:04     ` Petr Vorel
2022-09-13  8:15       ` Cyril Hrubis
2022-09-13  8:37         ` Petr Vorel
2022-09-13 14:30         ` Petr Vorel
2022-09-09 14:18 ` [LTP] [PATCH v5 08/10] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
2022-09-09 14:18 ` [LTP] [PATCH v5 09/10] shell: Add tests for TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-09-09 14:18 ` [LTP] [PATCH v5 10/10] df01.sh: Convert to TST_ALL_FILESYSTEMS=1 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.