* [LTP] [PATCH v3 0/4] shell loader rewrite to support TST_SETUP
@ 2025-06-09 12:45 Petr Vorel
2025-06-09 12:45 ` [LTP] [PATCH v3 1/4] shell lib: Add support for test cleanup Petr Vorel
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Petr Vorel @ 2025-06-09 12:45 UTC (permalink / raw)
To: ltp
Hi Cyril, all,
Link to v2:
https://patchwork.ozlabs.org/project/ltp/list/?series=454866&state=*
https://lore.kernel.org/ltp/20250430130417.43523-1-pvorel@suse.cz/
Link to v1:
https://patchwork.ozlabs.org/project/ltp/list/?series=446566&state=*
https://lore.kernel.org/ltp/20250228172439.3276777-1-pvorel@suse.cz/
Changes v2->v3
* Create tst_run.sh
simplification asked by Cyril https://lore.kernel.org/ltp/aBSSF8bPjoKz8Umx@yuki.lan/
* Fixes failure on an old Ubuntu Bionic
We discussed about full PATH
https://lore.kernel.org/ltp/aBSHoimhpmTj1l_A@yuki.lan/, but in the end
it was missing quoting which fails in old dash 0.5.8-2.10:
https://productionresultssa8.blob.core.windows.net/actions-results/9f7016e0-4f86-42b1-bece-346740e3837c/workflow-job-run-301c527f-be9e-5180-ae5c-c845d75794a8/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-06-09T11%3A43%3A38Z&sig=S1txTtKxNtqGDD0PGi7vswaNxWqaemKfMV9KUJo%2F9n4%3D&ske=2025-06-09T20%3A28%3A00Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-06-09T08%3A28%3A00Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-05-05&sp=r&spr=https&sr=b&st=2025-06-09T11%3A33%3A33Z&sv=2025-05-05
*** Running 'shell_loader_all_filesystems.sh' (exp: TPASS) ***
tst_tmpdir.c:317: TINFO: Using /tmp/LTP_sheiFmNGP as tmpdir (overlayfs filesystem)
tst_device.c:99: TINFO: Found free device 0 '/dev/loop0'
tst_test.c:1953: TINFO: LTP version: 20250530
tst_test.c:1956: TINFO: Tested kernel: 6.11.0-1015-azure #15~24.04.1-Ubuntu SMP Thu May 1 02:52:08 UTC 2025 x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/boot/config-6.11.0-1015-azure'
tst_test.c:1776: TINFO: Overall timeout per run is 0h 00m 30s
tst_supported_fs_types.c:97: TINFO: Kernel supports ext2
tst_supported_fs_types.c:62: TINFO: mkfs.ext2 does exist
tst_supported_fs_types.c:97: TINFO: Kernel supports ext3
tst_supported_fs_types.c:62: TINFO: mkfs.ext3 does exist
tst_supported_fs_types.c:97: TINFO: Kernel supports ext4
tst_supported_fs_types.c:62: TINFO: mkfs.ext4 does exist
tst_supported_fs_types.c:97: TINFO: Kernel supports xfs
tst_supported_fs_types.c:58: TINFO: mkfs.xfs does not exist
tst_supported_fs_types.c:97: TINFO: Kernel supports btrfs
tst_supported_fs_types.c:58: TINFO: mkfs.btrfs does not exist
tst_supported_fs_types.c:105: TINFO: Skipping bcachefs because of FUSE blacklist
tst_supported_fs_types.c:97: TINFO: Kernel supports vfat
tst_supported_fs_types.c:58: TINFO: mkfs.vfat does not exist
tst_supported_fs_types.c:128: TINFO: Filesystem exfat is not supported
tst_supported_fs_types.c:128: TINFO: Filesystem ntfs is not supported
tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
tst_test.c:1888: TINFO: === Testing on ext2 ===
tst_test.c:1217: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts=''
mke2fs 1.44.1 (24-Mar-2018)
tst_test.c:1230: TINFO: Mounting /dev/loop0 to /tmp/LTP_sheiFmNGP/ltp_mntpoint fstyp=ext2 flags=0
/__w/ltp/ltp/testcases/lib/tests//shell_loader_all_filesystems.sh: 20: local: /tmp/LTP_sheiFmNGP/ltp_mntpoint: bad variable name
Which was simply fixed:
- local mounted=$(grep $mntpath /proc/mounts)
+ local mounted="$(grep $mntpath /proc/mounts)"
But maybe we should document or even check somewhere if the PATH is full
path.
Tested:
https://github.com/pevik/ltp/actions/runs/15534603740
Hopefully this is a final version which can be merged.
Kind regards,
Petr
Cyril Hrubis (1):
shell lib: Add support for test cleanup
Petr Vorel (3):
shell: Move shell code into functions
shell lib: Add basic support for test setup
shell: Add shell_loader_setup_cleanup.sh test
testcases/kernel/mem/vma/vma05.sh | 45 ++++++++++---------
testcases/lib/run_tests.sh | 5 ++-
testcases/lib/tests/shell_loader.sh | 19 +++++---
.../lib/tests/shell_loader_all_filesystems.sh | 26 ++++++-----
.../lib/tests/shell_loader_brk_cleanup.sh | 25 +++++++++++
testcases/lib/tests/shell_loader_c_child.sh | 15 ++++---
testcases/lib/tests/shell_loader_cleanup.sh | 25 +++++++++++
.../lib/tests/shell_loader_filesystems.sh | 23 ++++++----
.../lib/tests/shell_loader_invalid_block.sh | 7 ++-
.../tests/shell_loader_invalid_metadata.sh | 7 ++-
testcases/lib/tests/shell_loader_kconfigs.sh | 7 ++-
.../lib/tests/shell_loader_no_metadata.sh | 7 ++-
.../lib/tests/shell_loader_setup_cleanup.sh | 31 +++++++++++++
.../lib/tests/shell_loader_supported_archs.sh | 7 ++-
testcases/lib/tests/shell_loader_tags.sh | 7 ++-
testcases/lib/tests/shell_loader_tcnt.sh | 7 ++-
.../lib/tests/shell_loader_wrong_metadata.sh | 7 ++-
testcases/lib/tst_env.sh | 5 ---
testcases/lib/tst_run.sh | 16 +++++++
19 files changed, 226 insertions(+), 65 deletions(-)
create mode 100755 testcases/lib/tests/shell_loader_brk_cleanup.sh
create mode 100755 testcases/lib/tests/shell_loader_cleanup.sh
create mode 100755 testcases/lib/tests/shell_loader_setup_cleanup.sh
create mode 100644 testcases/lib/tst_run.sh
Diff v2->v3:
diff --git testcases/kernel/mem/vma/vma05.sh testcases/kernel/mem/vma/vma05.sh
index e7780e8957..c560eecbcd 100755
--- testcases/kernel/mem/vma/vma05.sh
+++ testcases/kernel/mem/vma/vma05.sh
@@ -39,7 +39,7 @@
# }
# ---
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
@@ -71,4 +71,4 @@ tst_test()
fi
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader.sh testcases/lib/tests/shell_loader.sh
index 01acf6d352..78dba06b25 100755
--- testcases/lib/tests/shell_loader.sh
+++ testcases/lib/tests/shell_loader.sh
@@ -14,7 +14,7 @@
# }
# ---
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
@@ -27,4 +27,4 @@ tst_test()
esac
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_all_filesystems.sh testcases/lib/tests/shell_loader_all_filesystems.sh
index 1a54b2d81c..3c3978f51c 100755
--- testcases/lib/tests/shell_loader_all_filesystems.sh
+++ testcases/lib/tests/shell_loader_all_filesystems.sh
@@ -12,12 +12,12 @@
# }
# ---
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
- local mntpath=$(realpath ltp_mntpoint)
- local mounted=$(grep $mntpath /proc/mounts)
+ local mntpath="$(realpath ltp_mntpoint)"
+ local mounted="$(grep $mntpath /proc/mounts)"
local device path
tst_res TINFO "In shell"
@@ -32,4 +32,4 @@ tst_test()
fi
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_brk_cleanup.sh testcases/lib/tests/shell_loader_brk_cleanup.sh
index 95303d6409..4e8ce4f737 100755
--- testcases/lib/tests/shell_loader_brk_cleanup.sh
+++ testcases/lib/tests/shell_loader_brk_cleanup.sh
@@ -10,7 +10,7 @@
TST_CLEANUP=cleanup
-. tst_env.sh
+. tst_loader.sh
cleanup()
{
@@ -22,4 +22,4 @@ tst_test()
tst_brk TBROK "Test exits"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_c_child.sh testcases/lib/tests/shell_loader_c_child.sh
index c33decb1df..13480968f9 100755
--- testcases/lib/tests/shell_loader_c_child.sh
+++ testcases/lib/tests/shell_loader_c_child.sh
@@ -13,7 +13,7 @@
# }
# ---
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
@@ -25,4 +25,4 @@ tst_test()
shell_c_child
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_cleanup.sh testcases/lib/tests/shell_loader_cleanup.sh
index 4918df5ff2..91071a5a75 100755
--- testcases/lib/tests/shell_loader_cleanup.sh
+++ testcases/lib/tests/shell_loader_cleanup.sh
@@ -10,7 +10,7 @@
TST_CLEANUP=do_cleanup
-. tst_env.sh
+. tst_loader.sh
do_cleanup()
{
@@ -22,4 +22,4 @@ tst_test()
tst_res TPASS "Test is executed"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_filesystems.sh testcases/lib/tests/shell_loader_filesystems.sh
index 98466b918c..d584503adb 100755
--- testcases/lib/tests/shell_loader_filesystems.sh
+++ testcases/lib/tests/shell_loader_filesystems.sh
@@ -22,7 +22,7 @@
# }
# ---
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
@@ -40,4 +40,4 @@ tst_test()
fi
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_invalid_block.sh testcases/lib/tests/shell_loader_invalid_block.sh
index d2f5dc564f..be45303d79 100755
--- testcases/lib/tests/shell_loader_invalid_block.sh
+++ testcases/lib/tests/shell_loader_invalid_block.sh
@@ -20,11 +20,11 @@
# This is an invalid block that breaks the test.
# ---
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
tst_res TPASS "This should pass!"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_invalid_metadata.sh testcases/lib/tests/shell_loader_invalid_metadata.sh
index 52b3e69695..c4c7579243 100755
--- testcases/lib/tests/shell_loader_invalid_metadata.sh
+++ testcases/lib/tests/shell_loader_invalid_metadata.sh
@@ -12,11 +12,11 @@
# ---
#
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
tst_res TFAIL "Shell loader should TBROK the test"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_kconfigs.sh testcases/lib/tests/shell_loader_kconfigs.sh
index 61222ba115..d03bc99cac 100755
--- testcases/lib/tests/shell_loader_kconfigs.sh
+++ testcases/lib/tests/shell_loader_kconfigs.sh
@@ -9,11 +9,11 @@
# }
# ---
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
tst_res TPASS "Shell loader works fine!"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_no_metadata.sh testcases/lib/tests/shell_loader_no_metadata.sh
index 77c4420964..2ad458ef8d 100755
--- testcases/lib/tests/shell_loader_no_metadata.sh
+++ testcases/lib/tests/shell_loader_no_metadata.sh
@@ -5,11 +5,11 @@
# This test has no metadata and should not be executed
#
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
tst_res TFAIL "Shell loader should TBROK the test"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_setup_cleanup.sh testcases/lib/tests/shell_loader_setup_cleanup.sh
index fd149cedb0..8184278313 100755
--- testcases/lib/tests/shell_loader_setup_cleanup.sh
+++ testcases/lib/tests/shell_loader_setup_cleanup.sh
@@ -11,7 +11,7 @@
TST_SETUP=setup
TST_CLEANUP=cleanup
-. tst_env.sh
+. tst_loader.sh
setup()
{
@@ -28,4 +28,4 @@ tst_test()
tst_res TPASS "Test is executed"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_supported_archs.sh testcases/lib/tests/shell_loader_supported_archs.sh
index eda243003b..a45cc59b7d 100755
--- testcases/lib/tests/shell_loader_supported_archs.sh
+++ testcases/lib/tests/shell_loader_supported_archs.sh
@@ -9,11 +9,11 @@
# }
# ---
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
tst_res TPASS "We are running on supported architecture"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_tags.sh testcases/lib/tests/shell_loader_tags.sh
index 91e5a2ab2c..56eadaf7a2 100755
--- testcases/lib/tests/shell_loader_tags.sh
+++ testcases/lib/tests/shell_loader_tags.sh
@@ -12,11 +12,11 @@
# }
# ---
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
tst_res TFAIL "Fails the test so that tags are shown."
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_tcnt.sh testcases/lib/tests/shell_loader_tcnt.sh
index bfdc6b7576..cf2a0b74ec 100755
--- testcases/lib/tests/shell_loader_tcnt.sh
+++ testcases/lib/tests/shell_loader_tcnt.sh
@@ -12,11 +12,11 @@
# ---
#
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
tst_res TPASS "Iteration $1"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tests/shell_loader_wrong_metadata.sh testcases/lib/tests/shell_loader_wrong_metadata.sh
index 7ac4f348ee..35c535beed 100755
--- testcases/lib/tests/shell_loader_wrong_metadata.sh
+++ testcases/lib/tests/shell_loader_wrong_metadata.sh
@@ -12,11 +12,11 @@
# ---
#
-. tst_env.sh
+. tst_loader.sh
tst_test()
{
tst_res TFAIL "Shell loader should TBROK the test"
}
-. tst_loader.sh
+. tst_run.sh
diff --git testcases/lib/tst_loader.sh testcases/lib/tst_loader.sh
index ba6961353c..62c9cc6d8f 100644
--- testcases/lib/tst_loader.sh
+++ testcases/lib/tst_loader.sh
@@ -3,20 +3,11 @@
# Copyright (c) 2024-2025 Cyril Hrubis <chrubis@suse.cz>
#
# This is a loader for shell tests that use the C test library.
+#
if [ -z "$LTP_IPC_PATH" ]; then
tst_run_shell $(basename "$0") "$@"
exit $?
+else
+ . tst_env.sh
fi
-
-. tst_env.sh
-
-if [ -n "$TST_CLEANUP" ]; then
- trap $TST_CLEANUP EXIT
-fi
-
-if [ -n "$TST_SETUP" ]; then
- $TST_SETUP
-fi
-
-tst_test
diff --git testcases/lib/tst_run.sh testcases/lib/tst_run.sh
new file mode 100644
index 0000000000..ded2cd2099
--- /dev/null
+++ testcases/lib/tst_run.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2025 Cyril Hrubis <chrubis@suse.cz>
+# Copyright (c) 2025 Petr Vorel <pvorel@suse.cz>
+
+. tst_env.sh
+
+if [ -n "$TST_CLEANUP" ]; then
+ trap $TST_CLEANUP EXIT
+fi
+
+if [ -n "$TST_SETUP" ]; then
+ $TST_SETUP
+fi
+
+tst_test
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread* [LTP] [PATCH v3 1/4] shell lib: Add support for test cleanup
2025-06-09 12:45 [LTP] [PATCH v3 0/4] shell loader rewrite to support TST_SETUP Petr Vorel
@ 2025-06-09 12:45 ` Petr Vorel
2025-06-12 3:46 ` Li Wang via ltp
2025-06-09 12:45 ` [LTP] [PATCH v3 2/4] shell: Move shell code into functions Petr Vorel
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Petr Vorel @ 2025-06-09 12:45 UTC (permalink / raw)
To: ltp
From: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
The same as in v2.
testcases/lib/run_tests.sh | 4 +++-
.../lib/tests/shell_loader_brk_cleanup.sh | 20 +++++++++++++++++++
testcases/lib/tests/shell_loader_cleanup.sh | 20 +++++++++++++++++++
testcases/lib/tst_env.sh | 4 ++++
4 files changed, 47 insertions(+), 1 deletion(-)
create mode 100755 testcases/lib/tests/shell_loader_brk_cleanup.sh
create mode 100755 testcases/lib/tests/shell_loader_cleanup.sh
diff --git a/testcases/lib/run_tests.sh b/testcases/lib/run_tests.sh
index 321f74e5fe..128cee3377 100755
--- a/testcases/lib/run_tests.sh
+++ b/testcases/lib/run_tests.sh
@@ -9,6 +9,7 @@ shell_loader_filesystems.sh
shell_loader_kconfigs.sh
shell_loader_supported_archs.sh
shell_loader_tcnt.sh
+shell_loader_cleanup.sh
shell_test01
shell_test02
shell_test03
@@ -21,7 +22,8 @@ TESTS_TBROK="
shell_loader_invalid_block.sh
shell_loader_invalid_metadata.sh
shell_loader_no_metadata.sh
-shell_loader_wrong_metadata.sh"
+shell_loader_wrong_metadata.sh
+shell_loader_brk_cleanup.sh"
TESTS_TCONF="shell_test06"
diff --git a/testcases/lib/tests/shell_loader_brk_cleanup.sh b/testcases/lib/tests/shell_loader_brk_cleanup.sh
new file mode 100755
index 0000000000..8c704a5406
--- /dev/null
+++ b/testcases/lib/tests/shell_loader_brk_cleanup.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2024-2025 Cyril Hrubis <chrubis@suse.cz>
+#
+# ---
+# env
+# {
+# }
+# ---
+
+TST_CLEANUP=cleanup
+
+. tst_loader.sh
+
+cleanup()
+{
+ tst_res TINFO "Cleanup runs"
+}
+
+tst_brk TBROK "Test exits"
diff --git a/testcases/lib/tests/shell_loader_cleanup.sh b/testcases/lib/tests/shell_loader_cleanup.sh
new file mode 100755
index 0000000000..fb7bbdf5a9
--- /dev/null
+++ b/testcases/lib/tests/shell_loader_cleanup.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2024-2025 Cyril Hrubis <chrubis@suse.cz>
+#
+# ---
+# env
+# {
+# }
+# ---
+
+TST_CLEANUP=do_cleanup
+
+. tst_loader.sh
+
+do_cleanup()
+{
+ tst_res TINFO "Cleanup executed"
+}
+
+tst_res TPASS "Test is executed"
diff --git a/testcases/lib/tst_env.sh b/testcases/lib/tst_env.sh
index 68f9a0daa9..b13bab37c3 100644
--- a/testcases/lib/tst_env.sh
+++ b/testcases/lib/tst_env.sh
@@ -35,3 +35,7 @@ tst_brk_()
alias tst_res="tst_res_ $tst_script_name \$LINENO"
alias tst_brk="tst_brk_ $tst_script_name \$LINENO"
+
+if [ -n "$TST_CLEANUP" ]; then
+ trap $TST_CLEANUP EXIT
+fi
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH v3 1/4] shell lib: Add support for test cleanup
2025-06-09 12:45 ` [LTP] [PATCH v3 1/4] shell lib: Add support for test cleanup Petr Vorel
@ 2025-06-12 3:46 ` Li Wang via ltp
0 siblings, 0 replies; 13+ messages in thread
From: Li Wang via ltp @ 2025-06-12 3:46 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Mon, Jun 9, 2025 at 8:46 PM Petr Vorel <pvorel@suse.cz> wrote:
> From: Cyril Hrubis <chrubis@suse.cz>
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>
Reviewed-by: Li Wang <liwang@redhat.com>
---
> The same as in v2.
>
> testcases/lib/run_tests.sh | 4 +++-
> .../lib/tests/shell_loader_brk_cleanup.sh | 20 +++++++++++++++++++
> testcases/lib/tests/shell_loader_cleanup.sh | 20 +++++++++++++++++++
> testcases/lib/tst_env.sh | 4 ++++
> 4 files changed, 47 insertions(+), 1 deletion(-)
> create mode 100755 testcases/lib/tests/shell_loader_brk_cleanup.sh
> create mode 100755 testcases/lib/tests/shell_loader_cleanup.sh
>
> diff --git a/testcases/lib/run_tests.sh b/testcases/lib/run_tests.sh
> index 321f74e5fe..128cee3377 100755
> --- a/testcases/lib/run_tests.sh
> +++ b/testcases/lib/run_tests.sh
> @@ -9,6 +9,7 @@ shell_loader_filesystems.sh
> shell_loader_kconfigs.sh
> shell_loader_supported_archs.sh
> shell_loader_tcnt.sh
> +shell_loader_cleanup.sh
> shell_test01
> shell_test02
> shell_test03
> @@ -21,7 +22,8 @@ TESTS_TBROK="
> shell_loader_invalid_block.sh
> shell_loader_invalid_metadata.sh
> shell_loader_no_metadata.sh
> -shell_loader_wrong_metadata.sh"
> +shell_loader_wrong_metadata.sh
> +shell_loader_brk_cleanup.sh"
>
> TESTS_TCONF="shell_test06"
>
> diff --git a/testcases/lib/tests/shell_loader_brk_cleanup.sh
> b/testcases/lib/tests/shell_loader_brk_cleanup.sh
> new file mode 100755
> index 0000000000..8c704a5406
> --- /dev/null
> +++ b/testcases/lib/tests/shell_loader_brk_cleanup.sh
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2024-2025 Cyril Hrubis <chrubis@suse.cz>
> +#
> +# ---
> +# env
> +# {
> +# }
> +# ---
> +
> +TST_CLEANUP=cleanup
> +
> +. tst_loader.sh
> +
> +cleanup()
> +{
> + tst_res TINFO "Cleanup runs"
> +}
> +
> +tst_brk TBROK "Test exits"
> diff --git a/testcases/lib/tests/shell_loader_cleanup.sh
> b/testcases/lib/tests/shell_loader_cleanup.sh
> new file mode 100755
> index 0000000000..fb7bbdf5a9
> --- /dev/null
> +++ b/testcases/lib/tests/shell_loader_cleanup.sh
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2024-2025 Cyril Hrubis <chrubis@suse.cz>
> +#
> +# ---
> +# env
> +# {
> +# }
> +# ---
> +
> +TST_CLEANUP=do_cleanup
> +
> +. tst_loader.sh
> +
> +do_cleanup()
> +{
> + tst_res TINFO "Cleanup executed"
> +}
> +
> +tst_res TPASS "Test is executed"
> diff --git a/testcases/lib/tst_env.sh b/testcases/lib/tst_env.sh
> index 68f9a0daa9..b13bab37c3 100644
> --- a/testcases/lib/tst_env.sh
> +++ b/testcases/lib/tst_env.sh
> @@ -35,3 +35,7 @@ tst_brk_()
>
> alias tst_res="tst_res_ $tst_script_name \$LINENO"
> alias tst_brk="tst_brk_ $tst_script_name \$LINENO"
> +
> +if [ -n "$TST_CLEANUP" ]; then
> + trap $TST_CLEANUP EXIT
> +fi
> --
> 2.49.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* [LTP] [PATCH v3 2/4] shell: Move shell code into functions
2025-06-09 12:45 [LTP] [PATCH v3 0/4] shell loader rewrite to support TST_SETUP Petr Vorel
2025-06-09 12:45 ` [LTP] [PATCH v3 1/4] shell lib: Add support for test cleanup Petr Vorel
@ 2025-06-09 12:45 ` Petr Vorel
2025-06-12 3:47 ` Li Wang via ltp
2025-06-09 12:45 ` [LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup Petr Vorel
2025-06-09 12:45 ` [LTP] [PATCH v3 4/4] shell: Add shell_loader_setup_cleanup.sh test Petr Vorel
3 siblings, 1 reply; 13+ messages in thread
From: Petr Vorel @ 2025-06-09 12:45 UTC (permalink / raw)
To: ltp
This is a preparation to make next changes smaller.
No functional changes.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
NOTE: it's important to properly quote strings when assign with local.
Otherwise shell_loader_all_filesystems.sh fails on old dash 0.5.8-2.10 on local export:
/__w/ltp/ltp/testcases/lib/tests//shell_loader_all_filesystems.sh: 20: local: /tmp/LTP_sheiFmNGP/ltp_mntpoint: bad variable name
Quote grep subcomand helps. While at it quote also realpath subcomand.
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v2->v3:
* quoting to fix local on old dash:
+++ testcases/lib/tests/shell_loader_all_filesystems.sh
- local mntpath=$(realpath ltp_mntpoint)
- local mounted=$(grep $mntpath /proc/mounts)
+ local mntpath="$(realpath ltp_mntpoint)"
+ local mounted="$(grep $mntpath /proc/mounts)"
testcases/kernel/mem/vma/vma05.sh | 45 ++++++++++---------
testcases/lib/tests/shell_loader.sh | 19 +++++---
.../lib/tests/shell_loader_all_filesystems.sh | 26 ++++++-----
.../lib/tests/shell_loader_brk_cleanup.sh | 7 ++-
testcases/lib/tests/shell_loader_c_child.sh | 15 ++++---
testcases/lib/tests/shell_loader_cleanup.sh | 7 ++-
.../lib/tests/shell_loader_filesystems.sh | 23 ++++++----
.../lib/tests/shell_loader_invalid_block.sh | 7 ++-
.../tests/shell_loader_invalid_metadata.sh | 7 ++-
testcases/lib/tests/shell_loader_kconfigs.sh | 7 ++-
.../lib/tests/shell_loader_no_metadata.sh | 7 ++-
.../lib/tests/shell_loader_supported_archs.sh | 7 ++-
testcases/lib/tests/shell_loader_tags.sh | 7 ++-
testcases/lib/tests/shell_loader_tcnt.sh | 7 ++-
.../lib/tests/shell_loader_wrong_metadata.sh | 7 ++-
15 files changed, 137 insertions(+), 61 deletions(-)
diff --git a/testcases/kernel/mem/vma/vma05.sh b/testcases/kernel/mem/vma/vma05.sh
index f4c76b7034..11d6b2ad86 100755
--- a/testcases/kernel/mem/vma/vma05.sh
+++ b/testcases/kernel/mem/vma/vma05.sh
@@ -41,29 +41,34 @@
. tst_loader.sh
-ulimit -c unlimited
-unset DEBUGINFOD_URLS
+tst_test()
+{
+ ulimit -c unlimited
+ unset DEBUGINFOD_URLS
-if [ $(uname -m) = "x86_64" ]; then
- if LINE=$(grep "vsyscall" /proc/self/maps); then
- RIGHT="ffffffffff600000-ffffffffff601000[[:space:]][r-]-xp"
- if echo "$LINE" | grep -q "$RIGHT"; then
- tst_res TPASS "[vsyscall] reported correctly"
- else
- tst_res TFAIL "[vsyscall] reporting wrong"
+ if [ $(uname -m) = "x86_64" ]; then
+ if LINE=$(grep "vsyscall" /proc/self/maps); then
+ RIGHT="ffffffffff600000-ffffffffff601000[[:space:]][r-]-xp"
+ if echo "$LINE" | grep -q "$RIGHT"; then
+ tst_res TPASS "[vsyscall] reported correctly"
+ else
+ tst_res TFAIL "[vsyscall] reporting wrong"
+ fi
fi
fi
-fi
-rm -rf core*
-{ vma05_vdso; } > /dev/null 2>&1
-[ -f core ] || tst_brk TBROK "missing core file"
+ rm -rf core*
+ { vma05_vdso; } > /dev/null 2>&1
+ [ -f core ] || tst_brk TBROK "missing core file"
-TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\
- vma05_vdso ./core* 2> /dev/null)
+ TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\
+ vma05_vdso ./core* 2> /dev/null)
-if echo "$TRACE" | grep -qF "??"; then
- tst_res TFAIL "[vdso] bug not patched"
-else
- tst_res TPASS "[vdso] backtrace complete"
-fi
+ if echo "$TRACE" | grep -qF "??"; then
+ tst_res TFAIL "[vdso] bug not patched"
+ else
+ tst_res TPASS "[vdso] backtrace complete"
+ fi
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader.sh b/testcases/lib/tests/shell_loader.sh
index a7c5848ff5..73812c3e23 100755
--- a/testcases/lib/tests/shell_loader.sh
+++ b/testcases/lib/tests/shell_loader.sh
@@ -16,10 +16,15 @@
. tst_loader.sh
-tst_res TPASS "Shell loader works fine!"
-case "$PWD" in
- /tmp/*)
- tst_res TPASS "We are running in temp directory in $PWD";;
- *)
- tst_res TFAIL "We are not running in temp directory but $PWD";;
-esac
+tst_test()
+{
+ tst_res TPASS "Shell loader works fine!"
+ case "$PWD" in
+ /tmp/*)
+ tst_res TPASS "We are running in temp directory in $PWD";;
+ *)
+ tst_res TFAIL "We are not running in temp directory but $PWD";;
+ esac
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_all_filesystems.sh b/testcases/lib/tests/shell_loader_all_filesystems.sh
index 91fac89fd6..8fe3809a5e 100755
--- a/testcases/lib/tests/shell_loader_all_filesystems.sh
+++ b/testcases/lib/tests/shell_loader_all_filesystems.sh
@@ -14,16 +14,22 @@
. tst_loader.sh
-tst_res TINFO "In shell"
+tst_test()
+{
+ local mntpath="$(realpath ltp_mntpoint)"
+ local mounted="$(grep $mntpath /proc/mounts)"
+ local device path
-mntpath=$(realpath ltp_mntpoint)
-mounted=$(grep $mntpath /proc/mounts)
+ tst_res TINFO "In shell"
-if [ -n "$mounted" ]; then
- device=$(echo $mounted |cut -d' ' -f 1)
- path=$(echo $mounted |cut -d' ' -f 2)
+ if [ -n "$mounted" ]; then
+ device=$(echo $mounted |cut -d' ' -f 1)
+ path=$(echo $mounted |cut -d' ' -f 2)
- tst_res TPASS "$device mounted at $path"
-else
- tst_res TFAIL "Device not mounted!"
-fi
+ tst_res TPASS "$device mounted at $path"
+ else
+ tst_res TFAIL "Device not mounted!"
+ fi
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_brk_cleanup.sh b/testcases/lib/tests/shell_loader_brk_cleanup.sh
index 8c704a5406..ff33345ce3 100755
--- a/testcases/lib/tests/shell_loader_brk_cleanup.sh
+++ b/testcases/lib/tests/shell_loader_brk_cleanup.sh
@@ -17,4 +17,9 @@ cleanup()
tst_res TINFO "Cleanup runs"
}
-tst_brk TBROK "Test exits"
+tst_test()
+{
+ tst_brk TBROK "Test exits"
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_c_child.sh b/testcases/lib/tests/shell_loader_c_child.sh
index 34629e6d26..b2b8f3d057 100755
--- a/testcases/lib/tests/shell_loader_c_child.sh
+++ b/testcases/lib/tests/shell_loader_c_child.sh
@@ -15,9 +15,14 @@
. tst_loader.sh
-if [ -n "LTP_IPC_PATH" ]; then
- tst_res TPASS "LTP_IPC_PATH=$LTP_IPC_PATH!"
-fi
+tst_test()
+{
+ if [ -n "LTP_IPC_PATH" ]; then
+ tst_res TPASS "LTP_IPC_PATH=$LTP_IPC_PATH!"
+ fi
-tst_res TINFO "Running C child"
-shell_c_child
+ tst_res TINFO "Running C child"
+ shell_c_child
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_cleanup.sh b/testcases/lib/tests/shell_loader_cleanup.sh
index fb7bbdf5a9..684901b51f 100755
--- a/testcases/lib/tests/shell_loader_cleanup.sh
+++ b/testcases/lib/tests/shell_loader_cleanup.sh
@@ -17,4 +17,9 @@ do_cleanup()
tst_res TINFO "Cleanup executed"
}
-tst_res TPASS "Test is executed"
+tst_test()
+{
+ tst_res TPASS "Test is executed"
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_filesystems.sh b/testcases/lib/tests/shell_loader_filesystems.sh
index b7e1f9ba49..b2c9d2f7d1 100755
--- a/testcases/lib/tests/shell_loader_filesystems.sh
+++ b/testcases/lib/tests/shell_loader_filesystems.sh
@@ -24,15 +24,20 @@
. tst_loader.sh
-tst_res TINFO "In shell"
+tst_test()
+{
+ tst_res TINFO "In shell"
-mntpoint=$(realpath ltp_mntpoint)
-mounted=$(grep $mntpoint /proc/mounts)
+ mntpoint=$(realpath ltp_mntpoint)
+ mounted=$(grep $mntpoint /proc/mounts)
-if [ -n "$mounted" ]; then
- fs=$(echo $mounted |cut -d' ' -f 3)
+ if [ -n "$mounted" ]; then
+ fs=$(echo $mounted |cut -d' ' -f 3)
- tst_res TPASS "Mounted device formatted with $fs"
-else
- tst_res TFAIL "Device not mounted!"
-fi
+ tst_res TPASS "Mounted device formatted with $fs"
+ else
+ tst_res TFAIL "Device not mounted!"
+ fi
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_invalid_block.sh b/testcases/lib/tests/shell_loader_invalid_block.sh
index 01811c971d..370c9043bc 100755
--- a/testcases/lib/tests/shell_loader_invalid_block.sh
+++ b/testcases/lib/tests/shell_loader_invalid_block.sh
@@ -22,4 +22,9 @@
. tst_loader.sh
-tst_res TPASS "This should pass!"
+tst_test()
+{
+ tst_res TPASS "This should pass!"
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_invalid_metadata.sh b/testcases/lib/tests/shell_loader_invalid_metadata.sh
index aeae066841..3834f1b9ed 100755
--- a/testcases/lib/tests/shell_loader_invalid_metadata.sh
+++ b/testcases/lib/tests/shell_loader_invalid_metadata.sh
@@ -14,4 +14,9 @@
. tst_loader.sh
-tst_res TFAIL "Shell loader should TBROK the test"
+tst_test()
+{
+ tst_res TFAIL "Shell loader should TBROK the test"
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_kconfigs.sh b/testcases/lib/tests/shell_loader_kconfigs.sh
index b896f03ce0..e1b6187554 100755
--- a/testcases/lib/tests/shell_loader_kconfigs.sh
+++ b/testcases/lib/tests/shell_loader_kconfigs.sh
@@ -11,4 +11,9 @@
. tst_loader.sh
-tst_res TPASS "Shell loader works fine!"
+tst_test()
+{
+ tst_res TPASS "Shell loader works fine!"
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_no_metadata.sh b/testcases/lib/tests/shell_loader_no_metadata.sh
index e344327ed3..b664b48b57 100755
--- a/testcases/lib/tests/shell_loader_no_metadata.sh
+++ b/testcases/lib/tests/shell_loader_no_metadata.sh
@@ -7,4 +7,9 @@
. tst_loader.sh
-tst_res TFAIL "Shell loader should TBROK the test"
+tst_test()
+{
+ tst_res TFAIL "Shell loader should TBROK the test"
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_supported_archs.sh b/testcases/lib/tests/shell_loader_supported_archs.sh
index 45f0b1b1c2..9ad24f9c03 100755
--- a/testcases/lib/tests/shell_loader_supported_archs.sh
+++ b/testcases/lib/tests/shell_loader_supported_archs.sh
@@ -11,4 +11,9 @@
. tst_loader.sh
-tst_res TPASS "We are running on supported architecture"
+tst_test()
+{
+ tst_res TPASS "We are running on supported architecture"
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_tags.sh b/testcases/lib/tests/shell_loader_tags.sh
index 0b9416ea9a..c780a66c57 100755
--- a/testcases/lib/tests/shell_loader_tags.sh
+++ b/testcases/lib/tests/shell_loader_tags.sh
@@ -14,4 +14,9 @@
. tst_loader.sh
-tst_res TFAIL "Fails the test so that tags are shown."
+tst_test()
+{
+ tst_res TFAIL "Fails the test so that tags are shown."
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_tcnt.sh b/testcases/lib/tests/shell_loader_tcnt.sh
index ecf48396d6..93bd612ee2 100755
--- a/testcases/lib/tests/shell_loader_tcnt.sh
+++ b/testcases/lib/tests/shell_loader_tcnt.sh
@@ -14,4 +14,9 @@
. tst_loader.sh
-tst_res TPASS "Iteration $1"
+tst_test()
+{
+ tst_res TPASS "Iteration $1"
+}
+
+tst_test
diff --git a/testcases/lib/tests/shell_loader_wrong_metadata.sh b/testcases/lib/tests/shell_loader_wrong_metadata.sh
index b90b212371..8f18741100 100755
--- a/testcases/lib/tests/shell_loader_wrong_metadata.sh
+++ b/testcases/lib/tests/shell_loader_wrong_metadata.sh
@@ -14,4 +14,9 @@
. tst_loader.sh
-tst_res TFAIL "Shell loader should TBROK the test"
+tst_test()
+{
+ tst_res TFAIL "Shell loader should TBROK the test"
+}
+
+tst_test
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH v3 2/4] shell: Move shell code into functions
2025-06-09 12:45 ` [LTP] [PATCH v3 2/4] shell: Move shell code into functions Petr Vorel
@ 2025-06-12 3:47 ` Li Wang via ltp
0 siblings, 0 replies; 13+ messages in thread
From: Li Wang via ltp @ 2025-06-12 3:47 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Mon, Jun 9, 2025 at 8:45 PM Petr Vorel <pvorel@suse.cz> wrote:
> This is a preparation to make next changes smaller.
> No functional changes.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>
Reviewed-by: Li Wang <liwang@redhat.com>
> NOTE: it's important to properly quote strings when assign with local.
> Otherwise shell_loader_all_filesystems.sh fails on old dash 0.5.8-2.10 on
> local export:
>
> /__w/ltp/ltp/testcases/lib/tests//shell_loader_all_filesystems.sh: 20:
> local: /tmp/LTP_sheiFmNGP/ltp_mntpoint: bad variable name
>
> Quote grep subcomand helps. While at it quote also realpath subcomand.
>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Changes v2->v3:
> * quoting to fix local on old dash:
>
> +++ testcases/lib/tests/shell_loader_all_filesystems.sh
>
> - local mntpath=$(realpath ltp_mntpoint)
> - local mounted=$(grep $mntpath /proc/mounts)
> + local mntpath="$(realpath ltp_mntpoint)"
> + local mounted="$(grep $mntpath /proc/mounts)"
>
> testcases/kernel/mem/vma/vma05.sh | 45 ++++++++++---------
> testcases/lib/tests/shell_loader.sh | 19 +++++---
> .../lib/tests/shell_loader_all_filesystems.sh | 26 ++++++-----
> .../lib/tests/shell_loader_brk_cleanup.sh | 7 ++-
> testcases/lib/tests/shell_loader_c_child.sh | 15 ++++---
> testcases/lib/tests/shell_loader_cleanup.sh | 7 ++-
> .../lib/tests/shell_loader_filesystems.sh | 23 ++++++----
> .../lib/tests/shell_loader_invalid_block.sh | 7 ++-
> .../tests/shell_loader_invalid_metadata.sh | 7 ++-
> testcases/lib/tests/shell_loader_kconfigs.sh | 7 ++-
> .../lib/tests/shell_loader_no_metadata.sh | 7 ++-
> .../lib/tests/shell_loader_supported_archs.sh | 7 ++-
> testcases/lib/tests/shell_loader_tags.sh | 7 ++-
> testcases/lib/tests/shell_loader_tcnt.sh | 7 ++-
> .../lib/tests/shell_loader_wrong_metadata.sh | 7 ++-
> 15 files changed, 137 insertions(+), 61 deletions(-)
>
> diff --git a/testcases/kernel/mem/vma/vma05.sh
> b/testcases/kernel/mem/vma/vma05.sh
> index f4c76b7034..11d6b2ad86 100755
> --- a/testcases/kernel/mem/vma/vma05.sh
> +++ b/testcases/kernel/mem/vma/vma05.sh
> @@ -41,29 +41,34 @@
>
> . tst_loader.sh
>
> -ulimit -c unlimited
> -unset DEBUGINFOD_URLS
> +tst_test()
> +{
> + ulimit -c unlimited
> + unset DEBUGINFOD_URLS
>
> -if [ $(uname -m) = "x86_64" ]; then
> - if LINE=$(grep "vsyscall" /proc/self/maps); then
> - RIGHT="ffffffffff600000-ffffffffff601000[[:space:]][r-]-xp"
> - if echo "$LINE" | grep -q "$RIGHT"; then
> - tst_res TPASS "[vsyscall] reported correctly"
> - else
> - tst_res TFAIL "[vsyscall] reporting wrong"
> + if [ $(uname -m) = "x86_64" ]; then
> + if LINE=$(grep "vsyscall" /proc/self/maps); then
> +
> RIGHT="ffffffffff600000-ffffffffff601000[[:space:]][r-]-xp"
> + if echo "$LINE" | grep -q "$RIGHT"; then
> + tst_res TPASS "[vsyscall] reported
> correctly"
> + else
> + tst_res TFAIL "[vsyscall] reporting wrong"
> + fi
> fi
> fi
> -fi
>
> -rm -rf core*
> -{ vma05_vdso; } > /dev/null 2>&1
> -[ -f core ] || tst_brk TBROK "missing core file"
> + rm -rf core*
> + { vma05_vdso; } > /dev/null 2>&1
> + [ -f core ] || tst_brk TBROK "missing core file"
>
> -TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\
> - vma05_vdso ./core* 2> /dev/null)
> + TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\
> + vma05_vdso ./core* 2> /dev/null)
>
> -if echo "$TRACE" | grep -qF "??"; then
> - tst_res TFAIL "[vdso] bug not patched"
> -else
> - tst_res TPASS "[vdso] backtrace complete"
> -fi
> + if echo "$TRACE" | grep -qF "??"; then
> + tst_res TFAIL "[vdso] bug not patched"
> + else
> + tst_res TPASS "[vdso] backtrace complete"
> + fi
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader.sh
> b/testcases/lib/tests/shell_loader.sh
> index a7c5848ff5..73812c3e23 100755
> --- a/testcases/lib/tests/shell_loader.sh
> +++ b/testcases/lib/tests/shell_loader.sh
> @@ -16,10 +16,15 @@
>
> . tst_loader.sh
>
> -tst_res TPASS "Shell loader works fine!"
> -case "$PWD" in
> - /tmp/*)
> - tst_res TPASS "We are running in temp directory in $PWD";;
> - *)
> - tst_res TFAIL "We are not running in temp directory but
> $PWD";;
> -esac
> +tst_test()
> +{
> + tst_res TPASS "Shell loader works fine!"
> + case "$PWD" in
> + /tmp/*)
> + tst_res TPASS "We are running in temp directory in
> $PWD";;
> + *)
> + tst_res TFAIL "We are not running in temp
> directory but $PWD";;
> + esac
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_all_filesystems.sh
> b/testcases/lib/tests/shell_loader_all_filesystems.sh
> index 91fac89fd6..8fe3809a5e 100755
> --- a/testcases/lib/tests/shell_loader_all_filesystems.sh
> +++ b/testcases/lib/tests/shell_loader_all_filesystems.sh
> @@ -14,16 +14,22 @@
>
> . tst_loader.sh
>
> -tst_res TINFO "In shell"
> +tst_test()
> +{
> + local mntpath="$(realpath ltp_mntpoint)"
> + local mounted="$(grep $mntpath /proc/mounts)"
> + local device path
>
> -mntpath=$(realpath ltp_mntpoint)
> -mounted=$(grep $mntpath /proc/mounts)
> + tst_res TINFO "In shell"
>
> -if [ -n "$mounted" ]; then
> - device=$(echo $mounted |cut -d' ' -f 1)
> - path=$(echo $mounted |cut -d' ' -f 2)
> + if [ -n "$mounted" ]; then
> + device=$(echo $mounted |cut -d' ' -f 1)
> + path=$(echo $mounted |cut -d' ' -f 2)
>
> - tst_res TPASS "$device mounted at $path"
> -else
> - tst_res TFAIL "Device not mounted!"
> -fi
> + tst_res TPASS "$device mounted at $path"
> + else
> + tst_res TFAIL "Device not mounted!"
> + fi
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_brk_cleanup.sh
> b/testcases/lib/tests/shell_loader_brk_cleanup.sh
> index 8c704a5406..ff33345ce3 100755
> --- a/testcases/lib/tests/shell_loader_brk_cleanup.sh
> +++ b/testcases/lib/tests/shell_loader_brk_cleanup.sh
> @@ -17,4 +17,9 @@ cleanup()
> tst_res TINFO "Cleanup runs"
> }
>
> -tst_brk TBROK "Test exits"
> +tst_test()
> +{
> + tst_brk TBROK "Test exits"
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_c_child.sh
> b/testcases/lib/tests/shell_loader_c_child.sh
> index 34629e6d26..b2b8f3d057 100755
> --- a/testcases/lib/tests/shell_loader_c_child.sh
> +++ b/testcases/lib/tests/shell_loader_c_child.sh
> @@ -15,9 +15,14 @@
>
> . tst_loader.sh
>
> -if [ -n "LTP_IPC_PATH" ]; then
> - tst_res TPASS "LTP_IPC_PATH=$LTP_IPC_PATH!"
> -fi
> +tst_test()
> +{
> + if [ -n "LTP_IPC_PATH" ]; then
> + tst_res TPASS "LTP_IPC_PATH=$LTP_IPC_PATH!"
> + fi
>
> -tst_res TINFO "Running C child"
> -shell_c_child
> + tst_res TINFO "Running C child"
> + shell_c_child
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_cleanup.sh
> b/testcases/lib/tests/shell_loader_cleanup.sh
> index fb7bbdf5a9..684901b51f 100755
> --- a/testcases/lib/tests/shell_loader_cleanup.sh
> +++ b/testcases/lib/tests/shell_loader_cleanup.sh
> @@ -17,4 +17,9 @@ do_cleanup()
> tst_res TINFO "Cleanup executed"
> }
>
> -tst_res TPASS "Test is executed"
> +tst_test()
> +{
> + tst_res TPASS "Test is executed"
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_filesystems.sh
> b/testcases/lib/tests/shell_loader_filesystems.sh
> index b7e1f9ba49..b2c9d2f7d1 100755
> --- a/testcases/lib/tests/shell_loader_filesystems.sh
> +++ b/testcases/lib/tests/shell_loader_filesystems.sh
> @@ -24,15 +24,20 @@
>
> . tst_loader.sh
>
> -tst_res TINFO "In shell"
> +tst_test()
> +{
> + tst_res TINFO "In shell"
>
> -mntpoint=$(realpath ltp_mntpoint)
> -mounted=$(grep $mntpoint /proc/mounts)
> + mntpoint=$(realpath ltp_mntpoint)
> + mounted=$(grep $mntpoint /proc/mounts)
>
> -if [ -n "$mounted" ]; then
> - fs=$(echo $mounted |cut -d' ' -f 3)
> + if [ -n "$mounted" ]; then
> + fs=$(echo $mounted |cut -d' ' -f 3)
>
> - tst_res TPASS "Mounted device formatted with $fs"
> -else
> - tst_res TFAIL "Device not mounted!"
> -fi
> + tst_res TPASS "Mounted device formatted with $fs"
> + else
> + tst_res TFAIL "Device not mounted!"
> + fi
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_invalid_block.sh
> b/testcases/lib/tests/shell_loader_invalid_block.sh
> index 01811c971d..370c9043bc 100755
> --- a/testcases/lib/tests/shell_loader_invalid_block.sh
> +++ b/testcases/lib/tests/shell_loader_invalid_block.sh
> @@ -22,4 +22,9 @@
>
> . tst_loader.sh
>
> -tst_res TPASS "This should pass!"
> +tst_test()
> +{
> + tst_res TPASS "This should pass!"
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_invalid_metadata.sh
> b/testcases/lib/tests/shell_loader_invalid_metadata.sh
> index aeae066841..3834f1b9ed 100755
> --- a/testcases/lib/tests/shell_loader_invalid_metadata.sh
> +++ b/testcases/lib/tests/shell_loader_invalid_metadata.sh
> @@ -14,4 +14,9 @@
>
> . tst_loader.sh
>
> -tst_res TFAIL "Shell loader should TBROK the test"
> +tst_test()
> +{
> + tst_res TFAIL "Shell loader should TBROK the test"
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_kconfigs.sh
> b/testcases/lib/tests/shell_loader_kconfigs.sh
> index b896f03ce0..e1b6187554 100755
> --- a/testcases/lib/tests/shell_loader_kconfigs.sh
> +++ b/testcases/lib/tests/shell_loader_kconfigs.sh
> @@ -11,4 +11,9 @@
>
> . tst_loader.sh
>
> -tst_res TPASS "Shell loader works fine!"
> +tst_test()
> +{
> + tst_res TPASS "Shell loader works fine!"
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_no_metadata.sh
> b/testcases/lib/tests/shell_loader_no_metadata.sh
> index e344327ed3..b664b48b57 100755
> --- a/testcases/lib/tests/shell_loader_no_metadata.sh
> +++ b/testcases/lib/tests/shell_loader_no_metadata.sh
> @@ -7,4 +7,9 @@
>
> . tst_loader.sh
>
> -tst_res TFAIL "Shell loader should TBROK the test"
> +tst_test()
> +{
> + tst_res TFAIL "Shell loader should TBROK the test"
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_supported_archs.sh
> b/testcases/lib/tests/shell_loader_supported_archs.sh
> index 45f0b1b1c2..9ad24f9c03 100755
> --- a/testcases/lib/tests/shell_loader_supported_archs.sh
> +++ b/testcases/lib/tests/shell_loader_supported_archs.sh
> @@ -11,4 +11,9 @@
>
> . tst_loader.sh
>
> -tst_res TPASS "We are running on supported architecture"
> +tst_test()
> +{
> + tst_res TPASS "We are running on supported architecture"
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_tags.sh
> b/testcases/lib/tests/shell_loader_tags.sh
> index 0b9416ea9a..c780a66c57 100755
> --- a/testcases/lib/tests/shell_loader_tags.sh
> +++ b/testcases/lib/tests/shell_loader_tags.sh
> @@ -14,4 +14,9 @@
>
> . tst_loader.sh
>
> -tst_res TFAIL "Fails the test so that tags are shown."
> +tst_test()
> +{
> + tst_res TFAIL "Fails the test so that tags are shown."
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_tcnt.sh
> b/testcases/lib/tests/shell_loader_tcnt.sh
> index ecf48396d6..93bd612ee2 100755
> --- a/testcases/lib/tests/shell_loader_tcnt.sh
> +++ b/testcases/lib/tests/shell_loader_tcnt.sh
> @@ -14,4 +14,9 @@
>
> . tst_loader.sh
>
> -tst_res TPASS "Iteration $1"
> +tst_test()
> +{
> + tst_res TPASS "Iteration $1"
> +}
> +
> +tst_test
> diff --git a/testcases/lib/tests/shell_loader_wrong_metadata.sh
> b/testcases/lib/tests/shell_loader_wrong_metadata.sh
> index b90b212371..8f18741100 100755
> --- a/testcases/lib/tests/shell_loader_wrong_metadata.sh
> +++ b/testcases/lib/tests/shell_loader_wrong_metadata.sh
> @@ -14,4 +14,9 @@
>
> . tst_loader.sh
>
> -tst_res TFAIL "Shell loader should TBROK the test"
> +tst_test()
> +{
> + tst_res TFAIL "Shell loader should TBROK the test"
> +}
> +
> +tst_test
> --
> 2.49.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* [LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup
2025-06-09 12:45 [LTP] [PATCH v3 0/4] shell loader rewrite to support TST_SETUP Petr Vorel
2025-06-09 12:45 ` [LTP] [PATCH v3 1/4] shell lib: Add support for test cleanup Petr Vorel
2025-06-09 12:45 ` [LTP] [PATCH v3 2/4] shell: Move shell code into functions Petr Vorel
@ 2025-06-09 12:45 ` Petr Vorel
2025-06-12 5:08 ` Li Wang via ltp
2025-06-12 7:48 ` Li Wang via ltp
2025-06-09 12:45 ` [LTP] [PATCH v3 4/4] shell: Add shell_loader_setup_cleanup.sh test Petr Vorel
3 siblings, 2 replies; 13+ messages in thread
From: Petr Vorel @ 2025-06-09 12:45 UTC (permalink / raw)
To: ltp
Add basic support for test cleanup in shell loader.
This required to:
* Source tst_env.sh also in the tests before test/setup/cleanup functions,
otherwise tst_res alias would not be found:
tests/shell_loader_setup_cleanup.sh: 22: tst_res: not found
* Add tst_run.sh
* Move sourcing tst_loader.sh at the end of the test (after
test/setup/cleanup functions), otherwise test/setup/cleanup would not be found:
tests/shell_loader_setup_cleanup.sh: 19: testcases/lib/tst_loader.sh: setup: not found
tests/shell_loader_setup_cleanup.sh: 22: testcases/lib/tst_loader.sh: tst_test: not found
This solves the problem of the order the scripts are sourced. Before it was:
test.sh
. tst_loader.sh
tst_run_shell test.sh
. tst_loader.sh
. tst_env.sh <- at this point in the execution it haven't even started parsing
test.sh so it cannot run functions from there at all
Now:
test.sh
. tst_loader.sh
tst_run_shell test.sh
. tst_loader.sh
. tst_env.sh
. tst_run.sh
There will be more improvements in the future, at least adding TST_CNT
support (will require changes in tst_test.c to handle timeouts).
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Co-developed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v2->v3:
* Create tst_run.sh (Cyril)
testcases/kernel/mem/vma/vma05.sh | 2 +-
testcases/lib/tests/shell_loader.sh | 2 +-
.../lib/tests/shell_loader_all_filesystems.sh | 2 +-
testcases/lib/tests/shell_loader_brk_cleanup.sh | 2 +-
testcases/lib/tests/shell_loader_c_child.sh | 2 +-
testcases/lib/tests/shell_loader_cleanup.sh | 2 +-
testcases/lib/tests/shell_loader_filesystems.sh | 2 +-
.../lib/tests/shell_loader_invalid_block.sh | 2 +-
.../lib/tests/shell_loader_invalid_metadata.sh | 2 +-
testcases/lib/tests/shell_loader_kconfigs.sh | 2 +-
testcases/lib/tests/shell_loader_no_metadata.sh | 2 +-
.../lib/tests/shell_loader_supported_archs.sh | 2 +-
testcases/lib/tests/shell_loader_tags.sh | 2 +-
testcases/lib/tests/shell_loader_tcnt.sh | 2 +-
.../lib/tests/shell_loader_wrong_metadata.sh | 2 +-
testcases/lib/tst_env.sh | 9 ---------
testcases/lib/tst_run.sh | 16 ++++++++++++++++
17 files changed, 31 insertions(+), 24 deletions(-)
create mode 100644 testcases/lib/tst_run.sh
diff --git a/testcases/kernel/mem/vma/vma05.sh b/testcases/kernel/mem/vma/vma05.sh
index 11d6b2ad86..c560eecbcd 100755
--- a/testcases/kernel/mem/vma/vma05.sh
+++ b/testcases/kernel/mem/vma/vma05.sh
@@ -71,4 +71,4 @@ tst_test()
fi
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader.sh b/testcases/lib/tests/shell_loader.sh
index 73812c3e23..78dba06b25 100755
--- a/testcases/lib/tests/shell_loader.sh
+++ b/testcases/lib/tests/shell_loader.sh
@@ -27,4 +27,4 @@ tst_test()
esac
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_all_filesystems.sh b/testcases/lib/tests/shell_loader_all_filesystems.sh
index 8fe3809a5e..3c3978f51c 100755
--- a/testcases/lib/tests/shell_loader_all_filesystems.sh
+++ b/testcases/lib/tests/shell_loader_all_filesystems.sh
@@ -32,4 +32,4 @@ tst_test()
fi
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_brk_cleanup.sh b/testcases/lib/tests/shell_loader_brk_cleanup.sh
index ff33345ce3..4e8ce4f737 100755
--- a/testcases/lib/tests/shell_loader_brk_cleanup.sh
+++ b/testcases/lib/tests/shell_loader_brk_cleanup.sh
@@ -22,4 +22,4 @@ tst_test()
tst_brk TBROK "Test exits"
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_c_child.sh b/testcases/lib/tests/shell_loader_c_child.sh
index b2b8f3d057..13480968f9 100755
--- a/testcases/lib/tests/shell_loader_c_child.sh
+++ b/testcases/lib/tests/shell_loader_c_child.sh
@@ -25,4 +25,4 @@ tst_test()
shell_c_child
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_cleanup.sh b/testcases/lib/tests/shell_loader_cleanup.sh
index 684901b51f..91071a5a75 100755
--- a/testcases/lib/tests/shell_loader_cleanup.sh
+++ b/testcases/lib/tests/shell_loader_cleanup.sh
@@ -22,4 +22,4 @@ tst_test()
tst_res TPASS "Test is executed"
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_filesystems.sh b/testcases/lib/tests/shell_loader_filesystems.sh
index b2c9d2f7d1..d584503adb 100755
--- a/testcases/lib/tests/shell_loader_filesystems.sh
+++ b/testcases/lib/tests/shell_loader_filesystems.sh
@@ -40,4 +40,4 @@ tst_test()
fi
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_invalid_block.sh b/testcases/lib/tests/shell_loader_invalid_block.sh
index 370c9043bc..be45303d79 100755
--- a/testcases/lib/tests/shell_loader_invalid_block.sh
+++ b/testcases/lib/tests/shell_loader_invalid_block.sh
@@ -27,4 +27,4 @@ tst_test()
tst_res TPASS "This should pass!"
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_invalid_metadata.sh b/testcases/lib/tests/shell_loader_invalid_metadata.sh
index 3834f1b9ed..c4c7579243 100755
--- a/testcases/lib/tests/shell_loader_invalid_metadata.sh
+++ b/testcases/lib/tests/shell_loader_invalid_metadata.sh
@@ -19,4 +19,4 @@ tst_test()
tst_res TFAIL "Shell loader should TBROK the test"
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_kconfigs.sh b/testcases/lib/tests/shell_loader_kconfigs.sh
index e1b6187554..d03bc99cac 100755
--- a/testcases/lib/tests/shell_loader_kconfigs.sh
+++ b/testcases/lib/tests/shell_loader_kconfigs.sh
@@ -16,4 +16,4 @@ tst_test()
tst_res TPASS "Shell loader works fine!"
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_no_metadata.sh b/testcases/lib/tests/shell_loader_no_metadata.sh
index b664b48b57..2ad458ef8d 100755
--- a/testcases/lib/tests/shell_loader_no_metadata.sh
+++ b/testcases/lib/tests/shell_loader_no_metadata.sh
@@ -12,4 +12,4 @@ tst_test()
tst_res TFAIL "Shell loader should TBROK the test"
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_supported_archs.sh b/testcases/lib/tests/shell_loader_supported_archs.sh
index 9ad24f9c03..a45cc59b7d 100755
--- a/testcases/lib/tests/shell_loader_supported_archs.sh
+++ b/testcases/lib/tests/shell_loader_supported_archs.sh
@@ -16,4 +16,4 @@ tst_test()
tst_res TPASS "We are running on supported architecture"
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_tags.sh b/testcases/lib/tests/shell_loader_tags.sh
index c780a66c57..56eadaf7a2 100755
--- a/testcases/lib/tests/shell_loader_tags.sh
+++ b/testcases/lib/tests/shell_loader_tags.sh
@@ -19,4 +19,4 @@ tst_test()
tst_res TFAIL "Fails the test so that tags are shown."
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_tcnt.sh b/testcases/lib/tests/shell_loader_tcnt.sh
index 93bd612ee2..cf2a0b74ec 100755
--- a/testcases/lib/tests/shell_loader_tcnt.sh
+++ b/testcases/lib/tests/shell_loader_tcnt.sh
@@ -19,4 +19,4 @@ tst_test()
tst_res TPASS "Iteration $1"
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tests/shell_loader_wrong_metadata.sh b/testcases/lib/tests/shell_loader_wrong_metadata.sh
index 8f18741100..35c535beed 100755
--- a/testcases/lib/tests/shell_loader_wrong_metadata.sh
+++ b/testcases/lib/tests/shell_loader_wrong_metadata.sh
@@ -19,4 +19,4 @@ tst_test()
tst_res TFAIL "Shell loader should TBROK the test"
}
-tst_test
+. tst_run.sh
diff --git a/testcases/lib/tst_env.sh b/testcases/lib/tst_env.sh
index b13bab37c3..585790a7d0 100644
--- a/testcases/lib/tst_env.sh
+++ b/testcases/lib/tst_env.sh
@@ -18,11 +18,6 @@ if [ -z "$LINENO" ]; then
LINENO=-1
fi
-if [ -z "$LTP_IPC_PATH" ]; then
- echo "This script has to be executed from a LTP loader!"
- exit 1
-fi
-
tst_brk_()
{
tst_res_ "$@"
@@ -35,7 +30,3 @@ tst_brk_()
alias tst_res="tst_res_ $tst_script_name \$LINENO"
alias tst_brk="tst_brk_ $tst_script_name \$LINENO"
-
-if [ -n "$TST_CLEANUP" ]; then
- trap $TST_CLEANUP EXIT
-fi
diff --git a/testcases/lib/tst_run.sh b/testcases/lib/tst_run.sh
new file mode 100644
index 0000000000..ded2cd2099
--- /dev/null
+++ b/testcases/lib/tst_run.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2025 Cyril Hrubis <chrubis@suse.cz>
+# Copyright (c) 2025 Petr Vorel <pvorel@suse.cz>
+
+. tst_env.sh
+
+if [ -n "$TST_CLEANUP" ]; then
+ trap $TST_CLEANUP EXIT
+fi
+
+if [ -n "$TST_SETUP" ]; then
+ $TST_SETUP
+fi
+
+tst_test
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup
2025-06-09 12:45 ` [LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup Petr Vorel
@ 2025-06-12 5:08 ` Li Wang via ltp
2025-06-12 7:48 ` Li Wang via ltp
1 sibling, 0 replies; 13+ messages in thread
From: Li Wang via ltp @ 2025-06-12 5:08 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Mon, Jun 9, 2025 at 8:46 PM Petr Vorel <pvorel@suse.cz> wrote:
> Add basic support for test cleanup in shell loader.
>
> This required to:
>
> * Source tst_env.sh also in the tests before test/setup/cleanup functions,
> otherwise tst_res alias would not be found:
> tests/shell_loader_setup_cleanup.sh: 22: tst_res: not found
>
> * Add tst_run.sh
> * Move sourcing tst_loader.sh at the end of the test (after
> test/setup/cleanup functions), otherwise test/setup/cleanup would not be
> found:
> tests/shell_loader_setup_cleanup.sh: 19: testcases/lib/tst_loader.sh:
> setup: not found
> tests/shell_loader_setup_cleanup.sh: 22: testcases/lib/tst_loader.sh:
> tst_test: not found
>
> This solves the problem of the order the scripts are sourced. Before it
> was:
>
> test.sh
> . tst_loader.sh
> tst_run_shell test.sh
> . tst_loader.sh
> . tst_env.sh <- at this point in the execution it haven't even
> started parsing
> test.sh so it cannot run functions from there at all
>
> Now:
>
> test.sh
> . tst_loader.sh
> tst_run_shell test.sh
> . tst_loader.sh
> . tst_env.sh
> . tst_run.sh
>
> There will be more improvements in the future, at least adding TST_CNT
> support (will require changes in tst_test.c to handle timeouts).
>
> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
> Co-developed-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>
Reviewed-by: Li Wang <liwang@redhat.com>
---
> Changes v2->v3:
> * Create tst_run.sh (Cyril)
>
> testcases/kernel/mem/vma/vma05.sh | 2 +-
> testcases/lib/tests/shell_loader.sh | 2 +-
> .../lib/tests/shell_loader_all_filesystems.sh | 2 +-
> testcases/lib/tests/shell_loader_brk_cleanup.sh | 2 +-
> testcases/lib/tests/shell_loader_c_child.sh | 2 +-
> testcases/lib/tests/shell_loader_cleanup.sh | 2 +-
> testcases/lib/tests/shell_loader_filesystems.sh | 2 +-
> .../lib/tests/shell_loader_invalid_block.sh | 2 +-
> .../lib/tests/shell_loader_invalid_metadata.sh | 2 +-
> testcases/lib/tests/shell_loader_kconfigs.sh | 2 +-
> testcases/lib/tests/shell_loader_no_metadata.sh | 2 +-
> .../lib/tests/shell_loader_supported_archs.sh | 2 +-
> testcases/lib/tests/shell_loader_tags.sh | 2 +-
> testcases/lib/tests/shell_loader_tcnt.sh | 2 +-
> .../lib/tests/shell_loader_wrong_metadata.sh | 2 +-
> testcases/lib/tst_env.sh | 9 ---------
> testcases/lib/tst_run.sh | 16 ++++++++++++++++
> 17 files changed, 31 insertions(+), 24 deletions(-)
> create mode 100644 testcases/lib/tst_run.sh
>
> diff --git a/testcases/kernel/mem/vma/vma05.sh
> b/testcases/kernel/mem/vma/vma05.sh
> index 11d6b2ad86..c560eecbcd 100755
> --- a/testcases/kernel/mem/vma/vma05.sh
> +++ b/testcases/kernel/mem/vma/vma05.sh
> @@ -71,4 +71,4 @@ tst_test()
> fi
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader.sh
> b/testcases/lib/tests/shell_loader.sh
> index 73812c3e23..78dba06b25 100755
> --- a/testcases/lib/tests/shell_loader.sh
> +++ b/testcases/lib/tests/shell_loader.sh
> @@ -27,4 +27,4 @@ tst_test()
> esac
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_all_filesystems.sh
> b/testcases/lib/tests/shell_loader_all_filesystems.sh
> index 8fe3809a5e..3c3978f51c 100755
> --- a/testcases/lib/tests/shell_loader_all_filesystems.sh
> +++ b/testcases/lib/tests/shell_loader_all_filesystems.sh
> @@ -32,4 +32,4 @@ tst_test()
> fi
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_brk_cleanup.sh
> b/testcases/lib/tests/shell_loader_brk_cleanup.sh
> index ff33345ce3..4e8ce4f737 100755
> --- a/testcases/lib/tests/shell_loader_brk_cleanup.sh
> +++ b/testcases/lib/tests/shell_loader_brk_cleanup.sh
> @@ -22,4 +22,4 @@ tst_test()
> tst_brk TBROK "Test exits"
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_c_child.sh
> b/testcases/lib/tests/shell_loader_c_child.sh
> index b2b8f3d057..13480968f9 100755
> --- a/testcases/lib/tests/shell_loader_c_child.sh
> +++ b/testcases/lib/tests/shell_loader_c_child.sh
> @@ -25,4 +25,4 @@ tst_test()
> shell_c_child
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_cleanup.sh
> b/testcases/lib/tests/shell_loader_cleanup.sh
> index 684901b51f..91071a5a75 100755
> --- a/testcases/lib/tests/shell_loader_cleanup.sh
> +++ b/testcases/lib/tests/shell_loader_cleanup.sh
> @@ -22,4 +22,4 @@ tst_test()
> tst_res TPASS "Test is executed"
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_filesystems.sh
> b/testcases/lib/tests/shell_loader_filesystems.sh
> index b2c9d2f7d1..d584503adb 100755
> --- a/testcases/lib/tests/shell_loader_filesystems.sh
> +++ b/testcases/lib/tests/shell_loader_filesystems.sh
> @@ -40,4 +40,4 @@ tst_test()
> fi
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_invalid_block.sh
> b/testcases/lib/tests/shell_loader_invalid_block.sh
> index 370c9043bc..be45303d79 100755
> --- a/testcases/lib/tests/shell_loader_invalid_block.sh
> +++ b/testcases/lib/tests/shell_loader_invalid_block.sh
> @@ -27,4 +27,4 @@ tst_test()
> tst_res TPASS "This should pass!"
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_invalid_metadata.sh
> b/testcases/lib/tests/shell_loader_invalid_metadata.sh
> index 3834f1b9ed..c4c7579243 100755
> --- a/testcases/lib/tests/shell_loader_invalid_metadata.sh
> +++ b/testcases/lib/tests/shell_loader_invalid_metadata.sh
> @@ -19,4 +19,4 @@ tst_test()
> tst_res TFAIL "Shell loader should TBROK the test"
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_kconfigs.sh
> b/testcases/lib/tests/shell_loader_kconfigs.sh
> index e1b6187554..d03bc99cac 100755
> --- a/testcases/lib/tests/shell_loader_kconfigs.sh
> +++ b/testcases/lib/tests/shell_loader_kconfigs.sh
> @@ -16,4 +16,4 @@ tst_test()
> tst_res TPASS "Shell loader works fine!"
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_no_metadata.sh
> b/testcases/lib/tests/shell_loader_no_metadata.sh
> index b664b48b57..2ad458ef8d 100755
> --- a/testcases/lib/tests/shell_loader_no_metadata.sh
> +++ b/testcases/lib/tests/shell_loader_no_metadata.sh
> @@ -12,4 +12,4 @@ tst_test()
> tst_res TFAIL "Shell loader should TBROK the test"
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_supported_archs.sh
> b/testcases/lib/tests/shell_loader_supported_archs.sh
> index 9ad24f9c03..a45cc59b7d 100755
> --- a/testcases/lib/tests/shell_loader_supported_archs.sh
> +++ b/testcases/lib/tests/shell_loader_supported_archs.sh
> @@ -16,4 +16,4 @@ tst_test()
> tst_res TPASS "We are running on supported architecture"
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_tags.sh
> b/testcases/lib/tests/shell_loader_tags.sh
> index c780a66c57..56eadaf7a2 100755
> --- a/testcases/lib/tests/shell_loader_tags.sh
> +++ b/testcases/lib/tests/shell_loader_tags.sh
> @@ -19,4 +19,4 @@ tst_test()
> tst_res TFAIL "Fails the test so that tags are shown."
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_tcnt.sh
> b/testcases/lib/tests/shell_loader_tcnt.sh
> index 93bd612ee2..cf2a0b74ec 100755
> --- a/testcases/lib/tests/shell_loader_tcnt.sh
> +++ b/testcases/lib/tests/shell_loader_tcnt.sh
> @@ -19,4 +19,4 @@ tst_test()
> tst_res TPASS "Iteration $1"
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tests/shell_loader_wrong_metadata.sh
> b/testcases/lib/tests/shell_loader_wrong_metadata.sh
> index 8f18741100..35c535beed 100755
> --- a/testcases/lib/tests/shell_loader_wrong_metadata.sh
> +++ b/testcases/lib/tests/shell_loader_wrong_metadata.sh
> @@ -19,4 +19,4 @@ tst_test()
> tst_res TFAIL "Shell loader should TBROK the test"
> }
>
> -tst_test
> +. tst_run.sh
> diff --git a/testcases/lib/tst_env.sh b/testcases/lib/tst_env.sh
> index b13bab37c3..585790a7d0 100644
> --- a/testcases/lib/tst_env.sh
> +++ b/testcases/lib/tst_env.sh
> @@ -18,11 +18,6 @@ if [ -z "$LINENO" ]; then
> LINENO=-1
> fi
>
> -if [ -z "$LTP_IPC_PATH" ]; then
> - echo "This script has to be executed from a LTP loader!"
> - exit 1
> -fi
> -
> tst_brk_()
> {
> tst_res_ "$@"
> @@ -35,7 +30,3 @@ tst_brk_()
>
> alias tst_res="tst_res_ $tst_script_name \$LINENO"
> alias tst_brk="tst_brk_ $tst_script_name \$LINENO"
> -
> -if [ -n "$TST_CLEANUP" ]; then
> - trap $TST_CLEANUP EXIT
> -fi
> diff --git a/testcases/lib/tst_run.sh b/testcases/lib/tst_run.sh
> new file mode 100644
> index 0000000000..ded2cd2099
> --- /dev/null
> +++ b/testcases/lib/tst_run.sh
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2025 Cyril Hrubis <chrubis@suse.cz>
> +# Copyright (c) 2025 Petr Vorel <pvorel@suse.cz>
> +
> +. tst_env.sh
> +
> +if [ -n "$TST_CLEANUP" ]; then
> + trap $TST_CLEANUP EXIT
> +fi
> +
> +if [ -n "$TST_SETUP" ]; then
> + $TST_SETUP
> +fi
> +
> +tst_test
> --
> 2.49.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup
2025-06-09 12:45 ` [LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup Petr Vorel
2025-06-12 5:08 ` Li Wang via ltp
@ 2025-06-12 7:48 ` Li Wang via ltp
2025-07-17 10:26 ` Petr Vorel
1 sibling, 1 reply; 13+ messages in thread
From: Li Wang via ltp @ 2025-06-12 7:48 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
PM Petr Vorel <pvorel@suse.cz> wrote:
> --- /dev/null
> +++ b/testcases/lib/tst_run.sh
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2025 Cyril Hrubis <chrubis@suse.cz>
> +# Copyright (c) 2025 Petr Vorel <pvorel@suse.cz>
> +
> +. tst_env.sh
> +
> +if [ -n "$TST_CLEANUP" ]; then
> + trap $TST_CLEANUP EXIT
> +fi
> +
> +if [ -n "$TST_SETUP" ]; then
> + $TST_SETUP
> +fi
> +
>
Here maybe better to have a check before the tst_test:
if ! declare -F tst_test > /dev/null; then
tst_brk TBROK "tst_test() function is not defined"
fi
> +tst_test
> --
> 2.49.0
>
Sorry, I should have pointed this out at the first review, but
the idea came to my mind a little bit delayed :).
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup
2025-06-12 7:48 ` Li Wang via ltp
@ 2025-07-17 10:26 ` Petr Vorel
2025-07-17 15:38 ` Cyril Hrubis
0 siblings, 1 reply; 13+ messages in thread
From: Petr Vorel @ 2025-07-17 10:26 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi Li, Cyril, all,
> PM Petr Vorel <pvorel@suse.cz> wrote:
...
> > +if [ -n "$TST_CLEANUP" ]; then
> > + trap $TST_CLEANUP EXIT
> > +fi
> > +
> > +if [ -n "$TST_SETUP" ]; then
> > + $TST_SETUP
> > +fi
> > +
@Li first, thanks a lot for your feedback.
> Here maybe better to have a check before the tst_test:
> if ! declare -F tst_test > /dev/null; then
> tst_brk TBROK "tst_test() function is not defined"
> fi
Sure, I can add a check for function existence. 'declare' is a bashism,
I use 'command -v' which we already use for $TST_SETUP and $TST_CLEANUP
in tst_test.h.
if [ -n "$TST_SETUP" ]; then
if command -v $TST_SETUP >/dev/null 2>/dev/null; then
TST_DO_CLEANUP=1
$TST_SETUP
else
tst_brk TBROK "TST_SETUP=$TST_SETUP declared, but function not defined (or cmd not found)"
fi
fi
> > +tst_test
> > --
> > 2.49.0
> Sorry, I should have pointed this out at the first review, but
> the idea came to my mind a little bit delayed :).
No problem :).
@Cyril any more feedback before I'll send a new version (v4)?
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* [LTP] [PATCH v3 4/4] shell: Add shell_loader_setup_cleanup.sh test
2025-06-09 12:45 [LTP] [PATCH v3 0/4] shell loader rewrite to support TST_SETUP Petr Vorel
` (2 preceding siblings ...)
2025-06-09 12:45 ` [LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup Petr Vorel
@ 2025-06-09 12:45 ` Petr Vorel
2025-06-12 5:08 ` Li Wang via ltp
2025-06-12 7:18 ` Li Wang via ltp
3 siblings, 2 replies; 13+ messages in thread
From: Petr Vorel @ 2025-06-09 12:45 UTC (permalink / raw)
To: ltp
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
The same as in v2.
testcases/lib/run_tests.sh | 1 +
.../lib/tests/shell_loader_setup_cleanup.sh | 31 +++++++++++++++++++
2 files changed, 32 insertions(+)
create mode 100755 testcases/lib/tests/shell_loader_setup_cleanup.sh
diff --git a/testcases/lib/run_tests.sh b/testcases/lib/run_tests.sh
index 128cee3377..5c309bbeb5 100755
--- a/testcases/lib/run_tests.sh
+++ b/testcases/lib/run_tests.sh
@@ -10,6 +10,7 @@ shell_loader_kconfigs.sh
shell_loader_supported_archs.sh
shell_loader_tcnt.sh
shell_loader_cleanup.sh
+shell_loader_setup_cleanup.sh
shell_test01
shell_test02
shell_test03
diff --git a/testcases/lib/tests/shell_loader_setup_cleanup.sh b/testcases/lib/tests/shell_loader_setup_cleanup.sh
new file mode 100755
index 0000000000..8184278313
--- /dev/null
+++ b/testcases/lib/tests/shell_loader_setup_cleanup.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2025 Petr Vorel <pvorel@suse.cz>
+#
+# ---
+# env
+# {
+# }
+# ---
+
+TST_SETUP=setup
+TST_CLEANUP=cleanup
+
+. tst_loader.sh
+
+setup()
+{
+ tst_res TINFO "setup executed"
+}
+
+cleanup()
+{
+ tst_res TINFO "Cleanup executed"
+}
+
+tst_test()
+{
+ tst_res TPASS "Test is executed"
+}
+
+. tst_run.sh
--
2.49.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH v3 4/4] shell: Add shell_loader_setup_cleanup.sh test
2025-06-09 12:45 ` [LTP] [PATCH v3 4/4] shell: Add shell_loader_setup_cleanup.sh test Petr Vorel
@ 2025-06-12 5:08 ` Li Wang via ltp
2025-06-12 7:18 ` Li Wang via ltp
1 sibling, 0 replies; 13+ messages in thread
From: Li Wang via ltp @ 2025-06-12 5:08 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Mon, Jun 9, 2025 at 8:45 PM Petr Vorel <pvorel@suse.cz> wrote:
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>
Reviewed-by: Li Wang <liwang@redhat.com>
---
> The same as in v2.
>
> testcases/lib/run_tests.sh | 1 +
> .../lib/tests/shell_loader_setup_cleanup.sh | 31 +++++++++++++++++++
> 2 files changed, 32 insertions(+)
> create mode 100755 testcases/lib/tests/shell_loader_setup_cleanup.sh
>
> diff --git a/testcases/lib/run_tests.sh b/testcases/lib/run_tests.sh
> index 128cee3377..5c309bbeb5 100755
> --- a/testcases/lib/run_tests.sh
> +++ b/testcases/lib/run_tests.sh
> @@ -10,6 +10,7 @@ shell_loader_kconfigs.sh
> shell_loader_supported_archs.sh
> shell_loader_tcnt.sh
> shell_loader_cleanup.sh
> +shell_loader_setup_cleanup.sh
> shell_test01
> shell_test02
> shell_test03
> diff --git a/testcases/lib/tests/shell_loader_setup_cleanup.sh
> b/testcases/lib/tests/shell_loader_setup_cleanup.sh
> new file mode 100755
> index 0000000000..8184278313
> --- /dev/null
> +++ b/testcases/lib/tests/shell_loader_setup_cleanup.sh
> @@ -0,0 +1,31 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2025 Petr Vorel <pvorel@suse.cz>
> +#
> +# ---
> +# env
> +# {
> +# }
> +# ---
> +
> +TST_SETUP=setup
> +TST_CLEANUP=cleanup
> +
> +. tst_loader.sh
> +
> +setup()
> +{
> + tst_res TINFO "setup executed"
> +}
> +
> +cleanup()
> +{
> + tst_res TINFO "Cleanup executed"
> +}
> +
> +tst_test()
> +{
> + tst_res TPASS "Test is executed"
> +}
> +
> +. tst_run.sh
> --
> 2.49.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH v3 4/4] shell: Add shell_loader_setup_cleanup.sh test
2025-06-09 12:45 ` [LTP] [PATCH v3 4/4] shell: Add shell_loader_setup_cleanup.sh test Petr Vorel
2025-06-12 5:08 ` Li Wang via ltp
@ 2025-06-12 7:18 ` Li Wang via ltp
1 sibling, 0 replies; 13+ messages in thread
From: Li Wang via ltp @ 2025-06-12 7:18 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Petr Vorel <pvorel@suse.cz> wrote:
> --- a/testcases/lib/run_tests.sh
> +++ b/testcases/lib/run_tests.sh
> @@ -10,6 +10,7 @@ shell_loader_kconfigs.sh
> shell_loader_supported_archs.sh
> shell_loader_tcnt.sh
> shell_loader_cleanup.sh
> +shell_loader_setup_cleanup.sh
>
One more word: With this shell_loader_setup_cleanup.sh, which contains
test shell_loader_cleanup.sh, maybe we can remove the latter one?
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-07-17 15:38 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-09 12:45 [LTP] [PATCH v3 0/4] shell loader rewrite to support TST_SETUP Petr Vorel
2025-06-09 12:45 ` [LTP] [PATCH v3 1/4] shell lib: Add support for test cleanup Petr Vorel
2025-06-12 3:46 ` Li Wang via ltp
2025-06-09 12:45 ` [LTP] [PATCH v3 2/4] shell: Move shell code into functions Petr Vorel
2025-06-12 3:47 ` Li Wang via ltp
2025-06-09 12:45 ` [LTP] [PATCH v3 3/4] shell lib: Add basic support for test setup Petr Vorel
2025-06-12 5:08 ` Li Wang via ltp
2025-06-12 7:48 ` Li Wang via ltp
2025-07-17 10:26 ` Petr Vorel
2025-07-17 15:38 ` Cyril Hrubis
2025-06-09 12:45 ` [LTP] [PATCH v3 4/4] shell: Add shell_loader_setup_cleanup.sh test Petr Vorel
2025-06-12 5:08 ` Li Wang via ltp
2025-06-12 7:18 ` Li Wang via ltp
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.