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],
12
AS_HELP_STRING([--enable-gcov],
13
[enable coverage testing with gcov]),
14
[use_gcov=$enableval], [use_gcov=no])
16
if test "x$use_gcov" = "xyes"; then
18
if test "$GCC" != "yes"; then
19
AC_MSG_ERROR([GCC is required for --enable-gcov])
22
# Check if ccache is being used
23
AC_CHECK_PROG(SHTOOL, shtool, shtool)
24
case `$SHTOOL path $CC` in
25
*ccache*[)] gcc_ccache=yes;;
29
if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
30
AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
33
lcov_version_list="1.6 1.7 1.8 1.9"
34
AC_CHECK_PROG(LCOV, lcov, lcov)
35
AC_CHECK_PROG(GENHTML, genhtml, genhtml)
38
AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
39
glib_cv_lcov_version=invalid
40
lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
41
for lcov_check_version in $lcov_version_list; do
42
if test "$lcov_version" = "$lcov_check_version"; then
43
glib_cv_lcov_version="$lcov_check_version (ok)"
48
lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
49
AC_MSG_ERROR([$lcov_msg])
52
case $glib_cv_lcov_version in
54
lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
55
AC_MSG_ERROR([$lcov_msg])
60
if test -z "$GENHTML"; then
61
AC_MSG_ERROR([Could not find genhtml from the lcov package])
67
# Remove all optimization flags from CFLAGS
69
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
72
# Add the special gcc flags
73
COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
74
COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
75
COVERAGE_LDFLAGS="-lgcov"
77
# Check availability of gcovr
78
AC_CHECK_PROG(GCOVR, gcovr, gcovr)
79
if test -z "$GCOVR"; then