From 7c1c6868d92e63add319dfd3a53227d665ae6e36 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 24 Apr 2013 10:52:42 +0200 Subject: [PATCH] Add --enable-coverage option for building with code coverage Also clean coverage files on 'make clean' https://bugs.freedesktop.org/show_bug.cgi?id=63868 --- .gitignore | 2 ++ configure.ac | 20 ++++++++++++++++++++ src/Makefile.am | 6 +++++- src/libaccountsservice/Makefile.am | 5 ++++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0130366..b34f7e1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ *-enum-types.h *-generated.c *-generated.h +*.gcda +*.gcno *.gir *.gmo *.la diff --git a/configure.ac b/configure.ac index aba5218..c90430d 100644 --- a/configure.ac +++ b/configure.ac @@ -57,6 +57,26 @@ AS_IF([test x$enable_admin_group = xauto], [ AC_DEFINE_UNQUOTED([ADMIN_GROUP], ["$enable_admin_group"], [Define to the group for administrator users]) dnl --------------------------------------------------------------------------- +dnl - coverage +dnl --------------------------------------------------------------------------- + +AC_MSG_CHECKING([whether to build with gcov testing]) +AC_ARG_ENABLE([coverage], + AS_HELP_STRING([--enable-coverage], + [Whether to enable gcov code coverage]), + [], [enable_coverage=no]) +AC_MSG_RESULT([$enable_coverage]) + +if test "$enable_coverage" = "yes"; then + if test "$GCC" != "yes"; then + AC_MSG_ERROR(Coverage testing requires GCC) + fi + CFLAGS="$CFLAGS -O0 -g --coverage" +fi + +AM_CONDITIONAL([WITH_COVERAGE], [test "$enable_coverage" = "yes"]) + +dnl --------------------------------------------------------------------------- dnl - Warnings dnl --------------------------------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index a053976..a5f08c1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,7 +44,11 @@ accounts_daemon_LDADD = \ libaccounts-generated.la \ $(POLKIT_LIBS) -CLEANFILES = $(BUILT_SOURCES) +CLEANFILES = \ + $(BUILT_SOURCES) \ + *.gcda \ + *.gcno \ + $(NULL) install-data-hook: $(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/AccountsService/users" diff --git a/src/libaccountsservice/Makefile.am b/src/libaccountsservice/Makefile.am index 5bff59f..bc0f428 100644 --- a/src/libaccountsservice/Makefile.am +++ b/src/libaccountsservice/Makefile.am @@ -1,7 +1,10 @@ END_OF_LIST = BUILT_SOURCES = $(END_OF_LIST) -CLEANFILES = $(END_OF_LIST) +CLEANFILES = \ + *.gcda \ + *.gcno \ + $(END_OF_LIST) AM_CPPFLAGS = \ -I. \ -- 1.8.1.4