Skip to content

Commit 4830eb7

Browse files
Geliang TangKernel Patches Daemon
Geliang Tang
authored and
Kernel Patches Daemon
committed
selftests/bpf: Use ASSERT_OK to skip ENOTSUPP
There are so many "ENOTSUPP" (-524) errors when running BPF selftests on a Loongarch platform since lacking BPF trampoline on Loongarch: ''' test_d_path_basic:PASS:setup 0 nsec libbpf: prog 'prog_stat': failed to attach: unknown error (-524) libbpf: prog 'prog_stat': failed to auto-attach: -524 test_d_path_basic:FAIL:setup attach failed: -524 #77/1 d_path/basic:FAIL #77/2 d_path/check_rdonly_mem:OK #77/3 d_path/check_alloc_mem:OK #77 d_path:FAIL ... ... test_module_attach:PASS:skel_open 0 nsec test_module_attach:PASS:set_attach_target 0 nsec test_module_attach:PASS:set_attach_target_explicit 0 nsec test_module_attach:PASS:skel_load 0 nsec libbpf: prog 'handle_fentry': failed to attach: unknown error (-524) libbpf: prog 'handle_fentry': failed to auto-attach: -524 test_module_attach:FAIL:skel_attach skeleton attach failed: -524 #167 module_attach:FAIL ... ... ringbuf_subtest:PASS:skel_open 0 nsec ringbuf_subtest:PASS:skel_load 0 nsec ringbuf_subtest:PASS:rw_cons_pos 0 nsec ringbuf_subtest:PASS:rw_extend 0 nsec ringbuf_subtest:PASS:exec_cons_pos_protect 0 nsec ringbuf_subtest:PASS:unmap_rw 0 nsec ringbuf_subtest:PASS:wr_prod_pos 0 nsec ringbuf_subtest:PASS:wr_prod_pos_err 0 nsec ringbuf_subtest:PASS:wr_data_page_one 0 nsec ringbuf_subtest:PASS:wr_data_page_one_err 0 nsec ringbuf_subtest:PASS:wr_data_page_two 0 nsec ringbuf_subtest:PASS:wr_data_page_all 0 nsec ringbuf_subtest:PASS:ro_prod_pos 0 nsec ringbuf_subtest:PASS:write_protect 0 nsec ringbuf_subtest:PASS:exec_protect 0 nsec ringbuf_subtest:PASS:ro_remap 0 nsec ringbuf_subtest:PASS:unmap_ro 0 nsec ringbuf_subtest:PASS:ro_prod_pos 0 nsec ringbuf_subtest:PASS:write_protect 0 nsec ringbuf_subtest:PASS:exec_protect 0 nsec ringbuf_subtest:PASS:ro_remap 0 nsec ringbuf_subtest:PASS:unmap_ro 0 nsec ringbuf_subtest:PASS:ringbuf_create 0 nsec ringbuf_subtest:FAIL:skel_attach skeleton attachment failed: -1 #277/1 ringbuf/ringbuf:FAIL #277/2 ringbuf/ringbuf_n:SKIP #277/3 ringbuf/ringbuf_map_key:SKIP #277 ringbuf:FAIL ... ... test_test_bprm_opts:PASS:skel_load 0 nsec libbpf: prog 'secure_exec': failed to attach: unknown error (-524) libbpf: prog 'secure_exec': failed to auto-attach: -524 test_test_bprm_opts:FAIL:attach attach failed: -524 #382 test_bprm_opts:FAIL ... ... test_test_ima:PASS:skel_load 0 nsec test_test_ima:PASS:ringbuf 0 nsec libbpf: prog 'bprm_committed_creds': failed to attach: \ unknown error (-524) libbpf: prog 'bprm_committed_creds': failed to auto-attach: -524 test_test_ima:FAIL:attach attach failed: -524 #384 test_ima:FAIL ... ... test_trace_ext:PASS:setup 0 nsec test_trace_ext:PASS:setup 0 nsec test_trace_ext:PASS:setup 0 nsec test_trace_ext:PASS:setup 0 nsec libbpf: prog 'test_pkt_md_access_new': failed to attach: \ unknown error (-524) libbpf: prog 'test_pkt_md_access_new': failed to auto-attach: -524 test_trace_ext:FAIL:setup freplace/test_pkt_md_access attach failed: -524 #397 trace_ext:FAIL ''' This patch uses ASSERT_OK() instead of CHECK() to skip these "ENOTSUPP" errors. With this change, the new output of these selftests look like: ''' #77/1 d_path/basic:SKIP #77/2 d_path/check_rdonly_mem:OK #77/3 d_path/check_alloc_mem:OK #77 d_path:OK (SKIP: 1/3) ... ... #167 module_attach:SKIP ... ... #277/1 ringbuf/ringbuf:SKIP #277/2 ringbuf/ringbuf_n:SKIP #277/3 ringbuf/ringbuf_map_key:SKIP #277 ringbuf:SKIP ... ... #382 test_bprm_opts:SKIP ... ... #384 test_ima:SKIP ... ... #397 trace_ext:SKIP ''' Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
1 parent 91cfacb commit 4830eb7

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

tools/testing/selftests/bpf/prog_tests/d_path.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static void test_d_path_basic(void)
129129
goto cleanup;
130130

131131
err = test_d_path__attach(skel);
132-
if (CHECK(err, "setup", "attach failed: %d\n", err))
132+
if (!ASSERT_OK(err, "setup"))
133133
goto cleanup;
134134

135135
bss = skel->bss;

tools/testing/selftests/bpf/prog_tests/module_attach.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void test_module_attach(void)
6262
bss = skel->bss;
6363

6464
err = test_module_attach__attach(skel);
65-
if (CHECK(err, "skel_attach", "skeleton attach failed: %d\n", err))
65+
if (!ASSERT_OK(err, "skel_attach"))
6666
goto cleanup;
6767

6868
/* trigger tracepoint */

tools/testing/selftests/bpf/prog_tests/ringbuf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static void ringbuf_subtest(void)
161161
goto cleanup;
162162

163163
err = test_ringbuf_lskel__attach(skel);
164-
if (CHECK(err, "skel_attach", "skeleton attachment failed: %d\n", err))
164+
if (!ASSERT_OK(err, "skel_attach"))
165165
goto cleanup;
166166

167167
trigger_samples();

tools/testing/selftests/bpf/prog_tests/test_bprm_opts.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void test_test_bprm_opts(void)
8888
goto close_prog;
8989

9090
err = bprm_opts__attach(skel);
91-
if (CHECK(err, "attach", "attach failed: %d\n", err))
91+
if (!ASSERT_OK(err, "attach"))
9292
goto close_prog;
9393

9494
/* Run the test with the secureexec bit unset */

tools/testing/selftests/bpf/prog_tests/test_ima.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void test_test_ima(void)
8383
goto close_prog;
8484

8585
err = ima__attach(skel);
86-
if (CHECK(err, "attach", "attach failed: %d\n", err))
86+
if (!ASSERT_OK(err, "attach"))
8787
goto close_prog;
8888

8989
measured_dir = mkdtemp(measured_dir_template);

tools/testing/selftests/bpf/prog_tests/trace_ext.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void test_trace_ext(void)
6060
}
6161

6262
err = test_trace_ext__attach(skel_ext);
63-
if (CHECK(err, "setup", "freplace/test_pkt_md_access attach failed: %d\n", err))
63+
if (!ASSERT_OK(err, "setup replace/test_pkt_md_access attach"))
6464
goto cleanup;
6565

6666
prog = skel_ext->progs.test_pkt_md_access_new;

0 commit comments

Comments
 (0)