selftests/bpf: Do not unload bpf_testmod in load_bpf_testmod
authorJiri Olsa <jolsa@kernel.org>
Mon, 15 May 2023 13:37:51 +0000 (15:37 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 17 May 2023 05:09:23 +0000 (22:09 -0700)
Do not unload bpf_testmod in load_bpf_testmod, instead call
unload_bpf_testmod separatelly.

This way we will be able use un/load_bpf_testmod functions
in other tests that un/load bpf_testmod module.

Acked-by: David Vernet <void@manifault.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20230515133756.1658301-6-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/test_progs.c
tools/testing/selftests/bpf/testing_helpers.c

index cebe62d29f8d8232ef9f0787b443133114199d19..4d582cac2c09e11834265abb3c1bef48a75437fa 100644 (file)
@@ -1657,9 +1657,14 @@ int main(int argc, char **argv)
        env.stderr = stderr;
 
        env.has_testmod = true;
-       if (!env.list_test_names && load_bpf_testmod(verbose())) {
-               fprintf(env.stderr, "WARNING! Selftests relying on bpf_testmod.ko will be skipped.\n");
-               env.has_testmod = false;
+       if (!env.list_test_names) {
+               /* ensure previous instance of the module is unloaded */
+               unload_bpf_testmod(verbose());
+
+               if (load_bpf_testmod(verbose())) {
+                       fprintf(env.stderr, "WARNING! Selftests relying on bpf_testmod.ko will be skipped.\n");
+                       env.has_testmod = false;
+               }
        }
 
        /* initializing tests */
index f73bc88f3eb6785ec71bd3f7578e1322209239ea..e01d7a62306ca20ff0d6cf834d3bdbba7c3af2e3 100644 (file)
@@ -359,9 +359,6 @@ int load_bpf_testmod(bool verbose)
 {
        int fd;
 
-       /* ensure previous instance of the module is unloaded */
-       unload_bpf_testmod(verbose);
-
        if (verbose)
                fprintf(stdout, "Loading bpf_testmod.ko...\n");