Re: [PATCH v2 2/7] Makefile: Include subdirectories in "make cover" reports

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ævar Arnfjörð Bjarmason wrote:

> 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.

All good things.  It might be good to add a GCOVFLAGS that can be
added to the "make" command line, then.

> +++ b/Makefile
> @@ -2280,8 +2280,11 @@ 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))
>  COVERAGE_CFLAGS = $(CFLAGS) -O0 -ftest-coverage -fprofile-arcs

What about coverage-untested-functions?

[...]
> @@ -2292,7 +2295,9 @@ coverage-build: coverage-clean
>  		-j1 test
>  
>  coverage-report:
> -	gcov -b *.c
> +	for dir in $(object_dirs); do \
> +		gcov --preserve-paths --branch-probabilities --all-blocks --object-directory=$$dir $$dir*.c; \
> +	done

This will not error out if "for" fails; maybe it would make sense to use
set -e or exit.

More importantly, it spews quite a lot of output:

| for dir in ./ block-sha1/ builtin/ compat/ xdiff/; do \
|                 gcov --preserve-paths --branch-probabilities --all-blocks --object-directory=$dir $dir*.c || exit; \
|         done
| ./abspath.gcno:version '405p', prefer '404*'
| ./abspath.gcda:version '405p', prefer version '404*'
| ./advice.gcno:version '405p', prefer '404*'
[...]
| ./ctype.gcno:cannot open graph file
[...]
| File 'wt-status.c'
| Lines executed:36.26% of 535
| Branches executed:39.78% of 279
| Taken at least once:20.43% of 279
| No calls
| wt-status.c:creating 'wt-status.c.gcov'
|
| File 'write_or_die.c'
[...]
| block-sha1/sha1.c:creating 'block-sha1#sha1.c.gcov'
|
| builtin/add.gcno:version '405p', prefer '404*'
[...]
| compat/basename.gcno:cannot open graph file
| compat/cygwin.gcno:cannot open graph file
[...]

Can gcov be convinced to be a little quieter (i.e., only useful warnings)?
(I don’t know; just asking.)

Here are the changes I squashed in for testing; please feel free to
take or leave what you like.

diff --git i/Makefile w/Makefile
index a95d260..b791ad5 100644
--- i/Makefile
+++ w/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
@@ -2285,9 +2286,11 @@ coverage-clean:
 	$(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
@@ -2295,9 +2298,9 @@ coverage-build: coverage-clean
 		-j1 test
 
 coverage-report:
-	for dir in $(object_dirs); do \
-		gcov --preserve-paths --branch-probabilities --all-blocks --object-directory=$$dir $$dir*.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
-- 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]