[svn] commit: r412 - in /branches/parkinglot: Makefile.am configure.ac

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Dec 29 16:07:21 UTC 2009


Author: jelte
Date: Tue Dec 29 16:07:20 2009
New Revision: 412

Log:
made a start with automating coverage tests;
configure --with-lcov will try /usr/bin and /usr/local/bin for the lcov and genhtml binaries
(use --with-lcov=PATH to specify a full path to the lcov binary, genhtml is assumed to be in the same one)
this enables a new makefile target; coverage
make coverage removes old coverage results, performs the tests (by depending on make check), and generates a new report in coverage/

Modified:
    branches/parkinglot/Makefile.am
    branches/parkinglot/configure.ac

Modified: branches/parkinglot/Makefile.am
==============================================================================
--- branches/parkinglot/Makefile.am (original)
+++ branches/parkinglot/Makefile.am Tue Dec 29 16:07:20 2009
@@ -1,5 +1,28 @@
 SUBDIRS = src
+USE_LCOV=@USE_LCOV@
+LCOV=@LCOV@
+GENHTML=@GENHTML@
 
-# is there a better way to automate this?
-test: all
-	find . -name \*unittests -type f -executable -exec {} \;
+clean-coverage:
+	@if [ $(USE_LCOV) = yes ] ; then \
+		$(LCOV) --directory . --zerocounters; \
+		rm -rf coverage/; \
+	else \
+		echo "Code coverage not enabled at configuration time"; \
+		exit 1; \
+	fi
+
+perform-coverage: check
+
+report-coverage:
+	$(LCOV) --capture --directory . --output-file all.info
+	$(LCOV) --remove all.info \
+			c++/4.4/\* \
+			boost/\* \
+			gtest/\* \
+			usr/include/\* \
+		--output report.info
+	$(GENHTML) -o coverage report.info 
+
+coverage: clean-coverage perform-coverage report-coverage
+

Modified: branches/parkinglot/configure.ac
==============================================================================
--- branches/parkinglot/configure.ac (original)
+++ branches/parkinglot/configure.ac Tue Dec 29 16:07:20 2009
@@ -32,12 +32,51 @@
         AC_DEFINE(HAVE_SIN_LEN, 1, Define to 1 if sockaddr_in has a sin_len member)],
         AC_MSG_RESULT(no))
 
+AC_ARG_WITH(lcov,
+[  --with-lcov         enable gtest and coverage target using the specified lcov], lcov="yes", lcov="no")
+
+AC_ARG_WITH(gtest,
+[  --with-gtest=PATH       specify a path to gtest header files (PATH/include) and library (PATH/lib)],
+    gtest_path="$withval", gtest_path="no")
+
+
+USE_LCOV="no"
+if test "$lcov" != "no"; then
+	# force gtest if not set
+	if test "$gtest_path" = "no"; then
+		gtest_path="yes"
+	fi
+	if test "$lcov" != "yes"; then
+		LCOV_PATHS=$lcov
+	else
+		LCOV_PATHS="/usr/bin/lcov /usr/local/bin/lcov"
+	fi
+	for f in $LCOV_PATHS; do
+		if test -x "$f"; then
+			USE_LCOV="yes"
+			LCOV=$f
+		fi
+	done
+	if test $USE_LCOV != "yes"; then
+		AC_MSG_ERROR([Cannot find lcov in: $LCOV_PATHS])
+	fi
+	# is genhtml always in the same directory?
+	GENHTML=`echo "$LCOV" | sed s/lcov$/genhtml/`
+	if test ! -x $GENHTML; then
+		AC_MSG_ERROR([genhtml not found, needed for lcov])
+	fi
+	CPPFLAGS="$(CPPFLAGS) -fprofile-arcs -ftest-coverage"
+	LIBS=" $(LIBS) -lgcov"
+	AC_SUBST(CPPFLAGS)
+	AC_SUBST(LIBS)
+	AC_SUBST(LCOV)
+	AC_SUBST(GENHTML)
+fi
+AC_SUBST(USE_LCOV)
+
 #
 # Check availablity of gtest, which will be used for unit tests.
 #
-AC_ARG_WITH(gtest,
-[  --with-gtest=PATH       specify a path to gtest header files (PATH/include) and library (PATH/lib)],
-    gtest_path="$withval", gtest_path="no")
 if test "$gtest_path" != "no"
 then
 	if test "$gtest_path" != "yes"; then




More information about the bind10-changes mailing list