[LTP] [PATCH v6 2/4] tst_test.c: Add tst_cmd_present check if a command is present
Cyril Hrubis
chrubis@suse.cz
Wed Jan 7 10:56:03 CET 2026
Hi!
> > > +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/
Indeed I missed that one, but that is incorrect, we will get to this
point only if we asked for a command that wasn't added to the
tst_test.needs_cmds array, which is a programming mistake and test
should report TBROK in that case.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list