[LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API

Petr Vorel pvorel@suse.cz
Wed Mar 15 03:01:40 CET 2023


> On Thu, Mar 09, 2023 at 03:59:17PM +0100, Petr Vorel wrote:
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> >  testcases/kernel/containers/share/ns_ifmove.c | 98 ++++++-------------
> >  1 file changed, 28 insertions(+), 70 deletions(-)

> >  	int intf_index, pid, rtnetlink_socket;

> >  	if (argc != 3) {
> > -		tst_resm(TINFO, "%s <INTERFACE_NAME> <NAMESPACE_PID>",
> > -			 argv[0]);
> > +		printf("ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>\n");
> >  		return 1;
> >  	}

> should we use tst_res(TINFO) instead of printf?

NO. If you look into testcases/lib/, none of *.c tools use tst_res().
The only separation between API for tests and API for tools / library
than TST_NO_DEFAULT_MAIN.

Actually, unless SAFE_*() are useful to use (here SAFE_SOCKET() and
SAFE_IOCTL()), we prefer to not use tst_test.h at all (see tst_cgctl.c,
tst_device.c, ...)

I also think that tst_get_free_pids.c does not need TST_NO_DEFAULT_MAIN and
tst_test workarounds.

Kind regards,
Petr


More information about the ltp mailing list