Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/timers: Clean up kernel version check in posix_timers

Several tests in the posix_timers selftest which test timer behavior
related to SIG_IGN fail on kernels older than 6.13. This is due to
a refactoring of signal handling in commit caf77435dd8a ("signal:
Handle ignored signals in do_sigaction(action != SIG_IGN)").

A previous attempt to fix this by adding a kernel version check to each
of the nine affected tests was suboptimal, as it resulted in emitting
the same skip message nine times.

Following the suggestion from Thomas Gleixner, this is refactored to
perform a single version check in main(). To satisfy the kselftest
framework's requirement for the test count to match the declared plan,
the plan is now conditionally set to 10 (for older kernels) or 19.

While setting the plan conditionally may seem complex, it is the
better approach to avoid the alternatives: either running tests on
unsupported kernels that are known to fail, or emitting a noisy series
of nine identical skip messages. A single informational message is now
printed instead when the tests are skipped.

Signed-off-by: Wake Liu <wakel@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250807085042.1690931-1-wakel@google.com/
Link: https://patch.msgid.link/20251103114502.584940-1-wakel@google.com

authored by

Wake Liu and committed by
Thomas Gleixner
05d89fe7 4518767b

+22 -10
+22 -10
tools/testing/selftests/timers/posix_timers.c
··· 18 18 #include <time.h> 19 19 #include <include/vdso/time64.h> 20 20 #include <pthread.h> 21 + #include <stdbool.h> 21 22 22 23 #include "../kselftest.h" 23 24 ··· 671 670 672 671 int main(int argc, char **argv) 673 672 { 673 + bool run_sig_ign_tests = ksft_min_kernel_version(6, 13); 674 + 674 675 ksft_print_header(); 675 - ksft_set_plan(19); 676 + if (run_sig_ign_tests) { 677 + ksft_set_plan(19); 678 + } else { 679 + ksft_set_plan(10); 680 + } 676 681 677 682 ksft_print_msg("Testing posix timers. False negative may happen on CPU execution \n"); 678 683 ksft_print_msg("based timers if other threads run on the CPU...\n"); ··· 702 695 check_timer_create(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); 703 696 check_timer_distribution(); 704 697 705 - check_sig_ign(0); 706 - check_sig_ign(1); 707 - check_rearm(); 708 - check_delete(); 709 - check_sigev_none(CLOCK_MONOTONIC, "CLOCK_MONOTONIC"); 710 - check_sigev_none(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); 711 - check_gettime(CLOCK_MONOTONIC, "CLOCK_MONOTONIC"); 712 - check_gettime(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); 713 - check_gettime(CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID"); 698 + if (run_sig_ign_tests) { 699 + check_sig_ign(0); 700 + check_sig_ign(1); 701 + check_rearm(); 702 + check_delete(); 703 + check_sigev_none(CLOCK_MONOTONIC, "CLOCK_MONOTONIC"); 704 + check_sigev_none(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); 705 + check_gettime(CLOCK_MONOTONIC, "CLOCK_MONOTONIC"); 706 + check_gettime(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); 707 + check_gettime(CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID"); 708 + } else { 709 + ksft_print_msg("Skipping SIG_IGN tests on kernel < 6.13\n"); 710 + } 711 + 714 712 check_overrun(CLOCK_MONOTONIC, "CLOCK_MONOTONIC"); 715 713 check_overrun(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); 716 714 check_overrun(CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID");