build-sys: Add support for --enable-test-coverage to configure

Add support for --enable-test-coverage that sets additional CFLAGS
and LDFLAGS.

gcov creates files with suffixes .gcov, .gcno, and .gcda that we
need clean up in a few directories.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2019-01-07 14:16:44 -05:00 committed by Stefan Berger
parent dc6e504522
commit 139925229d
3 changed files with 25 additions and 2 deletions

View File

@ -162,6 +162,10 @@ AC_ARG_ENABLE([fuzzer], AS_HELP_STRING([--enable-fuzzer], [Enable fuzzer]),
AC_SUBST([SANITIZERS])
AC_SUBST([FUZZER])
AC_ARG_ENABLE([test-coverage],
AS_HELP_STRING([--enable-test-coverage], [Enable test coverage flags]),
[COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage" COVERAGE_LDFLAGS="-fprofile-arcs"])
LT_INIT
AC_PROG_CC
AC_PROG_INSTALL
@ -209,7 +213,8 @@ if test "x$enable_hardening" != "xno"; then
fi
if test "$test_CFLAGS" != set; then
CFLAGS="$CFLAGS -Wall -Werror -Wreturn-type -Wsign-compare -Wno-self-assign"
CFLAGS="$CFLAGS $COVERAGE_CFLAGS -Wall -Werror -Wreturn-type -Wsign-compare -Wno-self-assign"
LDFLAGS="$LDFLAGS $COVERAGE_LDFLAGS"
fi
AC_CONFIG_FILES(Makefile \

View File

@ -598,4 +598,17 @@ EXTRA_DIST = \
libtpms.syms \
test.syms
CLEANFILES = a.out
CLEANFILES = \
a.out \
*.gcov \
*.gcda \
*.gcno \
tpm12/*.gcov \
tpm12/*.gcda \
tpm12/*.gcno \
tpm2/*.gcov \
tpm2/*.gcda \
tpm2/*.gcno \
tpm2/crypto/openssl/*.gcov \
tpm2/crypto/openssl/*.gcda \
tpm2/crypto/openssl/*.gcno

View File

@ -56,3 +56,8 @@ EXTRA_DIST = \
common \
tpm2_pcr_read.c \
tpm2_pcr_read.sh
CLEANFILES = \
*.gcov \
*.gcda \
*.gcno