[LTP] [PATCH v4 02/10] tst_test.sh/tst_brk(): Convert only TBROK to TWARN in cleanup
Petr Vorel
pvorel@suse.cz
Thu Dec 14 16:19:46 CET 2023
C API specifies (since 6440c5d0d):
WARNING: Calling tst_brk() in test cleanup() does not exit the test as well
and TBROK is converted to TWARN.
But shell API 1) changed *anything* to TWARN 2) do change only in exit.
Unify with C API => change also on cleanup() and convert only TBROK.
Also, TBROK in cleanup() was printed 2x (as TBROK and then as TWARN).
Fixing it requires TST_DO_CLEANUP to be unset *before* running cleanup
function ($TST_CLEANUP).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/tst_test.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index b5b38f524..a6a5d82a4 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -28,6 +28,7 @@ _tst_do_cleanup()
{
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_DO_CLEANUP=
$TST_CLEANUP
else
tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)"
@@ -126,8 +127,10 @@ tst_brk()
local res=$1
shift
- if [ "$TST_DO_EXIT" = 1 ]; then
+ # TBROK => TWARN on cleanup or exit
+ if [ "$res" = TBROK ] && [ "$TST_DO_EXIT" = 1 -o -z "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" ]; then
tst_res TWARN "$@"
+ TST_DO_CLEANUP=
return
fi
--
2.43.0
More information about the ltp
mailing list