diff --git a/configure.ac b/configure.ac index e1794642..29fd044a 100644 --- a/configure.ac +++ b/configure.ac @@ -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 \ diff --git a/src/Makefile.am b/src/Makefile.am index 76ddcc22..1541a14f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index cdf9ca1e..b01e9d1e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -56,3 +56,8 @@ EXTRA_DIST = \ common \ tpm2_pcr_read.c \ tpm2_pcr_read.sh + +CLEANFILES = \ + *.gcov \ + *.gcda \ + *.gcno