Change in libosmocore[master]: Add code coverage support

Vasil Velichkov gerrit-no-reply at lists.osmocom.org
Wed Apr 3 00:13:22 UTC 2019


Vasil Velichkov has uploaded this change for review. ( https://gerrit.osmocom.org/13496


Change subject: Add code coverage support
......................................................................

Add code coverage support

Configure with --enable-code-coverage then execute make check-code-coverage
and then open the resulting HTML report in your browser

Closes: OS#1987
Change-Id: I6f4ffb91bd7f3dd070aa09dd16d5ad1faf130a4c
---
M Makefile.am
M configure.ac
M src/Makefile.am
M src/codec/Makefile.am
M src/coding/Makefile.am
M src/ctrl/Makefile.am
M src/gb/Makefile.am
M src/gsm/Makefile.am
M src/pseudotalloc/Makefile.am
M src/sim/Makefile.am
M src/vty/Makefile.am
11 files changed, 43 insertions(+), 24 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/96/13496/1

diff --git a/Makefile.am b/Makefile.am
index 332ce65..5f8c46f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,6 +8,9 @@
 		 libosmogb.pc libosmoctrl.pc libosmocoding.pc libosmosim.pc
 
 @RELMAKE@
+ at CODE_COVERAGE_RULES@
+# Exclude some system headers from the code coverage report
+CODE_COVERAGE_IGNORE_PATTERN="/usr/include/*" "/usr/lib*"
 
 relengdir = $(includedir)
 releng_DATA = osmo-release.mk
diff --git a/configure.ac b/configure.ac
index 4a00e69..e88de21 100644
--- a/configure.ac
+++ b/configure.ac
@@ -334,6 +334,8 @@
 	AM_CONDITIONAL(HAVE_SSE4_1, false)
 fi
 
+AX_CODE_COVERAGE
+
 dnl Check if the compiler supports specified GCC's built-in function
 AC_DEFUN([CHECK_BUILTIN_SUPPORT], [
   AC_CACHE_CHECK(
diff --git a/src/Makefile.am b/src/Makefile.am
index 27ab702..4d28f8d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,8 +3,8 @@
 # before making any modifications: https://www.gnu.org/software/libtool/manual/html_node/Versioning.html
 LIBVERSION=12:1:0
 
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
-AM_CFLAGS = -Wall $(TALLOC_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include $(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = -Wall $(TALLOC_CFLAGS) $(CODE_COVERAGE_CFLAGS)
 
 if ENABLE_PSEUDOTALLOC
 AM_CPPFLAGS += -I$(top_srcdir)/src/pseudotalloc
@@ -12,7 +12,7 @@
 
 lib_LTLIBRARIES = libosmocore.la
 
-libosmocore_la_LIBADD = $(BACKTRACE_LIB) $(TALLOC_LIBS) $(LIBRARY_RT)
+libosmocore_la_LIBADD = $(BACKTRACE_LIB) $(TALLOC_LIBS) $(LIBRARY_RT) $(CODE_COVERAGE_LIBS)
 libosmocore_la_SOURCES = timer.c timer_gettimeofday.c timer_clockgettime.c \
 			 select.c signal.c msgb.c bits.c \
 			 bitvec.c bitcomp.c counter.c fsm.c \
diff --git a/src/codec/Makefile.am b/src/codec/Makefile.am
index b522d43..f11ff04 100644
--- a/src/codec/Makefile.am
+++ b/src/codec/Makefile.am
@@ -3,8 +3,8 @@
 # before making any modifications: https://www.gnu.org/software/libtool/manual/html_node/Versioning.html
 LIBVERSION=1:1:1
 
-AM_CPPFLAGS = -I$(top_srcdir)/include $(TALLOC_CFLAGS)
-AM_CFLAGS = -Wall
+AM_CPPFLAGS = -I$(top_srcdir)/include $(TALLOC_CFLAGS) $(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = -Wall $(CODE_COVERAGE_CFLAGS)
 
 if ENABLE_PSEUDOTALLOC
 AM_CPPFLAGS += -I$(top_srcdir)/src/pseudotalloc
@@ -15,4 +15,4 @@
 
 libosmocodec_la_SOURCES = gsm610.c gsm620.c gsm660.c gsm690.c ecu_fr.c
 libosmocodec_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined
-libosmocodec_la_LIBADD = $(top_builddir)/src/libosmocore.la
+libosmocodec_la_LIBADD = $(top_builddir)/src/libosmocore.la $(CODE_COVERAGE_LIBS)
diff --git a/src/coding/Makefile.am b/src/coding/Makefile.am
index c001c13..f179159 100644
--- a/src/coding/Makefile.am
+++ b/src/coding/Makefile.am
@@ -6,8 +6,9 @@
 AM_CPPFLAGS = \
 	-I"$(top_srcdir)/include" \
 	-I"$(top_builddir)/include" \
-	$(TALLOC_CFLAGS)
-AM_CFLAGS = -Wall
+	$(TALLOC_CFLAGS) \
+	$(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = -Wall $(CODE_COVERAGE_CFLAGS)
 
 if ENABLE_PSEUDOTALLOC
 AM_CPPFLAGS += -I$(top_srcdir)/src/pseudotalloc
@@ -30,6 +31,7 @@
 libosmocoding_la_LIBADD = \
 	../libosmocore.la \
 	../gsm/libosmogsm.la \
-	../codec/libosmocodec.la
+	../codec/libosmocodec.la \
+	$(CODE_COVERAGE_LIBS)
 
 EXTRA_DIST = libosmocoding.map
diff --git a/src/ctrl/Makefile.am b/src/ctrl/Makefile.am
index fe7c47d..537ea7c 100644
--- a/src/ctrl/Makefile.am
+++ b/src/ctrl/Makefile.am
@@ -3,7 +3,9 @@
 # before making any modifications: https://www.gnu.org/software/libtool/manual/html_node/Versioning.html
 LIBVERSION=3:0:3
 
-AM_CFLAGS = -Wall $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/include $(TALLOC_CFLAGS)
+AM_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = -Wall $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/include $(TALLOC_CFLAGS) \
+			$(CODE_COVERAGE_CFLAGS)
 
 if ENABLE_CTRL
 lib_LTLIBRARIES = libosmoctrl.la
@@ -14,7 +16,8 @@
 libosmoctrl_la_LIBADD = $(TALLOC_LIBS) \
 	$(top_builddir)/src/libosmocore.la \
 	$(top_builddir)/src/gsm/libosmogsm.la \
-	$(top_builddir)/src/vty/libosmovty.la
+	$(top_builddir)/src/vty/libosmovty.la \
+	$(CODE_COVERAGE_LIBS)
 
 if ENABLE_VTY
 libosmoctrl_la_SOURCES += control_vty.c
diff --git a/src/gb/Makefile.am b/src/gb/Makefile.am
index 3180f9c..530c8e1 100644
--- a/src/gb/Makefile.am
+++ b/src/gb/Makefile.am
@@ -2,8 +2,10 @@
 # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification
 LIBVERSION=8:0:2
 
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
-AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} -fno-strict-aliasing $(TALLOC_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \
+			$(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} -fno-strict-aliasing $(TALLOC_CFLAGS) \
+			$(CODE_COVERAGE_CFLAGS)
 
 # FIXME: this should eventually go into a milenage/Makefile.am
 noinst_HEADERS = common_vty.h gb_internal.h
@@ -15,7 +17,8 @@
 libosmogb_la_LIBADD = $(TALLOC_LIBS) \
 		$(top_builddir)/src/libosmocore.la \
 		$(top_builddir)/src/vty/libosmovty.la \
-		$(top_builddir)/src/gsm/libosmogsm.la
+		$(top_builddir)/src/gsm/libosmogsm.la \
+		$(CODE_COVERAGE_LIBS)
 
 libosmogb_la_SOURCES = gprs_ns.c gprs_ns_frgre.c gprs_ns_vty.c gprs_ns_sns.c \
 		  gprs_bssgp.c gprs_bssgp_util.c gprs_bssgp_vty.c \
diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index 9066500..010e5d9 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -3,8 +3,9 @@
 # before making any modifications: https://www.gnu.org/software/libtool/manual/html_node/Versioning.html
 LIBVERSION=11:0:0
 
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include $(TALLOC_CFLAGS)
-AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN}
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include $(TALLOC_CFLAGS) \
+			$(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} $(CODE_COVERAGE_CFLAGS)
 
 if ENABLE_PSEUDOTALLOC
 AM_CPPFLAGS += -I$(top_srcdir)/src/pseudotalloc
diff --git a/src/pseudotalloc/Makefile.am b/src/pseudotalloc/Makefile.am
index 3c78bba..f7a1ffc 100644
--- a/src/pseudotalloc/Makefile.am
+++ b/src/pseudotalloc/Makefile.am
@@ -1,4 +1,6 @@
-AM_CFLAGS = -Wall -I. $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/include
+AM_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = -Wall -I. $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/include \
+			$(CODE_COVERAGE_CFLAGS)
 
 if ENABLE_PSEUDOTALLOC
 
@@ -6,6 +8,7 @@
 
 libpseudotalloc_la_SOURCES = pseudotalloc.c
 libpseudotalloc_la_LDFLAGS = -no-undefined
+libpseudotalloc_la_LIBADD = $(CODE_COVERAGE_LIBS)
 
 nobase_include_HEADERS = talloc.h
 
diff --git a/src/sim/Makefile.am b/src/sim/Makefile.am
index ebf4739..cca5e23 100644
--- a/src/sim/Makefile.am
+++ b/src/sim/Makefile.am
@@ -3,9 +3,9 @@
 # before making any modifications: https://www.gnu.org/software/libtool/manual/html_node/Versioning.html
 LIBVERSION=0:2:0
 
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/include
-AM_CFLAGS = -fPIC -Wall $(PCSC_CFLAGS) $(TALLOC_CFLAGS)
-AM_LDFLAGS = $(COVERAGE_LDFLAGS)
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/include \
+			$(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = -fPIC -Wall $(PCSC_CFLAGS) $(TALLOC_CFLAGS) $(CODE_COVERAGE_CFLAGS)
 
 if ENABLE_PCSC
 # FIXME: only build the PC/SC dependent part conditional, but always build other parts
@@ -22,6 +22,7 @@
 	$(top_builddir)/src/libosmocore.la \
 	$(top_builddir)/src/gsm/libosmogsm.la \
 	$(TALLOC_LIBS) \
-	$(PCSC_LIBS)
+	$(PCSC_LIBS) \
+	$(CODE_COVERAGE_LIBS)
 
 endif
diff --git a/src/vty/Makefile.am b/src/vty/Makefile.am
index cdde0fa..4e2e5a5 100644
--- a/src/vty/Makefile.am
+++ b/src/vty/Makefile.am
@@ -3,8 +3,9 @@
 # before making any modifications: https://www.gnu.org/software/libtool/manual/html_node/Versioning.html
 LIBVERSION=6:0:2
 
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
-AM_CFLAGS = -Wall $(TALLOC_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \
+			$(CODE_COVERAGE_CPPFLAGS)
+AM_CFLAGS = -Wall $(TALLOC_CFLAGS) $(CODE_COVERAGE_CFLAGS)
 
 if ENABLE_VTY
 lib_LTLIBRARIES = libosmovty.la
@@ -14,5 +15,5 @@
 			fsm_vty.c talloc_ctx_vty.c \
 			tdef_vty.c
 libosmovty_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined
-libosmovty_la_LIBADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS)
+libosmovty_la_LIBADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) $(CODE_COVERAGE_LIBS)
 endif

-- 
To view, visit https://gerrit.osmocom.org/13496
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6f4ffb91bd7f3dd070aa09dd16d5ad1faf130a4c
Gerrit-Change-Number: 13496
Gerrit-PatchSet: 1
Gerrit-Owner: Vasil Velichkov <vvvelichkov at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190403/16b4b56f/attachment.html>


More information about the gerrit-log mailing list