@@ -56,7 +56,7 @@ ALL_TESTS := $(SANITY_TESTS) $(P0_TESTS) $(P1_TESTS) $(P2_TESTS) $(P3_TESTS)
5656COMMON_OBJS := $(COMMON_DIR ) /ff_log_stub.o $(COMMON_DIR ) /rte_stub.o
5757
5858# Default goal
59- .PHONY : all test test_p0 test_p1 test_sanity check clean coverage coverage_clean help
59+ .PHONY : all test test_p0 test_p1 test_p2 test_p3 test_sanity check clean coverage coverage_clean help
6060all : $(ALL_TESTS )
6161
6262help :
6666 @echo " make test_sanity - run hello-world sanity test"
6767 @echo " make test_p0 - run P0 tests only"
6868 @echo " make test_p1 - run P1 tests only"
69+ @echo " make test_p2 - run P2 tests only"
70+ @echo " make test_p3 - run P3 tests only"
71+ @echo " make check - run all tests under valgrind memcheck (FU-S2-1)"
6972 @echo " make clean - clean build artifacts (uses rm_tmp_file.sh wrapper)"
7073 @echo " make coverage - build with gcov + run tests + emit lcov HTML report"
7174 @echo " make coverage_clean - remove gcov/.gcda/.gcno + coverage_report/"
@@ -105,8 +108,43 @@ test: all
105108 done
106109 @echo " ALL TESTS PASS ($( words $( ALL_TESTS) ) binaries)"
107110
108- check : test
109- @echo " TODO: integrate valgrind --tool=memcheck per test (FU-S2-1)"
111+ # ----- check (FU-S2-1: valgrind memcheck per binary) ---------------------
112+ # Runs every test binary under valgrind --tool=memcheck. Definite leaks
113+ # fail the build (--errors-for-leak-kinds=definite + --error-exitcode=99).
114+ # Long-lived F-Stack config-cache leaks (lib/ff_config.c) are filtered
115+ # via valgrind.supp; see that file for the FU-S2-2-CFG-UNLOAD follow-up.
116+ VALGRIND ?= valgrind
117+ VALGRIND_SUPP := valgrind.supp
118+ VALGRIND_OPTS := --tool=memcheck \
119+ --leak-check=full \
120+ --errors-for-leak-kinds=definite \
121+ --error-exitcode=99 \
122+ --suppressions=$(VALGRIND_SUPP ) \
123+ --quiet
124+
125+ check : all
126+ @if ! command -v $(VALGRIND ) > /dev/null 2>&1 ; then \
127+ echo " ERROR: $( VALGRIND) not installed; please 'dnf install -y valgrind'" ; \
128+ exit 1; \
129+ fi
130+ @pass=0; fail=0; failed=" " ; \
131+ for t in $( ALL_TESTS) ; do \
132+ printf " ==> valgrind %-30s ... " " $$ t" ; \
133+ if $( RUN_ENV) $( VALGRIND) $( VALGRIND_OPTS) ./$$ t > /dev/null 2> /tmp/vg_$$ t.$$$$ .log; then \
134+ echo " OK" ; pass=$$((pass+1 ) ); \
135+ /data/workspace/rm_tmp_file.sh /tmp/vg_$$ t.$$$$ .log > /dev/null 2>&1 ; \
136+ else \
137+ echo " FAIL (see /tmp/vg_$$ t.$$$$ .log)" ; \
138+ fail=$$((fail+1 ) ); failed=" $$ failed $$ t" ; \
139+ fi ; \
140+ done ; \
141+ echo " " ; \
142+ echo " === valgrind summary: $$ pass pass / $$ fail fail ($( words $( ALL_TESTS) ) total) ===" ; \
143+ if [ $$ fail -gt 0 ]; then \
144+ echo " Failed binaries:$$ failed" ; \
145+ exit 1; \
146+ fi
147+ @echo " ALL VALGRIND CHECKS PASS"
110148
111149# ----- lib/*.c → lib_objs/*.o (independent of lib/Makefile, NFR-U-6) -----
112150$(LIB_OBJS_DIR ) :
0 commit comments