From: Jonathan Nieder <jrnieder@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Thomas Rast <trast@student.ethz.ch>
Subject: Re: [PATCH v2 2/7] Makefile: Include subdirectories in "make cover" reports
Date: Sun, 25 Jul 2010 12:02:42 -0500 [thread overview]
Message-ID: <20100725170242.GB25658@burratino> (raw)
In-Reply-To: <1280068861-17701-3-git-send-email-avarab@gmail.com>
Æ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
--
next prev parent reply other threads:[~2010-07-25 17:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-25 14:40 [PATCH v2 0/7] Detailed test coverage reports for Git Ævar Arnfjörð Bjarmason
2010-07-25 14:40 ` [PATCH v2 1/7] gitignore: Ignore files generated by "make coverage" Ævar Arnfjörð Bjarmason
2010-07-25 16:37 ` Jonathan Nieder
2010-07-25 14:40 ` [PATCH v2 2/7] Makefile: Include subdirectories in "make cover" reports Ævar Arnfjörð Bjarmason
2010-07-25 17:02 ` Jonathan Nieder [this message]
2010-07-25 14:40 ` [PATCH v2 3/7] Makefile: Split out the untested functions target Ævar Arnfjörð Bjarmason
2010-07-25 14:40 ` [PATCH v2 4/7] Makefile: Add coverage-report-cover-db target Ævar Arnfjörð Bjarmason
2010-07-25 17:13 ` Jonathan Nieder
2010-07-25 14:40 ` [PATCH v2 5/7] Makefile: Add coverage-report-cover-db-html target Ævar Arnfjörð Bjarmason
2010-07-25 17:17 ` Jonathan Nieder
2010-07-25 14:41 ` [PATCH v2 6/7] t/README: A new section about test coverage Ævar Arnfjörð Bjarmason
2010-07-25 14:41 ` [PATCH v2 7/7] t/README: Add a note about the dangers of coverage chasing Ævar Arnfjörð Bjarmason
2010-07-25 16:05 ` Jonathan Nieder
2010-07-25 19:27 ` Ævar Arnfjörð Bjarmason
2010-07-25 17:20 ` [PATCH v2 0/7] Detailed test coverage reports for Git Jonathan Nieder
2010-07-25 17:46 ` Ævar Arnfjörð Bjarmason
2010-07-25 17:48 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100725170242.GB25658@burratino \
--to=jrnieder@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=trast@student.ethz.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.