Thread (6 messages) read the whole thread 6 messages, 5 authors, 2026-03-06

Re: [PATCH v3 v3 1/2] selftests/harness: order TEST_F and XFAIL_ADD constructors

From: Thomas Weißschuh <hidden>
Date: 2026-03-05 09:09:35
Also in: linux-kselftest, lkml

On Wed, Feb 25, 2026 at 07:14:50PM +0800, Sun Jian wrote:
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 <redacted>
---
v3:
  - Move KSELFTEST_PRIO_* definitions above the TEST_SIGNAL() kdoc block.

v2:
  - Drop the lazy string-matching approach.
  - Use constructor priorities to enforce initialization order.
  Link:
    https://lore.kernel.org/all/20260224113859.12345-1-sun.jian.kdev@gmail.com/

v1:
  Link:
    https://lore.kernel.org/all/20260222111846.12345-1-sun.jian.kdev@gmail.com/
---
 tools/testing/selftests/kselftest_harness.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
FYI there is a selftest for the harness in
tools/testing/selftests/kselftest_harness/harness-selftest.c .
You could update this with your usecase to make sure, that this functionality
keeps working.

(...)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help