Skip to content

Commit

Permalink
Coverage
Browse files Browse the repository at this point in the history
- Add `--enable-gcov` and `gcov` make target for Code coverage
  • Loading branch information
jelu committed Aug 10, 2020
1 parent 80d4857 commit 97dfeb7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ AC_ARG_WITH([extra-ldflags], [AS_HELP_STRING([--with-extra-ldflags=CFLAGS], [Add
AH_TEMPLATE([TINYFRAME_TRACE], [Defined if trace of Frame Streams is enabled])
AC_ARG_ENABLE([trace], [AS_HELP_STRING([--enable-trace], [Enable trace output of Frame Streams])], [AC_DEFINE([TINYFRAME_TRACE])])

# Check --enable-gcov
AC_ARG_ENABLE([gcov], [AS_HELP_STRING([--enable-gcov], [Enable coverage testing])], [
coverage_cflags="--coverage -g -O0 -fno-inline -fno-inline-small-functions -fno-default-inline"
AC_MSG_NOTICE([enabling coverage testing... $coverage_cflags])
AS_VAR_APPEND(CFLAGS, [" $coverage_cflags"])
])
AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" != "xno"])
AM_EXTRA_RECURSIVE_TARGETS([gcov])

# pkg-config
PKG_INSTALLDIR

Expand Down
9 changes: 9 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
CLEANFILES = *.gcda *.gcno *.gcov

EXTRA_DIST =

SUBDIRS = test
Expand All @@ -10,3 +12,10 @@ nobase_include_HEADERS = tinyframe/tinyframe.h
nobase_nodist_include_HEADERS = tinyframe/version.h
libtinyframe_la_LDFLAGS = -version-info $(TINYFRAME_LIBRARY_VERSION)
EXTRA_DIST += tinyframe/version.h.in

if ENABLE_GCOV
gcov-local:
for src in $(libtinyframe_la_SOURCES); do \
gcov -l -r -s "$(srcdir)" "$$src"; \
done
endif
9 changes: 8 additions & 1 deletion src/test/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in

CLEANFILES = test*.log test*.trs test2.fstrm
CLEANFILES = test*.log test*.trs test2.fstrm *.gcda *.gcno *.gcov

AM_CFLAGS = -I$(top_srcdir)/src

Expand All @@ -16,3 +16,10 @@ EXTRA_DIST += test.fstrm
test2_SOURCES = test2.c
test2_LDADD = ../libtinyframe.la
test2_LDFLAGS = -static

if ENABLE_GCOV
gcov-local:
for src in $(test1_SOURCES) $(test2_SOURCES); do \
gcov -l -r -s "$(srcdir)" "$$src"; \
done
endif

0 comments on commit 97dfeb7

Please sign in to comment.