All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/4] shell: Add $TST_MOUNT_DEVICE support
@ 2022-05-10 15:54 Petr Vorel
  2022-05-10 15:54 ` [LTP] [PATCH v2 1/4] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Petr Vorel @ 2022-05-10 15:54 UTC (permalink / raw)
  To: ltp

Hi,

this is a preparation for .all_filesystems equivalent for shell.

changes v1->v2:
rebased

Petr Vorel (4):
  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

 doc/shell-test-api.txt                     |  2 ++
 lib/newlib_tests/shell/tst_mount_device.sh | 21 +++++++++++++++++++++
 testcases/commands/df/df01.sh              |  4 ++--
 testcases/lib/tst_test.sh                  | 14 ++++++++++++--
 4 files changed, 37 insertions(+), 4 deletions(-)
 create mode 100755 lib/newlib_tests/shell/tst_mount_device.sh

-- 
2.36.0


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

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

* [LTP] [PATCH v2 1/4] tst_test.sh: Add $TST_MOUNT_DEVICE
  2022-05-10 15:54 [LTP] [PATCH v2 0/4] shell: Add $TST_MOUNT_DEVICE support Petr Vorel
@ 2022-05-10 15:54 ` Petr Vorel
  2022-05-10 15:54 ` [LTP] [PATCH v2 2/4] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2022-05-10 15:54 UTC (permalink / raw)
  To: ltp

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

* [LTP] [PATCH v2 2/4] df01.sh: Use TST_MOUNT_DEVICE=1
  2022-05-10 15:54 [LTP] [PATCH v2 0/4] shell: Add $TST_MOUNT_DEVICE support Petr Vorel
  2022-05-10 15:54 ` [LTP] [PATCH v2 1/4] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
@ 2022-05-10 15:54 ` Petr Vorel
  2022-05-11 14:48   ` Petr Vorel
  2022-05-10 15:54 ` [LTP] [PATCH v2 3/4] tst_test.sh: Improve pattern for allowed variables Petr Vorel
  2022-05-10 15:54 ` [LTP] [PATCH v2 4/4] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
  3 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2022-05-10 15:54 UTC (permalink / raw)
  To: ltp

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

diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index f74032c96..cfc8feab8 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -1,6 +1,7 @@
 #!/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.
@@ -13,7 +14,7 @@ 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 +35,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] 7+ messages in thread

* [LTP] [PATCH v2 3/4] tst_test.sh: Improve pattern for allowed variables
  2022-05-10 15:54 [LTP] [PATCH v2 0/4] shell: Add $TST_MOUNT_DEVICE support Petr Vorel
  2022-05-10 15:54 ` [LTP] [PATCH v2 1/4] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
  2022-05-10 15:54 ` [LTP] [PATCH v2 2/4] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
@ 2022-05-10 15:54 ` Petr Vorel
  2022-05-10 15:54 ` [LTP] [PATCH v2 4/4] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
  3 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2022-05-10 15:54 UTC (permalink / raw)
  To: ltp

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

* [LTP] [PATCH v2 4/4] shell: Add test for TST_MOUNT_DEVICE=1
  2022-05-10 15:54 [LTP] [PATCH v2 0/4] shell: Add $TST_MOUNT_DEVICE support Petr Vorel
                   ` (2 preceding siblings ...)
  2022-05-10 15:54 ` [LTP] [PATCH v2 3/4] tst_test.sh: Improve pattern for allowed variables Petr Vorel
@ 2022-05-10 15:54 ` Petr Vorel
  2022-05-12 11:43   ` Petr Vorel
  3 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2022-05-10 15:54 UTC (permalink / raw)
  To: ltp

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..a30f15bf6
--- /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
+. tst_test.sh
+
+test1()
+{
+	tst_res TPASS "device formatted"
+}
+
+test2()
+{
+	EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts"
+}
+
+tst_run
-- 
2.36.0


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

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

* Re: [LTP] [PATCH v2 2/4] df01.sh: Use TST_MOUNT_DEVICE=1
  2022-05-10 15:54 ` [LTP] [PATCH v2 2/4] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
@ 2022-05-11 14:48   ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2022-05-11 14:48 UTC (permalink / raw)
  To: ltp

Hi,

> diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
...
> @@ -13,7 +14,7 @@ TST_OPTS="f:"
>  TST_USAGE=usage
>  TST_PARSE_ARGS=parse_args
>  TST_NEEDS_ROOT=1
> -TST_FORMAT_DEVICE=1
> +TST_MOUNT_DEVICE=1

I forget to remove TST_CLEANUP=tst_umount.

Therefore there is an error:
df01 13 TINFO: The '/tmp/LTP_df01.UaDhMw4Ifq/mntpoint' is not mounted, skipping umount

If this is the only error, I'll fix it during merge.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v2 4/4] shell: Add test for TST_MOUNT_DEVICE=1
  2022-05-10 15:54 ` [LTP] [PATCH v2 4/4] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
@ 2022-05-12 11:43   ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2022-05-12 11:43 UTC (permalink / raw)
  To: ltp

Hi all,

> +++ b/lib/newlib_tests/shell/tst_mount_device.sh
...
> +TST_MOUNT_DEVICE=1
> +TST_FS_TYPE=ext4
> +TST_TESTFUNC=test
> +TST_CNT=2
> +. tst_test.sh
Obviously loading should be later.
> +
> +test1()
> +{
> +	tst_res TPASS "device formatted"
> +}
> +
> +test2()
> +{
> +	EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts"
> +}
> +
Here.
I'll fix it before merge (if it's the only change requested).
> +tst_run

Kind regards,
Petr

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

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

end of thread, other threads:[~2022-05-12 11:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 15:54 [LTP] [PATCH v2 0/4] shell: Add $TST_MOUNT_DEVICE support Petr Vorel
2022-05-10 15:54 ` [LTP] [PATCH v2 1/4] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
2022-05-10 15:54 ` [LTP] [PATCH v2 2/4] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
2022-05-11 14:48   ` Petr Vorel
2022-05-10 15:54 ` [LTP] [PATCH v2 3/4] tst_test.sh: Improve pattern for allowed variables Petr Vorel
2022-05-10 15:54 ` [LTP] [PATCH v2 4/4] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
2022-05-12 11:43   ` 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.