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:
13
Makefile
13
Makefile
@@ -45,7 +45,7 @@ TESTS := tests/run.sh
|
||||
OBJECTS := $(SOURCES:%.c=$(BUILD_DIR)/%.o)
|
||||
DEPENDENCIES := $(OBJECTS:.o=.d)
|
||||
|
||||
.PHONY: all clean run test install uninstall
|
||||
.PHONY: all clean run test valgrind install uninstall
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
@@ -63,6 +63,17 @@ run: $(TARGET)
|
||||
test: $(TARGET)
|
||||
@FSNAP='$(CURDIR)/$(TARGET)' sh $(TESTS)
|
||||
|
||||
# The same suite with every invocation under memcheck. -q keeps stderr clean,
|
||||
# which matters because several tests compare it; a distinct exit code turns any
|
||||
# finding into a failed test rather than a note nobody reads.
|
||||
MEMCHECK := valgrind -q --error-exitcode=99 --leak-check=full \
|
||||
--errors-for-leak-kinds=all --track-origins=yes
|
||||
|
||||
valgrind: $(TARGET)
|
||||
@command -v valgrind >/dev/null 2>&1 || { \
|
||||
echo 'valgrind is not installed' >&2; exit 2; }
|
||||
@FSNAP='$(CURDIR)/$(TARGET)' VALGRIND='$(MEMCHECK)' sh $(TESTS)
|
||||
|
||||
install: $(TARGET)
|
||||
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -m 755 $(TARGET) $(DESTDIR)$(BINDIR)/$(NAME)
|
||||
|
||||
Reference in New Issue
Block a user