* [LTP] [PATCH 1/1] tst_env.sh: Backport common functions from tst_test.sh
@ 2025-11-20 16:19 Petr Vorel
2025-12-18 11:51 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2025-11-20 16:19 UTC (permalink / raw)
To: ltp
Backport:
* ROD()
* ROD_SILENT()
* EXPECT_PASS()
* EXPECT_PASS_BRK()
* EXPECT_FAIL()
* EXPECT_FAIL_BRK()
+ their dependencies.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
To allow to use ROD() when calling stress-ng in thermal01.sh.
Kind regards,
Petr
testcases/lib/tst_env.sh | 71 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/testcases/lib/tst_env.sh b/testcases/lib/tst_env.sh
index 585790a7d0..6a38f8f020 100644
--- a/testcases/lib/tst_env.sh
+++ b/testcases/lib/tst_env.sh
@@ -1,6 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2024-2025 Cyril Hrubis <chrubis@suse.cz>
+# Copyright (c) Linux Test Project, 2025
#
# This is a minimal test environment for a shell scripts executed from C by
# tst_run_shell() function. Shell tests must use the tst_loader.sh instead!
@@ -30,3 +31,73 @@ tst_brk_()
alias tst_res="tst_res_ $tst_script_name \$LINENO"
alias tst_brk="tst_brk_ $tst_script_name \$LINENO"
+
+ROD_SILENT()
+{
+ local tst_out
+
+ tst_out=$(tst_rod "$@" 2>&1)
+ if [ $? -ne 0 ]; then
+ echo "$tst_out"
+ tst_brk TBROK "$@ failed"
+ fi
+}
+
+ROD()
+{
+ tst_rod "$@"
+ if [ $? -ne 0 ]; then
+ tst_brk TBROK "$@ failed"
+ fi
+}
+
+_tst_expect_pass()
+{
+ local fnc="$1"
+ shift
+
+ tst_rod "$@"
+ if [ $? -eq 0 ]; then
+ tst_res TPASS "$@ passed as expected"
+ return 0
+ else
+ $fnc TFAIL "$@ failed unexpectedly"
+ return 1
+ fi
+}
+
+_tst_expect_fail()
+{
+ local fnc="$1"
+ shift
+
+ # redirect stderr since we expect the command to fail
+ tst_rod "$@" 2> /dev/null
+ if [ $? -ne 0 ]; then
+ tst_res TPASS "$@ failed as expected"
+ return 0
+ else
+ $fnc TFAIL "$@ passed unexpectedly"
+ return 1
+ fi
+}
+
+EXPECT_PASS()
+{
+ _tst_expect_pass tst_res "$@"
+}
+
+EXPECT_PASS_BRK()
+{
+ _tst_expect_pass tst_brk "$@"
+}
+
+EXPECT_FAIL()
+{
+ _tst_expect_fail tst_res "$@"
+}
+
+EXPECT_FAIL_BRK()
+{
+ _tst_expect_fail tst_brk "$@"
+}
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 1/1] tst_env.sh: Backport common functions from tst_test.sh
2025-11-20 16:19 [LTP] [PATCH 1/1] tst_env.sh: Backport common functions from tst_test.sh Petr Vorel
@ 2025-12-18 11:51 ` Andrea Cervesato via ltp
2025-12-18 13:55 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2025-12-18 11:51 UTC (permalink / raw)
To: Petr Vorel, ltp
Hi!
Is this still needed even if thermal test was rejected?
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 1/1] tst_env.sh: Backport common functions from tst_test.sh
2025-12-18 11:51 ` Andrea Cervesato via ltp
@ 2025-12-18 13:55 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2025-12-18 13:55 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi Andrea,
> Hi!
> Is this still needed even if thermal test was rejected?
Yes, it's not needed now.
The fact we haven't needed ROD is that there is only vma05.sh which is using
tst_loader.sh. Once we decide to rewrite at least some of LTP network tests to
shell loader (these will probably will not be converted to C) it will be needed.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-18 13:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20 16:19 [LTP] [PATCH 1/1] tst_env.sh: Backport common functions from tst_test.sh Petr Vorel
2025-12-18 11:51 ` Andrea Cervesato via ltp
2025-12-18 13:55 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox