[gdk-pixbuf] Enable coverage testing



commit 8d2aade60c486d7ac0e7ac9988448409d77eb75b
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Dec 20 22:14:00 2013 -0500

    Enable coverage testing
    
    Use --enable-coverage and make coverage to get it.

 Makefile.am  |   11 +++++++++++
 configure.ac |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 8b3550a..a726da5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,5 +34,16 @@ MAINTAINERCLEANFILES = \
        ltmain.sh \
        missing
 
+if WITH_COVERAGE
+.PHONY: coverage clear-coverage
+
+coverage:
+       $(AM_V_GEN) $(LCOV) --quiet --directory $(top_builddir) --capture --output-file 
$(top_builddir)/coverage.info --no-checksum --compat-libtool; \
+         $(GENHTML) --quiet --output-directory $(top_builddir)/coverage $(top_builddir)/coverage.info
+       @echo "file://$(abs_top_builddir)/coverage/index.html"
+
+clear-coverage:
+       $(AM_V_GEN) $(LCOV) --directory . --zerocounters
+endif
 
 -include $(top_srcdir)/git.mk
diff --git a/configure.ac b/configure.ac
index 5470084..be56c4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1027,6 +1027,44 @@ AC_SUBST(GDK_PIXBUF_LINK_FLAGS)
 
 GLIB_TESTS
 
+AC_MSG_CHECKING([whether to build with gcov testing])
+AC_ARG_ENABLE([coverage],
+               AS_HELP_STRING([--enable-coverage],
+                       [Whether to enable coverage testing ]),
+               [],
+               [enable_coverage=no])
+
+AC_MSG_RESULT([$enable_coverage])
+
+if test "$enable_coverage" = "yes"; then
+       if test "$GCC" != "yes"; then
+               AC_MSG_ERROR(Coverage testing requires GCC)
+       fi
+
+       AC_PATH_PROG(GCOV, gcov, no)
+       if test "$GCOV" = "no" ; then
+               AC_MSG_ERROR(gcov tool is not available)
+       fi
+
+       AC_PATH_PROG(LCOV, lcov, no)
+       if test "$LCOV" = "no" ; then
+               AC_MSG_ERROR(lcov tool is not installed)
+       fi
+
+       AC_PATH_PROG(GENHTML, genhtml, no)
+       if test "$GENHTML" = "no" ; then
+               AC_MSG_ERROR(lcov's genhtml tool is not installed)
+       fi
+
+       CFLAGS="$CFLAGS -O0 -g -fprofile-arcs -ftest-coverage"
+       LDFLAGS="$LDFLAGS -lgcov"
+fi
+
+AM_CONDITIONAL([WITH_COVERAGE], [test "$enable_coverage" = "yes"])
+AC_SUBST(LCOV)
+AC_SUBST(GCOV)
+AC_SUBST(GENHTML)
+
 ##################################################
 # Output commands
 ##################################################


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