mirror of
https://github.com/fscotto/fsnap.git
synced 2026-11-26 03:09:51 +00:00
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
This commit is contained in:
15
tests/run.sh
15
tests/run.sh
@@ -23,19 +23,28 @@ if [ ! -x "$FSNAP" ]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Set by `make valgrind` to a memcheck command line. Running the whole suite
|
||||
# under a checker is then just a matter of prefixing every invocation, which is
|
||||
# what fsnap() below is for. It stays empty for a plain `make test`.
|
||||
VALGRIND=${VALGRIND:-}
|
||||
|
||||
# A bug in the walker can make create block forever rather than fail -- opening
|
||||
# a FIFO waits for a writer that never comes. Cap every invocation so that turns
|
||||
# into a failing test instead of a hung suite. timeout(1) is not in POSIX, so
|
||||
# fall back to running unguarded where it is missing.
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
TIMEOUT="timeout 30"
|
||||
if [ -n "$VALGRIND" ]; then
|
||||
TIMEOUT="timeout 300" # memcheck costs an order of magnitude
|
||||
else
|
||||
TIMEOUT="timeout 30"
|
||||
fi
|
||||
else
|
||||
TIMEOUT=""
|
||||
fi
|
||||
|
||||
fsnap() {
|
||||
# shellcheck disable=SC2086 # deliberate split: TIMEOUT is a command prefix
|
||||
$TIMEOUT "$FSNAP" "$@"
|
||||
# shellcheck disable=SC2086 # deliberate split: both are command prefixes
|
||||
$TIMEOUT $VALGRIND "$FSNAP" "$@"
|
||||
}
|
||||
|
||||
testno=0
|
||||
|
||||
Reference in New Issue
Block a user