[LTP] [RFC PATCH 4/5] shell lib: Add basic support for test cleanup
Petr Vorel
pvorel@suse.cz
Fri Apr 25 20:33:45 CEST 2025
Hi Cyril,
...
> > +++ b/testcases/lib/tst_loader.sh
> > @@ -3,11 +3,8 @@
> > # 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") "$@"
> > + tst_run_shell tst_exec.sh $(basename "$0") "$@"
> > exit $?
> > -else
> > - . tst_env.sh
> > fi
> Do we really need the tst_exec.sh?
> Doesn't it work if we add what is in the tst_exec here?
I guess you mean to keep the original:
- tst_run_shell $(basename "$0") "$@"
instead of what I proposed:
+ tst_run_shell tst_exec.sh $(basename "$0") "$@"
I added it to get rid of previous error:
tst_res: not found
$ PATH="testcases/lib:testcases/lib/tests:$PATH" shell_loader_setup_cleanup.sh
tst_test.c:1903: TINFO: LTP version: 20250130-239-gc016fb0c0a
tst_test.c:1907: TINFO: Tested kernel: 6.12.20-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.20-1 (2025-03-23) x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/boot/config-6.12.20-amd64'
tst_test.c:1720: TINFO: Overall timeout per run is 0h 00m 30s
testcases/lib/tests/shell_loader_setup_cleanup.sh: 16: testcases/lib/tst_loader.sh: tst_res: not found
testcases/lib/tests/shell_loader_setup_cleanup.sh: 21: tst_res: not found
tst_test.c:452: TBROK: Invalid child (82160) exit value 127
tst_exec.sh added in this v1 contains:
. tst_env.sh
. "$1"
if [ -n "$TST_CLEANUP" ]; then
trap $TST_CLEANUP EXIT
fi
if [ -n "$TST_SETUP" ]; then
$TST_SETUP
fi
tst_test
---
The most important part is:
. "$1"
which is to source the script. This cannot be added into tst_loader.sh
(it would create indefinite loop), this must be somehow added to tst_run_shell.c
And the only way I come up with was to add it via the above mentioned change of
tst_run_shell.c running actually tst_exec.sh instead of the test directly.
I guess I'm missing something.
Feel free to look into my v2, likely it's obvious to you what am I missing:
https://github.com/pevik/ltp/blob/refs/heads/shell-loader-setup-cleanup.v2/testcases/lib/tst_loader.sh
Kind regards,
Petr
> The whole point of [ -z "$LTP_IPC_PATH" ]; is to detect when we are
> being re-executed by the tst_run_shell, so the else branch (which
> isn't really needed, because we do exit in the if) was when the test did
> run.
> If you change the tests to be in functions and source the tst_loader.sh
> at the end it should just work.
More information about the ltp
mailing list