[S] Change in openvpn[master]: configure: Add --enable-code-coverage

"flichtenheld \(Code Review\) via Openvpn-devel" <[email protected]>
Newsgroups gmane.network.openvpn.devel
Message-ID <b153b559d3c632f6dab307c09926a6704e15fada-EmailReplacePatchSet-HTML@gerrit.openvpn.net>
Attention is currently required from: flichtenheld, plaisthos, razvanc.

Hello plaisthos, razvanc, 

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1592?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Code-Review+2 by razvanc


Change subject: configure: Add --enable-code-coverage
......................................................................

configure: Add --enable-code-coverage

Can be used like this
./configure --enable-code-coverage
make
make check
make code-coverage-capture

Change-Id: I79b2dc4a550b1c5068a45407976b0dfc2f765b33
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M .gitignore
M Makefile.am
M configure.ac
A lcovrc
M m4/ax_code_coverage.m4
M src/openvpn/Makefile.am
6 files changed, 28 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1592/2

diff --git a/.gitignore b/.gitignore
index 04523af..e25e591 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
 *.[oa]
 *.l[oa]
+*.gcda
+*.gcno
 *.dll
 *.exe
 *.exe.*
@@ -18,6 +20,7 @@
 Makefile
 Makefile.in
 aclocal.m4
+aminclude_static.am
 autodefs.h
 autom4te.cache
 config.guess
diff --git a/Makefile.am b/Makefile.am
index feeaabb..716b2df 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,6 +22,8 @@
 #  with this program; if not, see <https://www.gnu.org/licenses/>.
 #
 
+include $(top_srcdir)/aminclude_static.am
+
 ACLOCAL_AMFLAGS = -I m4
 
 MAINTAINERCLEANFILES = \
@@ -45,7 +47,8 @@
 	CMakeLists.txt \
 	CMakePresets.json \
 	config.h.cmake.in \
-	forked-test-driver
+	forked-test-driver \
+	lcovrc
 
 .PHONY: config-version.h doxygen
 
@@ -97,3 +100,7 @@
 	SOURCE_DIR="$(abs_top_srcdir)" \
 	INCLUDE_FLAGS="$(LIBNL_GENL_CFLAGS)" \
 		"$(top_srcdir)/dev-tools/run-cppcheck.sh"
+
+CODE_COVERAGE_LCOV_SHOPTS=--config-file $(srcdir)/lcovrc
+clean-local: code-coverage-clean
+distclean-local: code-coverage-dist-clean
diff --git a/configure.ac b/configure.ac
index 469a475..bb9fd16 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,8 @@
 AC_CANONICAL_HOST
 AC_USE_SYSTEM_EXTENSIONS
 
+AX_CODE_COVERAGE
+
 AC_ARG_ENABLE(
 	[lzo],
 	[AS_HELP_STRING([--disable-lzo], [disable LZO compression support @<:@default=yes@:>@])],
@@ -1236,6 +1238,11 @@
 	ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-cast-function-type])
 fi
 
+# If coverage is enabled remove -O arguments from CFLAGS
+if test "$enable_code_coverage" = "yes"; then
+   [CFLAGS="`echo $CFLAGS | $SED -e 's/-O[s0-9]\\?//g'`"]
+fi
+
 if test "${enable_pedantic}" = "yes"; then
 	CFLAGS="${CFLAGS} -pedantic"
 	AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode])
@@ -1355,10 +1362,10 @@
 
 TEST_LDFLAGS="${OPTIONAL_CRYPTO_LIBS} ${OPTIONAL_PKCS11_HELPER_LIBS} ${OPTIONAL_LIBCAPNG_LIBS}"
 TEST_LDFLAGS="${TEST_LDFLAGS} ${OPTIONAL_LIBNL_GENL_LIBS}"
-TEST_LDFLAGS="${TEST_LDFLAGS} ${OPTIONAL_LZO_LIBS} ${CMOCKA_LIBS}"
+TEST_LDFLAGS="${TEST_LDFLAGS} ${OPTIONAL_LZO_LIBS} ${CMOCKA_LIBS} ${CODE_COVERAGE_LIBS}"
 TEST_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${OPTIONAL_PKCS11_HELPER_CFLAGS} ${OPTIONAL_LIBCAPNG_CFLAGS}"
 TEST_CFLAGS="${TEST_CFLAGS} ${OPTIONAL_LIBNL_GENL_CFLAGS} ${OPTIONAL_LZO_CFLAGS}"
-TEST_CFLAGS="${TEST_CFLAGS} -I\$(top_srcdir)/include ${CMOCKA_CFLAGS}"
+TEST_CFLAGS="${TEST_CFLAGS} -I\$(top_srcdir)/include ${CMOCKA_CFLAGS} ${CODE_COVERAGE_CFLAGS}"
 
 AC_SUBST([TEST_LDFLAGS])
 AC_SUBST([TEST_CFLAGS])
diff --git a/lcovrc b/lcovrc
new file mode 100644
index 0000000..0e4ac46
--- /dev/null
+++ b/lcovrc
@@ -0,0 +1,2 @@
+geninfo_external = 0
+geninfo_unexecuted_blocks = 1
diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4
index 216708a4..4a01ce6 100644
--- a/m4/ax_code_coverage.m4
+++ b/m4/ax_code_coverage.m4
@@ -232,13 +232,12 @@
 		AC_MSG_ERROR([Could not find genhtml from the lcov package])
 	])
 
-	AC_CHECK_LIB([gcov], [_gcov_init], [CODE_COVERAGE_LIBS="-lgcov"], [CODE_COVERAGE_LIBS=""])
-
 	dnl Build the code coverage flags
 	dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility
 	CODE_COVERAGE_CPPFLAGS="-DNDEBUG"
-	CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
-	CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
+	CODE_COVERAGE_CFLAGS="-O0 -g --coverage"
+	CODE_COVERAGE_CXXFLAGS="-O0 -g --coverage"
+	CODE_COVERAGE_LIBS="--coverage"
 
 	AC_SUBST([CODE_COVERAGE_CPPFLAGS])
 	AC_SUBST([CODE_COVERAGE_CFLAGS])
diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
index 4220d07..26eb36c 100644
--- a/src/openvpn/Makefile.am
+++ b/src/openvpn/Makefile.am
@@ -31,9 +31,12 @@
 	$(OPTIONAL_SYSTEMD_CFLAGS) \
 	$(OPTIONAL_PKCS11_HELPER_CFLAGS) \
 	$(OPTIONAL_INOTIFY_CFLAGS) \
+	$(CODE_COVERAGE_CFLAGS) \
 	-DPLUGIN_LIBDIR=\"${plugindir}\" \
 	-DDEFAULT_DNS_UPDOWN=\"${scriptdir}/dns-updown\"
 
+AM_LIBS = $(CODE_COVERAGE_LIBS)
+
 if WIN32
 # we want unicode entry point but not the macro
 AM_CFLAGS += -municode -UUNICODE

-- 
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1592?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I79b2dc4a550b1c5068a45407976b0dfc2f765b33
Gerrit-Change-Number: 1592
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: razvanc <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Attention: razvanc <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.