summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVítězslav Kříž <vitezslav.kriz@nic.cz>2016-02-15 15:19:10 +0100
committerVítězslav Kříž <vitezslav.kriz@nic.cz>2016-02-15 17:45:31 +0100
commitc476d14f28cdb1a2b62d5cbc7e20da1042060dee (patch)
tree84c345b8b5ca083b4382f6d6af83643b853b0fc5
parentMerge branch 'freebsd-dependency' into 'master' (diff)
downloadknot-c476d14f28cdb1a2b62d5cbc7e20da1042060dee.tar.xz
knot-c476d14f28cdb1a2b62d5cbc7e20da1042060dee.zip
code coverage macro works for gcc and clang
-rw-r--r--m4/code-coverage.m436
-rw-r--r--src/zscanner/tests/Makefile.inc4
-rw-r--r--tests-fuzz/Makefile.am2
-rw-r--r--tests/Makefile.am2
4 files changed, 15 insertions, 29 deletions
diff --git a/m4/code-coverage.m4 b/m4/code-coverage.m4
index 57a3a6e15..ae6c5a2c6 100644
--- a/m4/code-coverage.m4
+++ b/m4/code-coverage.m4
@@ -23,34 +23,12 @@ AC_DEFUN([AX_CODE_COVERAGE], [
AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage])
AS_IF([test "$enable_code_coverage" = "yes"], [
- dnl Check whether gcc is used
- AS_IF([test "$GCC" = "no"], [
- AC_MSG_ERROR([compiling with gcc is required for gcov code coverage])
- ])
-
AC_CHECK_PROG([LCOV], [lcov], [lcov])
- AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
+ AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
- lcov_version_list="1.6 1.7 1.8 1.9 1.10 1.11"
-
- AS_IF([test "$LCOV"], [
- AC_CACHE_CHECK([for lcov version], ac_cv_lvoc_version, [
- ac_cv_lcov_version=invalid
- lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
- for lcov_check_version in $lcov_version_list; do
- if test "$lcov_version" = "$lcov_check_version"; then
- ac_cv_lcov_version="$lcov_check_version (ok)"
- fi
- done
- ])
- ],[
- AC_MSG_ERROR([You must have one of the following lcov versions installed: $lcov_version_list to enable gcov code coverage reporting])
+ AS_IF([test -z "$LCOV"], [
+ AC_MSG_ERROR([Could not find lcov])
])
-
- AS_CASE([$ac_cv_lcov_version],
- [""|invalid], [AC_MSG_ERROR([You must have one of the following lcov versions installed: $lcov_version_list to enable gcov code coverage reporting])
- ])
-
AS_IF([test -z "$GENHTML"], [
AC_MSG_ERROR([Could not find genhtml from the lcov package])
])
@@ -60,10 +38,10 @@ AC_DEFUN([AX_CODE_COVERAGE], [
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
changequote([,])
- dnl Add the special gcc flags
- CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
- CODE_COVERAGE_LDFLAGS="-lgcov"
-
+ dnl Add the coverage flags (clang, gcc)
+ CODE_COVERAGE_CFLAGS="--coverage"
+ CODE_COVERAGE_LDFLAGS="--coverage"
+
AC_SUBST([CODE_COVERAGE_CFLAGS])
AC_SUBST([CODE_COVERAGE_LDFLAGS])
])
diff --git a/src/zscanner/tests/Makefile.inc b/src/zscanner/tests/Makefile.inc
index 08f068da9..9f8eac1f0 100644
--- a/src/zscanner/tests/Makefile.inc
+++ b/src/zscanner/tests/Makefile.inc
@@ -1,6 +1,8 @@
LDADD = \
$(top_builddir)/src/zscanner/libzscanner.la
+
+
tests_zscanner_tool_SOURCES = \
tests/zscanner-tool.c \
tests/tests.h \
@@ -8,6 +10,8 @@ tests_zscanner_tool_SOURCES = \
tests/processing.h \
tests/processing.c
+tests_zscanner_tool_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+
check_PROGRAMS = \
tests/zscanner-tool
diff --git a/tests-fuzz/Makefile.am b/tests-fuzz/Makefile.am
index 5a4b087a2..58084ea37 100644
--- a/tests-fuzz/Makefile.am
+++ b/tests-fuzz/Makefile.am
@@ -3,6 +3,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/dnssec/lib
+AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+
LDADD = \
$(top_builddir)/src/libknot.la
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0147745fe..a3683262e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,6 +4,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/dnssec/lib
+AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+
LDADD = \
$(top_builddir)/libtap/libtap.la \
$(top_builddir)/src/libknot.la \