Unit Testing Memory Mapped Device Drivers
summary
Describes a concrete method that replaces direct register dereferences with a hook so tests can redirect accesses to fake variables, uses EC_REGGE macro redefinition and native_sim as the test board, builds glue headers to compile Posix, and simulates edge/level behavior and a register-clear-on-read quirk. Claims and demonstrates 100% unit test coverage before and after adding level-interrupt emulation, and verifies the feature works on real hardware on first try.
AI-written summary · about
chapters (14)
- 0:00Unit testing device drivers
- 2:33Why unit testing is hard
- 3:59Case study: IT GPIO driver
- 5:03Intercepting register access with EC_REG
- 6:27Choosing Native Sim
- 8:11Build and header dependencies
- 10:24Redirecting to fake registers
- 11:49Verifying fake registers
- 13:35Testing GPIO functions
- 14:00Handling side effects
- 15:48Limitations and improvements
- 17:14Native Sim vs hardware
- 19:25Unit test driven development
- 21:57Q&A
related talks
26mUnit Testing Memory Mapped Device Drivers
01h 01mSimulating Low-Level Hardware Devices in Cpp
01h 01mAdvanced Unit Testing in C & C++
37mStreamlining Testing with Generic Tests and Emulators
20mHow to Mock in the 21st Century
40mZephyr Off-Chip Peripheral Emulation
28mTesting Drivers with KUnit (Does hardware have to be hard?)
55mComprehensive Testing of Embedded Software
