Add "check-lcov" target to generate an HTML code coverage report
for testsuite execution using lcov and genhtml.

Signed-off-by: Lance Richardson <lrich...@redhat.com>
---
 .gitignore        |  1 +
 INSTALL.md        |  6 ++++++
 tests/automake.mk | 17 +++++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/.gitignore b/.gitignore
index dbf33d2..077a178 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,3 +71,4 @@ OvsDpInterface.h
 testsuite.tmp.orig
 /rpm/
 /openvswitch-*.tar.gz
+/tests/lcov/
diff --git a/INSTALL.md b/INSTALL.md
index 9c96bbe..804c12a 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -514,6 +514,12 @@ The results of a testing run are reported in 
tests/testsuite.log.
 Please report test failures as bugs and include the testsuite.log in
 your report.
 
+If the build was configured with "--enable-coverage" and the "lcov"
+utility is installed, you can run the testsuite and generate a code
+coverage report by using "make check-lcov". All of the options for
+TESTSUITEFLAGS are available, so you can e.g.:
+      `make check-lcov TESTSUITEFLAGS=-j8 -k ovn`
+
 If you have "valgrind" installed, then you can also run the testsuite
 under valgrind by using "make check-valgrind" in place of "make
 check".  All the same options are available via TESTSUITEFLAGS.  When
diff --git a/tests/automake.mk b/tests/automake.mk
index 592f648..98c4df0 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -133,6 +133,23 @@ check-pycov: all tests/atconfig tests/atlocal $(TESTSUITE) 
clean-pycov
        @echo
        @COVERAGE_FILE=$(COVERAGE_FILE) $(COVERAGE) report
 
+# lcov support
+# Requires build with --enable-coverage and lcov/genhtml in $PATH
+CLEAN_LOCAL += clean-lcov
+clean-lcov:
+       rm -fr tests/lcov
+
+LCOV_OPTS = -b $(abs_top_builddir) -d $(abs_top_builddir) -q -c --rc 
lcov_branch_coverage=1
+GENHTML_OPTS = -q --branch-coverage --num-spaces 4
+check-lcov: all tests/atconfig tests/atlocal $(TESTSUITE) $(check_DATA) 
clean-lcov
+       find . -name '*.gcda' | xargs -n1 rm -f
+       -set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) 
$(TESTSUITEFLAGS); \
+       "$$@" || (test X'$(RECHECK)' = Xyes && "$$@" --recheck)
+       mkdir -p tests/lcov
+       lcov $(LCOV_OPTS) -o tests/lcov/coverage.info
+       genhtml $(GENHTML_OPTS) -o tests/lcov tests/lcov/coverage.info
+       @echo "coverage report generated at tests/lcov/index.html"
+
 # valgrind support
 
 valgrind_wrappers = \
-- 
2.5.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to