Skip to contentSkip to conversation

shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems)

PATCH Superseded Petr Vorel 4 participants 28 messages Sep 2, 2022 – Sep 12, 2022 Library code

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

v4 cover shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems)

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
Signature · 5 lines
2.37.2


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

PATCH v4 1/9 shell: Print mount command in tst_mount()

---
 testcases/lib/tst_test.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/lib/tst_test.sh +3 -1
index f884a278d..7c97b69fe 100644
@@ -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
Signature · 5 lines
2.37.2


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

PATCH v4 2/9 shell API/tests: Require root for TST_{FORMAT, MOUNT}_DEVICE

In reply to Petr Vorel

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.

---
 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(+)
lib/newlib_tests/shell/tst_format_device.sh +1 -0
index 73a919086..dbe4ea9e7 100755
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <[email protected]>
 
 TST_FORMAT_DEVICE=1
+TST_NEEDS_ROOT=1
 TST_TESTFUNC=test
 TST_CNT=2
 TST_DEV_FS_OPTS="-b 1024"
lib/newlib_tests/shell/tst_mount_device.sh +1 -0
index 561f878d2..70f80f84a 100755
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <[email protected]>
 
 TST_MOUNT_DEVICE=1
+TST_NEEDS_ROOT=1
 TST_FS_TYPE=ext4
 TST_TESTFUNC=test
 TST_CNT=3
lib/newlib_tests/shell/tst_mount_device_tmpfs.sh +1 -0
index 36a78bc85..ed2ba8c50 100755
@@ -3,6 +3,7 @@
 # Copyright (c) 2022 Petr Vorel <[email protected]>
 
 TST_MOUNT_DEVICE=1
+TST_NEEDS_ROOT=1
 TST_FS_TYPE=tmpfs
 TST_TESTFUNC=test
 
Signature · 5 lines
2.37.2


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

PATCH v4 3/9 tst_supported_fs: Implement skip list

In reply to Petr Vorel

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.

---
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(-)
testcases/lib/tst_supported_fs.c +44 -12
index 43eac194f..87be2b759 100644
@@ -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]);
 
testcases/misc/lvm/generate_lvm_runfile.sh +1 -1
index 477aed116..7f7e149d9 100755
@@ -17,7 +17,7 @@ generate_runfile()
 	trap '[ $? -eq 0 ] || tst_brk TBROK "Cannot create LVM runfile"' EXIT
 	INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl"
 	OUTFILE="$LTPROOT/runtest/lvm.local"
-	FS_LIST=`tst_supported_fs`
+	FS_LIST=$(tst_supported_fs -s tmpfs)
 	echo -n "" >"$OUTFILE"
 
 	for fsname in $FS_LIST; do
testcases/misc/lvm/prepare_lvm.sh +1 -1
index d3ae4b23f..29f386df8 100755
@@ -70,7 +70,7 @@ prepare_mounts()
 
 prepare_lvm()
 {
-	FS_LIST=`tst_supported_fs | sort -u`
+	FS_LIST=$(tst_supported_fs -s tmpfs | sort -u)
 	ROD mkdir -p "$LVM_TMPDIR"
 	ROD mkdir -p "$LVM_IMGDIR"
 	chmod 777 "$LVM_TMPDIR"
Signature · 5 lines
2.37.2


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

Re: [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list

Hi!

Quoted 53 lines

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.

---
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(-)
testcases/lib/tst_supported_fs.c +9 -3
index 43eac194f..87be2b759 100644
@@ -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;
 

testcases/lib/tst_supported_fs.c line 40

Quoted 10 lines
testcases/lib/tst_supported_fs.c +6 -4
-	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?

Quoted 12 lines
testcases/lib/tst_supported_fs.c +12 -0
+			return 1;
+
+		case 'h':
+			usage();
+			return 0;
+
+		case 's':
+			fs = optarg;
+			for (i = 0; fs[i]; i++) {
+				if (optarg[i] == SKIP_DELIMITER)
+					cnt++;
+			}

testcases/lib/tst_supported_fs.c line 62

Quoted 10 lines
testcases/lib/tst_supported_fs.c +10 -0
+			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);
Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list

Hi all,

Quoted 4 lines
Quoted 4 lines
testcases/lib/tst_supported_fs.c +0 -4
-	if (argc > 2) {
-		fprintf(stderr, "Can't specify multiple fs_type\n");
-		usage();
-		return 2;
Quoted 8 lines

testcases/lib/tst_supported_fs.c line 40

Quoted 6 lines
testcases/lib/tst_supported_fs.c +6 -0
+	while ((ret = getopt(argc, argv, "hs:"))) {
+		if (ret < 0)
+			break;
+
+		switch (ret) {
+		case '?':

No usage?

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

Quoted 25 lines
Quoted 12 lines
testcases/lib/tst_supported_fs.c +12 -0
+			return 1;
+
+		case 'h':
+			usage();
+			return 0;
+
+		case 's':
+			fs = optarg;
+			for (i = 0; fs[i]; i++) {
+				if (optarg[i] == SKIP_DELIMITER)
+					cnt++;
+			}

testcases/lib/tst_supported_fs.c line 62

Quoted 10 lines
testcases/lib/tst_supported_fs.c +10 -0
+			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.

Quoted 1 line
	skiplist = parse_skiplist(optarg);

+1, I'll post next version.

Kind regards,
Petr

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

Re: [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list

...

Quoted 5 lines
Quoted 4 lines

testcases/lib/tst_supported_fs.c line 40

Quoted 2 lines
testcases/lib/tst_supported_fs.c +2 -0
+		switch (ret) {
+		case '?':

No usage?

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

I mean to call usage() before return 1.

Kind regards,
Petr

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
testcases/lib/tst_supported_fs.c +5 -0
+			return 1;
+
+		case 'h':
+			usage();
+			return 0;
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#7 lore raw

Re: [LTP] [PATCH v4 3/9] tst_supported_fs: Implement skip list

In reply to Cyril Hrubis
Quoted 8 lines

testcases/lib/tst_supported_fs.c line 62

Quoted 4 lines
testcases/lib/tst_supported_fs.c +4 -0
+			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;
		}
	}

...

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

PATCH v4 4/9 tst_supported_fs: Support skip list when query single fs

In reply to Petr Vorel
---
 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(-)
include/tst_fs.h +10 -0
index cc6d9b547..e399aef54 100644
@@ -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.
  *
lib/tst_supported_fs_types.c +18 -0
index 9726d193a..8c9379c1b 100644
@@ -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;
testcases/lib/tst_supported_fs.c +1 -1
index 87be2b759..75945c809 100644
@@ -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++)
Signature · 5 lines
2.37.2


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

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Hi!

Quoted 40 lines
---
 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(-)
include/tst_fs.h +10 -0
index cc6d9b547..e399aef54 100644
@@ -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.
  *
lib/tst_supported_fs_types.c +3 -0
index 9726d193a..8c9379c1b 100644
@@ -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)
+{

lib/tst_supported_fs_types.c enum tst_fs_impl tst_fs_is_supported(const char *fs_type) · line 149

Quoted 10 lines
lib/tst_supported_fs_types.c +10 -0
+	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, "");

Quoted 24 lines
lib/tst_supported_fs_types.c +5 -0
+	}
+
+	return ret;
+}
+
 const char **tst_get_supported_fs_types(const char *const *skiplist)
 {
 	unsigned int i, j = 0;
testcases/lib/tst_supported_fs.c +1 -1
index 87be2b759..75945c809 100644
@@ -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++)
Signature · 1 line
2.37.2
Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Hi all,

Quoted 5 lines
Quoted 4 lines

+++ b/lib/tst_supported_fs_types.c

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

lib/tst_supported_fs_types.c enum tst_fs_impl tst_fs_is_supported(const char *fs_type) · line 149

Quoted 13 lines
lib/tst_supported_fs_types.c +13 -0
+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

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

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Hi!

Quoted 31 lines
Quoted 5 lines
Quoted 4 lines

+++ b/lib/tst_supported_fs_types.c

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

lib/tst_supported_fs_types.c enum tst_fs_impl tst_fs_is_supported(const char *fs_type) · line 149

Quoted 13 lines
lib/tst_supported_fs_types.c +13 -0
+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

Review int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); · line 175

Quoted 6 lines
(quoted diff) +2 -1
@@ -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

Review int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); · line 178

Quoted 3 lines
(quoted diff) +0 -0
        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.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Quoted 41 lines

Hi!

Quoted 31 lines
Quoted 5 lines
Quoted 4 lines

+++ b/lib/tst_supported_fs_types.c

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

lib/tst_supported_fs_types.c enum tst_fs_impl tst_fs_is_supported(const char *fs_type) · line 149

Quoted 13 lines
lib/tst_supported_fs_types.c +13 -0
+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

Review int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); · line 175

Quoted 6 lines
(quoted diff) +2 -1
@@ -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

Quoted 8 lines

Review int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); · line 178

Quoted 3 lines
(quoted diff) +0 -0
        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

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

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Quoted 6 lines · Petr Vorel
Quoted 5 lines

Hi!

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+++ b/lib/tst_supported_fs_types.c

lib/tst_supported_fs_types.c +0 -0
@@ -134,6 +134,24 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
  	return TST_FS_UNSUPPORTED;
  }
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/tst_supported_fs_types.c +8 -0
+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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

lib/tst_supported_fs_types.c enum tst_fs_impl tst_fs_is_supported(const char *fs_type) · line 149

Quoted 5 lines
lib/tst_supported_fs_types.c +5 -0
+		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.

Quoted 20 lines
Quoted 11 lines

Review int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); · line 175

Quoted 8 lines

+++ b/include/tst_fs.h

(quoted diff) +2 -1
@@ -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

Quoted 8 lines

Review int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); · line 178

Quoted 3 lines
(quoted diff) +0 -0
         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.

Quoted 5 lines

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

Signature · 11 lines
Martin Doucha   [email protected]
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
author
#14 lore raw

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Quoted 24 lines · Petr Vorel
Quoted 6 lines
Quoted 5 lines

Hi!

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+++ b/lib/tst_supported_fs_types.c

lib/tst_supported_fs_types.c +0 -0
@@ -134,6 +134,24 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
  	return TST_FS_UNSUPPORTED;
  }
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/tst_supported_fs_types.c +8 -0
+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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

lib/tst_supported_fs_types.c enum tst_fs_impl tst_fs_is_supported(const char *fs_type) · line 149

Quoted 5 lines
lib/tst_supported_fs_types.c +5 -0
+		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, "");

Quoted 2 lines

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

Quoted 23 lines
Quoted 22 lines
Quoted 11 lines

Review int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); · line 175

Quoted 8 lines

+++ b/include/tst_fs.h

(quoted diff) +2 -1
@@ -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

Quoted 8 lines

Review int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); · line 178

Quoted 3 lines
(quoted diff) +0 -0
         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.

Quoted 6 lines
Quoted 2 lines

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

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

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Quoted 3 lines · Petr Vorel

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.

Signature · 11 lines
Martin Doucha   [email protected]
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
author
#16 lore raw

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Quoted 8 lines · Petr Vorel
Quoted 3 lines

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)

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

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Quoted 5 lines · Petr Vorel
Quoted 3 lines

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.

Quoted 20 lines

+++ lib/tst_supported_fs_types.c

(quoted diff) +1 -8
@@ -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)
Signature · 11 lines
Martin Doucha   [email protected]
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
author
#18 lore raw

Re: [LTP] [PATCH v4 4/9] tst_supported_fs: Support skip list when query single fs

Quoted 8 lines · Petr Vorel
Quoted 5 lines
Quoted 3 lines

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

Quoted 10 lines
Quoted 10 lines

+++ lib/tst_supported_fs_types.c

(quoted diff) +0 -5
@@ -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)
Quoted 8 lines

Review enum tst_fs_impl tst_fs_is_supported(const char *fs_type) · line 144

Quoted 8 lines
(quoted diff) +1 -3
-		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

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

PATCH v4 5/9 shell: Add $TST_SKIP_FILESYSTEMS + tests

In reply to Petr Vorel

C API struct tst_test skip_filesystems member equivalent.

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

---
 doc/shell-test-api.txt                        |  2 ++
 .../shell/tst_skip_filesystems.sh             | 35 +++++++++++++++++++
 .../shell/tst_skip_filesystems_skip.sh        | 17 +++++++++
 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
doc/shell-test-api.txt +2 -0
index 65444541e..18ed144a9 100644
@@ -229,6 +229,8 @@ simply by setting right '$TST_FOO'.
 | 'TST_NEEDS_KCONFIGS'     | Checks kernel kconfigs support for the test (see below).
 | 'TST_NEEDS_KCONFIGS_IFS' | Used for splitting '$TST_NEEDS_KCONFIGS' variable,
                              default value is comma, it only supports single character.
+| 'TST_SKIP_FILESYSTEMS'   | Comma separated list of filesystems on which test will be skipped
+                             (tst_test.skip_filesystems equivalent).
 | 'TST_TIMEOUT'            | Maximum timeout set for the test in sec. Must be int >= 1,
                              or -1 (special value to disable timeout), default is 300.
                              Variable is meant be set in tests, not by user.
lib/newlib_tests/shell/tst_skip_filesystems.sh new file +35 -0
new file mode 100755
index 000000000..d7ce1c202
@@ -0,0 +1,35 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
+
+TST_MOUNT_DEVICE=1
+TST_NEEDS_ROOT=1
+TST_FS_TYPE=ext4
+TST_TESTFUNC=test
+TST_SKIP_FILESYSTEMS="btrfs,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
lib/newlib_tests/shell/tst_skip_filesystems_skip.sh new file +17 -0
new file mode 100755
index 000000000..6748d021d
@@ -0,0 +1,17 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
+
+TST_MOUNT_DEVICE=1
+TST_NEEDS_ROOT=1
+TST_FS_TYPE=ext4
+TST_TESTFUNC=test
+TST_SKIP_FILESYSTEMS="ext4"
+
+test()
+{
+	tst_res TFAIL "test should be skipped with TCONF"
+}
+
+. tst_test.sh
+tst_run
testcases/lib/tst_test.sh +6 -0
index 7c97b69fe..2937bd80c 100644
@@ -626,6 +626,7 @@ tst_run()
 	local _tst_max
 	local _tst_name
 	local _tst_pattern='[='\''"} \t\/:`$\;].*'
+	local ret
 
 	if [ -n "$TST_TEST_PATH" ]; then
 		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do
@@ -644,6 +645,7 @@ tst_run()
 			CHECKPOINT_WAIT|CHECKPOINT_WAKE);;
 			CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);;
 			DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);;
+			SKIP_FILESYSTEMS);;
 			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
 			esac
 		done
@@ -675,6 +677,10 @@ tst_run()
 			tst_brk TCONF "test requires kernel $TST_MIN_KVER+"
 	fi
 
+	tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE
+	ret=$?
+	[ $ret -ne 0 ] && return $ret
+
 	_tst_setup_timer
 
 	[ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1
Signature · 5 lines
2.37.2


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

Re: [LTP] [PATCH v4 5/9] shell: Add $TST_SKIP_FILESYSTEMS + tests

Hi all,

Quoted 12 lines

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

...

lib/newlib_tests/shell/tst_skip_filesystems.sh line 9

Quoted 11 lines

+++ b/lib/newlib_tests/shell/tst_skip_filesystems.sh

lib/newlib_tests/shell/tst_skip_filesystems.sh new file +9 -0
@@ -0,0 +1,35 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
+
+TST_MOUNT_DEVICE=1
+TST_NEEDS_ROOT=1
+TST_FS_TYPE=ext4
+TST_TESTFUNC=test
+TST_SKIP_FILESYSTEMS="btrfs,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

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

PATCH v4 6/9 tst_test.sh: Introduce TST_FS_TYPE_FUSE

In reply to Petr Vorel

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

---
 doc/shell-test-api.txt    |  2 ++
 testcases/lib/tst_test.sh | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
doc/shell-test-api.txt +2 -0
index 18ed144a9..e16080061 100644
@@ -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
testcases/lib/tst_test.sh +13 -1
index 2937bd80c..78dbfc1ce 100644
@@ -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);;
Signature · 5 lines
2.37.2


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

PATCH v4 7/9 tst_test.sh: Add $TST_ALL_FILESYSTEMS

In reply to Petr Vorel

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

Improve also $TST_SKIP_FILESYSTEMS to behave like .skip_filesystems.

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

213 lines not on this page · raw message

Signature · 5 lines
2.37.2


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

PATCH v4 8/9 shell: Add test for TST_ALL_FILESYSTEMS=1

In reply to Petr Vorel

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

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

---
 lib/newlib_tests/shell/tst_all_filesystems.sh | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh
lib/newlib_tests/shell/tst_all_filesystems.sh new file +27 -0
new file mode 100755
index 000000000..0ee1ab240
@@ -0,0 +1,27 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
+
+TST_ALL_FILESYSTEMS=1
+TST_NEEDS_ROOT=1
+TST_TESTFUNC=test
+TST_CNT=2
+
+test1()
+{
+	tst_res TPASS "device using filesystem"
+}
+
+test2()
+{
+	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
Signature · 5 lines
2.37.2


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

PATCH v4 9/9 df01.sh: Convert to TST_ALL_FILESYSTEMS=1

In reply to Petr Vorel
---
 runtest/commands              |  8 +-------
 runtest/smoketest             |  2 +-
 testcases/commands/df/df01.sh | 32 +++++++++-----------------------
 3 files changed, 11 insertions(+), 31 deletions(-)
runtest/commands +1 -7
index 8cfad0449..5ec2c3b69 100644
@@ -14,13 +14,7 @@ ln01_sh ln_tests.sh
 mkdir01_sh mkdir_tests.sh
 mv01_sh mv_tests.sh
 du01_sh du01.sh
-df01_ext2_sh df01.sh -f ext2
-df01_ext3_sh df01.sh -f ext3
-df01_ext4_sh df01.sh -f ext4
-df01_xfs_sh df01.sh -f xfs
-df01_vfat_sh df01.sh -f vfat
-df01_exfat_sh df01.sh -f exfat
-df01_ntfs_sh df01.sh -f ntfs
+df01_sh df01.sh
 mkfs01_sh mkfs01.sh
 mkfs01_ext2_sh mkfs01.sh -f ext2
 mkfs01_ext3_sh mkfs01.sh -f ext3
runtest/smoketest +1 -1
index 485f211fb..83eebfe7b 100644
@@ -12,7 +12,7 @@ stat04 symlink01 -T stat04
 utime01A symlink01 -T utime01
 rename01A symlink01 -T rename01
 splice02 splice02 -s 20
-df01_ext4_sh df01.sh -f ext4
+df01_sh df01.sh
 shell_test01 echo "SUCCESS" | shell_pipe01.sh
 ping602 ping02.sh -6
 macsec02 macsec02.sh
testcases/commands/df/df01.sh +9 -23
index 1e86d1c40..ddfa9d9a7 100755
@@ -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
Signature · 5 lines
2.37.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on the v4 series
#25 lore raw
In reply to Petr Vorel

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.

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#26 lore raw

Hi Li,

Quoted 3 lines

Hi Petr,

The whole patch set looks nice!

Thanks a lot for your time to review!

Quoted 3 lines

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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#27 lore raw
Quoted 16 lines · Petr Vorel

Hi Li,

Quoted 3 lines

Hi Petr,

The whole patch set looks nice!

Thanks a lot for your time to review!

Quoted 3 lines

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

Quoted 8 lines

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.

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp