From: Geliang Tang <tanggeliang@xxxxxxxxxx> Run dummy_st_ops selftests (./test_progs -t dummy_st_ops) on a Loongarch platform, some "unexpected arg" errors occur: ''' #78/1 dummy_st_ops/dummy_st_ops_attach:OK test_dummy_init_ret_value:FAIL:test_ret unexpected test_ret: \ actual 0 != expected 4076074229 #78/2 dummy_st_ops/dummy_init_ret_value:FAIL #78/3 dummy_st_ops/dummy_init_ptr_arg:SKIP test_dummy_multiple_args:FAIL:arg 0 unexpected arg 0: \ actual 0 != expected 7 test_dummy_multiple_args:FAIL:arg 1 unexpected arg 1: \ actual 0 != expected -100 test_dummy_multiple_args:FAIL:arg 2 unexpected arg 2: \ actual 0 != expected 35423 test_dummy_multiple_args:FAIL:arg 3 unexpected arg 3: \ actual 0 != expected 99 test_dummy_multiple_args:FAIL:arg 4 unexpected arg 4: \ actual 0 != expected 1311768467139281697 #78/4 dummy_st_ops/dummy_multiple_args:FAIL #78/5 dummy_st_ops/dummy_sleepable:SKIP #78/6 dummy_st_ops/dummy_sleepable_reject_null:OK #78/7 dummy_st_ops/test_unsupported_field_sleepable:OK #78 dummy_st_ops:FAIL ''' This is because BPF trampoline is not implemented on Loongarch yet, bpf_prog_test_run_opts() returns ENOTSUPP. This patch checks the return values of bpf_prog_test_run_opts() in dummy_st_ops to fix these errors. If error returned, goto the newly added label "out" to destroy the skel. Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx> --- tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c b/tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c index d3d94596ab79..a208801f524f 100644 --- a/tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c +++ b/tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c @@ -41,9 +41,11 @@ static void test_dummy_init_ret_value(void) fd = bpf_program__fd(skel->progs.test_1); err = bpf_prog_test_run_opts(fd, &attr); - ASSERT_OK(err, "test_run"); + if (!ASSERT_OK(err, "test_run")) + goto out; ASSERT_EQ(attr.retval, 0xf2f3f4f5, "test_ret"); +out: dummy_st_ops_success__destroy(skel); } @@ -115,13 +117,15 @@ static void test_dummy_multiple_args(void) fd = bpf_program__fd(skel->progs.test_2); err = bpf_prog_test_run_opts(fd, &attr); - ASSERT_OK(err, "test_run"); + if (!ASSERT_OK(err, "test_run")) + goto out; args[0] = 7; for (i = 0; i < ARRAY_SIZE(args); i++) { snprintf(name, sizeof(name), "arg %zu", i); ASSERT_EQ(skel->bss->test_2_args[i], args[i], name); } +out: dummy_st_ops_success__destroy(skel); } -- 2.43.0