Skip to content

Commit

Permalink
tests: enable basic lcov code coverage reporting support
Browse files Browse the repository at this point in the history
Add "check-lcov" target to generate an HTML code coverage report
for testsuite execution using lcov and genhtml.

Signed-off-by: Lance Richardson <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
hlrichardson authored and blp committed Mar 19, 2016
1 parent d9c8c57 commit 27de40d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ OvsDpInterface.h
testsuite.tmp.orig
/rpm/
/openvswitch-*.tar.gz
/tests/lcov/
6 changes: 6 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,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
Expand Down
17 changes: 17 additions & 0 deletions tests/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 = \
Expand Down

0 comments on commit 27de40d

Please sign in to comment.