* [PATCH v2] selftests: harness: Restore order of test functions
@ 2026-04-22 12:32 Thomas Weißschuh
2026-04-27 17:46 ` Shuah Khan
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2026-04-22 12:32 UTC (permalink / raw)
To: Kees Cook, Andy Lutomirski, Will Drewry, Shuah Khan, Sun Jian,
Jakub Kicinski
Cc: linux-kselftest, linux-kernel, Thomas Weißschuh
The recent addition of explicit constructor orders for fixture tests
broke the ordering of those relative to non-fixture tests and the
reverse-constructor-order detection.
Restore the ordering of the test functions relative to each other by
using the same explicit test order for all test registrations and
__constructor_order_first().
Rename the constant, as it is not specific to TEST_F() anymore.
Fixes: 6be268151426 ("selftests/harness: order TEST_F and XFAIL_ADD constructors")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Kees Cook <kees@kernel.org>
---
Changes in v2:
- Pick up review tag from Kees.
- Add missing closing brace in FIXTURE_VARIANT_ADD().
- Link to v1: https://patch.msgid.link/20260420-kselftests-harness-order-v1-1-b3c603782ce8@linutronix.de
---
The harness selftest flags this issue, but apparently that was not used.
---
tools/testing/selftests/kselftest_harness.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 75fb016cd190..cfdce9cd252e 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -76,7 +76,7 @@ static inline void __kselftest_memset_safe(void *s, int c, size_t n)
memset(s, c, n);
}
-#define KSELFTEST_PRIO_TEST_F 20000
+#define KSELFTEST_PRIO_TEST 20000
#define KSELFTEST_PRIO_XFAIL 20001
#define TEST_TIMEOUT_DEFAULT 30
@@ -194,7 +194,7 @@ static inline void __kselftest_memset_safe(void *s, int c, size_t n)
.fixture = &_fixture_global, \
.termsig = _signal, \
.timeout = TEST_TIMEOUT_DEFAULT, }; \
- static void __attribute__((constructor)) _register_##test_name(void) \
+ static void __attribute__((constructor(KSELFTEST_PRIO_TEST))) _register_##test_name(void) \
{ \
__register_test(&_##test_name##_object); \
} \
@@ -238,7 +238,7 @@ static inline void __kselftest_memset_safe(void *s, int c, size_t n)
FIXTURE_VARIANT(fixture_name); \
static struct __fixture_metadata _##fixture_name##_fixture_object = \
{ .name = #fixture_name, }; \
- static void __attribute__((constructor)) \
+ static void __attribute__((constructor(KSELFTEST_PRIO_TEST))) \
_register_##fixture_name##_data(void) \
{ \
__register_fixture(&_##fixture_name##_fixture_object); \
@@ -364,7 +364,7 @@ static inline void __kselftest_memset_safe(void *s, int c, size_t n)
_##fixture_name##_##variant_name##_object = \
{ .name = #variant_name, \
.data = &_##fixture_name##_##variant_name##_variant}; \
- static void __attribute__((constructor)) \
+ static void __attribute__((constructor(KSELFTEST_PRIO_TEST))) \
_register_##fixture_name##_##variant_name(void) \
{ \
__register_fixture_variant(&_##fixture_name##_fixture_object, \
@@ -468,7 +468,7 @@ static inline void __kselftest_memset_safe(void *s, int c, size_t n)
fixture_name##_teardown(_metadata, self, variant); \
} \
static struct __test_metadata *_##fixture_name##_##test_name##_object; \
- static void __attribute__((constructor(KSELFTEST_PRIO_TEST_F))) \
+ static void __attribute__((constructor(KSELFTEST_PRIO_TEST))) \
_register_##fixture_name##_##test_name(void) \
{ \
struct __test_metadata *object = mmap(NULL, sizeof(*object), \
@@ -1323,7 +1323,7 @@ static int test_harness_run(int argc, char **argv)
return KSFT_FAIL;
}
-static void __attribute__((constructor)) __constructor_order_first(void)
+static void __attribute__((constructor(KSELFTEST_PRIO_TEST))) __constructor_order_first(void)
{
__constructor_order_forward = true;
}
---
base-commit: c1f49dea2b8f335813d3b348fd39117fb8efb428
change-id: 20260420-kselftests-harness-order-9f641f204bde
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] selftests: harness: Restore order of test functions
2026-04-22 12:32 [PATCH v2] selftests: harness: Restore order of test functions Thomas Weißschuh
@ 2026-04-27 17:46 ` Shuah Khan
0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2026-04-27 17:46 UTC (permalink / raw)
To: Thomas Weißschuh, Kees Cook, Andy Lutomirski, Will Drewry,
Shuah Khan, Sun Jian, Jakub Kicinski
Cc: linux-kselftest, linux-kernel, Shuah Khan
On 4/22/26 06:32, Thomas Weißschuh wrote:
> The recent addition of explicit constructor orders for fixture tests
> broke the ordering of those relative to non-fixture tests and the
> reverse-constructor-order detection.
>
> Restore the ordering of the test functions relative to each other by
> using the same explicit test order for all test registrations and
> __constructor_order_first().
>
> Rename the constant, as it is not specific to TEST_F() anymore.
>
> Fixes: 6be268151426 ("selftests/harness: order TEST_F and XFAIL_ADD constructors")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> Reviewed-by: Kees Cook <kees@kernel.org>
> ---
> Changes in v2:
> - Pick up review tag from Kees.
> - Add missing closing brace in FIXTURE_VARIANT_ADD().
> - Link to v1: https://patch.msgid.link/20260420-kselftests-harness-order-v1-1-b3c603782ce8@linutronix.de
> ---
Applied to linux-kselftest fixes for Linux 7.1-rc2
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-27 17:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-22 12:32 [PATCH v2] selftests: harness: Restore order of test functions Thomas Weißschuh
2026-04-27 17:46 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox