Document the new Catch2 test suite

README.md: new "Testing" section -- the 4 category/tag-expression table,
what meson test covers vs. what stays manual, and tests/setup-tests.py.

CLAUDE.md: rewrote the self_test.{h,cpp} entry to describe its new role
(pure Catch2 Session::run() plumbing, ENABLE_TESTS-guarded) instead of the
hand-rolled tests it used to contain directly, and added a full
per-file breakdown of the new tests/unit, tests/integration, and
tests/support infrastructure -- including the real bugs found building it
(the two parse_args()/getopt_long state-reset bugs, the ScratchXdgDirs
mixed-iterator UB, the Catch2-inherited-SIGTERM-handler artifact, the
missing /sys mount and spdlog-writes-to-stdout findings), all in the same
narrative depth this file already uses throughout. Also updated the
"Build & test commands" flag list and meson test description.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
This commit is contained in:
2026-09-04 09:58:35 +00:00
parent 865862762d
commit b602de8e7b
2 changed files with 184 additions and 60 deletions
+33
View File
@@ -49,6 +49,39 @@ meson test -C buildDir
This also builds `buildDir/slocker-lite-priv-drop`, a small statically-linked helper
that `-r --user`/`--group` needs at runtime (see "How it works").
## Testing
`meson test -C buildDir` above runs three checks: the original fixture mount/unmount
smoke test, plus two of the four test categories `-t/--test` provides (see below) --
`meson test` only ever runs what's safe unprivileged with no network setup; the other
two categories are for a developer to run by hand on a real machine.
`-t`/`--test` runs this project's own built-in [Catch2](https://github.com/catchorg/Catch2)
test suite directly: `slocker-lite -t [-- <catch-command-line-options>]`. A bare `-t`
runs everything Catch2 finds; select a category with a tag expression (note the `--`
before it, needed since Catch2's own `-r/--reporter` and `-c/--section` would otherwise
collide with slocker-lite's own `-r/--run` and `-c/--cleanup`):
| Category | What it needs | Invocation |
|---|---|---|
| 1. Unit | Nothing | `slocker-lite -t -- "[unit]"` |
| 2. Integration | Nothing (no network, no root) | `slocker-lite -t -- "[integration]~[net]"` |
| 3. Integration, networked | A real image (see below), no root | `slocker-lite -t -- "[integration][net]~[root]"` |
| 4. Integration, root | Root | `slocker-lite -t -- "[integration][root]"` |
Append `~[slow]` to any of these to skip notably slow cases. A `[root]`-tagged test
`SKIP()`s cleanly (not a failure) when not actually run as root, and a
`[net]`-tagged one does the same when it needs a real container image it can't find
(see next) -- so a bare `-t` degrades gracefully rather than failing outright on a
plain rootless dev machine with no fixture set up.
Categories 3 and 4 need a real, runnable OCI image (something with an actual
`/bin/sh`, unlike the minimal single-file fixture the plain `meson test` smoke test
uses) at `images/busybox.tar`. Run `tests/setup-tests.py` to fetch one automatically
(via `skopeo`, `podman`, or `docker`, whichever is available -- does nothing if
`images/busybox.tar` already exists, e.g. your own build); or just drop your own
busybox-like image there directly.
## Usage
```