[LTP] [PATCH v6 2/4] tst_test.c: Add tst_cmd_present check if a command is present
Wei Gao
wegao@suse.com
Wed Jan 7 07:16:39 CET 2026
On Tue, Jan 06, 2026 at 11:02:20AM +0100, Cyril Hrubis wrote:
> Hi!
> > /*
> > * Validates exit status of child processes
> > */
> > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > index 42a54621e..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;
>
> For a third time, when we get here we asked for something that haven't
> been tested for so we should tst_brk() here!
>
I think you may have missed my earlier explanation of why we should avoid using tst_brk() here.
https://lore.kernel.org/ltp/aT-5tkQkM_g2VZ35@autotest-wegao.qe.prg2.suse.org/
> > +}
> > +
> > static void do_setup(int argc, char *argv[])
> > {
> > char *tdebug_env = getenv("LTP_ENABLE_DEBUG");
> > --
> > 2.52.0
> >
>
> --
> Cyril Hrubis
> chrubis@suse.cz
More information about the ltp
mailing list