From: Cyril Hrubis <chrubis@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it, Sebastian Chlad <sebastian.chlad@suse.com>
Subject: Re: [LTP] [PATCH 5/6] [WIP,RFC] tst_run.sh: Run setup() only once
Date: Wed, 18 Mar 2026 12:23:31 +0100 [thread overview]
Message-ID: <abqLM0iQY7nwPaDm@yuki.lan> (raw)
In-Reply-To: <abkh9aPkKAewapRr@redhat.com>
Hi!
> > NOTE: this is still not working on iterations (-i2), because
> > static int iterations is from tst_test.c is not propagated to
> > tst_run_shell.c. I wonder if I should set the value as environment
> > variable or add it into struct context.
>
> Passing the current iteration as env variable is feasible.
>
> Since LTP export an similar variable 'TST_ITERATIONS' in tst_test.sh,
> maybe define another env var for current loop, e.g. TST_ITERATION
> (or TST_CURRENT_LOOP), pass to tst_run.sh?
>
> Something like:
>
> 1. Create tst_get_cur_iteration(void) function in LTP core API
>
> 2. Export current loop in tst_run_shell.c before running run_shell_tcnt()
>
> static void run_shell_tcnt(unsigned int n)
> {
> ...
> char iter_buf[32];
>
> snprintf(iter_buf, sizeof(iter_buf), "%u", tst_get_cur_iteration());
>
> if (setenv("TST_ITERATION", iter_buf, 1))
> tst_brk(TBROK | TERRNO, "setenv(TST_ITERATION) failed");
>
> tst_run_script(shell_filename, params);
> }
>
> 3. Reuse it in tst_run.sh to run setup once globally
>
> [ "$1" == "1" ] && [ "${TST_ITERATION:-1}" == "1" ] && $TST_SETUP
It's a bit more complicated we do not have only iterations but also
duration and timeout per iteration. So we would need a function that
would return if the script should continue or not and also call the
heartbeat() function. Something as:
int tst_next_shell_iteration(void)
{
int cont = 0;
static int iteration = 0;
if (iteration < iterations)
cont = 1;
if (stop_time && get_time_ms() < stop_time())
cont = 1;
if (!cont)
return 0;
heartbeat();
return ++iteration;
}
The shell helper would call this and we would use it in tst_run.sh and
loop the tst_test() until we are said to stop.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-03-18 11:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 14:25 [LTP] [PATCH 0/6] [RFC,WIP] shell loader fixes + du01.sh rewrite Petr Vorel
2026-03-13 14:25 ` [LTP] [PATCH 1/6] tst_run.sh: Fix passing arguments Petr Vorel
2026-03-17 7:36 ` Li Wang via ltp
2026-03-18 14:17 ` Cyril Hrubis
2026-03-18 15:10 ` Petr Vorel
2026-03-13 14:25 ` [LTP] [PATCH 2/6] tst_env.sh: Backport common functions from tst_test.sh Petr Vorel
2026-03-17 7:54 ` Li Wang via ltp
2026-03-18 14:26 ` Cyril Hrubis
2026-03-18 15:02 ` Petr Vorel
2026-03-20 16:20 ` Cyril Hrubis
2026-03-23 12:06 ` Petr Vorel
2026-03-23 12:41 ` [LTP] isofs.sh rewrite [was Re: [PATCH 2/6] tst_env.sh: Backport common functions from tst_test.sh] Petr Vorel
2026-03-13 14:25 ` [LTP] [PATCH 3/6] shell_loader: Start test count from 1 Petr Vorel
2026-03-17 8:00 ` Li Wang via ltp
2026-03-13 14:25 ` [LTP] [RFC][PATCH 4/6] run_shell_tcnt: Add test count also for test_all Petr Vorel
2026-03-17 9:45 ` Li Wang via ltp
2026-03-13 14:25 ` [LTP] [PATCH 5/6] [WIP,RFC] tst_run.sh: Run setup() only once Petr Vorel
2026-03-17 9:42 ` Li Wang via ltp
2026-03-18 11:23 ` Cyril Hrubis [this message]
2026-03-18 12:26 ` Cyril Hrubis
2026-03-18 15:40 ` Petr Vorel
2026-03-20 15:15 ` Cyril Hrubis
2026-03-23 21:20 ` Petr Vorel
2026-03-13 14:26 ` [LTP] [PATCH 6/6] du01.sh: Rewrite into shell loader 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=abqLM0iQY7nwPaDm@yuki.lan \
--to=chrubis@suse.cz \
--cc=liwang@redhat.com \
--cc=ltp@lists.linux.it \
--cc=sebastian.chlad@suse.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox