[sheepdog] [PATCH 1/3] build: add 'make coverage' target

Kai Zhang kyle at zelin.io
Mon Jun 3 13:32:27 CEST 2013


Signed-off-by: Kai Zhang <kyle at zelin.io>
---
 .gitignore         |    4 ++++
 Makefile.am        |   15 +++++++++++++++
 collie/Makefile.am |    3 +++
 configure.ac       |    1 +
 sheep/Makefile.am  |    3 +++
 5 files changed, 26 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..a1bdf67 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
+
+coverage: clean
+	@rm -rf coverage
+	$(MAKE) AM_CFLAGS=--coverage && $(MAKE) check AM_CFLAGS=--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
+
diff --git a/collie/Makefile.am b/collie/Makefile.am
index bfbf660..e0d12d8 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..ef47672 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,7 @@ AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AC_PROG_RANLIB
 AC_CHECK_PROGS([GROFF], [groff])
+PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
 
 AM_MISSING_PROG(AUTOM4TE, autom4te, $missing_dir)
 
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