From: Wake Liu <wakel@google.com>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org
Cc: "Peter Zijlstra" <peterz@infradead.org>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"André Almeida" <andrealmeid@igalia.com>,
"Carlos Llamas" <cmllamas@google.com>,
linux-kernel@vger.kernel.org, wakel@google.com
Subject: [PATCH 3/7] selftests/futex: Migrate futex_requeue_pi_mismatched_ops to harness
Date: Mon, 1 Jun 2026 06:51:22 +0000 [thread overview]
Message-ID: <20260601065126.3623867-4-wakel@google.com> (raw)
In-Reply-To: <20260601065126.3623867-1-wakel@google.com>
Migrate futex_requeue_pi_mismatched_ops test to the kselftest harness framework,
removing mixed legacy ksft_* API usages and passing test metadata to helper thread.
Signed-off-by: Wake Liu <wakel@google.com>
---
.../futex_requeue_pi_mismatched_ops.c | 39 +++++++++++--------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c b/tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c
index f686e605359c..c55eadd261da 100644
--- a/tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c
+++ b/tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c
@@ -29,14 +29,17 @@
futex_t f1 = FUTEX_INITIALIZER;
futex_t f2 = FUTEX_INITIALIZER;
-int child_ret = 0;
+int child_ret;
void *blocking_child(void *arg)
{
+ struct __test_metadata *_metadata = (struct __test_metadata *)arg;
+
child_ret = futex_wait(&f1, f1, NULL, FUTEX_PRIVATE_FLAG);
if (child_ret < 0) {
child_ret = -errno;
- ksft_exit_fail_msg("futex_wait\n");
+ ASSERT_EQ(child_ret, 0)
+ TH_LOG("futex_wait failed: %s", strerror(errno));
}
return (void *)&child_ret;
}
@@ -46,8 +49,8 @@ TEST(requeue_pi_mismatched_ops)
pthread_t child;
int ret;
- if (pthread_create(&child, NULL, blocking_child, NULL))
- ksft_exit_fail_msg("pthread_create\n");
+ ASSERT_EQ(pthread_create(&child, NULL, blocking_child, _metadata), 0)
+ TH_LOG("pthread_create failed");
/* Allow the child to block in the kernel. */
sleep(1);
@@ -67,27 +70,31 @@ TEST(requeue_pi_mismatched_ops)
* FUTEX_WAKE.
*/
ret = futex_wake(&f1, 1, FUTEX_PRIVATE_FLAG);
- if (ret == 1)
+ if (ret == 1) {
ret = 0;
- else if (ret < 0)
- ksft_exit_fail_msg("futex_wake\n");
- else
- ksft_exit_fail_msg("futex_wake did not wake the child\n");
+ } else if (ret < 0) {
+ ASSERT_GE(ret, 0)
+ TH_LOG("futex_wake failed: %s", strerror(errno));
+ } else {
+ ASSERT_TRUE(0)
+ TH_LOG("futex_wake did not wake the child");
+ }
} else {
- ksft_exit_fail_msg("futex_cmp_requeue_pi\n");
+ ASSERT_TRUE(0)
+ TH_LOG("futex_cmp_requeue_pi failed with unexpected errno: %s", strerror(errno));
}
} else if (ret > 0) {
- ksft_test_result_fail("futex_cmp_requeue_pi failed to detect the mismatch\n");
+ EXPECT_EQ(ret, 0)
+ TH_LOG("futex_cmp_requeue_pi failed to detect the mismatch");
} else {
- ksft_exit_fail_msg("futex_cmp_requeue_pi found no waiters\n");
+ ASSERT_TRUE(0)
+ TH_LOG("futex_cmp_requeue_pi found no waiters");
}
pthread_join(child, NULL);
- if (!ret && !child_ret)
- ksft_test_result_pass("futex_requeue_pi_mismatched_ops passed\n");
- else
- ksft_test_result_pass("futex_requeue_pi_mismatched_ops failed\n");
+ EXPECT_EQ(ret, 0) TH_LOG("Test failed: ret=%d", ret);
+ EXPECT_EQ(child_ret, 0) TH_LOG("Child failed: child_ret=%d", child_ret);
}
TEST_HARNESS_MAIN
--
2.54.0.823.g6e5bcc1fc9-goog
next prev parent reply other threads:[~2026-06-01 6:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 6:51 [PATCH 0/7] selftests/futex: Migrate requeue, NUMA and robust list tests " Wake Liu
2026-06-01 6:51 ` [PATCH 1/7] selftests/futex: Migrate futex_requeue " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 2/7] selftests/futex: Migrate futex_requeue_pi " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` Wake Liu [this message]
2026-07-05 19:54 ` [tip: locking/futex] selftests/futex: Migrate futex_requeue_pi_mismatched_ops " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 4/7] selftests/futex: Migrate futex_requeue_pi_signal_restart " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 5/7] selftests/futex: Migrate futex_numa_mpol " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 6/7] selftests/futex: Migrate futex_priv_hash " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 7/7] selftests/futex: Migrate robust_list " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 8:24 ` [PATCH 0/7] selftests/futex: Migrate requeue, NUMA and robust list tests " Peter Zijlstra
2026-06-03 6:17 ` Wake Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260601065126.3623867-4-wakel@google.com \
--to=wakel@google.com \
--cc=andrealmeid@igalia.com \
--cc=cmllamas@google.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome