Page MenuHomeFreeBSD

df: Import tests from NetBSD
AcceptedPublic

Authored by jlduran on Dec 1 2025, 3:59 PM.
Tags
None
Referenced Files
F141803071: D54016.diff
Sat, Jan 10, 3:42 PM
Unknown Object (File)
Sat, Jan 10, 5:52 AM
Unknown Object (File)
Sat, Jan 10, 4:52 AM
Unknown Object (File)
Tue, Dec 30, 1:17 PM
Unknown Object (File)
Sun, Dec 28, 2:11 PM
Unknown Object (File)
Thu, Dec 25, 11:47 PM
Unknown Object (File)
Thu, Dec 25, 2:52 AM
Unknown Object (File)
Sat, Dec 20, 5:40 PM
Subscribers

Details

Reviewers
ngie
Group Reviewers
tests
Summary

Adapt NetBSD's tests to run on FreeBSD, rather than directly using the
tests under contrib, as the differences in spacing are significant.

It uses a mocked getmntinfo(3) implementation to ensure consistent file
system enumeration during testing, generating an h_df binary that is
used for testing.

Test Plan
$ kyua test
t_df:hflag  ->  passed  [0.021s]
t_df:normal  ->  passed  [0.010s]

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69261
Build 66144: arc lint + arc unit

Event Timeline

I see some potential changes to df in GH #1906, let's start adding tests.

NetBSD has fixed the output of their tests to match POSIX behavior (The percentage value shall be expressed as a positive integer, with any fractional result causing it to be rounded to the next highest integer) (lib/59811).

It is now our turn to fix it. Commit the output as is, for better comparison.

jlduran edited the test plan for this revision. (Show Details)
  • Keep the same NetBSD file name, we'll branch off our tests on another file.
ngie added inline comments.
bin/df/tests/getmntinfo.c
58
  • style(9) bug.
  • clarity around order of operations.
90–91
121–122
This revision is now accepted and ready to land.Mon, Dec 29, 1:22 AM

Thank you!
I wanted as few diffs with NetBSD as possible, but using nitems() is a good suggestion; I'll probably submit it to GNATS.

Thank you!
I wanted as few diffs with NetBSD as possible, but using nitems() is a good suggestion; I'll probably submit it to GNATS.

Ah, ok! If it's code that comes from NetBSD, we should use __arraycount(..) instead of nitems(..). __arraycount(..) is defined in libnetbsd.

What's the point of copying the NetBSD tests if we end up having to change everything about them, and then end up adding our own test script anyway as you do in D54265?

In D54016#1243870, @des wrote:

What's the point of copying the NetBSD tests if we end up having to change everything about them, and then end up adding our own test script anyway as you do in D54265?

The spacing between the columns is different. Also, getmntinfo.c is somewhat different on FreeBSD.
I tried to #ifdef this test, but it soon became obvious we should branch out (it became unreadable).

In D54016#1243870, @des wrote:

What's the point of copying the NetBSD tests if we end up having to change everything about them, and then end up adding our own test script anyway as you do in D54265?

I tried to #ifdef this test, but it soon became obvious we should branch out (it became unreadable).

Yes. Just write your own.

In D54016#1243888, @des wrote:
In D54016#1243870, @des wrote:

What's the point of copying the NetBSD tests if we end up having to change everything about them, and then end up adding our own test script anyway as you do in D54265?

I tried to #ifdef this test, but it soon became obvious we should branch out (it became unreadable).

Yes. Just write your own.

My name will also be added to the license header upon commit. It is in my best interest to keep these tests aligned as much as possible with NetBSD.