--- /dev/null
+Building with gcov support
+==========================
+
+The Open vSwitch "configure" script supports the following
+code-coverage related options:
+
+ --disable-coverage
+ --enable-coverage=no
+
+ Do not build with gcov code coverage support.
+
+ This is the default if no coverage option is passed to
+ "configure".
+
+ --enable-coverage
+ --enable-coverage=yes
+
+ Build with gcov code coverage support, but do not assume that any
+ coverage-related tools are installed and do not add special
+ coverage support to the test suite.
+
+ --enable-coverage=lcov
+
+ Build with gcov code coverage support, as above, but also add
+ support for coverage analysis to the test suite. Running "make
+ check" will produce a directory "tests/coverage.html" in the build
+ directory with an analysis of the test suite's coverage.
+
+ This setting requires the lcov suite of utilities to be installed.
+ The "lcov" and "genhtml" programs from lcov must be in PATH. lcov
+ is available at: http://ltp.sourceforge.net/coverage/lcov.php
AC_SYS_LARGEFILE
OVS_CHECK_USERSPACE
+OVS_CHECK_COVERAGE
OVS_CHECK_NDEBUG
OVS_CHECK_NETLINK
OVS_CHECK_OPENSSL
# See the License for the specific language governing permissions and
# limitations under the License.
+dnl Checks for --enable-coverage and updates CFLAGS and LDFLAGS appropriately.
+AC_DEFUN([OVS_CHECK_COVERAGE],
+ [AC_REQUIRE([AC_PROG_CC])
+ AC_ARG_ENABLE(
+ [coverage],
+ [AC_HELP_STRING([--enable-coverage],
+ [Enable gcov coverage tool.])],
+ [case "${enableval}" in
+ (lcov) coverage=true lcov=true ;;
+ (yes) coverage=true lcov=false ;;
+ (no) coverage=false lcov=false ;;
+ (*) AC_MSG_ERROR([bad value ${enableval} for --enable-coverage]) ;;
+ esac],
+ [coverage=false lcov=false])
+ if $coverage; then
+ CFLAGS="$CFLAGS -O0 --coverage"
+ LDFLAGS="$LDFLAGS --coverage"
+ fi
+ if $lcov; then
+ if lcov --version >/dev/null 2>&1; then :; else
+ AC_MSG_ERROR([--enable-coverage=lcov was specified but lcov is not in \$PATH])
+ fi
+ fi
+ AC_SUBST([LCOV], [$lcov])])
+
dnl Checks for --enable-ndebug and defines NDEBUG if it is specified.
AC_DEFUN([OVS_CHECK_NDEBUG],
[AC_ARG_ENABLE(
# -*- shell-script -*-
PERL='@PERL@'
+LCOV='@LCOV@'
$(srcdir)/tests/testsuite
TESTSUITE_AT = \
tests/testsuite.at \
+ tests/lcov-pre.at \
tests/library.at \
- tests/stp.at
+ tests/stp.at \
+ tests/lcov-post.at
TESTSUITE = $(srcdir)/tests/testsuite
DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE)
--- /dev/null
+AT_BANNER([code coverage])
+
+AT_SETUP([generate coverage.html with lcov])
+AT_CHECK([$LCOV || exit 77])
+AT_CHECK([cd $abs_builddir && genhtml -o coverage.html coverage.info], [0], [ignore], [ignore])
+AT_CLEANUP
--- /dev/null
+AT_BANNER([code coverage])
+
+m4_define([_OVS_RUN_LCOV], [test $LCOV = false || lcov -b $abs_top_builddir -d $abs_top_builddir $1])
+
+AT_SETUP([initialize lcov])
+AT_CHECK([rm -fr $abs_builddir/coverage.html])
+AT_CHECK([rm -f $abs_builddir/coverage.info])
+AT_CHECK([$LCOV || exit 77])
+AT_CHECK([_OVS_RUN_LCOV([-c -i -o - > $abs_builddir/coverage.info])], [0], [ignore], [ignore])
+AT_CLEANUP
+
+# OVS_CHECK_LCOV(COMMAND, [STATUS = `0'], [STDOUT = `'], [STDERR = `'],
+# [RUN-IF-FAIL], [RUN-IF-PASS])
+#
+# This macro is equivalent to AT_CHECK, except that COMMAND should be a single
+# shell command that invokes a program whose code coverage is to be measured
+# (if configure was invoked with --coverage).
+m4_define([OVS_CHECK_LCOV],
+ [AT_CHECK([_OVS_RUN_LCOV([-z])], [0], [ignore], [ignore])
+ AT_CHECK($@)
+ AT_CHECK([_OVS_RUN_LCOV([-c -o - >> $abs_builddir/coverage.info])], [0], [ignore], [ignore])])
AT_SETUP([test flow extractor])
AT_CHECK([$PERL `which flowgen.pl` >/dev/null 3>flows 4>pcap])
-AT_CHECK([test-flows <flows 3<pcap], [0], [checked 247 packets, 0 errors
+OVS_CHECK_LCOV([test-flows <flows 3<pcap], [0], [checked 247 packets, 0 errors
])
AT_CLEANUP
AT_SETUP([test TCP/IP checksumming])
-AT_CHECK([test-csum], [0], [ignore])
+OVS_CHECK_LCOV([test-csum], [0], [ignore])
AT_CLEANUP
AT_SETUP([test flow classifier])
-AT_CHECK([test-classifier], [0], [ignore])
+OVS_CHECK_LCOV([test-classifier], [0], [ignore])
AT_CLEANUP
AT_SETUP([test hash functions])
-AT_CHECK([test-hash], [0], [ignore])
+OVS_CHECK_LCOV([test-hash], [0], [ignore])
AT_CLEANUP
AT_SETUP([test hash map])
-AT_CHECK([test-hmap], [0], [ignore])
+OVS_CHECK_LCOV([test-hmap], [0], [ignore])
AT_CLEANUP
AT_SETUP([test linked lists])
-AT_CHECK([test-list], [0], [ignore])
+OVS_CHECK_LCOV([test-list], [0], [ignore])
AT_CLEANUP
AT_SETUP([test SHA-1])
-AT_CHECK([test-sha1], [0], [ignore])
+OVS_CHECK_LCOV([test-sha1], [0], [ignore])
AT_CLEANUP
AT_SETUP([test type properties])
-AT_CHECK([test-type-props], [0], [ignore])
+OVS_CHECK_LCOV([test-type-props], [0], [ignore])
AT_CLEANUP
AT_SETUP([test vconn library])
-AT_CHECK([test-vconn], [0], [ignore])
+OVS_CHECK_LCOV([test-vconn], [0], [ignore])
AT_CLEANUP
check 3 = F:5 F
check 4 = F:5 B
])
-AT_CHECK([test-stp test-stp-ieee802.1d-1998])
+OVS_CHECK_LCOV([test-stp test-stp-ieee802.1d-1998])
AT_CLEANUP
AT_SETUP([STP example from IEEE 802.1D-2004 figures 17.4 and 17.5])
check 6 = F:20 B F F
check 7 = F:20 B F B
])
-AT_CHECK([test-stp test-stp-ieee802.1d-2004-fig17.4])
+OVS_CHECK_LCOV([test-stp test-stp-ieee802.1d-2004-fig17.4])
AT_CLEANUP
AT_SETUP([STP example from IEEE 802.1D-2004 figure 17.6])
check 4 = F:20 F F
check 5 = F:10 F F
])
-AT_CHECK([test-stp test-stp-ieee802.1d-2004-fig17.6])
+OVS_CHECK_LCOV([test-stp test-stp-ieee802.1d-2004-fig17.6])
AT_CLEANUP
AT_SETUP([STP example from IEEE 802.1D-2004 figure 17.7])
check 1 = F F:10 F F F F F F
check 2 = F:20 D F F F F F F
])
-AT_CHECK([test-stp test-stp-ieee802.1d-2004-fig17.7])
+OVS_CHECK_LCOV([test-stp test-stp-ieee802.1d-2004-fig17.7])
AT_CLEANUP
AT_SETUP([STP.io.1.1: Link Failure])
check 0 = root
check 1 = D D F:10
])
-AT_CHECK([test-stp test-stp-iol-io-1.1])
+OVS_CHECK_LCOV([test-stp test-stp-iol-io-1.1])
AT_CLEANUP
AT_SETUP([STP.io.1.2: Repeated Network])
check 0 = rootid:0x111 F B
check 1 = rootid:0x111 B F:10
])
-AT_CHECK([test-stp test-stp-iol-io-1.2])
+OVS_CHECK_LCOV([test-stp test-stp-iol-io-1.2])
AT_CLEANUP
AT_SETUP([STP.io.1.4: Network Initialization])
check 2 = F:10 B F
check 3 = F:10 B B
])
-AT_CHECK([test-stp test-stp-iol-io-1.4])
+OVS_CHECK_LCOV([test-stp test-stp-iol-io-1.4])
AT_CLEANUP
AT_SETUP([STP.io.1.5: Topology Change])
check 2 = B F:10 F F
check 3 = B F:20 B B
])
-AT_CHECK([test-stp test-stp-iol-io-1.5])
+OVS_CHECK_LCOV([test-stp test-stp-iol-io-1.5])
AT_CLEANUP
AT_SETUP([STP.op.1.1 and STP.op.1.2])
bridge 0 0x123 =
check 0 = root
])
-AT_CHECK([test-stp test-stp-iol-op-1.1])
+OVS_CHECK_LCOV([test-stp test-stp-iol-op-1.1])
AT_CLEANUP
AT_SETUP([STP.op.1.4: All Ports Initialized to Designated Ports])
run 1000
check 0 = F F F F F F
])
-AT_CHECK([test-stp test-stp-iol-op-1.4])
+OVS_CHECK_LCOV([test-stp test-stp-iol-op-1.4])
AT_CLEANUP
AT_SETUP([STP.op.3.1: Root Bridge Selection: Root ID Values])
check 0 = rootid:0x111 root
check 1 = rootid:0x111 F:10
])
-AT_CHECK([test-stp test-stp-iol-op-3.1])
+OVS_CHECK_LCOV([test-stp test-stp-iol-op-3.1])
AT_CLEANUP
AT_SETUP([STP.op.3.3: Root Bridge Selection: Bridge ID Values])
check 1 = rootid:0x333^0x6000 F:20
check 2 = rootid:0x333^0x6000 F:10 F
])
-AT_CHECK([test-stp test-stp-iol-op-3.3])
+OVS_CHECK_LCOV([test-stp test-stp-iol-op-3.3])
AT_CLEANUP
AT_SETUP([STP.op.3.3: Root Bridge Selection: Bridge ID Values])
check 1 = rootid:0x333^0x6000 F:20
check 2 = rootid:0x333^0x6000 F:10 F
])
-AT_CHECK([test-stp test-stp-iol-op-3.4])
+OVS_CHECK_LCOV([test-stp test-stp-iol-op-3.4])
AT_CLEANUP
AT_TESTED([ovs-vswitchd])
+m4_include([tests/lcov-pre.at])
m4_include([tests/library.at])
m4_include([tests/stp.at])
+m4_include([tests/lcov-post.at])