From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/2] shell lib: Add support for test cleanup
Date: Fri, 14 Feb 2025 15:07:42 +0100 [thread overview]
Message-ID: <Z69OLsDLMzNw6RGt@yuki.lan> (raw)
In-Reply-To: <20250214135531.GB2221874@pevik>
Hi!
> Unfortunately TST_SETUP will not work that way - function is not found or if you
> load tst_env.sh at the end, it complains about missing tst_res or tst_brk:
>
> ./tests/./shell_loader_brk_cleanup.sh: line 16: tst_res: command not found
>
> Obviously it does not help to add it to tst_loader.sh.
>
> I'm surprised it checks that, is there shopt option which could disable it?
The problem here the order the scripts are sourced. It looks like this:
test.sh
. tst_loader.sh
tst_run_shell test.sh
. tst_loader.sh
. tst_env.sh <- at this point in the execution you haven't even started
parsing test.sh so you cannot run functions from there
at all
If you wanted to have separate setup function you would have to build
things differently, you would have to execute a library shell script
by the tst_run_shell tool, which would source the test.sh and execute
the functions passed to it. So the execution would look like:
test.sh
. tst_loader.sh
tst_run_shell tst_exec.sh test.sh
. test.sh
. tst_env.sh
And then the tst_exec.sh would do:
. "$1"
if [ -n "$TST_SETUP" ]; then
$TST_SETUP
fi
$TST_TEST
or something along these lines.
And the test.sh would have to look like:
TST_SETUP=setup
TST_CLEANUP=cleanup
TST_TEST=runtest
. tst_loader.sh
setup()
{
...
}
cleanup()
{
...
}
runtest()
{
...
}
All the code would have to be in functions.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-02-14 14:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 11:21 [LTP] [PATCH 0/2] shell lib: Add very simple cleanup support Cyril Hrubis
2025-02-14 11:21 ` [LTP] [PATCH 1/2] testcases/lib/run_tests.sh Cyril Hrubis
2025-02-14 13:37 ` Petr Vorel
2025-02-28 11:49 ` Petr Vorel
2025-02-14 11:21 ` [LTP] [PATCH 2/2] shell lib: Add support for test cleanup Cyril Hrubis
2025-02-14 13:55 ` Petr Vorel
2025-02-14 14:07 ` Cyril Hrubis [this message]
2025-02-14 14:18 ` Cyril Hrubis
2025-02-17 7:44 ` Petr Vorel
2025-02-25 10:25 ` Cyril Hrubis
2025-02-25 11:00 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z69OLsDLMzNw6RGt@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.