From 139925229dc79675de5ec346eb4d84b7439ebea6 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Mon, 7 Jan 2019 14:16:44 -0500 Subject: [PATCH] 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 --- configure.ac | 7 ++++++- src/Makefile.am | 15 ++++++++++++++- tests/Makefile.am | 5 +++++ 3 files changed, 25 insertions(+), 2 deletions(-) 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