]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Update the code coverage m4 to support modern options, hook it up
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 14 Sep 2023 12:59:29 +0000 (14:59 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 Oct 2023 10:43:21 +0000 (12:43 +0200)
configure.ac
m4/pdns_enable_coverage.m4
pdns/dnsdistdist/configure.ac
pdns/dnsdistdist/m4/pdns_enable_coverage.m4 [new symlink]
pdns/recursordist/configure.ac
pdns/recursordist/m4/pdns_enable_coverage.m4 [new symlink]

index 8f6fde4604a16b02784ed9777455b0ee4d52a9c9..348127854d4e8611e7c77aecdc7167c1a3a34b6a 100644 (file)
@@ -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
 
index 17846ffa1690fd64580d34af9b569786d867bdc3..9e06468bc9eed8b645e3fcfcb019a0adb7fb0675 100644 (file)
@@ -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])
     ])
index feeeba3a12879b8b7774cce0a8d9ed0aa8c1c4f5..e30075c25c00c746af57a4a26b23c5452671949d 100644 (file)
@@ -131,6 +131,7 @@ PDNS_INIT_AUTO_VARS
 
 PDNS_ENABLE_SANITIZERS
 PDNS_ENABLE_LTO
+PDNS_ENABLE_COVERAGE
 
 PDNS_CHECK_PYTHON_VENV
 
diff --git a/pdns/dnsdistdist/m4/pdns_enable_coverage.m4 b/pdns/dnsdistdist/m4/pdns_enable_coverage.m4
new file mode 120000 (symlink)
index 0000000..9af5272
--- /dev/null
@@ -0,0 +1 @@
+../../../m4/pdns_enable_coverage.m4
\ No newline at end of file
index 231f3ae7a2647ab6de37c5dc395dc88431ed1901..f1f1a504c6168ebb183fed9e7271396609e27750 100644 (file)
@@ -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"], [
diff --git a/pdns/recursordist/m4/pdns_enable_coverage.m4 b/pdns/recursordist/m4/pdns_enable_coverage.m4
new file mode 120000 (symlink)
index 0000000..9af5272
--- /dev/null
@@ -0,0 +1 @@
+../../../m4/pdns_enable_coverage.m4
\ No newline at end of file