Skip to content

Commit

Permalink
Update the code coverage m4 to support modern options, hook it up
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Oct 9, 2023
1 parent 4015a5c commit a985c6a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ PDNS_ENABLE_UNIT_TESTS
PDNS_ENABLE_BACKEND_UNIT_TESTS
PDNS_ENABLE_REPRODUCIBLE
PDNS_ENABLE_FUZZ_TARGETS
PDNS_ENABLE_COVERAGE

PDNS_WITH_SQLITE3

Expand Down
19 changes: 17 additions & 2 deletions m4/pdns_enable_coverage.m4
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,24 @@ AC_DEFUN([PDNS_ENABLE_COVERAGE], [
[enable_coverage=no]
)
AC_MSG_RESULT([$enable_coverage])
AS_IF([test "x$enable_coverage" != "xno"], [
AS_IF([test "x$enable_coverage" = "xclang"], [
dnl let's see if the clang++ specific format is supported,
dnl as it has a much lower overhead and is more accurate,
dnl see https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
gl_COMPILER_OPTION_IF([-fprofile-instr-generate -fcoverage-mapping], [
CFLAGS="$CFLAGS -DCOVERAGE -DCLANG_COVERAGE -fprofile-instr-generate -fcoverage-mapping"
CXXFLAGS="$CXXFLAGS -DCOVERAGE -DCLANG_COVERAGE -fprofile-instr-generate -fcoverage-mapping"
], [
AC_MSG_ERROR([$CXX does not support gathering coverage data in the clang format])
])
])
AS_IF([test "x$enable_coverage" = "xyes"], [
gl_COMPILER_OPTION_IF([-fprofile-arcs -ftest-coverage], [
CXXFLAGS="$CXXFLAGS -U_FORTIFY_SOURCE -g -O0 -fprofile-arcs -ftest-coverage"
CFLAGS="$CFLAGS -DCOVERAGE --coverage"
CXXFLAGS="$CXXFLAGS -DCOVERAGE --coverage"
LDFLAGS="$LDFLAGS --coverage"
], [
AC_MSG_ERROR([$CXX does not support gathering coverage data])
])
Expand Down
1 change: 1 addition & 0 deletions pdns/dnsdistdist/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ PDNS_INIT_AUTO_VARS

PDNS_ENABLE_SANITIZERS
PDNS_ENABLE_LTO
PDNS_ENABLE_COVERAGE

PDNS_CHECK_PYTHON_VENV

Expand Down
1 change: 1 addition & 0 deletions pdns/dnsdistdist/m4/pdns_enable_coverage.m4
1 change: 1 addition & 0 deletions pdns/recursordist/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ AS_IF([test -n "$pdns_context_library"], [AC_MSG_RESULT([$pdns_context_library])

PDNS_ENABLE_UNIT_TESTS
PDNS_ENABLE_REPRODUCIBLE
PDNS_ENABLE_COVERAGE

PDNS_WITH_LUA([mandatory])
AS_IF([test "x$LUAPC" = "xluajit"], [
Expand Down
1 change: 1 addition & 0 deletions pdns/recursordist/m4/pdns_enable_coverage.m4

0 comments on commit a985c6a

Please sign in to comment.