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

Wei Gao wegao@suse.com
Wed Mar 15 05:38:57 CET 2023


On Wed, Mar 15, 2023 at 03:01:40AM +0100, Petr Vorel wrote:
> > 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.
Got it, this is lib API. Why ns_ifmove.c's parent directory name is 
"share" instead of "lib" or at least contain "lib" key word?

> 
> 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.
Is there possible split current tst_test.h to two files and remove 
TST_NO_DEFAULT_MAIN workaround? Such as tst_tools.h(include SAFE*) for lib api
and main.h for testcase.

> 
> Kind regards,
> Petr


More information about the ltp mailing list