News for hackers. Stuff that matters.
Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by ilyt on Friday November 25, 2022 @09:42AM (#33742781)
SQLite doesn't have hardware drivers (that IIRC are still majority of kernel bugs) that need actual hardware to test (as hardware mocks are at best mildly useful, coz real hardware can be... weird)

And unit testing is relatively useless, what would be useful are end to end tests that start with userspace API but that's much harder task, altho hopefully those tests wouldn't need to be changed that often.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by exDM69 on Friday November 25, 2022 @10:13AM (#33743056)
I work as a software developer in a hardware company. We have A LOT of tests.

But testing costs a lot more when there is hardware present. It's a whole new dimension in your testing matrix. You can't run on cloud provider CI. Hardware has failures, someone needs to be there to reboot the systems and swap out broken ones (and thing break when they run hot 24/7). And you need some way to test whether the hardware did what it is supposed to do.

Although some kernel driver developers have testing clusters with real hardware (like GPU drivers devs), there is no effin way Linux could be effectively tested without someone paying a lot of money to set up real hardware and people to keep it running.

Of course the hardware can be simulated but simulation and emulation are slow (and potentially expensive). At work we run tests on simulation for next gen hardware which doesn't exist yet. It is about 100,000x slower than the real deal, so it's obviously not a solution that scales up.

Testing purely software products without a hardware dimension is so much simpler and cheaper.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by q-big on Friday November 25, 2022 @10:33AM (#33743274)
> Although some kernel driver developers have testing clusters with real hardware (like GPU drivers devs), there is no effin way Linux could be effectively tested without someone paying a lot of money to set up real hardware and people to keep it running.

Just crowdsource this testing: I am sure that there exist some people who own the piece of hardware and are willing to run a test script, say, every

* night

* week

* new testing version of the kernel

(depending on your level of passion for the hardware and/or Linux). I do believe that there do exist a lot of people who would join such a crowdsourcing effort if the necessary infrastructure existed (i.e. it is very easy to run and submit the results).

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by exDM69 on Friday November 25, 2022 @10:53AM (#33743507)
I think you are vastly overestimating the willingness and capability of volunteers and underestimating the effort needed to coordinate such an effort.

And having any kind of manual intervention required will almost certainly reduce the reliability of the testing.

This is further complicated by the need to reboot with a different kernel image. Qemu and virtual machines can't do all kinds of hw testing needed.

And in fact, the kernel is already tested like this. Just very irregularly and sporadically. The end users will do the field testing and it is surprisingly effective in finding bugs.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by q-big on Friday November 25, 2022 @11:56AM (#33744313)
> I think you are vastly overestimating the willingness and capability of volunteers and underestimating the effort needed to coordinate such an effort.

> And having any kind of manual intervention required will almost certainly reduce the reliability of the testing.

Perhaps I am underestimating the necessary effort, but the willingness and capability problem can in my opinion be solved by sufficiently streamlining and documenting the processes of running the test procedure.

If the testing procedure cannot be successfully run by a "somewhat experienced Linux nerd", this should be considered a usability bug of the testing procedure (and thus be fixed).

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by carlhjerpe on Friday November 25, 2022 @10:54AM (#33743514)
The NixOS community would be perfect for this, since "nothing" (i wouldn't wanna do experimental filesystems) can break my system, I just atomicly roll back to my previous generation and report it broken :)
Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by hinkley on Friday November 25, 2022 @01:37PM (#33745405)
I thought they already had clusters like this. Maybe I’m thinking of FreeBSD?

Dogfooding of builds is also testing, just a different kind.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by hinkley on Friday November 25, 2022 @01:36PM (#33745392)
I think people have forgotten or indeed never learned in the first place that testing terminology borrows from physical device testing culture. A “fixture” for instance is a mock environment that you place a piece of hardware into to verify it.

Hardware testing takes up a pretty sizable portion of the development cycle. Why do we think we are special?

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by wstuartcl on Saturday November 26, 2022 @12:45PM (#33754824)
kind of this -- I can't imagine any hardware company moving forward without fixture test flows of all sorts and a lot of effort put into them. It really seems like an area where software tries to stand on the edge of "art" forgetting that there is a science and craft needed when teams revolt against testing.
Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by mastax on Friday November 25, 2022 @10:08AM (#33743013)
A project as large and well funded as the Linux kernel could have a hardware test farm at least with reasonable coverage of popular hardware. "But Linux isn't that well funded!" Sure, but it's orders of magnitude better funded than Embassy[0], which runs tests on real hardware automatically before every merge.

There's also the Linux testing project, which is technically third party. It's not clear to me how extensive it is but for a project as important as Linux I think it has to be graded as "needs improvement."

[0] https://github.com/embassy-rs/embassy

[1] https://linux-test-project.github.io/

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by jve on Friday November 25, 2022 @10:15AM (#33743084)
You can buy TH3 Testing Support for SQLite. Sole item on pricing page (https://www.sqlite.org/prosupport.html) that has "call" as a price. From their page: "The TH3 test harness is an aviation-grade test suite for SQLite. SQLite developers can run TH3 on specialized hardware and/or using specialized compile-time options, according to customer specification, either remotely or on customer premises. Pricing for this services is on a case-by-case basis depending on requirements."

SQLite Test Harness #3 (hereafter "TH3") is one of three test harnesses used for testing SQLite. TH3 meets the following objectives:

- TH3 is able to run on embedded platforms that lack the support infrastructure of workstations.

- TH3 tests SQLite in an as-deployed configuration using only published and documented interfaces. In other words, TH3 tests the compiled object code, not the source code, thus verifying that no problems were introduced by compiler bugs. "Test what you fly and fly what you test."

- TH3 checks SQLite's response to out-of-memory errors, disk I/O errors, and power loss during transaction commit.

- TH3 exercises SQLite in a variety of run-time configurations (UTF8 vs UTF16, different pages sizes, varying journal modes, etc.)

- TH3 achieves 100% branch test coverage (and 100% MC/DC) over the SQLite core. (Test coverage of extensions such as FTS and RTREE is less than 100%).

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by JonChesterfield on Friday November 25, 2022 @11:00AM (#33743589)
> tests the compiled object code, not the source code

That's not something you see called out very often. Correct code fed to a broken compiler can definitely give you a broken binary. Likewise a correct binary will pass on a correct simulator and may fail on broken hardware.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by hinkley on Friday November 25, 2022 @01:41PM (#33745447)
I would note here that SQLite gets reasonably close to the Unix Philosophy. It’s not really a feature factory sort of application. That does make it quite a bit easier to write good tests. Applications that don’t know what they are or what they do are difficult to pin down.

I take that as an argument not for or against tests but against making it easy for management to turn your project into a feature factory.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by silvestrov on Friday November 25, 2022 @10:00AM (#33742959)
In other words: unit testing requires that your code is a unit.

i.e. does not depend on external timing or fickle hardware.

Very, very difficult to unit test someting that runs using hardware interupts.

Re:Ask HN: Why the Linux Kernel doesn't have unit tests? by thayne on Saturday November 26, 2022 @12:03AM (#33750168)
> real hardware can be... weird

That weirdness is precisely the sort of thing you want automated tests for.