Commit e318759e authored by Vasil Velichkov's avatar Vasil Velichkov Committed by Lev Walkin

Add code coverage using lcov and gcov

To generate the code coverage report you need gcov and lcov installed
and then execute

 ./configure --enable-code-coverage
 make check-code-coverage

 Writing directory view page.
 Overall coverage rate:
   lines......: 76.5% (10519 of 13759 lines)
   functions..: 85.5% (491 of 574 functions)
   branches...: 57.5% (7040 of 12250 branches)
 file:///home/user/asn1c/asn1c-0.9.28-coverage/index.html

Open the index.html with a web browser
parent b98b286d
......@@ -68,3 +68,6 @@ doc/docsrc/*.xdv
# /skeletons/tests/
/skeletons/tests/check-*
#code coverage
*.gcno
*.gcda
ACLOCAL_AMFLAGS = -I m4
@CODE_COVERAGE_RULES@
SUBDIRS = \
libasn1parser libasn1fix \
libasn1print libasn1compiler \
......
@CODE_COVERAGE_RULES@
SUBDIRS = . tests
......
@CODE_COVERAGE_RULES@
SUBDIRS = check-src
......
......@@ -75,6 +75,20 @@ AC_ARG_ENABLE(test-Werror,
TESTSUITE_CFLAGS="-Werror -W -Wpointer-arith"
])
AX_CODE_COVERAGE
AS_IF([test x$enable_code_coverage != xno], [
CFLAGS="$CFLAGS $CODE_COVERAGE_CFLAGS"
# The CODE_COVERAGE_CPPFLAGS contains -DNDEBUG flag
# which removes assert(...) macros from code coverage and improves the
# branches score. But when it is defined it results in few
# unsed-but-set-variable warnings that are treated as errors in the travis-ci
# build because these variables are only used inside assert macros.
# error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]
#CPPFLAGS="$CPPFLAGS $CODE_COVERAGE_CPPFLAGS"
CXXFLAGS="$CXXFLAGS $CODE_COVERAGE_CXXFLAGS"
LDFLAGS="$LDFLAGS $CODE_COVERAGE_LDFLAGS"
])
AC_SUBST(ADD_CFLAGS)
AC_SUBST(TESTSUITE_CFLAGS)
......
@CODE_COVERAGE_RULES@
AM_CFLAGS = @ADD_CFLAGS@
AM_CPPFLAGS = \
......
This diff is collapsed.
@CODE_COVERAGE_RULES@
check_PROGRAMS = \
check-ber_tlv_tag \
check-length \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment