selftests/futex: Skip futex_waitv tests if ENOSYS
PATCH 1/1 selftests/futex: Skip futex_waitv tests if ENOSYS
The futex_waitv() syscall was introduced in Linux 5.16. The existing test in futex_wait_timeout.c will fail on kernels older than 5.16 due to the syscall not being implemented.
Modify the test_timeout() function to check if the error returned is ENOSYS. If it is, skip the test and report it as such, rather than failing. This ensures the selftests can be run on a wider range of kernel versions without false negatives.
--- .../selftests/futex/functional/futex_wait_timeout.c | 11 ++++++++--- .../testing/selftests/futex/functional/futex_waitv.c | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-)
tools/testing/selftests/futex/functional/futex_wait_timeout.c +8 -3
@@ -64,9 +64,14 @@ void *get_pi_lock(void *arg)static void test_timeout (int res,int *ret,char *test_name,int err) {if (!res || errno != err) { -ksft_test_result_fail ("%s returned %d\n" , test_name, - res <0 ? errno : res); - *ret =RET_FAIL ; +if (errno ==ENOSYS ) { +ksft_test_result_skip ("%s: %s\n" , + test_name,strerror (errno)); + }else { +ksft_test_result_fail ("%s returned %d\n" , test_name, + res <0 ? errno : res); + *ret =RET_FAIL ; + } }else {ksft_test_result_pass ("%s succeeds\n" , test_name); }
tools/testing/selftests/futex/functional/futex_waitv.c +8 -0
@@ -59,6 +59,14 @@ void *waiterfn(void *arg)int main (int argc,char *argv[]) { +if (!ksft_min_kernel_version (5 ,16 )) { +ksft_print_header (); +ksft_set_plan (0 ); +ksft_print_msg ("%s: FUTEX_WAITV not implemented until 5.16\n" , +basename (argv[0 ])); +ksft_print_cnts (); +return KSFT_SKIP ; + }pthread_t waiter;int res, ret =RET_PASS ;struct timespec to;
Signature · 1 line
2.50.1.703.g449372360f-goog
PATCH v2 1/1 selftests/futex: Skip futex_waitv tests if ENOSYS
The futex_waitv() syscall was introduced in Linux 5.16. The existing test in futex_wait_timeout.c will fail on kernels older than 5.16 due to the syscall not being implemented.
Modify the test_timeout() function to check if the error returned is ENOSYS. If it is, skip the test and report it as such, rather than failing. This ensures the selftests can be run on a wider range of kernel versions without false negatives.
--- .../selftests/futex/functional/futex_wait_timeout.c | 10 +++++++--- tools/testing/selftests/futex/functional/futex_waitv.c | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-)
tools/testing/selftests/futex/functional/futex_wait_timeout.c +7 -3
@@ -64,9 +64,13 @@ void *get_pi_lock(void *arg)static void test_timeout (int res,int *ret,char *test_name,int err) {if (!res || errno != err) { -ksft_test_result_fail ("%s returned %d\n" , test_name, - res <0 ? errno : res); - *ret =RET_FAIL ; +if (errno ==ENOSYS ) { +ksft_test_result_skip ("%s: %m\n" , test_name); + }else { +ksft_test_result_fail ("%s returned %d\n" , test_name, + res <0 ? errno : res); + *ret =RET_FAIL ; + } }else {ksft_test_result_pass ("%s succeeds\n" , test_name); }
tools/testing/selftests/futex/functional/futex_waitv.c +8 -0
@@ -59,6 +59,14 @@ void *waiterfn(void *arg)int main (int argc,char *argv[]) { +if (!ksft_min_kernel_version (5 ,16 )) { +ksft_print_header (); +ksft_set_plan (0 ); +ksft_print_msg ("%s: FUTEX_WAITV not implemented until 5.16\n" , +basename (argv[0 ])); +ksft_print_cnts (); +return KSFT_SKIP ; + }pthread_t waiter;int res, ret =RET_PASS ;struct timespec to;
Signature · 1 line
2.50.1.703.g449372360f-goog
André Almeida
reviewerHi Wake Liu,
Em 08/08/2025 04:15, Wake Liu escreveu:
Quoted 9 lines
The
futex_waitv()syscall was introduced in Linux 5.16. The existing test infutex_wait_timeout.cwill fail on kernels older than 5.16 due to the syscall not being implemented.Modify the
test_timeout()function to check if the error returned is ENOSYS. If it is, skip the test and report it as such, rather than failing. This ensures the selftests can be run on a wider range of kernel versions without false negatives.
Quoted 4 lines
Signed-off-by Wake Liu <[email protected]>--- .../selftests/futex/functional/futex_wait_timeout.c | 10 +++++++--- tools/testing/selftests/futex/functional/futex_waitv.c | 8 ++++++++
tools/testing/selftests/futex/functional/futex_wait_wouldblock.c also have a call for futex_waitv().
Apart from that, futex2_wait() and futex2_wake() syscalls may need something similar?
PATCH v2 1/1 selftests/futex: Skip futex_waitv tests if ENOSYS
The futex_waitv() syscall was introduced in Linux 5.16. The existing test in futex_wait_timeout.c will fail on kernels older than 5.16 due to the syscall not being implemented.
Modify the test_timeout() function to check if the error returned is ENOSYS. If it is, skip the test and report it as such, rather than failing. This ensures the selftests can be run on a wider range of kernel versions without false negatives.
---
+V1 -> V2:
+- Addressed review comments from André Almeida. +- Applied ENOSYS check to futex_wait_wouldblock.c as well. --- .../selftests/futex/functional/futex_wait_timeout.c | 10 +++++++--- .../futex/functional/futex_wait_wouldblock.c | 12 ++++++++---- .../testing/selftests/futex/functional/futex_waitv.c | 8 ++++++++ 3 files changed, 23 insertions(+), 7 deletions(-)
tools/testing/selftests/futex/functional/futex_wait_timeout.c +7 -3
@@ -64,9 +64,13 @@ void *get_pi_lock(void *arg)static void test_timeout (int res,int *ret,char *test_name,int err) {if (!res || errno != err) { -ksft_test_result_fail ("%s returned %d\n" , test_name, - res <0 ? errno : res); - *ret =RET_FAIL ; +if (errno ==ENOSYS ) { +ksft_test_result_skip ("%s: %m\n" , test_name); + }else { +ksft_test_result_fail ("%s returned %d\n" , test_name, + res <0 ? errno : res); + *ret =RET_FAIL ; + } }else {ksft_test_result_pass ("%s succeeds\n" , test_name); }
tools/testing/selftests/futex/functional/futex_wait_wouldblock.c +8 -4
@@ -98,10 +98,14 @@ int main(int argc, char *argv[])info ("Calling futex_waitv on f1: %u @ %p with val=%u\n" , f1, &f1, f1+1 ); res =futex_waitv (&waitv,1 ,0 , &to,CLOCK_MONOTONIC );if (!res || errno !=EWOULDBLOCK ) { -ksft_test_result_fail ("futex_waitv returned: %d %s\n" , - res ? errno : res, - res ?strerror (errno) :"" ); - ret =RET_FAIL ; +if (errno ==ENOSYS ) { +ksft_test_result_skip ("futex_waitv: %m\n" ); + }else { +ksft_test_result_fail ("futex_waitv returned: %d %s\n" , + res ? errno : res, + res ?strerror (errno) :"" ); + ret =RET_FAIL ; + } }else {ksft_test_result_pass ("futex_waitv\n" ); }
tools/testing/selftests/futex/functional/futex_waitv.c +8 -0
@@ -59,6 +59,14 @@ void *waiterfn(void *arg)int main (int argc,char *argv[]) { +if (!ksft_min_kernel_version (5 ,16 )) { +ksft_print_header (); +ksft_set_plan (0 ); +ksft_print_msg ("%s: FUTEX_WAITV not implemented until 5.16\n" , +basename (argv[0 ])); +ksft_print_cnts (); +return KSFT_SKIP ; + }pthread_t waiter;int res, ret =RET_PASS ;struct timespec to;
Signature · 1 line
2.50.1.703.g449372360f-goog