kunit_driver_create(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« kunit_driver_create β€” the kernel API manual, but make it cute

okay so bestie, you know how I keep talking about KUnit and you keep nodding like you get it? today's the day we fix that. this page lives in the Kernel API Manual, section 9, and it's about making a driver that's literally just there for testing. no pressure, no prod, just vibes ✨


🌸 NAME 🌸

kunit_driver_create β€” creates a struct device_driver and attaches it to the kunit_bus

like, that's it. that's the whole job. and honestly? iconic. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

struct device_driver * kunit_driver_create (struct kunit *test , const
char *name );

look at her. two arguments, returns a pointer. she's not complicated, she's just focused. πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • test β€” the test context object. yes, the one you've been passing around everywhere. she's the main character here 🫢
  • name β€” the name you're giving to the driver you just created. pick something cute, it's gonna wear it forever πŸ’–

✨ DESCRIPTION ✨

so what does it actually do? it creates a struct device_driver attached to the kunit_bus, and it gives that driver the name name. that's the whole thing, no hidden tricks, no surprise side quests 🌈

and here's the part that lowkey slays: this driver gets automatically cleaned up on test exit. you don't have to remember to free it, you don't have to write a teardown, you don't have to lie awake at 3am wondering if you leaked something 😭 KUnit handles it. periodt.


πŸ”₯ RETURN πŸ”₯

a stub struct device_driver, managed by KUnit, with the name name. that's what you get back. a little guy, fully managed, ready to go πŸ’œ

ngl the word "stub" is doing a lot of work here β€” it's a stand-in driver for your test, not a real one you'd ship. keep that in mind bestie πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

go read those next, iykyk 🧚


okay and before you close the tab β€” this whole thing comes from ./include/kunit, dated October 2026, and the version stamp up top is kunit_driver_create(9) because we stay on brand πŸ’… mwah, go write some tests bestie, you're gonna ate πŸ“β­

πŸ“¦ where this page comes from