Em 25/05/2026 06:20, Wake Liu escreveu:
Migrate futex_wait test to the kselftest harness framework,
removing mixed legacy ksft_* API usages and ensuring proper thread joining.


Why is this patchset not part of the same series that you just sent?

Signed-off-by: Wake Liu <[email protected]>
---
  .../selftests/futex/functional/futex_wait.c   | 125 +++++++++++-------
  1 file changed, 77 insertions(+), 48 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/futex_wait.c 
b/tools/testing/selftests/futex/functional/futex_wait.c
index 7b8879409007..ed4b040600b8 100644
--- a/tools/testing/selftests/futex/functional/futex_wait.c
+++ b/tools/testing/selftests/futex/functional/futex_wait.c
@@ -9,6 +9,7 @@
  #include <sys/shm.h>
  #include <sys/mman.h>
  #include <fcntl.h>
+#include <stdlib.h>
#include "futextest.h"
  #include "kselftest_harness.h"
@@ -19,125 +20,153 @@
void *futex; +struct waiter_args {
+       struct __test_metadata *_metadata;
+       unsigned int flags;
+};
+
  static void *waiterfn(void *arg)
  {
+       struct waiter_args *args = (struct waiter_args *)arg;
+       struct __test_metadata *_metadata = args->_metadata;

As much as I like the benefits of being able to properly use the harness macros in threads, I fell like we are touching private structs here. Are they safe to be used concurrently? If a child thread an the main thread fails, does that counts as two fails?

Perhaps we should have a look to create a kselftest wrapper for pthread_create().

        struct timespec to;
-       unsigned int flags = 0;
-
-       if (arg)
-               flags = *((unsigned int *) arg);
+       int res;
to.tv_sec = 0;
        to.tv_nsec = timeout_ns;
- if (futex_wait(futex, 0, &to, flags))
-               printf("waiter failed errno %d\n", errno);
+       res = futex_wait(futex, 0, &to, args->flags);
+       if (res) {
+               EXPECT_EQ(res, 0)

I have changed it to ASSERT_EQ(res, -1) just to see what happens when a child thread fails, but the test still reported PASSED: 3 / 3

Reply via email to