selftests/bpf: Load bpf_testmod for verifier test
authorJiri Olsa <jolsa@kernel.org>
Mon, 15 May 2023 13:37:53 +0000 (15:37 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 17 May 2023 05:09:23 +0000 (22:09 -0700)
Loading bpf_testmod kernel module for verifier test. We will
move all the tests kfuncs into bpf_testmod in following change.

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

index e4657c5bc3f12ee92e0c1db62aabd60c2941db37..285ea4aba1945d3ddeb176920ffd415e1913456c 100644 (file)
@@ -40,6 +40,7 @@
 #include "bpf_util.h"
 #include "test_btf.h"
 #include "../../../include/linux/filter.h"
+#include "testing_helpers.h"
 
 #ifndef ENOTSUPP
 #define ENOTSUPP 524
@@ -1684,6 +1685,12 @@ static int do_test(bool unpriv, unsigned int from, unsigned int to)
 {
        int i, passes = 0, errors = 0;
 
+       /* ensure previous instance of the module is unloaded */
+       unload_bpf_testmod(verbose);
+
+       if (load_bpf_testmod(verbose))
+               return EXIT_FAILURE;
+
        for (i = from; i < to; i++) {
                struct bpf_test *test = &tests[i];
 
@@ -1711,6 +1718,8 @@ static int do_test(bool unpriv, unsigned int from, unsigned int to)
                }
        }
 
+       unload_bpf_testmod(verbose);
+
        printf("Summary: %d PASSED, %d SKIPPED, %d FAILED\n", passes,
               skips, errors);
        return errors ? EXIT_FAILURE : EXIT_SUCCESS;