kunit_get_current_test(9)
π kunit_get_current_test(9) β like, the Kernel API Manual, bestie π
okay so picture this: you're poking around in kernel land, you open up the manual, and the very first line is literally just kunit_get_current_test(9) β that's the page, that's the vibe, we're here. β¨
πΈ NAME πΈ
kunit_get_current_test β returns a pointer to the KUnit test that's currently running. that's it. that's the whole job. and she does it flawlessly. π
π¦ SYNOPSIS π¦
struct kunit * kunit_get_current_test (void );
look at her. no drama, no args, just vibes and a return type. π«Ά
π ARGUMENTS π
voidβ no arguments, bestie. zero. none. she takes nothing and gives everything. main character energy fr fr. π
β DESCRIPTION β
okay so here's the tea β β if a KUnit test is running in the current task, this function hands you back a pointer to its associated struct kunit. iconic. and once you've got that pointer? you can pass it straight into any KUnit function or assertion. it's giving "universal key to the KUnit kingdom". π₯
and if no test is running? or if a test is running in a different task? then she just returns NULL. no test, no pointer, no problem. that's the whole deal. π
the truly gorgeous part: this function is safe to call even when KUnit is disabled. no cap. if CONFIG_KUNIT isn't enabled, it literally compiles down to nothing and returns quickly because β say it with me β no test is running. π§
so yeah, you can call her anytime, anywhere, in any build config, and she will never make it weird. obsessed. π
π SEE ALSO π
- the kernel file
./include/kunit/test-bug.hβ go read it, iykyk π kunit_fail_current_test(9)πkunit_is_suppressed_warning(9)π
π sign-off π
this little masterpiece lives in ./include/kunit, and it's stamped October 2026 β so yeah, she's not just iconic, she's from the future. slay. periodt. π¦β¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms