Linux OS developers : do they unit test their code ?
If yes :
- since this OS is coded in C, how do they manage to write effectively unit tests in this language ?
- what are the “zones” in OS where unit testing is easier to write ? where is it harder ? where is it valuable ?
7
In general I would say that kernel code is not unit tested (I’m sure there are some exceptions). There are a few things that make kernel code difficult to unit test
- Kernel code generally interfaces with hardware.
- Kernel code does not link to the standard c library, it uses kernel specific headers etc.
You could decouple all of your functions that do not interface with the kernel API or hardware, but that has not been my experience of what actually happens.
I think most kernel code is tested using “integration tests” where command line apps are written to exercise the userspace interface to the kernel code.
Finally, C code itself can be unit tested. I write C code almost everyday and it gets unit tested.