]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selftests/harness: order TEST_F and XFAIL_ADD constructors
authorSun Jian <sun.jian.kdev@gmail.com>
Wed, 25 Feb 2026 11:14:50 +0000 (19:14 +0800)
committerSasha Levin <sashal@kernel.org>
Thu, 12 Mar 2026 11:09:58 +0000 (07:09 -0400)
commit74afc9fd7d9153eceb6f5aaa8af411d830926e4b
tree4da41913f9a58147b254db8c5ad5b00fbbbb5ea6
parentff14cd44c85c20ad69479db73698185de291550c
selftests/harness: order TEST_F and XFAIL_ADD constructors

[ Upstream commit 6be2681514261324c8ee8a1c6f76cefdf700220f ]

TEST_F() allocates and registers its struct __test_metadata via mmap()
inside its constructor, and only then assigns the
_##fixture_##test##_object pointer.

XFAIL_ADD() runs in a constructor too and reads
_##fixture_##test##_object to initialize xfail->test. If XFAIL_ADD runs
first, xfail->test can be NULL and the expected failure will be reported
as FAIL.

Use constructor priorities to ensure TEST_F registration runs before
XFAIL_ADD, without adding extra state or runtime lookups.

Fixes: 2709473c9386 ("selftests: kselftest_harness: support using xfail")
Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>
Link: https://patch.msgid.link/20260225111451.347923-1-sun.jian.kdev@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/kselftest_harness.h