summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-09-28 05:45:37 -0700
committerDan Nicholson <dbn.lists@gmail.com>2012-09-28 05:45:37 -0700
commite68baa746395f4d5c7b8ab16093c044026b2d1fd (patch)
treedba5b9ffd03a2f44e837fdebc5c189ae9f4cd2e5 /configure.ac
parenta35c3fc95e00c6817be124ec335713edfbfe913d (diff)
downloadpkg-config-e68baa746395f4d5c7b8ab16093c044026b2d1fd.tar.gz
Add optional usage of gcov for test coverage
Use gcov to find how much code coverage our current testing gets. This can be enabled by passing --with-gcov to configure and running "make gcov". This is limited to gcc. Here's a run from the current code (for some reason, gcov insists on profiling gstring.h). /usr/bin/gcov pkg.h pkg.c parse.h parse.c main.c File 'pkg.c' Lines executed:73.16% of 611 pkg.c:creating 'pkg.c.gcov' File '/usr/include/glib-2.0/glib/gstring.h' Lines executed:100.00% of 6 /usr/include/glib-2.0/glib/gstring.h:creating 'gstring.h.gcov' File 'parse.c' Lines executed:79.67% of 492 parse.c:creating 'parse.c.gcov' File 'main.c' Lines executed:57.34% of 293 main.c:creating 'main.c.gcov'
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac21
1 files changed, 21 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index c6c24a2..3909055 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,6 +182,27 @@ fi
AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_CFLAGS)
+dnl
+dnl Optional gcov test coverage usage
+dnl
+AC_ARG_WITH([gcov],
+ [AS_HELP_STRING([--with-gcov], [gcov test coverage @<:@default=no@:>@])],
+ [],
+ [with_gcov=no])
+if test "x$with_gcov" = xyes; then
+ if test "$GCC" = no; then
+ AC_MSG_ERROR([gcov test coverage can only be used with GCC])
+ fi
+
+ AC_PATH_PROG([GCOV], [gcov], [AC_MSG_ERROR([could not find gcov program])])
+ GCOV_CFLAGS="-fprofile-arcs -ftest-coverage"
+
+ # Ensure there's no optimizing since last -O wins and CFLAGS is used
+ # at the end of COMPILE/LTCOMPILE.
+ CFLAGS="${CFLAGS+$CFLAGS }-O0"
+fi
+AC_SUBST([GCOV_CFLAGS])
+
AC_CONFIG_FILES([
Makefile
check/Makefile