Commit 497d40b1 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Gerrit Code Review
Browse files

build: add CONFIG_COVERAGE code coverage option



Collect coverage information for use with gcov.

Coverage is disabled on FreeBSD because the current version of clang
provided by FreeBSD can't successfully link with -ftest-coverage enabled
(the compiler-rt support libs are too old).

Change-Id: Icc444936caa852bfb9a02b37223209319a27a770
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent ae80d88b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
*.a
*.d
*.gcda
*.gcno
*.o
*~
*.swp
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@
# Build with debug logging. Turn off for performance testing and normal usage
CONFIG_DEBUG?=y

# Build with code coverage instrumentation.
CONFIG_COVERAGE=n

# This directory should contain 'include' and 'lib' directories for your DPDK
# installation. Alternatively you can specify this on the command line
# with 'make DPDK_DIR=/path/to/dpdk'.
+2 −2
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ $MAKE $MAKEFLAGS clean

timing_enter scanbuild_make
fail=0
time $scanbuild $MAKE $MAKEFLAGS DPDK_DIR=$DPDK_DIR CONFIG_DEBUG=y || fail=1
time $scanbuild $MAKE $MAKEFLAGS DPDK_DIR=$DPDK_DIR $MAKECONFIG || fail=1
timing_exit scanbuild_make

# Check that header file dependencies are working correctly by
@@ -34,7 +34,7 @@ timing_exit scanbuild_make
#  header file and re-making.
STAT1=`stat examples/nvme/identify/identify`
touch lib/nvme/nvme_internal.h
$MAKE $MAKEFLAGS DPDK_DIR=$DPDK_DIR CONFIG_DEBUG=y || fail=1
$MAKE $MAKEFLAGS DPDK_DIR=$DPDK_DIR $MAKECONFIG || fail=1
STAT2=`stat examples/nvme/identify/identify`

if [ "$STAT1" == "$STAT2" ]; then
+18 −0
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ src=$(readlink -f $(dirname $0))
out=$PWD
cd $src

if hash lcov; then
	# zero out coverage data
	lcov -q -c -i -d $src -o cov_base.info
fi

# set up huge pages
timing_enter afterboot
./scripts/configure_hugepages.sh 3072
@@ -45,3 +50,16 @@ trap - SIGINT SIGTERM EXIT

# catch any stray core files
process_core

if hash lcov; then
	# generate coverage data and combine with baseline
	lcov -q -c -d $src -o cov_test.info
	lcov -q -a cov_base.info -a cov_test.info -o cov_total.info
	lcov -q -r cov_total.info '/usr/*' -o cov_total.info
	lcov -q -r cov_total.info 'test/*' -o cov_total.info
	genhtml cov_total.info --legend -t "SPDK" -o $out/coverage
	chmod -R a+rX $out/coverage
	rm cov_base.info cov_test.info
	mv cov_total.info $out/cov_total.info
	find . -name "*.gcda" -delete
fi
+8 −0
Original line number Diff line number Diff line
@@ -76,6 +76,14 @@ COMMON_CFLAGS += -DNDEBUG -O2
COMMON_CFLAGS += -D_FORTIFY_SOURCE=2
endif

ifeq ($(CONFIG_COVERAGE), y)
COMMON_CFLAGS += -fprofile-arcs -ftest-coverage
LDFLAGS += -fprofile-arcs -ftest-coverage
ifeq ($(OS),FreeBSD)
LDFLAGS += --coverage
endif
endif

CFLAGS   += $(COMMON_CFLAGS) -Wno-pointer-sign -std=gnu11

MAKEFLAGS += --no-print-directory
Loading