[LTP] [PATCH v7 3/4] ioctl_loop01.c: Add new support .needs_cmds
Li Wang
liwang@redhat.com
Mon Jan 19 07:27:08 CET 2026
Wei Gao <wegao@suse.com> wrote:
> > > > Can we just reuse the 'tst_test->needs_cmds.present' result?
> > > >
> > > You cannot access tst_test->needs_cmds.present directly as if it were a
> > > single variable,
> > > because needs_cmds is an array (a list) of structures. To get the status
> > > of a specific command
> > > like "parted", you must iterate through that list to find the entry
> > > matching that name.
> > >
> >
> > So how about using: tst_test->needs_cmds[0].present?
> Yes, i think direct indexing is more efficient, but helper function is more readable
> and extensible(If someone add more entry into .needs_cmds it possible break the
> test case).
Yes, but not entirely, once we have the function tst_cmd_present(),
we need to manually write the "commands" again, and easy to typo.
Even if we plan to add this feature, perhaps it's better not to
place it in tst_test.h or tst_test.c, as that may not be the best fit.
We should respect the principle of high cohesion and low coupling.
--
Regards,
Li Wang
More information about the ltp
mailing list