On Thu, Aug 20, 2020 at 6:29 PM Carlos Neira <cneirabustos@xxxxxxxxx> wrote: > > Currently tests for bpf_get_ns_current_pid_tgid() are outside test_progs. > This change folds test cases into test_progs. > > Changes from V6: > - Rebased changes. > > Signed-off-by: Carlos Neira <cneirabustos@xxxxxxxxx> > --- Acked-by: Andrii Nakryiko <andriin@xxxxxx> > tools/testing/selftests/bpf/.gitignore | 1 - > tools/testing/selftests/bpf/Makefile | 3 +- > .../bpf/prog_tests/ns_current_pid_tgid.c | 85 ---------- > .../bpf/prog_tests/ns_current_pidtgid.c | 133 +++++++++++++++ > .../bpf/progs/test_ns_current_pid_tgid.c | 37 ---- > .../bpf/progs/test_ns_current_pidtgid.c | 25 +++ > .../bpf/test_current_pid_tgid_new_ns.c | 160 ------------------ > 7 files changed, 159 insertions(+), 285 deletions(-) > delete mode 100644 tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c > create mode 100644 tools/testing/selftests/bpf/prog_tests/ns_current_pidtgid.c > delete mode 100644 tools/testing/selftests/bpf/progs/test_ns_current_pid_tgid.c > create mode 100644 tools/testing/selftests/bpf/progs/test_ns_current_pidtgid.c > delete mode 100644 tools/testing/selftests/bpf/test_current_pid_tgid_new_ns.c > [...] > diff --git a/tools/testing/selftests/bpf/prog_tests/ns_current_pidtgid.c b/tools/testing/selftests/bpf/prog_tests/ns_current_pidtgid.c > new file mode 100644 > index 000000000000..f41c1ff5de94 > --- /dev/null > +++ b/tools/testing/selftests/bpf/prog_tests/ns_current_pidtgid.c > @@ -0,0 +1,133 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* Copyright (c) 2020 Carlos Neira cneirabustos@xxxxxxxxx */ > + > +#define _GNU_SOURCE > +#include <test_progs.h> > +#include "test_ns_current_pidtgid.skel.h" > +#include <sys/stat.h> > +#include <sys/types.h> > +#include <unistd.h> > +#include <sys/syscall.h> > +#include <sched.h> > +#include <sys/wait.h> > +#include <sys/mount.h> > +#include <sys/fcntl.h> > + > +#define STACK_SIZE (1024 * 1024) > +static char child_stack[STACK_SIZE]; > + > +void test_ns_current_pid_tgid_global_ns(void) > +{ [...] > +cleanup: > + setns(pidns_fd, CLONE_NEWPID); > + test_ns_current_pidtgid__destroy(skel); > + > + return err; > +} > + > +void test_ns_current_pid_tgid_new_ns(void) nit: this and test_ns_current_pid_tgid_global_ns() above would ideally be static functions > +{ > + int wstatus, duration = 0; > + pid_t cpid; > + [..]