[LTP] [PATCH 1/2] tst_test: Add $LTP_SINGLE_ITERATION to limit variant

Petr Vorel pvorel@suse.cz
Mon Feb 24 19:00:57 CET 2025


Hi Cyril,
> Hi!
> >  	lib_pid = getpid();
> >  	tst_test = self;
> > @@ -1899,7 +1901,6 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)

> >  	tst_res(TINFO, "LTP version: "LTP_VERSION);

> > -
> >  	uname(&uval);
> >  	tst_res(TINFO, "Tested kernel: %s %s %s", uval.release, uval.version, uval.machine);

> > @@ -1908,10 +1909,20 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)

> >  	set_overall_timeout();

> > -	if (tst_test->test_variants)
> > +	if (tst_test->test_variants) {
> >  		test_variants = tst_test->test_variants;
> > +		only_variant = getenv("LTP_SINGLE_VARIANT");
> > +		if (only_variant && only_variant[0] != '\0') {
> > +			tst_variant = MIN(SAFE_STRTOL((char *)only_variant, 0, INT_MAX),
> > +							  test_variants - 1);
> > +			tst_res(TINFO, "WARNING: testing only variant %d of %d",
> > +					tst_variant, test_variants - 1);
> > +			test_variants = tst_variant + 1;
> > +		}
> > +	}
> > +
> > +	for (; tst_variant < test_variants; tst_variant++) {

> > -	for (tst_variant = 0; tst_variant < test_variants; tst_variant++) {
> >  		if (tst_test->all_filesystems || count_fs_descs() > 1)
> >  			ret |= run_tcases_per_fs();
> >  		else

> Can we instead add a function that would set two integer variables,
> first_variant and last variant as:

> static void setup_variants(unsigned int *first_variant, unsigned int *last_variant)
> {
> 	//setup the defaults and parse the variables here
> }

Sure, I'll send v2 if you see the patch useful (Li was not sure if this is
useful).

> And the we can do:

> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index e2803f04a..d19fe9aba 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1885,7 +1885,7 @@ unsigned int tst_variant;
>  void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
>  {
>         int ret = 0;
> -       unsigned int test_variants = 1;
> +       unsigned int first_variant, last_variant;
>         struct utsname uval;

>         lib_pid = getpid();
> @@ -1908,10 +1908,9 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)

>         set_overall_timeout();

> -       if (tst_test->test_variants)
> -               test_variants = tst_test->test_variants;
> +       setup_variants(&first_variant, &last_variant);

> -       for (tst_variant = 0; tst_variant < test_variants; tst_variant++) {
> +       for (tst_variant = first_variant; tst_variant <= last_variant; tst_variant++) {
>                 if (tst_test->all_filesystems || count_fs_descs() > 1)
>                         ret |= run_tcases_per_fs();
>                 else
> diff --git a/testcases/kernel/syscalls/pause/pause01.c b/testcases/kernel/syscalls/pause/pause01.c
> index adce0ddcf..74a7e514e 100644
> --- a/testcases/kernel/syscalls/pause/pause01.c
> +++ b/testcases/kernel/syscalls/pause/pause01.c
> @@ -20,6 +20,8 @@ static void do_child(void)
>         SAFE_SIGNAL(SIGINT, sig_handler);
>         TST_EXP_FAIL(pause(), EINTR);
>         TST_CHECKPOINT_WAKE(0);
> +
> +       tst_res(TPASS, "Process resumed from pause()");

I guess this is part of some other work, right? (there is no TST_EXP_FAIL() in
pause01.c).

Kind regards,
Petr


More information about the ltp mailing list