Skip to content

Commit

Permalink
selftests/bpf: Check ASSERT_OK(err) in dummy_st_ops
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Geliang Tang authored and Kernel Patches Daemon committed Jul 9, 2024
1 parent f447ee0 commit b5bb412
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/dummy_st_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit b5bb412

Please sign in to comment.