summaryrefslogtreecommitdiff
path: root/m4/ax_code_coverage.m4
diff options
context:
space:
mode:
authorOlaf Mandel <olaf@mandel.name>2015-10-13 20:41:53 +0200
committerOlaf Mandel <olaf@mandel.name>2015-10-13 20:41:53 +0200
commit7fadb5b146f81e90d661dc89ad0edc1e4d239dd6 (patch)
treeebf32f9650f36594b8bd92f2905e9801b14d52cc /m4/ax_code_coverage.m4
parent94155ebfebc8d73678335668d0464153585022cd (diff)
downloadautoconf-archive-7fadb5b146f81e90d661dc89ad0edc1e4d239dd6.tar.gz
AX_CODE_COVERAGE: add CPPFLAGS to skip assertions
The assert() statement is a very helpful tool for quality assurance in nearly every kind of software project. But during code coverage it unnecessarily decreases the branch coverage percentage as assertions should never fail. This is probably not what the user expects as the branch contained inside the assert() statement is not visible in the code. So in a workflow where first the "check" target is run to see if any test fails (e.g. because of a failing assertion) and then the code coverage is consulted to see how much of the code was exercised, the assertions should not be counted. Implement this by adding a variable CODE_COVERAGE_CPPFLAGS which is defined to -DNDEBUG if CODE_COVERAGE_ENABLED.
Diffstat (limited to 'm4/ax_code_coverage.m4')
-rw-r--r--m4/ax_code_coverage.m410
1 files changed, 7 insertions, 3 deletions
diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4
index 8595129..84d1077 100644
--- a/m4/ax_code_coverage.m4
+++ b/m4/ax_code_coverage.m4
@@ -8,9 +8,10 @@
#
# DESCRIPTION
#
-# Defines CODE_COVERAGE_CFLAGS and CODE_COVERAGE_LDFLAGS which should be
-# included in the CFLAGS and LIBS/LDFLAGS variables of every build target
-# (program or library) which should be built with code coverage support.
+# Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS and
+# CODE_COVERAGE_LDFLAGS which should be included in the CPPFLAGS, CFLAGS
+# and LIBS/LDFLAGS variables of every build target (program or library)
+# which should be built with code coverage support.
# Also defines CODE_COVERAGE_RULES which should be substituted in your
# Makefile; and $enable_code_coverage which can be used in subsequent
# configure output. CODE_COVERAGE_ENABLED is defined and substituted, and
@@ -33,6 +34,7 @@
#
# @CODE_COVERAGE_RULES@
# my_program_LIBS = ... $(CODE_COVERAGE_LDFLAGS) ...
+# my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ...
# my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ...
#
# This results in a "check-code-coverage" rule being added to any
@@ -137,9 +139,11 @@ AC_DEFUN([AX_CODE_COVERAGE],[
])
dnl Build the code coverage flags
+ CODE_COVERAGE_CPPFLAGS="-DNDEBUG"
CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
CODE_COVERAGE_LDFLAGS="-lgcov"
+ AC_SUBST([CODE_COVERAGE_CPPFLAGS])
AC_SUBST([CODE_COVERAGE_CFLAGS])
AC_SUBST([CODE_COVERAGE_LDFLAGS])
])