TEST(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ TEST(9) ✨

okay so bestie, this is from the Kernel API Manual and it's literally the moment you define a test in the kselftest harness. it's giving main character energy for your whole test suite πŸ’…


πŸŽ€ NAME πŸŽ€

TEST β€” defines the test function and creates the registration stub. no cap, it's the whole vibe of setting up a test by name ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

TEST (test_name );

🌸 ARGUMENTS 🌸

  • test_name β€” the test name. that's it. that's the argument. periodt πŸ’–

πŸ’œ DESCRIPTION πŸ’œ

TEST(name) { implementation }

okay so this defines a test by its name. lowkey important: names must be unique and tests must not be run in parallel. like, do not even try it. fr fr.

the block containing the implementation is a function, so scoping should be treated as such β€” it's giving real function energy, not just some fake little macro situation. if you wanna return early you can absolutely do a bare return; statement and that's iconic of you.

EXPECT_* and ASSERT_* are valid in a TEST { } context. iykyk πŸ‘‘


🌈 SEE ALSO 🌈

bestie, the reference list is long but we're gonna get through it together, no skipping, every single one matters:

Kernel file ./tools/testing/selftests/kselftest_harness.h example(9), TH_LOG(9), SKIP(9), TEST_SIGNAL(9), FIXTURE_DATA(9), FIXTURE(9), FIXTURE_SETUP(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)


later besties πŸ’– this page came from ./tools/testing/selftests and its version is October 2026. it's literally the definition of a whole vibe, and now you know how to define a test. slay ✨🫢

πŸ“¦ where this page comes from