aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/helper_restricted.c
diff options
context:
space:
mode:
authorGravatar Andrii Nakryiko <andrii@kernel.org> 2022-04-18 17:24:51 -0700
committerGravatar Alexei Starovoitov <ast@kernel.org> 2022-04-19 13:48:20 -0700
commit0d7fefebea552771b17682a12330ea47e369a5df (patch)
tree534a13d97e1dcd5ff32b64e221984193555926a8 /tools/testing/selftests/bpf/prog_tests/helper_restricted.c
parentlibbpf: Support opting out from autoloading BPF programs declaratively (diff)
downloadlinux-0d7fefebea552771b17682a12330ea47e369a5df.tar.gz
linux-0d7fefebea552771b17682a12330ea47e369a5df.tar.bz2
linux-0d7fefebea552771b17682a12330ea47e369a5df.zip
selftests/bpf: Use non-autoloaded programs in few tests
Take advantage of new libbpf feature for declarative non-autoloaded BPF program SEC() definitions in few test that test single program at a time out of many available programs within the single BPF object. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20220419002452.632125-2-andrii@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/helper_restricted.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/helper_restricted.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/helper_restricted.c b/tools/testing/selftests/bpf/prog_tests/helper_restricted.c
index e1de5f80c3b2..0354f9b82c65 100644
--- a/tools/testing/selftests/bpf/prog_tests/helper_restricted.c
+++ b/tools/testing/selftests/bpf/prog_tests/helper_restricted.c
@@ -6,11 +6,10 @@
void test_helper_restricted(void)
{
int prog_i = 0, prog_cnt;
- int duration = 0;
do {
struct test_helper_restricted *test;
- int maybeOK;
+ int err;
test = test_helper_restricted__open();
if (!ASSERT_OK_PTR(test, "open"))
@@ -21,12 +20,11 @@ void test_helper_restricted(void)
for (int j = 0; j < prog_cnt; ++j) {
struct bpf_program *prog = *test->skeleton->progs[j].prog;
- maybeOK = bpf_program__set_autoload(prog, prog_i == j);
- ASSERT_OK(maybeOK, "set autoload");
+ bpf_program__set_autoload(prog, true);
}
- maybeOK = test_helper_restricted__load(test);
- CHECK(!maybeOK, test->skeleton->progs[prog_i].name, "helper isn't restricted");
+ err = test_helper_restricted__load(test);
+ ASSERT_ERR(err, "load_should_fail");
test_helper_restricted__destroy(test);
} while (++prog_i < prog_cnt);