FIXTURE_SETUP(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… FIXTURE_SETUP(9) β€” the kernel API manual page, but make it make sense ✨

okay bestie, this is FIXTURE_SETUP from section 9 of the kernel API manual, and honestly she's a little baddie πŸŽ€ β€” she builds the setup function for your fixture, no cap.


✨ NAME ✨

FIXTURE_SETUP β€” prepares the setup function for the fixture. the _metadata_ is included so that EXPECT_*, ASSERT_* etc. work correctly 🫢

like, the metadata is literally part of the deal so your assertions don't fumble the bag. iykyk πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

FIXTURE_SETUP (fixture_name );

that's it. that's the whole vibe check. ⭐


🌸 ARGUMENTS 🌸

  • fixture_name β€” the fixture name πŸŽ€ (yes queen, just the name, that's the whole argument)

πŸ‘‘ DESCRIPTION πŸ‘‘

okay so here's the shape of it, bestie:

FIXTURE_SETUP(fixture_name) { implementation }

she populates the required "setup" function for a fixture β€” main character energy fr fr πŸ”₯

and here's the gorgeous part: an instance of the datatype defined with FIXTURE_DATA will be exposed as self for the implementation πŸ’– so your implementation gets handed self and can just do its thing, iconic.

the ASSERT_* macros are valid for use in this context ✨ β€” and they will preempt the execution of any dependent fixture tests 😭 so like, if an assert goes off in here, the dependent tests don't even get to run. it's giving bouncer at the club.

also!! a bare return; statement may be used to return early πŸ¦‹ β€” that's your little early-exit moment, use her wisely.


🌈 SEE ALSO 🌈

the whole friend group, assembled πŸ’œ:

  • the kernel file ./tools/testing/selftests/kselftest_harness.h example(9) β€” that's the example, go look at it, it's giving tutorial
  • TH_LOG(9)
  • SKIP(9)
  • TEST(9)
  • TEST_SIGNAL(9)
  • FIXTURE_DATA(9)
  • FIXTURE(9)
  • FIXTURE_TEARDOWN(9)
  • FIXTURE_TEARDOWN_PARENT(9)
  • FIXTURE_VARIANT(9)
  • FIXTURE_VARIANT_ADD(9)
  • TEST_F(9)
  • TEST_HARNESS_MAIN(9)
  • operators(9)
  • ASSERT_EQ(9)
  • ASSERT_NE(9)
  • ASSERT_LT(9)
  • ASSERT_LE(9)
  • ASSERT_GT(9)
  • ASSERT_GE(9)
  • ASSERT_NULL(9)
  • ASSERT_TRUE(9)
  • ASSERT_FALSE(9)
  • ASSERT_STREQ(9)
  • ASSERT_STRNE(9)
  • EXPECT_EQ(9)
  • EXPECT_NE(9)
  • EXPECT_LT(9)
  • EXPECT_LE(9)
  • EXPECT_GT(9)
  • EXPECT_GE(9)
  • EXPECT_NULL(9)
  • EXPECT_TRUE(9)
  • EXPECT_FALSE(9)
  • EXPECT_STREQ(9)
  • EXPECT_STRNE(9)
  • XFAIL_ADD(9)

πŸ’€ reminder bestie: ASSERT_* inside this setup context will preempt the execution of any dependent fixture tests. that's not a vibe, that's a fact. don't come for me, come for the header.

okay that's the page, mwah 😘 β€” sourced from ./tools/testing/selftests, dated October 2026, and that's the whole FIXTURE_SETUP(9) situation. slay, periodt, go write your tests πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from