~ps-jenkins/indicator-datetime/utopic-proposed

« back to all changes in this revision

Viewing changes to m4/gcov.m4

  • Committer: Allan LeSage
  • Date: 2011-12-07 00:43:35 UTC
  • mto: This revision was merged to the branch mainline in revision 152.
  • Revision ID: allanlesage@gmail.com-20111207004335-cituc6bfe0syhpfa
Added coverage reporting via gcov config and targets.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Checks for existence of coverage tools:
 
2
#  * gcov
 
3
#  * lcov
 
4
#  * genhtml
 
5
#  * gcovr
 
6
 
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,
 
11
[
 
12
AC_ARG_ENABLE(gcov,
 
13
  AS_HELP_STRING([--enable-gcov],
 
14
                 [enable coverage testing with gcov]),
 
15
  [use_gcov=$enableval], [use_gcov=no])
 
16
 
 
17
  if test "x$use_gcov" = "xyes"; then
 
18
  # we need gcc:
 
19
  if test "$GCC" != "yes"; then
 
20
    AC_MSG_ERROR([GCC is required for --enable-gcov])
 
21
  fi
 
22
 
 
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;;
 
27
    *[)] gcc_ccache=no;;
 
28
  esac
 
29
 
 
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.])
 
32
  fi
 
33
 
 
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)
 
38
 
 
39
  if test "$LCOV"; then
 
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)"
 
46
        fi
 
47
      done
 
48
    ])
 
49
  else
 
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])
 
52
  fi
 
53
 
 
54
  case $glib_cv_lcov_version in
 
55
    ""|invalid[)]
 
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])
 
58
      LCOV="exit 0;"
 
59
      ;;
 
60
  esac
 
61
 
 
62
  if test -z "$GENHTML"; then
 
63
    AC_MSG_ERROR([Could not find genhtml from the lcov package])
 
64
  fi
 
65
 
 
66
  if test -z "$GCOVR"; then
 
67
    AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr])
 
68
  fi
 
69
 
 
70
 
 
71
  # Remove all optimization flags from CFLAGS
 
72
  changequote({,})
 
73
  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
 
74
  changequote([,])
 
75
 
 
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"
 
80
 
 
81
fi
 
82
])]) # AC_TDD_GCOV
 
83