[LTP] [PATCH v1 1/5] Rewrite mountns01 test using new LTP API
Petr Vorel
pvorel@suse.cz
Mon Feb 7 23:02:31 CET 2022
Hi Andrea,
> Removed libclone from Makefile and used LTP API to replace it.
> mountns01 has been adapted to use the new LTP API.
Thanks for this effort!
> +++ b/testcases/kernel/containers/mountns/Makefile
...
> include $(top_srcdir)/include/mk/testcases.mk
> -include $(abs_srcdir)/../Makefile.inc
> -
> -LDLIBS := -lclone $(LDLIBS)
> -
Removing this makes this commit (and I guess all but the last commits) uncompilable.
IMHO this is no-go as it breaks bisecting.
But even keeping it for all not yet rewritten tests:
include $(abs_srcdir)/../Makefile.inc
mountns02 mountns03 mountns04 mountns05: LDLIBS := -lclone $(LDLIBS)
breaks the compilation:
$ make mountns02
make -C ../libclone -f "testcases/kernel/containers/mountns/../libclone/Makefile" all
make[1]: Entering directory 'testcases/kernel/containers/libclone'
../../../../include/mk/sparse.mk:6: warning: overriding recipe for target 'tools/sparse/sparse-ltp'
../../../../include/mk/sparse.mk:6: warning: ignoring old recipe for target 'tools/sparse/sparse-ltp'
../../../../include/mk/sparse.mk:9: warning: overriding recipe for target 'tools/sparse'
../../../../include/mk/sparse.mk:9: warning: ignoring old recipe for target 'tools/sparse'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory 'testcases/kernel/containers/libclone'
/usr/bin/ld: testcases/kernel/containers/mountns/../libclone/libclone.a(libclone.o): in function `do_unshare_tests':
testcases/kernel/containers/libclone/libclone.c:59: undefined reference to `tst_brk'
collect2: error: ld returned 1 exit status
make: *** [../../../../include/mk/rules.mk:37: mountns02] Error 1
> include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/containers/mountns/common.h b/testcases/kernel/containers/mountns/common.h
> new file mode 100644
> index 000000000..971f2381a
> --- /dev/null
> +++ b/testcases/kernel/containers/mountns/common.h
nit: maybe mountns.h would be a better name.
...
> +static void check_newns(void)
> +{
> + int pid, status;
> +
> + if (tst_kvercmp(2, 4, 19) < 0)
> + tst_brk(TCONF, "CLONE_NEWNS not supported");
We can safely remove check for kernel 2.4 :).
> +
> + pid = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, dummy_child, NULL);
> + if (pid < 0)
> + tst_brk(TCONF, "CLONE_NEWNS not supported");
Yes, I'd also be for keeping ltp_clone_quick() from quite obscure cloner.[hc].
SAFE_CLONE() / tst_clone() use nice clone3() interface, but that's was added
quite recently (kernel 5.3). It'd be nice one day rewrite/cleanup also also
cloner.[hc].
> diff --git a/testcases/kernel/containers/mountns/mountns01.c b/testcases/kernel/containers/mountns/mountns01.c
...
> #define _GNU_SOURCE
IMHO _GNU_SOURCE is not needed. Or at least it compiles without it
> +
> #include <sys/wait.h>
> #include <sys/mount.h>
> -#include <stdio.h>
> -#include <errno.h>
> -#include "mountns_helper.h"
> -#include "test.h"
> -#include "safe_macros.h"
> -
> -char *TCID = "mountns01";
> -int TST_TOTAL = 2;
> +#include "common.h"
> +#include "tst_test.h"
> #if defined(MS_SHARED) && defined(MS_PRIVATE) && defined(MS_REC)
These were added in glibc in 2010 (glibc 2.12), we can safely remove this check.
Kind regards,
Petr
More information about the ltp
mailing list