aboutsummaryrefslogtreecommitdiff
path: root/Makefile.am.coverage
diff options
context:
space:
mode:
authorAllan LeSage <allan.lesage@canonical.com>2013-11-21 19:14:21 +0000
committerTarmac <Unknown>2013-11-21 19:14:21 +0000
commit875ee4d733ce751fcd8d974a32c4bfdebbe501a3 (patch)
tree406500af69bd6555eb4e4dc63e3711bd341bb6b4 /Makefile.am.coverage
parentf90c7c21d0e82779356eaa8ae471703cda45d7cc (diff)
parentbf2aab363e93263b1615f1811524fb22b14bf34b (diff)
downloadayatana-indicator-keyboard-875ee4d733ce751fcd8d974a32c4bfdebbe501a3.tar.gz
ayatana-indicator-keyboard-875ee4d733ce751fcd8d974a32c4bfdebbe501a3.tar.bz2
ayatana-indicator-keyboard-875ee4d733ce751fcd8d974a32c4bfdebbe501a3.zip
Add gcov coverage tooling; use ./autogen.sh --enable-gcov and then make coverage-html to see a report of what's covered. You can read about the rationale in this old blog post: http://qualityhour.wordpress.com/2012/01/29/test-coverage-tutorial-for-cc-autotools-projects/ .
Approved by William Hua, PS Jenkins bot.
Diffstat (limited to 'Makefile.am.coverage')
-rw-r--r--Makefile.am.coverage48
1 files changed, 48 insertions, 0 deletions
diff --git a/Makefile.am.coverage b/Makefile.am.coverage
new file mode 100644
index 00000000..fb977474
--- /dev/null
+++ b/Makefile.am.coverage
@@ -0,0 +1,48 @@
+
+# Coverage targets
+
+.PHONY: clean-gcno clean-gcda \
+ coverage-html generate-coverage-html clean-coverage-html \
+ coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr
+
+clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr
+
+if HAVE_GCOV
+
+clean-gcno:
+ @echo Removing old coverage instrumentation
+ -find -name '*.gcno' -print | xargs -r rm
+
+clean-gcda:
+ @echo Removing old coverage results
+ -find -name '*.gcda' -print | xargs -r rm
+
+coverage-html: clean-gcda
+ -$(MAKE) $(AM_MAKEFLAGS) -k check
+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
+
+generate-coverage-html:
+ @echo Collecting coverage data
+ $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool
+ LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
+
+clean-coverage-html: clean-gcda
+ -$(LCOV) --directory $(top_builddir) -z
+ -rm -rf coverage.info coveragereport
+
+if HAVE_GCOVR
+
+coverage-gcovr: clean-gcda
+ -$(MAKE) $(AM_MAKEFLAGS) -k check
+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr
+
+generate-coverage-gcovr:
+ @echo Generating coverage GCOVR report
+ $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml
+
+clean-coverage-gcovr: clean-gcda
+ -rm -rf $(top_builddir)/coverage.xml
+
+endif # HAVE_GCOVR
+
+endif # HAVE_GCOV