STRUCT KUNIT_SUITE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ struct kunit_suite(9) β€” the Kernel API Manual, bestie edition πŸ’œ

okay so you've wandered into the Kernel API Manual and the page you want is struct kunit_suite(9). sit down, grab a strawberry πŸ“, and let me tell you about the single most iconic little struct in KUnit land.


✨ NAME ✨

struct kunit_suite β€” literally just describes a related collection of &struct kunit_case. that's it. that's the whole vibe. it's the group chat and the test cases are the members πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

struct kunit_suite {
    const char name[256];
    int (*suite_init)(struct kunit_suite *suite);
    void (*suite_exit)(struct kunit_suite *suite);
    int (*init)(struct kunit *test);
    void (*exit)(struct kunit *test);
    struct kunit_case *test_cases;
    struct kunit_attributes attr;
 };

like, look at her. seven fields. every single one serving c*nt. πŸ”₯


πŸŽ€ Members πŸŽ€

okay let's go field by field, no skipping, we're doing all of them:

  • name β€” the name of the test. purely informational, bestie β€” it's giving "decorative but make it diagnostic" ✨
  • suite_init β€” called once per test suite before the test cases. she arrives first, sets up the vibes 🧚
  • suite_exit β€” called once per test suite after all test cases. she's the last one to leave the party and she turns off the lights πŸŒ™
  • init β€” called before every test case. every. single. one. consistency queen πŸ‘‘
  • exit β€” called after every test case. yep, matches init. periodt πŸ’…
  • test_cases β€” a null terminated array of test cases. null terminated!! don't forget the terminator or it's gonna keep reading and that's not the energy we want 😭
  • attr β€” the attributes associated with the test suite πŸŽ€

🌈 Description 🌈

so a kunit_suite is a collection of related struct kunit_case s, such that init is called before every test case and exit is called after every test case. sound familiar? it's the same idea as a test fixture or a test class in other unit testing frameworks like JUnit or Googletest. like, if you know, you know β€” iykyk 🫢

⚠️ okay this part is important so pay attention: note that exit and suite_exit will run even if init or suite_init fail. so make sure they can handle any inconsistent state which may result. like, your cleanup has to be built different, it cannot be assuming everything went to plan. no cap. πŸ’€

and the rule that ties it all together: every struct kunit_case must be associated with a kunit_suite for KUnit to run it. no suite, no run. that's the whole gatekeeping situation πŸ‘‘


⭐ SEE ALSO ⭐

the lore is deep, bestie. it's in the kernel file ./include/kunit/test.h and here's the full squad:


that's the whole page, bestie, you ate it up πŸ’– this one lives in ./include/kunit and the manual page is dated October 2026, filed under struct kunit_suite(9). go forth and write tests, and remember: always clean up after yourself. πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from