kunit_driver_create(9)
π« 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 π
- Kernel file
./include/kunit/device.h kunit_device_register(9)kunit_device_register_with_driver(9)kunit_device_unregister(9)
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
- 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