[LTP] [RFC PATCH 4/5] shell lib: Add basic support for test cleanup

Cyril Hrubis chrubis@suse.cz
Wed Apr 30 10:52:03 CEST 2025


Hi!
> 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

So the problem seems to be that if shell parses the script before we
define aliases they are not expanded in the code shell already parsed.


This works:

alias tst_res="..."

tst_res TINFO "foo"


This does not:

tst_res TINFO "foo"

alias tst_res="..."

The tst_loader.sh has to be sourced first after all.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list