Skip to contentSkip to conversation

shell: $TST_ALL_FILESYSTEMS (.all_filesystems)

PATCH Superseded Petr Vorel 2 participants 27 messages May 12, 2022 – Jun 3, 2022

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

cover shell: $TST_ALL_FILESYSTEMS (.all_filesystems)

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


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

PATCH 1/8 tst_test.sh: Add $TST_MOUNT_DEVICE

---
 doc/shell-test-api.txt    |  2 ++
 testcases/lib/tst_test.sh | 12 +++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
doc/shell-test-api.txt +2 -0
index df5ebbdf0..65444541e 100644
@@ -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.
testcases/lib/tst_test.sh +11 -1
index 28b7d12ba..1fe77d50d 100644
@@ -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
Signature · 5 lines
2.36.0


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

Re: [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE

Hi!

testcases/lib/tst_test.sh _tst_do_exit() · line 44

Quoted 1 line
testcases/lib/tst_test.sh +1 -0
+	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?

Quoted 25 lines
testcases/lib/tst_test.sh +5 -1
+		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

testcases/lib/tst_test.sh tst_run() · line 717

Quoted 10 lines
testcases/lib/tst_test.sh +5 -0
 	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.

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE

Hi Cyril,

Quoted 5 lines

Hi!

testcases/lib/tst_test.sh _tst_do_exit() · line 44

Quoted 1 line
testcases/lib/tst_test.sh +1 -0
+	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

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

PATCH 2/8 df01.sh: Use TST_MOUNT_DEVICE=1

In reply to Petr Vorel
---
 testcases/commands/df/df01.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
testcases/commands/df/df01.sh +2 -3
index f74032c96..976e205bf 100755
@@ -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 <[email protected]>
 # Author: Zhang Jin <[email protected]>
 #
 # 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}')
 }
 
Signature · 5 lines
2.36.0


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

PATCH 3/8 tst_test.sh: Improve pattern for allowed variables

In reply to Petr Vorel

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.

---
 testcases/lib/tst_test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/tst_test.sh +1 -1
index 1fe77d50d..0f1a63aac 100644
@@ -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);;
Signature · 5 lines
2.36.0


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

Re: [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables

Hi!

testcases/lib/tst_test.sh tst_run() · line 624

Quoted 3 lines
testcases/lib/tst_test.sh +1 -1
 	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.

Quoted 6 lines
testcases/lib/tst_test.sh +0 -0
 			case "$_tst_i" in
 			DISABLE_APPARMOR|DISABLE_SELINUX);;
 			SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
Signature · 1 line
2.36.0
Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables

Quoted 13 lines

Hi!

testcases/lib/tst_test.sh tst_run() · line 624

Quoted 3 lines
testcases/lib/tst_test.sh +1 -1
 	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?
Quoted 1 line

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

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

Re: [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables

Hi!

Quoted 19 lines
Quoted 12 lines

testcases/lib/tst_test.sh tst_run() · line 624

Quoted 3 lines
testcases/lib/tst_test.sh +1 -1
 	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?
Quoted 1 line

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

Review

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

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables

Quoted 18 lines

Hi!

Quoted 16 lines
Quoted 12 lines

testcases/lib/tst_test.sh tst_run() · line 624

Quoted 3 lines
testcases/lib/tst_test.sh +1 -1
 	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?
Quoted 1 line

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

Quoted 7 lines

Review

Quoted 4 lines

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

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

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

PATCH 4/8 shell: Add test for TST_MOUNT_DEVICE=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_mount_device.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100755 lib/newlib_tests/shell/tst_mount_device.sh
lib/newlib_tests/shell/tst_mount_device.sh new file +21 -0
new file mode 100755
index 000000000..c8f185626
@@ -0,0 +1,21 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <[email protected]>
+
+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
Signature · 5 lines
2.36.0


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

PATCH 5/8 shell: Add tst_clear_device

In reply to Petr Vorel

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

---
 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
testcases/lib/.gitignore +1 -0
index c0d4dc851..579f84250 100644
@@ -1,6 +1,7 @@
 /tst_check_drivers
 /tst_check_kconfigs
 /tst_checkpoint
+/tst_clear_device
 /tst_device
 /tst_getconf
 /tst_get_free_pids
testcases/lib/Makefile +1 -1
index f2de0c832..d5a8b08ac 100644
@@ -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
testcases/lib/tst_clear_device.c new file +47 -0

47 lines not on this page · raw message

Signature · 5 lines
2.36.0


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

Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device

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

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device

Hi Cyril,

Quoted 2 lines

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

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

Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device

Hi!

Quoted 2 lines
Quoted 1 line

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?

Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device

Quoted 6 lines

Hi!

Quoted 2 lines
Quoted 1 line

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

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

Re: [LTP] [PATCH 5/8] shell: Add tst_clear_device

In reply to Petr Vorel

Hi all,

Quoted 2 lines
testcases/lib/tst_clear_device.c new file +0 -0

...

testcases/lib/tst_clear_device.c line 34

Quoted 12 lines
testcases/lib/tst_clear_device.c new file +12 -0
+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

Quoted 13 lines
testcases/lib/tst_clear_device.c new file +13 -0
+	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;
+}
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#19 lore raw

PATCH 6/8 tst_test.sh: Add $TST_ALL_FILESYSTEMS

In reply to Petr Vorel
---
 doc/shell-test-api.txt    |   1 +
 testcases/lib/tst_test.sh | 106 ++++++++++++++++++++++++--------------
 2 files changed, 69 insertions(+), 38 deletions(-)
doc/shell-test-api.txt +1 -0
index 65444541e..93073be13 100644
@@ -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,
testcases/lib/tst_test.sh +68 -38

179 lines not on this page · raw message

Signature · 5 lines
2.36.0


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

Re: [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS

Hi!

Quoted 42 lines
testcases/lib/tst_test.sh +25 -1
+_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

testcases/lib/tst_test.sh tst_run() · line 689

Quoted 10 lines
testcases/lib/tst_test.sh +3 -1
 
-	_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.

Quoted 99 lines
testcases/lib/tst_test.sh +38 -22
+		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()
Signature · 1 line
2.36.0
Signature · 5 lines
Cyril Hrubis
[email protected]

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

Re: [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS

Hi Cyril,

...

Quoted 10 lines

testcases/lib/tst_test.sh tst_run() · line 689

Quoted 6 lines
testcases/lib/tst_test.sh +2 -0
+	[ "$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

Quoted 8 lines
Quoted 8 lines
testcases/lib/tst_test.sh +8 -0
+		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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#22 lore raw

PATCH 7/8 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..8509a7481
@@ -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_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
Signature · 5 lines
2.36.0


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

Re: [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1

Hi all,

lib/newlib_tests/shell/tst_all_filesystems.sh line 11

Quoted 13 lines

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

lib/newlib_tests/shell/tst_all_filesystems.sh new file +11 -0
@@ -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_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

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

PATCH 8/8 nfs07.sh: Use TST_ALL_FILESYSTEMS=1

In reply to Petr Vorel
---
 testcases/network/nfs/nfs_stress/nfs07.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/network/nfs/nfs_stress/nfs07.sh +2 -0
index 34f60cb44..00cd6e007 100755
@@ -1,6 +1,7 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) 2021 SUSE LLC <[email protected]>
+# 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()
 {
Signature · 5 lines
2.36.0


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

Re: [LTP] [PATCH 8/8] nfs07.sh: Use TST_ALL_FILESYSTEMS=1

Hi,

Quoted 1 line
 testcases/network/nfs/nfs_stress/nfs07.sh | 2 ++

...

Quoted 4 lines

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

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