News for hackers. Stuff that matters.
Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by fiedzia on Friday November 25, 2022 @09:59AM (#33742948)
> Do you really need tests for the read(2) syscall when Linux is running on a billion devices, and that syscall is called some 10^12 times per second globally?

Yes, you do, because otherwise you will find that some change or new hardware will break it.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by sph on Friday November 25, 2022 @10:08AM (#33743020)
If some hardware breaks it, the hardware must be seriously broken.

If a change breaks it, some one will probably have called read(2) a few times before that kernel is shipped to you. A change is filtered through multiple developer and the kernel has some kind of smoke and consistency tests it is subject to. Also there are people and companies that compile their kernel from the master branch and run software on it.

No one's gonna ship Linux with a broken read syscall. And if there were tests, one could still ship a broken read syscall anyway.

Tests do not guarantee the absence of bugs.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by Cyph0n on Friday November 25, 2022 @10:17AM (#33743102)
> Also there are people and companies that compile their kernel from the master branch and run software on it.

Genuinely curious: why would a company ever do this?

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by quesera on Friday November 25, 2022 @10:37AM (#33743322)
> why would a company ever do this?

Distro kernels are general purpose and include a lot of stuff you do not need.

A custom-configured kernel is much smaller and (consequently, theoretically) more secure.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by Cyph0n on Friday November 25, 2022 @11:19AM (#33743821)
Not sure I follow. A custom kernel doesn’t need to based on master.
Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by sph on Friday November 25, 2022 @10:25AM (#33743189)
I was thinking of Red Hat (for example), that pays kernel developers and regularly tests and backports features for its paying customers. That means having a finger of the pulse of the kernel tree, and trying changes to decide whether it might be worth to port them to their supported kernel branch (which lags behind master).
Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by Cyph0n on Friday November 25, 2022 @11:18AM (#33743810)
Ah, Red Hat is indeed a good example. Thanks for clarifying.
Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by carlhjerpe on Friday November 25, 2022 @11:00AM (#33743581)
If you have 100000 servers it's in your interest to test HEAD on 100 of them to be able to catch and bugs before they hit a release. That's how open-source should work!
Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by Cyph0n on Friday November 25, 2022 @11:23AM (#33743872)
Why not run 1-2 releases behind and test/qualify a later release?

A commenter below gave a good example of a company that would need to run a bleeding edge kernel (Red Hat). The vast majority of companies would never need to do that though.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by fiedzia on Friday November 25, 2022 @12:01PM (#33744373)
> Why not run 1-2 releases behind and test/qualify a later release?

This may work for most people, but not all. It's easier to get things fixed while developers still work on something, than weeks/months later. Also if you have not most-popular hardware/software configuration, testing done by others isn't necessarily sufficient for you.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by sph on Friday November 25, 2022 @12:01PM (#33744393)
Maybe your company needs that super duper new feature that's on master. Or you're Google scale and that 0.5% improvement in IO throughput would save you millions a year. You wouldn't want to wait until it hits the stable branch if possible.
Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by fiedzia on Friday November 25, 2022 @11:18AM (#33743805)
> If some hardware breaks it, the hardware must be seriously broken.

And it sometimes is.

> If a change breaks it, some one will probably have called read(2) a few times before that kernel is shipped to you.

I've seen to many kernel bugs on new hardware to believe this is enough. Maybe not in read(), but still in something that should work. Throwing testing on users may have been acceptable in the past, but not anymore.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by Veuxdo on Friday November 25, 2022 @10:14AM (#33743072)
If the read(2) implementation itself never changes, then unit tests of it shouldn't ever break, I think...