Page MenuHomeFreeBSD

chroot: add some basic tests
Needs RevisionPublic

Authored by kevans on Aug 15 2025, 5:06 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 9, 5:31 AM
Unknown Object (File)
Mon, Sep 29, 6:52 PM
Unknown Object (File)
Sun, Sep 28, 11:43 PM
Unknown Object (File)
Sat, Sep 27, 9:19 AM
Unknown Object (File)
Wed, Sep 24, 2:45 PM
Unknown Object (File)
Sun, Sep 21, 3:15 PM
Unknown Object (File)
Wed, Sep 17, 4:55 AM
Unknown Object (File)
Wed, Sep 17, 3:14 AM
Subscribers

Details

Reviewers
emaste
ngie
Group Reviewers
tests
Summary

This tests that the -u, -g, -G, and -n options all work pretty much as
described. For -u we ensure that the group isn't touched, but this
might need re-worked in the future if we start taking the user's groups
with us.

Diff Detail

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

Event Timeline

ngie added inline comments.
usr.sbin/chroot/tests/chroot_test.sh
61

I'm guessing that the assumption is that /COPYRIGHT exists on the running system? It seems like it would be a good idea to create a known file in rootdir then test for it instead.

usr.sbin/chroot/tests/chroot_test.sh
61

We're looking for something that's not in rootdir, presumably to make sure that the chroot worked. We could perhaps atf_skip if /COPYRIGHT doesn't exist, or check that only the expected files exist or if that's too awkward just that the right number of files exist e.g. find / | wc -l?

usr.sbin/chroot/tests/chroot_test.sh
61

I think a positive test for /.chroot_file would probably be fine here. I was somewhat thinking of failures modes and had initially landed on making sure that something known to exist in the system root doesn't exist in the chroot, but some failure mode where the new root ends up being a mix of chroot-path files and system-root files would be very weird.

ngie requested changes to this revision.Aug 27 2025, 1:31 AM

atf_set "require.config" "allow_sysctl_side_effects" should be tested as well in the testcase headers for the tests that modify the systemwide sysctls.

This revision now requires changes to proceed.Aug 27 2025, 1:31 AM