Skip to content

Commit a7986c2

Browse files
Geliang TangKernel Patches Daemon
Geliang Tang
authored and
Kernel Patches Daemon
committed
selftests/bpf: Check ASSERT_OK(err) in dummy_st_ops
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@kylinos.cn>
1 parent b3c242d commit a7986c2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ static void test_dummy_init_ret_value(void)
4141

4242
fd = bpf_program__fd(skel->progs.test_1);
4343
err = bpf_prog_test_run_opts(fd, &attr);
44-
ASSERT_OK(err, "test_run");
44+
if (!ASSERT_OK(err, "test_run"))
45+
goto out;
4546
ASSERT_EQ(attr.retval, 0xf2f3f4f5, "test_ret");
4647

48+
out:
4749
dummy_st_ops_success__destroy(skel);
4850
}
4951

@@ -115,13 +117,15 @@ static void test_dummy_multiple_args(void)
115117

116118
fd = bpf_program__fd(skel->progs.test_2);
117119
err = bpf_prog_test_run_opts(fd, &attr);
118-
ASSERT_OK(err, "test_run");
120+
if (!ASSERT_OK(err, "test_run"))
121+
goto out;
119122
args[0] = 7;
120123
for (i = 0; i < ARRAY_SIZE(args); i++) {
121124
snprintf(name, sizeof(name), "arg %zu", i);
122125
ASSERT_EQ(skel->bss->test_2_args[i], args[i], name);
123126
}
124127

128+
out:
125129
dummy_st_ops_success__destroy(skel);
126130
}
127131

0 commit comments

Comments
 (0)