[sheepdog] [PATCH v3 1/3] build: add 'make coverage' target
Kai Zhang
kyle at zelin.io
Sat Jun 8 12:17:21 CEST 2013
Signed-off-by: Kai Zhang <kyle at zelin.io>
---
.gitignore | 4 ++++
Makefile.am | 15 +++++++++++++++
collie/Makefile.am | 3 +++
configure.ac | 11 +++++++++++
sheep/Makefile.am | 3 +++
5 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index 60448d4..1c40a20 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,9 @@
*.orig
*.rej
cscope.*
+*.gcda
+*.gcno
+*.info
#
# for GLOBAL
@@ -36,6 +39,7 @@ shepherd/shepherd
# directories
.deps
autom4te.cache
+coverage
aclocal.m4
Makefile
diff --git a/Makefile.am b/Makefile.am
index 16eb532..2d2e158 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -37,6 +37,7 @@ dist-clean-local:
clean-generic:
rm -rf $(SPEC) $(TARFILE) cscope*
find -name '*.orig' -or -name '*.rej' | xargs rm -f
+ find -name '*.gcno' -or -name '*.gcda' -or -name '*.info' | xargs rm -f
cscope:
@echo create cscope.out
@@ -82,3 +83,17 @@ check-style:
@for dir in lib collie sheep include sheepfs; do \
make -C $$dir check-style CHECK_STYLE="$(CHECK_STYLE)"; \
done
+
+if BUILD_COVERAGE
+coverage: clean check
+ @rm -rf coverage
+
+ @for dir in collie sheep ; do \
+ $(MAKE) -C $$dir coverage; \
+ done
+
+ @lcov -a collie/collie.info -a sheep/sheep.info \
+ -o sheep.info && \
+ lcov -r sheep.info /usr/include/\* -o sheep.info && \
+ genhtml sheep.info -o coverage
+endif
diff --git a/collie/Makefile.am b/collie/Makefile.am
index c363347..c128cd1 100644
--- a/collie/Makefile.am
+++ b/collie/Makefile.am
@@ -51,3 +51,6 @@ check-syntax:
check-style:
@$(CHECK_STYLE) $(collie_SOURCES) $(noinst_HEADERS)
+
+coverage:
+ @lcov -d . -c -o collie.info
diff --git a/configure.ac b/configure.ac
index e06e55c..4ccadbd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -179,9 +179,14 @@ AC_ARG_ENABLE([debug],
[ --enable-debug : enable debug build. ],
[ default="no" ])
+AC_ARG_ENABLE([unittest],
+ [ --enable-unittest : enable unittest. ],
+ [ default="no" ])
+
AC_ARG_ENABLE([coverage],
[ --enable-coverage : coverage analysis of the codebase. ],
[ default="no" ])
+AM_CONDITIONAL(BUILD_COVERAGE, test x$enable_coverage = xyes)
AC_ARG_ENABLE([corosync],
[ --enable-corosync : build corosync cluster driver ],,
@@ -326,11 +331,17 @@ if test "x${enable_coverage}" = xyes && \
COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
PACKAGE_FEATURES="$PACKAGE_FEATURES coverage"
+ enable_unittest="yes"
else
COVERAGE_CFLAGS=""
COVERAGE_LDFLAGS=""
fi
+if test "x${enable_unittest}" = xyes; then
+ PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
+fi
+AM_CONDITIONAL(BUILD_UNITTEST, test x$enable_unittest = xyes)
+
if test "x${enable_fatal_warnings}" = xyes && \
cc_supports_flag -Werror ; then
diff --git a/sheep/Makefile.am b/sheep/Makefile.am
index e20579f..4916409 100644
--- a/sheep/Makefile.am
+++ b/sheep/Makefile.am
@@ -62,3 +62,6 @@ check-syntax:
check-style:
@$(CHECK_STYLE) $(sheep_SOURCES) $(noinst_HEADERS)
+
+coverage:
+ @lcov -d . -c -o sheep.info
--
1.7.1
More information about the sheepdog
mailing list