From de0eed5be4c33f73b64c570ef2c84bdaec621092 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Tue, 20 Jan 2015 10:24:43 +0100 Subject: [PATCH] add a --enable-coverage switch --- .gitignore | 3 +++ Makefile.am | 26 ++++++++++++++++++++++++++ configure.ac | 7 +++++++ tests/Makefile.am | 4 ++++ 4 files changed, 40 insertions(+) diff --git a/.gitignore b/.gitignore index 916424a..63b9b89 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,6 @@ tests/pam_test tests/pam_test.log tests/pam_test.o tests/pam_test.trs +coverage/ +tests/pam_test.gcno +ykpamcfg.gcno diff --git a/Makefile.am b/Makefile.am index 96b1acb..0571ae4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -79,6 +79,32 @@ SUFFIXES = .1.txt .1 .8.txt .8 .8.txt.8: $(A2X) --format=manpage -a revdate="Version $(VERSION)" $< + +if ENABLE_COV +AM_CFLAGS += --coverage +AM_LDFLAGS = --coverage + +cov-reset: + rm -fr coverage + find . -name "*.gcda" -exec rm {} \; + lcov --directory . --zerocounters + +cov-report: + mkdir -p coverage + lcov --compat-libtool --directory . --capture --output-file coverage/app.info + lcov --extract coverage/app.info '*.c' --output-file coverage/app2.info + genhtml -o coverage/ coverage/app2.info + +cov: + make cov-report + +clean-local: + make cov-reset + +check: + make cov +endif + # Release ChangeLog: diff --git a/configure.ac b/configure.ac index 2a72149..f48c08e 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,13 @@ AC_ARG_WITH(pam-dir, esac]) AC_MSG_NOTICE([PAM installation path $PAMDIR]) +AC_ARG_ENABLE([coverage], + [AS_HELP_STRING([--enable-coverage], + [use Gcov to test the test suite])], + [], + [enable_cov=no]) +AM_CONDITIONAL([ENABLE_COV],[test '!' "$enable_cov" = no]) + AC_ARG_ENABLE([gcc-warnings], [AS_HELP_STRING([--enable-gcc-warnings], [turn on lots of GCC warnings (for developers)])], diff --git a/tests/Makefile.am b/tests/Makefile.am index dd802bb..56ed5b4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,3 +36,7 @@ pam_test_LDADD = ../libpam_real.la ../libpam_util.la @LTLIBYUBIKEY@ @LTLIBYKCLIE check_PROGRAMS = test util_test pam_test TESTS = $(check_PROGRAMS) + +if ENABLE_COV +AM_LDFLAGS += --coverage +endif