]> git.ipfire.org Git - thirdparty/linux.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)
committerJakub Kicinski <kuba@kernel.org>
Thu, 5 Mar 2026 15:34:54 +0000 (07:34 -0800)
commit6be2681514261324c8ee8a1c6f76cefdf700220f
tree2169814d15a0e20c19880b7d41b15e9a8932f76d
parent37380976cf22893537ff229224a0daa2f4a28e65
selftests/harness: order TEST_F and XFAIL_ADD constructors

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>
tools/testing/selftests/kselftest_harness.h