From bc548efe0037839e1a4a611e5f0f24b33fc39dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 25 Jul 2010 19:52:40 +0000 Subject: Makefile: Include subdirectories in "make cover" reports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 1f11618cfd..e1e150df9c 100644 --- a/Makefile +++ b/Makefile @@ -1485,6 +1485,7 @@ ifndef V QUIET_BUILT_IN = @echo ' ' BUILTIN $@; QUIET_GEN = @echo ' ' GEN $@; QUIET_LNCP = @echo ' ' LN/CP $@; + QUIET_GCOV = @echo ' ' GCOV $@; QUIET_SUBDIR0 = +@subdir= QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ $(MAKE) $(PRINT_DIR) -C $$subdir @@ -2291,11 +2292,16 @@ coverage: $(MAKE) coverage-build $(MAKE) coverage-report +object_dirs := $(sort $(dir $(OBJECTS))) coverage-clean: - rm -f *.gcda *.gcno + $(RM) $(addsuffix *.gcov,$(object_dirs)) + $(RM) $(addsuffix *.gcda,$(object_dirs)) + $(RM) $(addsuffix *.gcno,$(object_dirs)) + $(RM) coverage-untested-functions COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov +GCOVFLAGS = --preserve-paths --branch-probabilities --all-blocks coverage-build: coverage-clean $(MAKE) CFLAGS="$(COVERAGE_CFLAGS)" LDFLAGS="$(COVERAGE_LDFLAGS)" all @@ -2303,7 +2309,9 @@ coverage-build: coverage-clean -j1 test coverage-report: - gcov -b *.c + $(QUIET_GCOV)for dir in $(object_dirs); do \ + gcov $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \ + done grep '^function.*called 0 ' *.c.gcov \ | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \ - | tee coverage-untested-functions + > coverage-untested-functions -- cgit v1.2.1 From b5eed98104853dfed63e5c9f2a6214df74f7b0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 25 Jul 2010 19:52:41 +0000 Subject: Makefile: Split out the untested functions target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the coverage-report target so that it doesn't generate the coverage-untested-functions file by default. I'm adding more targets for doing various things with the gcov files, and they shouldn't all run by default. Signed-off-by: Ævar Arnfjörð Bjarmason Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e1e150df9c..11f1df2787 100644 --- a/Makefile +++ b/Makefile @@ -2312,6 +2312,8 @@ coverage-report: $(QUIET_GCOV)for dir in $(object_dirs); do \ gcov $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \ done + +coverage-untested-functions: coverage-report grep '^function.*called 0 ' *.c.gcov \ | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \ > coverage-untested-functions -- cgit v1.2.1 From 7432bd5fbde117620e3b47d28e05827a334f42bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 25 Jul 2010 19:52:42 +0000 Subject: Makefile: Add cover_db target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a target to convert the *.gcov files to a Devel::Cover database. That database can subsequently be formatted by the cover(1) tool which is included with Devel::Cover. Signed-off-by: Ævar Arnfjörð Bjarmason Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 11f1df2787..0de4c6ed5e 100644 --- a/Makefile +++ b/Makefile @@ -2298,6 +2298,7 @@ coverage-clean: $(RM) $(addsuffix *.gcda,$(object_dirs)) $(RM) $(addsuffix *.gcno,$(object_dirs)) $(RM) coverage-untested-functions + $(RM) -r cover_db/ COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov @@ -2317,3 +2318,6 @@ coverage-untested-functions: coverage-report grep '^function.*called 0 ' *.c.gcov \ | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \ > coverage-untested-functions + +cover_db: coverage-report + gcov2perl -db cover_db *.gcov -- cgit v1.2.1 From df07acfe0bf000e0852c31e65d915faf3d1b43f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 25 Jul 2010 19:52:43 +0000 Subject: Makefile: Add cover_db_html target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a target to generate a detailed HTML report for the entire Git codebase using Devel::Cover's cover(1) tool. Output it in cover_db_html instead of the default cover_db, so that it isn't mixed up with our raw report files. The target depends on the coverage-report-cover-db target, it may be run redundantly if it was previously run. But the HTML output won't be affected by running gcov2perl twice, so I didn't try to avoid that small redundancy. Signed-off-by: Ævar Arnfjörð Bjarmason Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0de4c6ed5e..c83fc29993 100644 --- a/Makefile +++ b/Makefile @@ -2299,6 +2299,7 @@ coverage-clean: $(RM) $(addsuffix *.gcno,$(object_dirs)) $(RM) coverage-untested-functions $(RM) -r cover_db/ + $(RM) -r cover_db_html/ COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs COVERAGE_LDFLAGS = $(CFLAGS) -O0 -lgcov @@ -2321,3 +2322,6 @@ coverage-untested-functions: coverage-report cover_db: coverage-report gcov2perl -db cover_db *.gcov + +cover_db_html: cover_db + cover -report html -outputdir cover_db_html cover_db -- cgit v1.2.1 From e146d1772b57f595cd7c6537045eedbb82b98e37 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Mon, 26 Jul 2010 09:43:41 +0200 Subject: Makefile: make gcov invocation configurable If you customize CC to use a different version of gcc, most likely you also need to use a different version of gcov. Make it configurable. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c83fc29993..194c26fc5e 100644 --- a/Makefile +++ b/Makefile @@ -308,6 +308,7 @@ TCL_PATH = tclsh TCLTK_PATH = wish PTHREAD_LIBS = -lpthread PTHREAD_CFLAGS = +GCOV = gcov export TCL_PATH TCLTK_PATH @@ -2312,7 +2313,7 @@ coverage-build: coverage-clean coverage-report: $(QUIET_GCOV)for dir in $(object_dirs); do \ - gcov $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \ + $(GCOV) $(GCOVFLAGS) --object-directory=$$dir $$dir*.c || exit; \ done coverage-untested-functions: coverage-report -- cgit v1.2.1