[LTP] [PATCH v5 1/3] lib: Add support option for .needs_cmds

Petr Vorel pvorel@suse.cz
Fri Dec 12 12:16:18 CET 2025


> Hi!
> > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > index da5314c50..67553f65d 100644
> > --- a/lib/tst_test.c
> > +++ b/lib/tst_test.c
> > @@ -1365,6 +1365,19 @@ static const char *default_fs_type(void)
> >  	return tst_dev_fs_type();
> >  }

> > +bool tst_cmd_present(const char *cmd)
> > +{
> > +	struct tst_cmd *pcmd = tst_test->needs_cmds;
> > +
> > +	while (pcmd->cmd) {
> > +		if (!strcmp(pcmd->cmd, cmd))
> > +			return pcmd->present;
> > +
> > +		pcmd++;
> > +	}
> > +	return false;

> Once again, we should tst_brk(TBROK, "Unexpected command '%s'", cmd) here since we asked for
> something that we haven't checked for!

Good point. I'm sorry to overlook this in my review.

Also, strictly speaking tst_cmd_present() is only defined, not used. The commit
is about changing .needs_cmds from char array (string) to struct tst_cmd.
Therefore it could be in a separate commit. We don't have to be too strict, but
given how many tests needed to be adapted adding tst_cmd_present() is somehow
buried with other changes.

Kind regards,
Petr


More information about the ltp mailing list