selftests/bpf: Skip timer cases when bpf_timer is not supported

When enable CONFIG_PREEMPT_RT, verifier will reject bpf_timer with
returning -EOPNOTSUPP.

Therefore, skip test cases when errno is EOPNOTSUPP.

cd tools/testing/selftests/bpf
./test_progs -t timer
125     free_timer:SKIP
456     timer:SKIP
457/1   timer_crash/array:SKIP
457/2   timer_crash/hash:SKIP
457     timer_crash:SKIP
458     timer_lockup:SKIP
459     timer_mim:SKIP
Summary: 5/0 PASSED, 6 SKIPPED, 0 FAILED

Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Link: https://lore.kernel.org/r/20250910125740.52172-3-leon.hwang@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
pull/824/head
Leon Hwang 2025-09-10 20:57:40 +08:00 committed by Alexei Starovoitov
parent e25ddfb388
commit fbdd61c94b
5 changed files with 20 additions and 0 deletions

View File

@ -124,6 +124,10 @@ void test_free_timer(void)
int err; int err;
skel = free_timer__open_and_load(); skel = free_timer__open_and_load();
if (!skel && errno == EOPNOTSUPP) {
test__skip();
return;
}
if (!ASSERT_OK_PTR(skel, "open_load")) if (!ASSERT_OK_PTR(skel, "open_load"))
return; return;

View File

@ -86,6 +86,10 @@ void serial_test_timer(void)
int err; int err;
timer_skel = timer__open_and_load(); timer_skel = timer__open_and_load();
if (!timer_skel && errno == EOPNOTSUPP) {
test__skip();
return;
}
if (!ASSERT_OK_PTR(timer_skel, "timer_skel_load")) if (!ASSERT_OK_PTR(timer_skel, "timer_skel_load"))
return; return;

View File

@ -12,6 +12,10 @@ static void test_timer_crash_mode(int mode)
struct timer_crash *skel; struct timer_crash *skel;
skel = timer_crash__open_and_load(); skel = timer_crash__open_and_load();
if (!skel && errno == EOPNOTSUPP) {
test__skip();
return;
}
if (!ASSERT_OK_PTR(skel, "timer_crash__open_and_load")) if (!ASSERT_OK_PTR(skel, "timer_crash__open_and_load"))
return; return;
skel->bss->pid = getpid(); skel->bss->pid = getpid();

View File

@ -59,6 +59,10 @@ void test_timer_lockup(void)
} }
skel = timer_lockup__open_and_load(); skel = timer_lockup__open_and_load();
if (!skel && errno == EOPNOTSUPP) {
test__skip();
return;
}
if (!ASSERT_OK_PTR(skel, "timer_lockup__open_and_load")) if (!ASSERT_OK_PTR(skel, "timer_lockup__open_and_load"))
return; return;

View File

@ -65,6 +65,10 @@ void serial_test_timer_mim(void)
goto cleanup; goto cleanup;
timer_skel = timer_mim__open_and_load(); timer_skel = timer_mim__open_and_load();
if (!timer_skel && errno == EOPNOTSUPP) {
test__skip();
return;
}
if (!ASSERT_OK_PTR(timer_skel, "timer_skel_load")) if (!ASSERT_OK_PTR(timer_skel, "timer_skel_load"))
goto cleanup; goto cleanup;