All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems)
@ 2022-05-12 19:45 Petr Vorel
  2022-05-12 19:45 ` [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
                   ` (7 more replies)
  0 siblings, 8 replies; 27+ messages in thread
From: Petr Vorel @ 2022-05-12 19:45 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

Hi,

.all_filesystems implementation for shell.
Motivation is to add .all_filesystems for shell NFS tests.
Now added to nfs07.sh (fast test).

It required to export tst_clear_device() for shell via tst_clear_device.c.
TODO: doc
NOTE: df01.sh and mkfs01.sh should probably be converted to use it.

Kind regards,
Petr

Petr Vorel (8):
  tst_test.sh: Add $TST_MOUNT_DEVICE
  df01.sh: Use TST_MOUNT_DEVICE=1
  tst_test.sh: Improve pattern for allowed variables
  shell: Add test for TST_MOUNT_DEVICE=1
  shell: Add tst_clear_device
  tst_test.sh: Add $TST_ALL_FILESYSTEMS
  shell: Add test for TST_ALL_FILESYSTEMS=1
  nfs07.sh: Use TST_ALL_FILESYSTEMS=1

 doc/shell-test-api.txt                        |   3 +
 lib/newlib_tests/shell/tst_all_filesystems.sh |  27 +++++
 lib/newlib_tests/shell/tst_mount_device.sh    |  21 ++++
 testcases/commands/df/df01.sh                 |   5 +-
 testcases/lib/.gitignore                      |   1 +
 testcases/lib/Makefile                        |   2 +-
 testcases/lib/tst_clear_device.c              |  47 ++++++++
 testcases/lib/tst_test.sh                     | 104 ++++++++++++------
 testcases/network/nfs/nfs_stress/nfs07.sh     |   2 +
 9 files changed, 176 insertions(+), 36 deletions(-)
 create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh
 create mode 100755 lib/newlib_tests/shell/tst_mount_device.sh
 create mode 100644 testcases/lib/tst_clear_device.c

-- 
2.36.0


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

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

* [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE
  2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
@ 2022-05-12 19:45 ` Petr Vorel
  2022-05-30 14:04   ` Cyril Hrubis
  2022-05-12 19:45 ` [LTP] [PATCH 2/8] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 27+ messages in thread
From: Petr Vorel @ 2022-05-12 19:45 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

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

diff --git a/doc/shell-test-api.txt b/doc/shell-test-api.txt
index df5ebbdf0..65444541e 100644
--- a/doc/shell-test-api.txt
+++ b/doc/shell-test-api.txt
@@ -214,6 +214,8 @@ simply by setting right '$TST_FOO'.
                              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
                              https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#formatting-device-with-a-filesystem[Formatting device with a filesystem].
+| 'TST_MOUNT_DEVICE'       | Mount device, see
+                             https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#mounting-and-unmounting-filesystems[Mounting and unmounting filesystems].
 | 'TST_NEEDS_ROOT'         | Exit the test with 'TCONF' unless executed under root.
                              Alternatively the 'tst_require_root' command can be used.
 | 'TST_NEEDS_TMPDIR'       | Create test temporary directory and cd into it.
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 28b7d12ba..1fe77d50d 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -41,6 +41,10 @@ _tst_do_exit()
 		fi
 	fi
 
+	if [ "$TST_MOUNT_DEVICE" = 1 -a "$TST_MOUNT_FLAG" = 1 ]; then
+		tst_umount
+	fi
+
 	if [ "$TST_NEEDS_DEVICE" = 1 -a "$TST_DEVICE_FLAG" = 1 ]; then
 		if ! tst_device release "$TST_DEVICE"; then
 			tst_res TWARN "Failed to release device '$TST_DEVICE'"
@@ -632,7 +636,7 @@ tst_run()
 			NET_SKIP_VARIABLE_INIT|NEEDS_CHECKPOINTS);;
 			CHECKPOINT_WAIT|CHECKPOINT_WAKE);;
 			CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);;
-			DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE);;
+			DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);;
 			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
 			esac
 		done
@@ -666,6 +670,7 @@ tst_run()
 
 	_tst_setup_timer
 
+	[ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1
 	[ "$TST_FORMAT_DEVICE" = 1 ] && TST_NEEDS_DEVICE=1
 	[ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1
 
@@ -702,6 +707,11 @@ tst_run()
 		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
+
 	[ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints
 
 	if [ -n "$TST_SETUP" ]; then
-- 
2.36.0


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

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

* [LTP] [PATCH 2/8] df01.sh: Use TST_MOUNT_DEVICE=1
  2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
  2022-05-12 19:45 ` [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
@ 2022-05-12 19:45 ` Petr Vorel
  2022-05-30 14:13   ` Cyril Hrubis
  2022-05-12 19:45 ` [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables Petr Vorel
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 27+ messages in thread
From: Petr Vorel @ 2022-05-12 19:45 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/commands/df/df01.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index f74032c96..976e205bf 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -1,19 +1,19 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) 2015 Fujitsu Ltd.
+# Copyright (c) 2018-2022 Petr Vorel <pvorel@suse.cz>
 # Author: Zhang Jin <jy_zhangjin@cn.fujitsu.com>
 #
 # Test df command with some basic options.
 
 TST_CNT=12
 TST_SETUP=setup
-TST_CLEANUP=tst_umount
 TST_TESTFUNC=test
 TST_OPTS="f:"
 TST_USAGE=usage
 TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
-TST_FORMAT_DEVICE=1
+TST_MOUNT_DEVICE=1
 
 usage()
 {
@@ -34,7 +34,6 @@ parse_args()
 
 setup()
 {
-	tst_mount
 	DF_FS_TYPE=$(mount | grep "$TST_DEVICE" | awk 'NR==1{print $5}')
 }
 
-- 
2.36.0


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

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

* [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables
  2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
  2022-05-12 19:45 ` [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
  2022-05-12 19:45 ` [LTP] [PATCH 2/8] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
@ 2022-05-12 19:45 ` Petr Vorel
  2022-05-30 14:21   ` Cyril Hrubis
  2022-05-12 19:45 ` [LTP] [PATCH 4/8] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 27+ messages in thread
From: Petr Vorel @ 2022-05-12 19:45 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

to allow using '... $TST_FOO'

i.e. without filtering '
EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts"
would produce warning:
tst_mount_device 1 TWARN: Reserved variable TST_FS_TYPE' used!
because sed filters it as: FS_TYPE'

Will be needed for next commit.

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

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 1fe77d50d..0f1a63aac 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -621,7 +621,7 @@ tst_run()
 	local _tst_name
 
 	if [ -n "$TST_TEST_PATH" ]; then
-		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
+		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`'"'"'].*//'); do
 			case "$_tst_i" in
 			DISABLE_APPARMOR|DISABLE_SELINUX);;
 			SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
-- 
2.36.0


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

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

* [LTP] [PATCH 4/8] shell: Add test for TST_MOUNT_DEVICE=1
  2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (2 preceding siblings ...)
  2022-05-12 19:45 ` [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables Petr Vorel
@ 2022-05-12 19:45 ` Petr Vorel
  2022-05-30 15:05   ` Cyril Hrubis
  2022-05-12 19:45 ` [LTP] [PATCH 5/8] shell: Add tst_clear_device Petr Vorel
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 27+ messages in thread
From: Petr Vorel @ 2022-05-12 19:45 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

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

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/newlib_tests/shell/tst_mount_device.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100755 lib/newlib_tests/shell/tst_mount_device.sh

diff --git a/lib/newlib_tests/shell/tst_mount_device.sh b/lib/newlib_tests/shell/tst_mount_device.sh
new file mode 100755
index 000000000..c8f185626
--- /dev/null
+++ b/lib/newlib_tests/shell/tst_mount_device.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+
+TST_MOUNT_DEVICE=1
+TST_FS_TYPE=ext4
+TST_TESTFUNC=test
+TST_CNT=2
+
+test1()
+{
+	EXPECT_PASS "cd $TST_MNTPOINT"
+}
+
+test2()
+{
+	EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts"
+}
+
+. tst_test.sh
+tst_run
-- 
2.36.0


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

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

* [LTP] [PATCH 5/8] shell: Add tst_clear_device
  2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (3 preceding siblings ...)
  2022-05-12 19:45 ` [LTP] [PATCH 4/8] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
@ 2022-05-12 19:45 ` Petr Vorel
  2022-05-30 15:12   ` Cyril Hrubis
  2022-06-01 10:37   ` Petr Vorel
  2022-05-12 19:45 ` [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
                   ` (2 subsequent siblings)
  7 siblings, 2 replies; 27+ messages in thread
From: Petr Vorel @ 2022-05-12 19:45 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

Binary required for shell $TST_ALL_FILESYSTEMS implementation
(C .all_filesystems uses it).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/.gitignore         |  1 +
 testcases/lib/Makefile           |  2 +-
 testcases/lib/tst_clear_device.c | 47 ++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 testcases/lib/tst_clear_device.c

diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore
index c0d4dc851..579f84250 100644
--- a/testcases/lib/.gitignore
+++ b/testcases/lib/.gitignore
@@ -1,6 +1,7 @@
 /tst_check_drivers
 /tst_check_kconfigs
 /tst_checkpoint
+/tst_clear_device
 /tst_device
 /tst_getconf
 /tst_get_free_pids
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile
index f2de0c832..d5a8b08ac 100644
--- a/testcases/lib/Makefile
+++ b/testcases/lib/Makefile
@@ -12,6 +12,6 @@ MAKE_TARGETS		:= tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\
 			   tst_device tst_net_iface_prefix tst_net_ip_prefix tst_net_vars\
 			   tst_getconf tst_supported_fs tst_check_drivers tst_get_unused_port\
 			   tst_get_median tst_hexdump tst_get_free_pids tst_timeout_kill\
-			   tst_check_kconfigs
+			   tst_check_kconfigs tst_clear_device
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/tst_clear_device.c b/testcases/lib/tst_clear_device.c
new file mode 100644
index 000000000..4111c7248
--- /dev/null
+++ b/testcases/lib/tst_clear_device.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ */
+
+#include <stdio.h>
+#include <sys/stat.h>
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+#include "old/old_device.h"
+
+extern struct tst_test *tst_test;
+
+static struct tst_test test = {
+};
+
+static void print_help(void)
+{
+	fprintf(stderr, "\nUsage: tst_clear_device block_device\n");
+}
+
+int main(int argc, char *argv[])
+{
+	/*
+	 * Force messages to be printed from the new library i.e. tst_test.c
+	 *
+	 * The new library prints messages into stderr while the old one prints
+	 * them into stdout. When messages are printed into stderr we can
+	 * safely do:
+	 *
+	 * DEV=$(tst_device acquire)
+	 */
+	tst_test = &test;
+	struct stat st;
+
+	if (argc < 2)
+		goto help;
+
+	if (stat(argv[1], &st) < 0 || !S_ISBLK(st.st_mode))
+		goto help;
+
+	return tst_clear_device(argv[1]);
+help:
+	print_help();
+	return 1;
+}
-- 
2.36.0


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

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

* [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (4 preceding siblings ...)
  2022-05-12 19:45 ` [LTP] [PATCH 5/8] shell: Add tst_clear_device Petr Vorel
@ 2022-05-12 19:45 ` Petr Vorel
  2022-05-31 12:25   ` Cyril Hrubis
  2022-05-12 19:45 ` [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
  2022-05-12 19:45 ` [LTP] [PATCH 8/8] nfs07.sh: Use TST_ALL_FILESYSTEMS=1 Petr Vorel
  7 siblings, 1 reply; 27+ messages in thread
From: Petr Vorel @ 2022-05-12 19:45 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

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

diff --git a/doc/shell-test-api.txt b/doc/shell-test-api.txt
index 65444541e..93073be13 100644
--- a/doc/shell-test-api.txt
+++ b/doc/shell-test-api.txt
@@ -199,6 +199,7 @@ 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).
 | '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,
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 0f1a63aac..f2786bc71 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -28,23 +28,12 @@ fi
 trap "tst_brk TBROK 'test interrupted'" INT
 trap "unset _tst_setup_timer_pid; tst_brk TBROK 'test terminated'" TERM
 
+# FIXME: debug called more times => check things moved out of it
 _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_DEVICE" = 1 -a "$TST_MOUNT_FLAG" = 1 ]; then
-		tst_umount
-	fi
-
 	if [ "$TST_NEEDS_DEVICE" = 1 -a "$TST_DEVICE_FLAG" = 1 ]; then
 		if ! tst_device release "$TST_DEVICE"; then
 			tst_res TWARN "Failed to release device '$TST_DEVICE'"
@@ -61,8 +50,6 @@ _tst_do_exit()
 		rm $LTP_IPC_PATH
 	fi
 
-	_tst_cleanup_timer
-
 	if [ $TST_FAIL -gt 0 ]; then
 		ret=$((ret|1))
 	fi
@@ -613,17 +600,41 @@ _tst_init_checkpoints()
 	export LTP_IPC_PATH
 }
 
+_prepare_device()
+{
+	if [ "$TST_FORMAT_DEVICE" = 1 ]; then
+		tst_clear_device $TST_DEVICE
+		tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS
+	fi
+
+	if [ "$TST_MOUNT_DEVICE" = 1 ]; then
+		tst_mount
+		TST_MOUNT_FLAG=1
+	fi
+}
+
+_tst_run_tcases_per_fs()
+{
+	for _tst_fs in $(tst_supported_fs); do
+		tst_res TINFO "Testing on $_tst_fs"
+		TST_FS_TYPE="$_tst_fs"
+		_prepare_device
+		_tst_run_iterations
+	done
+}
+
 tst_run()
 {
 	local _tst_i
 	local _tst_data
+	local _tst_fs
 	local _tst_max
 	local _tst_name
 
 	if [ -n "$TST_TEST_PATH" ]; then
 		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`'"'"'].*//'); 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);;
@@ -668,12 +679,23 @@ tst_run()
 			tst_brk TCONF "test requires kernel $TST_MIN_KVER+"
 	fi
 
-	_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_NEEDS_DEVICE" = 1 -a -z "$TST_MOUNT_FLAG" ]; 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
+	fi
+
 	if [ "$TST_NEEDS_TMPDIR" = 1 ]; then
 		if [ -z "$TMPDIR" ]; then
 			export TMPDIR="/tmp"
@@ -684,35 +706,30 @@ 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}"
+	[ -z "$TST_ALL_FILESYSTEMS" ] && _prepare_device
 
-		TST_DEVICE_FLAG=1
+	if [ -n "$TST_ALL_FILESYSTEMS" ]; 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
 
-	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
+	_tst_setup_timer
 
 	if [ -n "$TST_SETUP" ]; then
 		if command -v $TST_SETUP >/dev/null 2>/dev/null; then
@@ -724,7 +741,7 @@ 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))
@@ -735,9 +752,22 @@ tst_run()
 		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_DEVICE" = 1 -a "$TST_MOUNT_FLAG" = 1 ]; then
+		tst_umount
+	fi
+
+	_tst_cleanup_timer
 }
 
 _tst_run_tests()
-- 
2.36.0


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

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

* [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1
  2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (5 preceding siblings ...)
  2022-05-12 19:45 ` [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
@ 2022-05-12 19:45 ` Petr Vorel
  2022-05-13  8:17   ` Petr Vorel
  2022-05-31 12:43   ` Cyril Hrubis
  2022-05-12 19:45 ` [LTP] [PATCH 8/8] nfs07.sh: Use TST_ALL_FILESYSTEMS=1 Petr Vorel
  7 siblings, 2 replies; 27+ messages in thread
From: Petr Vorel @ 2022-05-12 19:45 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

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

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/newlib_tests/shell/tst_all_filesystems.sh | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh

diff --git a/lib/newlib_tests/shell/tst_all_filesystems.sh b/lib/newlib_tests/shell/tst_all_filesystems.sh
new file mode 100755
index 000000000..8509a7481
--- /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_TESTFUNC=test
+TST_CNT=2
+
+test1()
+{
+	tst_res TPASS "device using filesystem"
+}
+
+test2()
+{
+	local pattern
+
+
+	if [ "$TST_FS_TYPE" = "exfat" -o "$TST_FS_TYPE" = "ntfs" ]; then
+		pattern="|fuseblk"
+	fi
+
+	EXPECT_PASS "grep -E '$TST_MNTPOINT ($TST_FS_TYPE${pattern})' /proc/mounts"
+}
+
+. tst_test.sh
+tst_run
-- 
2.36.0


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

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

* [LTP] [PATCH 8/8] nfs07.sh: Use TST_ALL_FILESYSTEMS=1
  2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
                   ` (6 preceding siblings ...)
  2022-05-12 19:45 ` [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
@ 2022-05-12 19:45 ` Petr Vorel
  2022-05-13  9:08   ` Petr Vorel
  7 siblings, 1 reply; 27+ messages in thread
From: Petr Vorel @ 2022-05-12 19:45 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/network/nfs/nfs_stress/nfs07.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/testcases/network/nfs/nfs_stress/nfs07.sh b/testcases/network/nfs/nfs_stress/nfs07.sh
index 34f60cb44..00cd6e007 100755
--- a/testcases/network/nfs/nfs_stress/nfs07.sh
+++ b/testcases/network/nfs/nfs_stress/nfs07.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) 2021 SUSE LLC <mdoucha@suse.cz>
+# Copyright (c) Linux Test Project, 2022
 #
 # DESCRIPTION: Create a large number of files and directories on NFS volume.
 # Then check whether they can be listed via NFS.
@@ -12,6 +13,7 @@ TST_PARSE_ARGS="do_parse_args"
 TST_TESTFUNC="do_test"
 TST_SETUP="do_setup"
 TST_USAGE="show_usage"
+TST_ALL_FILESYSTEMS=1
 
 do_parse_args()
 {
-- 
2.36.0


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

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

* Re: [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1
  2022-05-12 19:45 ` [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
@ 2022-05-13  8:17   ` Petr Vorel
  2022-05-31 12:43   ` Cyril Hrubis
  1 sibling, 0 replies; 27+ messages in thread
From: Petr Vorel @ 2022-05-13  8:17 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

Hi all,

> +++ 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_TESTFUNC=test
> +TST_CNT=2
> +
> +test1()
> +{
> +	tst_res TPASS "device using filesystem"
Probably going to the directory is better testing:

EXPECT_PASS "cd $TST_MNTPOINT"

(I originally counted as successful testing even running TST_ALL_FILESYSTEMS=1
is kind of a smoke test.)

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH 8/8] nfs07.sh: Use TST_ALL_FILESYSTEMS=1
  2022-05-12 19:45 ` [LTP] [PATCH 8/8] nfs07.sh: Use TST_ALL_FILESYSTEMS=1 Petr Vorel
@ 2022-05-13  9:08   ` Petr Vorel
  0 siblings, 0 replies; 27+ messages in thread
From: Petr Vorel @ 2022-05-13  9:08 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

Hi,

>  testcases/network/nfs/nfs_stress/nfs07.sh | 2 ++
...
>  TST_TESTFUNC="do_test"
>  TST_SETUP="do_setup"
>  TST_USAGE="show_usage"
> +TST_ALL_FILESYSTEMS=1

It will not be that simple. Because $TST_TMPDIR is not the mountpoint
($TST_MNTPOINT mountpoint is $PWD/mntpoint, which is $TST_TMPDIR/mntpoint for
$TST_ALL_FILESYSTEMS) IMHO we need at least to:

1) cd to $TST_MNTPOINT on lhost and rhost (nfs_setup_server() runs NFS server
on lhost for netns, otherwise on rhost)
2) local_dir and remote_dir in nfs_setup need to use $TST_MNTPOINT instead of $TST_TMPDIR
=> it'd be easier to port *all* NFS tests to $TST_ALL_FILESYSTEMS, not sure if we
want that.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE
  2022-05-12 19:45 ` [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
@ 2022-05-30 14:04   ` Cyril Hrubis
  2022-06-01  6:38     ` Petr Vorel
  0 siblings, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2022-05-30 14:04 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
> +	if [ "$TST_MOUNT_DEVICE" = 1 -a "$TST_MOUNT_FLAG" = 1 ]; then

Isn't the TST_MOUNT_DEVICE redundant here? We set the mount flag only if
the device was mounted by the library. Or do I miss something?

> +		tst_umount
> +	fi
> +
>  	if [ "$TST_NEEDS_DEVICE" = 1 -a "$TST_DEVICE_FLAG" = 1 ]; then
>  		if ! tst_device release "$TST_DEVICE"; then
>  			tst_res TWARN "Failed to release device '$TST_DEVICE'"
> @@ -632,7 +636,7 @@ tst_run()
>  			NET_SKIP_VARIABLE_INIT|NEEDS_CHECKPOINTS);;
>  			CHECKPOINT_WAIT|CHECKPOINT_WAKE);;
>  			CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);;
> -			DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE);;
> +			DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);;
>  			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
>  			esac
>  		done
> @@ -666,6 +670,7 @@ tst_run()
>  
>  	_tst_setup_timer
>  
> +	[ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1
>  	[ "$TST_FORMAT_DEVICE" = 1 ] && TST_NEEDS_DEVICE=1
>  	[ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1
>  
> @@ -702,6 +707,11 @@ tst_run()
>  		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
> +
>  	[ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints
>  
>  	if [ -n "$TST_SETUP" ]; then

Other than that it looks fine.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 2/8] df01.sh: Use TST_MOUNT_DEVICE=1
  2022-05-12 19:45 ` [LTP] [PATCH 2/8] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
@ 2022-05-30 14:13   ` Cyril Hrubis
  0 siblings, 0 replies; 27+ messages in thread
From: Cyril Hrubis @ 2022-05-30 14:13 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
This looks obviously correct.

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

* Re: [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables
  2022-05-12 19:45 ` [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables Petr Vorel
@ 2022-05-30 14:21   ` Cyril Hrubis
  2022-06-03 12:24     ` Petr Vorel
  0 siblings, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2022-05-30 14:21 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
>  	if [ -n "$TST_TEST_PATH" ]; then
> -		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
> +		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`'"'"'].*//'); do
                                                                                           ^
											   Isn't
											   the
											   content
											   between
											   []
											   just
											   set?

Shouldn't adding just ' between the [] suffice? The " is already there.

>  			case "$_tst_i" in
>  			DISABLE_APPARMOR|DISABLE_SELINUX);;
>  			SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
> -- 
> 2.36.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 4/8] shell: Add test for TST_MOUNT_DEVICE=1
  2022-05-12 19:45 ` [LTP] [PATCH 4/8] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
@ 2022-05-30 15:05   ` Cyril Hrubis
  0 siblings, 0 replies; 27+ messages in thread
From: Cyril Hrubis @ 2022-05-30 15:05 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
Looks good:

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

* Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device
  2022-05-12 19:45 ` [LTP] [PATCH 5/8] shell: Add tst_clear_device Petr Vorel
@ 2022-05-30 15:12   ` Cyril Hrubis
  2022-06-01 10:34     ` Petr Vorel
  2022-06-01 10:37   ` Petr Vorel
  1 sibling, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2022-05-30 15:12 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
Can't we just add clear command to the tst_device.c instead?

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-05-12 19:45 ` [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
@ 2022-05-31 12:25   ` Cyril Hrubis
  2022-06-01  8:41     ` Petr Vorel
  0 siblings, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2022-05-31 12:25 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
> +_prepare_device()
> +{
> +	if [ "$TST_FORMAT_DEVICE" = 1 ]; then
> +		tst_clear_device $TST_DEVICE
> +		tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS
> +	fi
> +
> +	if [ "$TST_MOUNT_DEVICE" = 1 ]; then
> +		tst_mount
> +		TST_MOUNT_FLAG=1
> +	fi
> +}
> +
> +_tst_run_tcases_per_fs()
> +{
> +	for _tst_fs in $(tst_supported_fs); do
> +		tst_res TINFO "Testing on $_tst_fs"
> +		TST_FS_TYPE="$_tst_fs"
> +		_prepare_device
> +		_tst_run_iterations
> +	done
> +}
> +
>  tst_run()
>  {
>  	local _tst_i
>  	local _tst_data
> +	local _tst_fs
>  	local _tst_max
>  	local _tst_name
>  
>  	if [ -n "$TST_TEST_PATH" ]; then
>  		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`'"'"'].*//'); 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);;
> @@ -668,12 +679,23 @@ tst_run()
>  			tst_brk TCONF "test requires kernel $TST_MIN_KVER+"
>  	fi
>  
> -	_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_NEEDS_DEVICE" = 1 -a -z "$TST_MOUNT_FLAG" ]; then

I do not get the TST_MOUNT_FLAG, what do we need it for? The tst_run()
should be called exactly once in the test and at this point the
TST_MOUNT_FLAG cannot be set.

> +		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
> +	fi
>
>  	if [ "$TST_NEEDS_TMPDIR" = 1 ]; then
>  		if [ -z "$TMPDIR" ]; then
>  			export TMPDIR="/tmp"
> @@ -684,35 +706,30 @@ 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}"
> +	[ -z "$TST_ALL_FILESYSTEMS" ] && _prepare_device
>  
> -		TST_DEVICE_FLAG=1
> +	if [ -n "$TST_ALL_FILESYSTEMS" ]; 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
>  
> -	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
> +	_tst_setup_timer
>  
>  	if [ -n "$TST_SETUP" ]; then
>  		if command -v $TST_SETUP >/dev/null 2>/dev/null; then
> @@ -724,7 +741,7 @@ 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))
> @@ -735,9 +752,22 @@ tst_run()
>  		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_DEVICE" = 1 -a "$TST_MOUNT_FLAG" = 1 ]; then
> +		tst_umount
> +	fi
> +
> +	_tst_cleanup_timer
>  }
>  
>  _tst_run_tests()
> -- 
> 2.36.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1
  2022-05-12 19:45 ` [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
  2022-05-13  8:17   ` Petr Vorel
@ 2022-05-31 12:43   ` Cyril Hrubis
  1 sibling, 0 replies; 27+ messages in thread
From: Cyril Hrubis @ 2022-05-31 12:43 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
Looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE
  2022-05-30 14:04   ` Cyril Hrubis
@ 2022-06-01  6:38     ` Petr Vorel
  0 siblings, 0 replies; 27+ messages in thread
From: Petr Vorel @ 2022-06-01  6:38 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Martin Doucha, ltp

Hi Cyril,

> Hi!
> > +	if [ "$TST_MOUNT_DEVICE" = 1 -a "$TST_MOUNT_FLAG" = 1 ]; then

> Isn't the TST_MOUNT_DEVICE redundant here? We set the mount flag only if
> the device was mounted by the library. Or do I miss something?
No, you're right $TST_MOUNT_DEVICE is redundant. I noted this after sending a
patch, just forget to note it on ML. Thanks!

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS
  2022-05-31 12:25   ` Cyril Hrubis
@ 2022-06-01  8:41     ` Petr Vorel
  0 siblings, 0 replies; 27+ messages in thread
From: Petr Vorel @ 2022-06-01  8:41 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Martin Doucha, ltp

Hi Cyril,

...
> > +	[ "$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_NEEDS_DEVICE" = 1 -a -z "$TST_MOUNT_FLAG" ]; then

> I do not get the TST_MOUNT_FLAG, what do we need it for? The tst_run()
> should be called exactly once in the test and at this point the
> TST_MOUNT_FLAG cannot be set.

Correct, $TST_MOUNT_FLAG should be removed here.
Thanks,
Petr

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


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

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

* Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device
  2022-05-30 15:12   ` Cyril Hrubis
@ 2022-06-01 10:34     ` Petr Vorel
  2022-06-01 11:22       ` Cyril Hrubis
  0 siblings, 1 reply; 27+ messages in thread
From: Petr Vorel @ 2022-06-01 10:34 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Martin Doucha, ltp

Hi Cyril,

> Hi!
> Can't we just add clear command to the tst_device.c instead?
Not sure what you mean, can you be more specific?

I wasn't clear in git commit message that shell API also needs call
tst_clear_device(), but we use mkfs.* binary directly, instead of tst_mkfs_()
via SAFE_MKFS(), but this is obvious to you.

Alternatively we could create binary testcases/lib/tst_mkfs.c which would 
run SAFE_MKFS(). We already have all code in C and both C and shell API would be
even more consistent.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device
  2022-05-12 19:45 ` [LTP] [PATCH 5/8] shell: Add tst_clear_device Petr Vorel
  2022-05-30 15:12   ` Cyril Hrubis
@ 2022-06-01 10:37   ` Petr Vorel
  1 sibling, 0 replies; 27+ messages in thread
From: Petr Vorel @ 2022-06-01 10:37 UTC (permalink / raw)
  To: ltp; +Cc: Martin Doucha

Hi all,

> --- /dev/null
> +++ b/testcases/lib/tst_clear_device.c
...
> +int main(int argc, char *argv[])
> +{
> +	/*
> +	 * Force messages to be printed from the new library i.e. tst_test.c
> +	 *
> +	 * The new library prints messages into stderr while the old one prints
> +	 * them into stdout. When messages are printed into stderr we can
> +	 * safely do:
> +	 *
> +	 * DEV=$(tst_device acquire)
> +	 */
> +	tst_test = &test;
I guess this whole workaround is not needed for binary being used only in new
shell API (note for myself in case we decided to introduce new binary wrapper).

Kind regards,
Petr

> +	struct stat st;
> +
> +	if (argc < 2)
> +		goto help;
> +
> +	if (stat(argv[1], &st) < 0 || !S_ISBLK(st.st_mode))
> +		goto help;
> +
> +	return tst_clear_device(argv[1]);
> +help:
> +	print_help();
> +	return 1;
> +}

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

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

* Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device
  2022-06-01 10:34     ` Petr Vorel
@ 2022-06-01 11:22       ` Cyril Hrubis
  2022-06-01 13:17         ` Petr Vorel
  0 siblings, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2022-06-01 11:22 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
> > Can't we just add clear command to the tst_device.c instead?
> Not sure what you mean, can you be more specific?

We do have tst_device binary that has two commands acquire and release,
why can't we add clear command for that binary instead?

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device
  2022-06-01 11:22       ` Cyril Hrubis
@ 2022-06-01 13:17         ` Petr Vorel
  0 siblings, 0 replies; 27+ messages in thread
From: Petr Vorel @ 2022-06-01 13:17 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Martin Doucha, ltp

> Hi!
> > > Can't we just add clear command to the tst_device.c instead?
> > Not sure what you mean, can you be more specific?

> We do have tst_device binary that has two commands acquire and release,
> why can't we add clear command for that binary instead?
Ah, you mean testcases/lib/tst_device.c. I forget on this one, I was looking
just into lib/tst_device.c. Makes sense, thx!

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables
  2022-05-30 14:21   ` Cyril Hrubis
@ 2022-06-03 12:24     ` Petr Vorel
  2022-06-03 13:23       ` Cyril Hrubis
  0 siblings, 1 reply; 27+ messages in thread
From: Petr Vorel @ 2022-06-03 12:24 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Martin Doucha, ltp

> Hi!
> >  	if [ -n "$TST_TEST_PATH" ]; then
> > -		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
> > +		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`'"'"'].*//'); do
>                                                                                            ^
> 											   Isn't
> 											   the
> 											   content
> 											   between
> 											   []
> 											   just
> 											   set?

> Shouldn't adding just ' between the [] suffice? The " is already there.

Well, '"'"' was my version of adding ' (quoted with " and ' at the start and end
were for ending previous '.

But this is shorter: '\'', therefore suggest

-		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
+		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[='\''"} \t\/:`].*//'); do

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables
  2022-06-03 12:24     ` Petr Vorel
@ 2022-06-03 13:23       ` Cyril Hrubis
  2022-06-03 18:44         ` Petr Vorel
  0 siblings, 1 reply; 27+ messages in thread
From: Cyril Hrubis @ 2022-06-03 13:23 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Martin Doucha, ltp

Hi!
> > >  	if [ -n "$TST_TEST_PATH" ]; then
> > > -		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
> > > +		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`'"'"'].*//'); do
> >                                                                                            ^
> > 											   Isn't
> > 											   the
> > 											   content
> > 											   between
> > 											   []
> > 											   just
> > 											   set?
> 
> > Shouldn't adding just ' between the [] suffice? The " is already there.
> 
> Well, '"'"' was my version of adding ' (quoted with " and ' at the start and end
> were for ending previous '.
>
> But this is shorter: '\'', therefore suggest
> 
> -		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
> +		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[='\''"} \t\/:`].*//'); do

I would say that '\'' is stil insane, but I guess that we can't do
better than that.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables
  2022-06-03 13:23       ` Cyril Hrubis
@ 2022-06-03 18:44         ` Petr Vorel
  0 siblings, 0 replies; 27+ messages in thread
From: Petr Vorel @ 2022-06-03 18:44 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Martin Doucha, ltp

> Hi!
> > > >  	if [ -n "$TST_TEST_PATH" ]; then
> > > > -		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
> > > > +		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`'"'"'].*//'); do
> > >                                                                                            ^
> > > 											   Isn't
> > > 											   the
> > > 											   content
> > > 											   between
> > > 											   []
> > > 											   just
> > > 											   set?

> > > Shouldn't adding just ' between the [] suffice? The " is already there.

> > Well, '"'"' was my version of adding ' (quoted with " and ' at the start and end
> > were for ending previous '.

> > But this is shorter: '\'', therefore suggest

> > -		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
> > +		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[='\''"} \t\/:`].*//'); do

> I would say that '\'' is stil insane, but I guess that we can't do
> better than that.
IMHO better than using variable:
local _tst_q="'"
for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[='$_tst_q'"} \t\/:`].*//'); do

insane: well, POSIX shell is insane :).

Kind regards,
Petr

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

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

end of thread, other threads:[~2022-06-03 18:44 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
2022-05-30 14:04   ` Cyril Hrubis
2022-06-01  6:38     ` Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 2/8] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
2022-05-30 14:13   ` Cyril Hrubis
2022-05-12 19:45 ` [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables Petr Vorel
2022-05-30 14:21   ` Cyril Hrubis
2022-06-03 12:24     ` Petr Vorel
2022-06-03 13:23       ` Cyril Hrubis
2022-06-03 18:44         ` Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 4/8] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
2022-05-30 15:05   ` Cyril Hrubis
2022-05-12 19:45 ` [LTP] [PATCH 5/8] shell: Add tst_clear_device Petr Vorel
2022-05-30 15:12   ` Cyril Hrubis
2022-06-01 10:34     ` Petr Vorel
2022-06-01 11:22       ` Cyril Hrubis
2022-06-01 13:17         ` Petr Vorel
2022-06-01 10:37   ` Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
2022-05-31 12:25   ` Cyril Hrubis
2022-06-01  8:41     ` Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-05-13  8:17   ` Petr Vorel
2022-05-31 12:43   ` Cyril Hrubis
2022-05-12 19:45 ` [LTP] [PATCH 8/8] nfs07.sh: Use TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-05-13  9:08   ` 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.