Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How would you unit test device drivers?


Mock the hardware or set up a testing harness (mostly the same work as involved with setting up for hands-free git bisect ing on the kernel).


Virtual machines...


You may want to rethink your statement. How are virtual machines going to help in unit testing drivers that work with real hardware?


You sound like my old boss :-) I used VMs to develop USB drivers with great success.

At my university we wrote basic operating system, VESA and SATA drivers were mostly developed using VMWare.

And it is possible to connect PCIe devices to VMs, but it requires lot of work.


This only works if you already have a virtual machine with a high quality model of the hardware you're trying to test the driver for. For core PC devices like VESA and SATA this is mostly OK (though you still have a high risk of introducing opposing bugs in the device model and the driver which cancel each other out, so it can't replace testing with real hardware entirely). But it won't scale to the huge range of drivers for more or less obscure hardware which the kernel has these days -- writing a device model is about as much work again as writing the device driver, maybe more, and often devices just don't have enough documentation to write an accurate model. Nor is it likely to identify regressions like "we accidentally reverted the fix for this hardware bug that only affects rev 0 SCSI adaptors from manufacturer X".


Yes, but you need the actual physical hardware to work with. It's completely impractical for the kernel to unit test drivers that work with hardware that most developers do not have access to.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: