Testing Drivers with KUnit (Does hardware have to be hard?)
summary
KUnit is the in-kernel unit test framework (since Linux 5.5) and now hosts almost 1,000 upstream tests. The talk lays out concrete tooling: static stubbing / function redirection, resource helpers (kunit_resource, defer actions), and proposals for device fakes via kunit_device versus root_device or platform_device. Hardware mocking options include UML’s LOGIC_IOMEM, variable redirection, and QEMU backchannels. Limits noted: global hardware state, weak multi-thread support, tricky user memory contexts, and gcov works reliably with Clang for coverage.
AI-written summary · about
chapters (11)
- 0:00Introduction to KUnit
- 1:03What is KUnit?
- 2:05Easy vs hard to test code
- 5:39Why drivers are hard to test
- 8:10Challenges with global state
- 11:19Refactoring for testability
- 14:09Function redirection in tests
- 16:41Testing device drivers
- 19:09Future solutions for hardware testing
- 22:44Emulating hardware in QEMU
- 24:57KUnit growth and adoption
related talks
44mKUnit - Unit Testing for the Linux Kernel
30mKernel Testing with KUnit: Bridging the Gap
24mKUnit Testing Insufficiencies
45mKUnit: Past, Present, and Future
45m"KUnit: Past, Present, and Future"
16mHow do we make KUnit work for us?
19mHow to introduce KUnit to physical...
18mKUnit: Function Redirection and More
