[cheese] Add code coverage reporting, using lcov
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Add code coverage reporting, using lcov
- Date: Sat, 24 Dec 2011 17:05:17 +0000 (UTC)
commit 8e9260e9674b9b75d750206e4317f96d10eef510
Author: David King <amigadave amigadave com>
Date: Sat Dec 24 17:53:36 2011 +0100
Add code coverage reporting, using lcov
Introduce new Makfile targets lcov and lcov-clean, to generate an HTML
report of libcheese test code coverage and clean up the generated files.
Check for lcov and genhtml in configure.ac.
.gitignore | 4 ++++
Makefile.am | 28 +++++++++++++++++++++++++++-
configure.ac | 22 ++++++++++++++++++++++
3 files changed, 53 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index cde7e86..d734900 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+*.gcda
+*.gcno
*.gmo
*.la
*.lo
@@ -13,6 +15,8 @@ Makefile
Makefile.in*
/autom4te.cache/
/build-aux/
+/cheese-lcov/
+/cheese-lcov.info
/data/*.desktop
/data/*.desktop.in
/data/cheese-gtk.pc
diff --git a/Makefile.am b/Makefile.am
index 9123537..34a2c4a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -432,6 +432,31 @@ test:
echo "Test run disabled due to the lack of GLib testing utilities"
endif
+# Code coverage reporting.
+if CHEESE_ENABLE_LCOV
+# Depend on full-report so that all the tests are run.
+lcov: full-report
+ $(AM_V_at)$(LCOV) --base-directory $(top_builddir) \
+ --directory $(top_builddir)/libcheese --capture \
+ --output-file cheese-lcov.info --test-name CHEESE \
+ --no-checksum --compat-libtool
+ $(AM_V_at)LANG=C $(LCOV_GENHTML) --prefix $(top_builddir) \
+ --output-directory cheese-lcov --title "Cheese code coverage" \
+ --legend --show-details cheese-lcov.info
+
+lcov-clean:
+ $(AM_V_at)$(LCOV) --directory $(top_builddir) -z
+ $(AM_V_at)rm -rf cheese-lcov.info cheese-lcov
+ $(AM_V_at)find -name '*.gcda' -exec rm -f {} +
+else # !CHEESE_ENABLE_LCOV
+lcov:
+ $(AM_V_at)echo "Code coverage reporting not available"
+
+lcov-clean:
+ $(AM_V_at)rm -rf cheese-lcov.info cheese-lcov
+ $(AM_V_at)find -name '*.gcda' -exec rm -f {} +
+endif
+
# gtk-doc
gtkdoc_builddir = $(top_builddir)/docs/reference
gtkdoc_distdir = $(top_distdir)/docs/reference
@@ -442,7 +467,7 @@ all-local: $(bin_PROGRAMS)
# run make test as part of make check.
check-local: test
cd $(gtkdoc_builddir) && $(MAKE) $(AM_MAKEFlAGS) check
-clean-local:
+clean-local: lcov-clean
cd $(gtkdoc_builddir) && $(MAKE) $(AM_MAKEFLAGS) clean
distclean-local:
cd $(gtkdoc_builddir) && $(MAKE) $(AM_MAKEFLAGS) distclean
@@ -538,3 +563,4 @@ git-changelog-hook:
fi
.PHONY: docs git-changelog-hook test test-report perf-report full-report
+.PHONY: lcov lcov-clean
diff --git a/configure.ac b/configure.ac
index 3b18c8b..7558fc3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,6 +155,28 @@ AS_IF([test "x$GTESTER" = "xnotfound" -o "x$GTESTER_REPORT" = "xnotfound"],
AC_SUBST([GTESTER_REPORT])])
AM_CONDITIONAL([CHEESE_ENABLE_TESTS], [test "x$CHEESE_ENABLE_TESTS" = "xtrue"])
+# Check for lcov.
+AC_ARG_ENABLE([lcov],
+ [AS_HELP_STRING([--disable-lcov], [Disable lcov code coverage testing])])
+
+AS_IF([test "x$enable_lcov" != "xno"],
+ [AC_PATH_PROG([LCOV], [lcov], [notfound])
+ AC_PATH_PROG([LCOV_GENHTML], [genhtml], [notfound])
+ AS_IF([test "x$LCOV" = "xnotfound" -o "x$LCOV_GENHTML" = "xnotfound"],
+ [have_lcov=no],
+ [have_lcov=yes])],
+ [have_lcov=no])
+
+AS_IF([test "x$have_lcov" = "xyes"],
+ [AC_SUBST([LCOV])
+ AC_SUBST([LCOV_GENHTML])
+ CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
+ LDFLAGS="$LDFLAGS -lgcov"],
+ [AS_IF([test "x$enable_lcov" = "xyes"],
+ [AC_MSG_ERROR([lcov code coverage reporting requested but not found])])])
+
+AM_CONDITIONAL([CHEESE_ENABLE_LCOV], [test "x$have_lcov" = "xyes"])
+
AC_MSG_CHECKING([for glib-mkenums script])
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
AS_IF([test "x$GLIB_MKENUMS" = "x"],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]