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

Petr Vorel pvorel@suse.cz
Wed Apr 30 13:47:01 CEST 2025


Hi Cyril,

> Hi!
> And one possible solution is to source the environment first and the
> loader last, on the top of your shell-loader-setup-cleanup.v2 branch:

> diff --git a/testcases/lib/tests/shell_loader.sh b/testcases/lib/tests/shell_loader.sh
> index eeed122c1..01acf6d35 100755
> --- a/testcases/lib/tests/shell_loader.sh
> +++ b/testcases/lib/tests/shell_loader.sh
> @@ -14,6 +14,8 @@
>  # }
>  # ---

> +. tst_env.sh
> +

OK, that is the missing piece, thank you!

i.e. sourcing tst_env.sh at the beginning before test function setup and
tst_loader.sh at the end after test function setup). I thought we would avoid
sourcing two files in the tests, that's why I haven't tried, but that's a minor
detail. And it's better solution than having tst_exec.sh, which requires
tst_run_shell.c modification, just to do the same thing (source tst_env.sh).

Kind regards,
Petr

>  tst_test()
>  {
>         tst_res TPASS "Shell loader works fine!"
> diff --git a/testcases/lib/tst_env.sh b/testcases/lib/tst_env.sh
> index 68f9a0daa..585790a7d 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_ "$@"


More information about the ltp mailing list