Re:Ask HN: Why the Linux Kernel doesn't have unit tests?
by titzer on Friday November 25, 2022 @11:18AM
(#33743811)
There are some gray areas, sure. I usually find a way around making mocks, but maybe it's just the domains I am in. My biggest mistakes are mostly just writing tests that are too intertwined with internal interfaces. So they break all the time and need to be adjusted when refactoring. That's a drag.
Re:Ask HN: Why the Linux Kernel doesn't have unit tests?
by thayne on Friday November 25, 2022 @11:11PM
(#33749835)
I think the same is true of any sufficiently complex project. There are areas where unit tests are valuable, and areas where the costs outweigh the benefits. There isn't anything really special about a kernel in that regard (except for the specific things that aren't worth unit testing).
Re:Ask HN: Why the Linux Kernel doesn't have unit tests?
by closeparen on Saturday November 26, 2022 @03:47PM
(#33756561)
In a commercial setting, unit test coverage inevitably becomes a KPI that needs to be driven upwards regardless of whether rank and file engineers consider it worthwhile in particular cases.
Re:Ask HN: Why the Linux Kernel doesn't have unit tests?
by xg15 on Saturday November 26, 2022 @03:53AM
(#33751120)
> As an example, device drivers that are tied tightly to hardware. While it would sound nice to have an nvidia GPU fake/mock, in reality it is probably not possible to create one, keep it up to date, etc. The complexity would be enormous and might not show anything as you wouldn't know if it was a bug in the fake or driver.
Ok, but then again: How would you make sure your Nvidia driver is working correctly?
However, I think there are parts that probably should NOT be unit tested, because unit testing isn't free and slows down change by getting very close to internals. As an example, device drivers that are tied tightly to hardware. While it would sound nice to have an nvidia GPU fake/mock, in reality it is probably not possible to create one, keep it up to date, etc. The complexity would be enormous and might not show anything as you wouldn't know if it was a bug in the fake or driver.
As such, I retain my answer of: it depends what you are trying to accomplish. Different testing strategies for different types of code and domains.