1
# Checks for existence of coverage tools:
7
# Sets ac_cv_check_gcov to yes if tooling is present
8
# and reports the executables to the variables LCOV, GCOVR and GENHTML.
9
AC_DEFUN([AC_TDD_GCOV],
10
[AC_CACHE_CHECK([whether code coverage tools are available], ac_cv_check_gcov,
13
AS_HELP_STRING([--enable-gcov],
14
[enable coverage testing with gcov]),
15
[use_gcov=$enableval], [use_gcov=no])
17
if test "x$use_gcov" = "xyes"; then
19
if test "$GCC" != "yes"; then
20
AC_MSG_ERROR([GCC is required for --enable-gcov])
23
# Check if ccache is being used
24
AC_CHECK_PROG(SHTOOL, shtool, shtool)
25
case `$SHTOOL path $CC` in
26
*ccache*[)] gcc_ccache=yes;;
30
if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
31
AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
34
lcov_version_list="1.6 1.7 1.8 1.9"
35
AC_CHECK_PROG(LCOV, lcov, lcov)
36
AC_CHECK_PROG(GENHTML, genhtml, genhtml)
37
AC_CHECK_PROG(GCOVR, gcovr, gcovr)
40
AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
41
glib_cv_lcov_version=invalid
42
lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
43
for lcov_check_version in $lcov_version_list; do
44
if test "$lcov_version" = "$lcov_check_version"; then
45
glib_cv_lcov_version="$lcov_check_version (ok)"
50
lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
51
AC_MSG_ERROR([$lcov_msg])
54
case $glib_cv_lcov_version in
56
lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
57
AC_MSG_ERROR([$lcov_msg])
62
if test -z "$GENHTML"; then
63
AC_MSG_ERROR([Could not find genhtml from the lcov package])
66
if test -z "$GCOVR"; then
67
AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr])
71
# Remove all optimization flags from CFLAGS
73
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
76
# Add the special gcc flags
77
COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
78
COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
79
COVERAGE_LDFLAGS="-lgcov"