summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2010-06-08 17:19:50 +0000
committerStef Walter <stef@memberwebs.com>2010-06-08 17:19:50 +0000
commit5bf7553731217d4134d19feca0ca827b0645b445 (patch)
tree9ea3a2f8df66c4b67cf7460353dec22eea94cb2a
parent730506a27cd9d34bdf5002482f7a938063e5ee03 (diff)
downloadgnome-keyring-5bf7553731217d4134d19feca0ca827b0645b445.tar.gz
Implement coverage of tests using gcov and lcov.
-rw-r--r--.gitignore3
-rw-r--r--Makefile.am11
-rw-r--r--configure.in48
-rw-r--r--testing/.gitignore2
-rw-r--r--testing/Makefile.am4
-rw-r--r--testing/testing.make11
6 files changed, 67 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index df854033..990c6795 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,9 @@ run-tests
.libs
.deps
.anjuta*
+*.gcov
+*.gcno
+*.gcda
/compile
/ABOUT-NLS
diff --git a/Makefile.am b/Makefile.am
index fb9ec480..4106ac31 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,3 +57,14 @@ dist-hook:
install-pam:
@echo "WARNING: install-pam is no longer used, use the --with-pam-dir configure option instead"
+
+if WITH_COVERAGE
+check-am:
+ $(LCOV) --directory . --zerocounters
+
+coverage: check
+ mkdir -p testing/coverage
+ $(LCOV) --directory . --capture --output-file testing/coverage.info
+ $(GENHTML) --output-directory testing/coverage testing/coverage.info
+ echo "Coverage info in: testing/coverage/index.html"
+endif \ No newline at end of file
diff --git a/configure.in b/configure.in
index edf5dae9..0940e09c 100644
--- a/configure.in
+++ b/configure.in
@@ -444,15 +444,47 @@ fi
AM_CONDITIONAL(WITH_TESTS, test "$enable_tests" = "yes")
-AC_ARG_ENABLE(coverage,
- AC_HELP_STRING([--enable-coverage],
- [Build coverage testing into gnome-keyring]))
-
-if test "$enable_coverage" = "yes"; then
- CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
- LDFLAGS="$LDFLAGS -fprofile-arcs -ftest-coverage"
+# ----------------------------------------------------------------------
+# Coverage
+
+AC_MSG_CHECKING([whether to build with gcov testing])
+AC_ARG_ENABLE([gcov],
+ AS_HELP_STRING([--enable-gcov],
+ [Whether to enable coverage testing ]),
+ [],
+ [enable_gcov=no])
+
+AC_MSG_RESULT([$enable_gcov])
+
+if test "$enable_gcov" = "yes"; then
+ if test "$GCC" != "yes"; then
+ AC_MSG_ERROR(Coverage testing requires GCC)
+ fi
+
+ AC_PATH_PROG(GCOV, gcov, no)
+ if test "$GCOV" = "no" ; then
+ AC_MSG_ERROR(gcov tool is not available)
+ fi
+
+ AC_PATH_PROG(LCOV, lcov, no)
+ if test "$LCOV" = "no" ; then
+ AC_MSG_ERROR(lcov tool is not installed)
+ fi
+
+ AC_PATH_PROG(GENHTML, genhtml, no)
+ if test "$GENHTML" = "no" ; then
+ AC_MSG_ERROR(lcov's genhtml tool is not installed)
+ fi
+
+ CFLAGS="$CFLAGS -O0 -g -fprofile-arcs -ftest-coverage"
+ LDFLAGS="$LDFLAGS -lgcov"
fi
+AM_CONDITIONAL([WITH_COVERAGE], [test "$enable_gcov" = "yes"])
+AC_SUBST(LCOV)
+AC_SUBST(GCOV)
+AC_SUBST(GENHTML)
+
# ----------------------------------------------------------------------
# Valgrind
@@ -609,5 +641,5 @@ echo " Debug Build: $debug_status"
echo " Valgrind: $valgrind_status"
echo " Pkcs#11 Tests $p11_tests_status"
echo " Tests, -Werror: $tests_status"
+echo " Test Coverage: $enable_gcov"
echo
-
diff --git a/testing/.gitignore b/testing/.gitignore
new file mode 100644
index 00000000..d85786a5
--- /dev/null
+++ b/testing/.gitignore
@@ -0,0 +1,2 @@
+/coverage
+/coverage.info
diff --git a/testing/Makefile.am b/testing/Makefile.am
index 82bb2154..6304d6ff 100644
--- a/testing/Makefile.am
+++ b/testing/Makefile.am
@@ -17,3 +17,7 @@ LIBS = \
$(GTHREAD_LIBS)
noinst_PROGRAMS =
+
+CLEANFILES = \
+ coverage \
+ coverage.info
diff --git a/testing/testing.make b/testing/testing.make
index d7575a8c..3266e506 100644
--- a/testing/testing.make
+++ b/testing/testing.make
@@ -38,7 +38,11 @@ run_tests_LDADD = \
$(DAEMON_LIBS)
run_tests_CFLAGS = \
- $(TESTING_FLAGS)
+ $(TESTING_FLAGS) \
+ $(GCOV_CFLAGS)
+
+run_tests_LDFLAGS = \
+ $(GCOV_LDFLAGS)
BUILT_SOURCES = \
test-framework.c \
@@ -48,7 +52,6 @@ BUILT_SOURCES = \
# Run the tests
test: $(noinst_PROGRAMS)
- gtester --verbose -k -m=slow ./run-tests
+ TEST_DATA=$(srcdir)/test-data gtester --verbose -k -m=slow ./run-tests
-check-am: $(noinst_PROGRAMS)
- TEST_DATA=$(srcdir)/test-data gtester -m=slow --verbose ./run-tests
+check-am: $(noinst_PROGRAMS) test