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

Hi,

next step to all_filesystems support for shell.

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              |  3 +--
 testcases/lib/tst_test.sh                  | 14 ++++++++++++--
 4 files changed, 36 insertions(+), 4 deletions(-)
 create mode 100755 lib/newlib_tests/shell/tst_mount_device.sh

-- 
2.35.1


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

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

* [LTP] [PATCH 1/4] tst_test.sh: Add $TST_MOUNT_DEVICE
  2022-03-23 19:04 [LTP] [PATCH 0/4] shell: Add $TST_MOUNT_DEVICE support Petr Vorel
@ 2022-03-23 19:04 ` Petr Vorel
  2022-03-23 19:04 ` [LTP] [PATCH 2/4] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2022-03-23 19:04 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 4c16f36250..04bfc0ace2 100644
--- a/doc/shell-test-api.txt
+++ b/doc/shell-test-api.txt
@@ -209,6 +209,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 d97df9ab4a..e411ee9192 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
@@ -677,6 +681,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
 
@@ -713,6 +718,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.35.1


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

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

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

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

diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index 86df940861..b6537ef53d 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -13,7 +13,7 @@ TST_OPTS="f:"
 TST_USAGE=usage
 TST_PARSE_ARGS=parse_args
 TST_NEEDS_ROOT=1
-TST_FORMAT_DEVICE=1
+TST_MOUNT_DEVICE=1
 . tst_test.sh
 
 usage()
@@ -35,7 +35,6 @@ parse_args()
 
 setup()
 {
-	tst_mount
 	DF_FS_TYPE=$(mount | grep "$TST_DEVICE" | awk 'NR==1{print $5}')
 }
 
-- 
2.35.1


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

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

* [LTP] [PATCH 3/4] tst_test.sh: Improve pattern for allowed variables
  2022-03-23 19:04 [LTP] [PATCH 0/4] shell: Add $TST_MOUNT_DEVICE support Petr Vorel
  2022-03-23 19:04 ` [LTP] [PATCH 1/4] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
  2022-03-23 19:04 ` [LTP] [PATCH 2/4] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
@ 2022-03-23 19:04 ` Petr Vorel
  2022-03-23 19:04 ` [LTP] [PATCH 4/4] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2022-03-23 19:04 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 e411ee9192..0d289eb097 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.35.1


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

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

* [LTP] [PATCH 4/4] shell: Add test for TST_MOUNT_DEVICE=1
  2022-03-23 19:04 [LTP] [PATCH 0/4] shell: Add $TST_MOUNT_DEVICE support Petr Vorel
                   ` (2 preceding siblings ...)
  2022-03-23 19:04 ` [LTP] [PATCH 3/4] tst_test.sh: Improve pattern for allowed variables Petr Vorel
@ 2022-03-23 19:04 ` Petr Vorel
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2022-03-23 19:04 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 0000000000..a30f15bf69
--- /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.35.1


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

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

end of thread, other threads:[~2022-03-23 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23 19:04 [LTP] [PATCH 0/4] shell: Add $TST_MOUNT_DEVICE support Petr Vorel
2022-03-23 19:04 ` [LTP] [PATCH 1/4] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
2022-03-23 19:04 ` [LTP] [PATCH 2/4] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
2022-03-23 19:04 ` [LTP] [PATCH 3/4] tst_test.sh: Improve pattern for allowed variables Petr Vorel
2022-03-23 19:04 ` [LTP] [PATCH 4/4] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.