[Devel] [PATCH hci-8.1 6/6] selftests/futex: fail futex_waitv when the waiter failed
Eva Kurchatova
eva.kurchatova at virtuozzo.com
Mon Oct 26 15:40:15 MSK 2026
The waiter thread records a failed futex_waitv() with
ksft_test_result_fail() and the test exits with the status its main
thread collected, so a waiter that returned the wrong index or an
error was reported as a pass; and the main thread never waited for the
waiter, so its result could land after the verdict. Join the waiter
after each wake and fail when it recorded a failure.
https://virtuozzo.atlassian.net/browse/VSTOR-134205
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
---
tools/testing/selftests/futex/functional/futex_waitv.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/testing/selftests/futex/functional/futex_waitv.c b/tools/testing/selftests/futex/functional/futex_waitv.c
index a94337f677e1..20fc537c400c 100644
--- a/tools/testing/selftests/futex/functional/futex_waitv.c
+++ b/tools/testing/selftests/futex/functional/futex_waitv.c
@@ -100,6 +100,7 @@ int main(int argc, char *argv[])
usleep(WAKE_WAIT_US);
res = futex_wake(u64_to_ptr(waitv[NR_FUTEXES - 1].uaddr), 1, FUTEX_PRIVATE_FLAG);
+ pthread_join(waiter, NULL);
if (res != 1) {
ksft_test_result_fail("futex_wake private returned: %d %s\n",
res ? errno : res,
@@ -133,6 +134,7 @@ int main(int argc, char *argv[])
usleep(WAKE_WAIT_US);
res = futex_wake(u64_to_ptr(waitv[NR_FUTEXES - 1].uaddr), 1, 0);
+ pthread_join(waiter, NULL);
if (res != 1) {
ksft_test_result_fail("futex_wake shared returned: %d %s\n",
res ? errno : res,
@@ -232,6 +234,10 @@ int main(int argc, char *argv[])
ksft_test_result_pass("futex_waitv invalid clockid\n");
}
+ /* The waiter records its own failures */
+ if (ksft_get_fail_cnt())
+ ret = RET_FAIL;
+
ksft_print_cnts();
return ret;
}
--
2.56.0
More information about the Devel
mailing list