Commit Graph

4 Commits

Author SHA1 Message Date
2a1051980b Improve snapshot handling and CLI workflows 2026-11-01 16:52:17 +01:00
c63530da34 Implement snapshot verification command 2026-11-01 16:31:51 +01:00
Fabio Scotto di Santolo
8c34ab4f4e Add a make valgrind target
Runs the existing suite with every fsnap invocation under memcheck,
rather than duplicating a list of commands in the Makefile: tests/run.sh
already funnels each call through fsnap(), so a command prefix is all it
takes. VALGRIND is empty for a plain `make test`.

-q keeps stderr clean, which matters because several tests compare it,
and --error-exitcode=99 turns a finding into a failing test instead of a
note nobody reads. The per-invocation timeout goes to 300s, since
memcheck costs an order of magnitude: the whole suite takes about 25
seconds against a fraction of a second without it.

Checked the same way as the suite itself. Dropping the free() of the
getline buffer in list keeps `make test` green at 91 passed while `make
valgrind` fails, which is the whole point of having it. Replacing the
calloc in RecordObjectNew with malloc is caught too, and named precisely:
free() on an uninitialised value at types.c:420. Baseline green either
side, and the missing-valgrind guard exits 2 with a clear message.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018KyCHPAxWzqa3vHKdXJkgx
2026-08-26 16:19:50 +02:00
Fabio Scotto di Santolo
aad607e5f0 Add a test suite and a make test target
91 black-box checks in tests/run.sh, driving the built binary because
that is the only interface the tool has. POSIX sh, no dependencies, no
framework; TAP-ish output and a non-zero exit when anything fails.

Covers the tree shapes SPEC.md section 22 asks for -- regular and empty
files, nested directories, symlinks, broken symlinks, symlinks to
directories, hard links, FIFOs, sockets, unusual filenames and permission
errors -- the parser cases from sections 14 and 15, the diff
classifications, argument handling, and the resource rules from sections
9 and 11. What the environment cannot provide is skipped, not failed.

Every bug fixed in this branch is pinned by a test: the 2^32 comparison
truncation, the symlink checksum, target-before-fingerprint ordering, the
mkstemp template unlink, errno surviving a cleanup failure, the empty
snapshot in diff, and create over each entry type that used to abort it.

Invocations run under timeout(1) where it exists. Without it a walker
regression makes create block on a FIFO forever, which hangs the suite
instead of failing it -- found by reintroducing exactly that bug.

Checked by mutation: seven deliberate regressions, one per fix, each
caught by the test written for it, with the baseline green either side.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018KyCHPAxWzqa3vHKdXJkgx
2026-08-26 16:13:27 +02:00