mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/futex: Dynamically skip unsupported tests
@ 2026-06-24  7:02 Wake Liu
  2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Wake Liu @ 2026-06-24  7:02 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Thomas Gleixner, Peter Zijlstra, Ingo Molnar, Darren Hart,
	Davidlohr Bueso, linux-kselftest, linux-kernel, Wake Liu

Some new futex tests rely on kernel features that may not be supported
on all configurations (e.g., FUTEX2_NUMA or PR_FUTEX_HASH).
Currently, these tests fail with EINVAL when the features are missing.

This patch adds dynamic skip logic to:
1. futex_priv_hash: Skip if PR_FUTEX_HASH returns ENOSYS or EINVAL.
2. futex_numa_mpol: Skip if futex2 or FUTEX2_NUMA returns ENOSYS or EINVAL.

This allows the tests to pass (as SKIPPED) on kernels without support,
while preserving coverage on configurations that do support them.

Signed-off-by: Wake Liu <wakel@google.com>
---
 tools/testing/selftests/futex/functional/futex_numa_mpol.c | 2 ++
 tools/testing/selftests/futex/functional/futex_priv_hash.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
index 78c0f7a59e17..d215acf88120 100644
--- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c
+++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
@@ -103,6 +103,8 @@ static void __test_futex(void *futex_ptr, int err_value, unsigned int futex_flag
 			break;
 		}
 		if (ret < 0) {
+			if (errno == ENOSYS || (errno == EINVAL && (futex_flags & FUTEX2_NUMA)))
+				ksft_exit_skip("futex2 or FUTEX2_NUMA not supported by kernel\n");
 			ksft_exit_fail_msg("Failed futex2_wake(%d, 0x%x): %m\n",
 					   to_wake, futex_flags);
 		}
diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/tools/testing/selftests/futex/functional/futex_priv_hash.c
index e8079d7c65e8..27c3ea5ff3ed 100644
--- a/tools/testing/selftests/futex/functional/futex_priv_hash.c
+++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c
@@ -145,6 +145,8 @@ TEST(priv_hash)
 	}
 	/* First thread, expect to be 0, not yet initialized */
 	ret = futex_hash_slots_get();
+	if (ret < 0 && errno == EINVAL)
+		ksft_exit_skip("PR_FUTEX_HASH not supported by kernel\n");
 	if (ret != 0)
 		ksft_exit_fail_msg("futex_hash_slots_get() failed: %d, %m\n", ret);
 
-- 
2.55.0.rc0.799.gd6f94ed593-goog


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tip: locking/futex] selftests/futex: Dynamically skip unsupported tests
  2026-06-24  7:02 [PATCH] selftests/futex: Dynamically skip unsupported tests Wake Liu
@ 2026-07-05 19:54 ` tip-bot2 for Wake Liu
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Wake Liu @ 2026-07-05 19:54 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Wake Liu, Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the locking/futex branch of tip:

Commit-ID:     50c121e5a57abe446e46825fb9c69ac419765d5c
Gitweb:        https://git.kernel.org/tip/50c121e5a57abe446e46825fb9c69ac419765d5c
Author:        Wake Liu <wakel@google.com>
AuthorDate:    Wed, 24 Jun 2026 07:02:23 
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Sun, 05 Jul 2026 21:49:18 +02:00

selftests/futex: Dynamically skip unsupported tests

Some new futex tests rely on kernel features that may not be supported
on all configurations (e.g., FUTEX2_NUMA or PR_FUTEX_HASH).
Currently, these tests fail with EINVAL when the features are missing.

Add dynamic skip logic to:

 - futex_priv_hash: Skip if PR_FUTEX_HASH returns ENOSYS or EINVAL.

 - futex_numa_mpol: Skip if futex2 or FUTEX2_NUMA returns ENOSYS or EINVAL.

This allows the tests to pass (as SKIPPED) on kernels without support,
while preserving coverage on configurations that do support them.

[ tglx: Adapt to harness changes, massage change log ]

Signed-off-by: Wake Liu <wakel@google.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260624070223.1533167-1-wakel@google.com
---
 tools/testing/selftests/futex/functional/futex_numa_mpol.c | 3 +++
 tools/testing/selftests/futex/functional/futex_priv_hash.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
index c79184f..4ffcf41 100644
--- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c
+++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
@@ -107,6 +107,9 @@ static void __test_futex(struct __test_metadata *_metadata, void *futex_ptr, int
 			break;
 		}
 		if (ret < 0) {
+			if (errno == ENOSYS || (errno == EINVAL && (futex_flags & FUTEX2_NUMA)))
+				SKIP(return, "futex2 or FUTEX2_NUMA not supported by kernel");
+
 			ASSERT_GE(ret, 0) {
 				TH_LOG("Failed futex2_wake(%d, 0x%x): %s",
 				       to_wake, futex_flags, strerror(errno));
diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/tools/testing/selftests/futex/functional/futex_priv_hash.c
index a742a79..a8742e2 100644
--- a/tools/testing/selftests/futex/functional/futex_priv_hash.c
+++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c
@@ -143,6 +143,9 @@ TEST(priv_hash)
 
 	/* First thread, expect to be 0, not yet initialized */
 	ret = futex_hash_slots_get();
+	if (ret < 0 && errno == EINVAL)
+		SKIP(return, "PR_FUTEX_HASH not supported by kernel");
+
 	ASSERT_EQ(ret, 0)
 		TH_LOG("futex_hash_slots_get() failed: %d, %s", ret, strerror(errno));
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-05 19:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-24  7:02 [PATCH] selftests/futex: Dynamically skip unsupported tests Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu

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