@matheusbsbs / matheus-bagliano / commits / bc548efe00
Fork 0

Makefile: Include subdirectories in "make cover" reports

We generate profiling files in all the $(OBJECTS) dirs. Aggregate results from there, and add them to the corresponding clean target. Also expand the gcov arguments. Generate reports for things like "x() || y()" using --all-blocks, and add --preserve-paths since we're profiling in subdirectories now. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jul 25, 2010 at 19:52 UTC bc548efe0037839e1a4a611e5f0f24b33fc39dc5
1 file changed +11 -3
Makefile
+11 -3
@@ -1485,6 +1485,7 @@ ifndef V
1485 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
1486 QUIET_GEN = @echo ' ' GEN $@;
1487 QUIET_LNCP = @echo ' ' LN/CP $@;
1488 + QUIET_GCOV = @echo ' ' GCOV $@;
1489 QUIET_SUBDIR0 = +@subdir=
1490 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
1491 $(MAKE) $(PRINT_DIR) -C $$subdir
@@ -2291,11 +2292,16 @@ coverage:
2292 $(MAKE) coverage-build
2293 $(MAKE) coverage-report
2294
2295 +object_dirs := $(sort $(dir $(OBJECTS)))
2296 coverage-clean:
2295 - rm -f *.gcda *.gcno
2297 + $(RM) $(addsuffix *.gcov,$(object_dirs))
2298 + $(RM) $(addsuffix *.gcda,$(object_dirs))
2299 + $(RM) $(addsuffix *.gcno,$(object_dirs))
2300 + $(RM) coverage-untested-functions
2301
2302 COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs
2303 COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov
2304 +GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks
2305
2306 coverage-build: coverage-clean
2307 $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all
@@ -2303,7 +2309,9 @@ coverage-build: coverage-clean
2309 -j1 test
2310
2311 coverage-report:
2306 - gcov -b *.c
2312 + $(QUIET_GCOV)for dir in $(object_dirs); do \
2313 + gcov $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \
2314 + done
2315 grep '^function.*called 0 ' *.c.gcov \
2316 | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \
2309 - | tee coverage-untested-functions
2317 + > coverage-untested-functions