kunit_activate_static_stub(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kunit_activate_static_stub (9) β€” from the Kernel API Manual, bestie ✨

okay so. this is a page from the Kernel API Manual and honestly it's giving "tiny header file, huge power" energy. let's get into it 🫢


✨ NAME ✨

kunit_activate_static_stub β€” replace a function using static stubs. that's it. that's the whole vibe. πŸ”₯


✨ SYNOPSIS ✨

kunit_activate_static_stub (test , real_fn_addr , replacement_addr );

three args, no notes, slay πŸ’…


✨ ARGUMENTS ✨

  • test β€” a pointer to the struct kunit test context for the current test. like, the test you're literally in right now. main character energy πŸ‘‘
  • real_fn_addr β€” the address of the function you wanna replace. the og, the original, the one getting swapped out πŸ™ˆ
  • replacement_addr β€” the address of the function you're replacing it with. the understudy that's about to eat πŸ“

✨ DESCRIPTION ✨

when it's activated, calls to real_fn_addr from within this test β€” even if they're called indirectly β€” will instead call replacement_addr. sneak attack. ninja swap. no cap, that's the whole trick 🧚

⚠️ important caveat bestie, don't skip this: the function pointed to by real_fn_addr must begin with the static stub prologue in KUNIT_STATIC_STUB_REDIRECT for this to work. no prologue, no redirect. that's the deal πŸ’€

also, real_fn_addr and replacement_addr must have the same type. matching types only, mismatches are not it 😭

and when you're done being dramatic, the redirection can be disabled again with kunit_deactivate_static_stub. cleanup era 🌸


✨ SEE ALSO ✨

iykyk πŸ‘€


and that's the page!! this masterpiece lives in ./include/kunit and the version/date stamp on it is October 2026 β€” so yeah, mark your calendars, bestie πŸŽ€πŸ’–

πŸ“¦ where this page comes from