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: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
ae80d88bcb
commit
497d40b19b
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,7 @@
|
|||||||
*.a
|
*.a
|
||||||
*.d
|
*.d
|
||||||
|
*.gcda
|
||||||
|
*.gcno
|
||||||
*.o
|
*.o
|
||||||
*~
|
*~
|
||||||
*.swp
|
*.swp
|
||||||
|
3
CONFIG
3
CONFIG
@ -34,6 +34,9 @@
|
|||||||
# Build with debug logging. Turn off for performance testing and normal usage
|
# Build with debug logging. Turn off for performance testing and normal usage
|
||||||
CONFIG_DEBUG?=y
|
CONFIG_DEBUG?=y
|
||||||
|
|
||||||
|
# Build with code coverage instrumentation.
|
||||||
|
CONFIG_COVERAGE=n
|
||||||
|
|
||||||
# This directory should contain 'include' and 'lib' directories for your DPDK
|
# This directory should contain 'include' and 'lib' directories for your DPDK
|
||||||
# installation. Alternatively you can specify this on the command line
|
# installation. Alternatively you can specify this on the command line
|
||||||
# with 'make DPDK_DIR=/path/to/dpdk'.
|
# with 'make DPDK_DIR=/path/to/dpdk'.
|
||||||
|
@ -26,7 +26,7 @@ $MAKE $MAKEFLAGS clean
|
|||||||
|
|
||||||
timing_enter scanbuild_make
|
timing_enter scanbuild_make
|
||||||
fail=0
|
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
|
timing_exit scanbuild_make
|
||||||
|
|
||||||
# Check that header file dependencies are working correctly by
|
# Check that header file dependencies are working correctly by
|
||||||
@ -34,7 +34,7 @@ timing_exit scanbuild_make
|
|||||||
# header file and re-making.
|
# header file and re-making.
|
||||||
STAT1=`stat examples/nvme/identify/identify`
|
STAT1=`stat examples/nvme/identify/identify`
|
||||||
touch lib/nvme/nvme_internal.h
|
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`
|
STAT2=`stat examples/nvme/identify/identify`
|
||||||
|
|
||||||
if [ "$STAT1" == "$STAT2" ]; then
|
if [ "$STAT1" == "$STAT2" ]; then
|
||||||
|
18
autotest.sh
18
autotest.sh
@ -18,6 +18,11 @@ src=$(readlink -f $(dirname $0))
|
|||||||
out=$PWD
|
out=$PWD
|
||||||
cd $src
|
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
|
# set up huge pages
|
||||||
timing_enter afterboot
|
timing_enter afterboot
|
||||||
./scripts/configure_hugepages.sh 3072
|
./scripts/configure_hugepages.sh 3072
|
||||||
@ -45,3 +50,16 @@ trap - SIGINT SIGTERM EXIT
|
|||||||
|
|
||||||
# catch any stray core files
|
# catch any stray core files
|
||||||
process_core
|
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
|
||||||
|
@ -76,6 +76,14 @@ COMMON_CFLAGS += -DNDEBUG -O2
|
|||||||
COMMON_CFLAGS += -D_FORTIFY_SOURCE=2
|
COMMON_CFLAGS += -D_FORTIFY_SOURCE=2
|
||||||
endif
|
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
|
CFLAGS += $(COMMON_CFLAGS) -Wno-pointer-sign -std=gnu11
|
||||||
|
|
||||||
MAKEFLAGS += --no-print-directory
|
MAKEFLAGS += --no-print-directory
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
set -xe
|
set -xe
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
|
|
||||||
|
MAKECONFIG='CONFIG_DEBUG=y'
|
||||||
|
|
||||||
case `uname` in
|
case `uname` in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
DPDK_DIR=/usr/local/share/dpdk/x86_64-native-bsdapp-clang
|
DPDK_DIR=/usr/local/share/dpdk/x86_64-native-bsdapp-clang
|
||||||
@ -9,6 +11,7 @@ case `uname` in
|
|||||||
Linux)
|
Linux)
|
||||||
DPDK_DIR=/usr/local/dpdk-2.1.0/x86_64-native-linuxapp-gcc
|
DPDK_DIR=/usr/local/dpdk-2.1.0/x86_64-native-linuxapp-gcc
|
||||||
MAKE=make
|
MAKE=make
|
||||||
|
MAKECONFIG="$MAKECONFIG CONFIG_COVERAGE=y"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown OS in $0"
|
echo "Unknown OS in $0"
|
||||||
|
Loading…
Reference in New Issue
Block a user