[dconf/wip/reorg: 471/523] Add support for measuring testcase coverage



commit 8330ed133c521418af9695b833697f8f48b789ff
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jul 5 23:19:59 2012 -0400

    Add support for measuring testcase coverage
    
    You need to ./configure with --enable-gcov and then type 'make lcov'.
    
    HTML report goes into ./lcov-html/index.html

 .gitignore   |    4 ++++
 Makefile.am  |   21 +++++++++++++++++++++
 configure.ac |    9 +++++++++
 3 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index beccb04..6538832 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,10 @@ Makefile
 *.gir
 *.typelib
 
+# gcov
+*.gcda
+*.gcno
+
 # autofoo stuff here
 /m4/
 /aux/
diff --git a/Makefile.am b/Makefile.am
index a30c0de..6f243f7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,3 +9,24 @@ SUBDIRS += editor
 endif
 
 DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
+
+.PHONY: lcov lcov-clean
+# use recursive makes in order to ignore errors during check
+lcov:
+	-$(MAKE) $(AM_MAKEFLAGS) lcov-clean
+	-$(MAKE) $(AM_MAKEFLAGS) -k check
+	lcov --directory $(top_builddir) --capture --output-file dconf-lcov.info --test-name dconf --no-checksum --compat-libtool
+	LANG=C genhtml --prefix $(top_builddir) --output-directory lcov-html --legend --show-details dconf-lcov.info
+	@echo
+	@echo "     file://$(abs_top_builddir)/lcov-html/index.html"
+	@echo
+
+clean-am: lcov-clean gcno-clean
+
+gcno-clean:
+	-find -name '*.gcno' -exec rm -f '{}' ';'
+
+lcov-clean:
+	-lcov --directory $(top_builddir) -z
+	-find -name '*.gcda' -exec rm -f '{}' ';'
+	rm -rf lcov-html dconf-lcov.info
diff --git a/configure.ac b/configure.ac
index 2b41e78..25c32da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,6 +51,15 @@ AC_SUBST(dconfincludedir, ${includedir}/dconf)
 
 AC_PATH_PROG(gio_QUERYMODULES, gio-querymodules, no)
 
+AC_ARG_ENABLE(gcov,
+              AC_HELP_STRING([--enable-gcov],
+                             [enable generation of code coverage information]))
+
+if test "x$enable_gcov" == "xyes"; then
+  CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
+  LDFLAGS="$LDFLAGS -lgcov"
+fi
+
 AC_CONFIG_FILES([
   common/Makefile
   gvdb/Makefile



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