unittests.sh: use valgrind if installed and not using ASAN
Automatically uses valgrind with the same options as CI does provided that it is available ASAN is not enabled. NOTE: if you don't want to use valgrind then enable ASAN Change-Id: I44f8322680eb2608464eb128d49d20dc1d311f0c Signed-off-by: Paul Luse <paul.e.luse@intel.com> Reviewed-on: https://review.gerrithub.io/369064 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
36a0d1e5d1
commit
b9244352b0
@ -76,7 +76,7 @@ timing_exit rbd_setup
|
||||
|
||||
if [ $SPDK_TEST_UNITTEST -eq 1 ]; then
|
||||
timing_enter unittest
|
||||
valgrind="$valgrind" run_test ./unittest.sh
|
||||
run_test ./unittest.sh
|
||||
timing_exit unittest
|
||||
fi
|
||||
|
||||
|
@ -27,6 +27,11 @@ fi
|
||||
: ${SPDK_RUN_ASAN=0}; export SPDK_RUN_ASAN
|
||||
: ${SPDK_RUN_UBSAN=1}; export SPDK_RUN_UBSAN
|
||||
|
||||
# pass our valgrind desire on to unittest.sh
|
||||
if [ $SPDK_RUN_VALGRIND -eq 0 ]; then
|
||||
export valgrind=''
|
||||
fi
|
||||
|
||||
config_params='--enable-debug --enable-werror'
|
||||
|
||||
export UBSAN_OPTIONS='halt_on_error=1:print_stacktrace=1:abort_on_error=1'
|
||||
@ -102,13 +107,6 @@ if [ -z "$output_dir" ]; then
|
||||
export output_dir
|
||||
fi
|
||||
|
||||
# Valgrind does not work well when ASAN is enabled, so only use valgrind if ASAN is disabled
|
||||
if [ $SPDK_RUN_ASAN -eq 0 ] && [ $SPDK_RUN_VALGRIND -eq 1 ] && hash valgrind &> /dev/null; then
|
||||
valgrind='valgrind --leak-check=full --error-exitcode=2'
|
||||
else
|
||||
valgrind=''
|
||||
fi
|
||||
|
||||
function timing() {
|
||||
direction="$1"
|
||||
testname="$2"
|
||||
|
17
unittest.sh
17
unittest.sh
@ -1,10 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Environment variables:
|
||||
# $valgrind Valgrind executable name, if desired
|
||||
# $valgrind Specify the valgrind command line, if not
|
||||
# then a default command line is used
|
||||
|
||||
set -xe
|
||||
|
||||
# if ASAN is enabled, use it. If not use valgrind if installed but allow
|
||||
# the env variable to override the default shown below.
|
||||
if [ -z ${valgrind+x} ]; then
|
||||
if grep -q '#undef SPDK_CONFIG_ASAN' config.h && hash valgrind; then
|
||||
valgrind='valgrind --leak-check=full --error-exitcode=2'
|
||||
else
|
||||
valgrind=''
|
||||
fi
|
||||
fi
|
||||
|
||||
# setup local unit test coverage if cov is available
|
||||
if hash lcov && grep -q '#define SPDK_CONFIG_COVERAGE 1' config.h; then
|
||||
cov_avail="yes"
|
||||
@ -105,5 +116,9 @@ if [ "$cov_avail" = "yes" ]; then
|
||||
else
|
||||
echo "WARN: lcov not installed or SPDK built without coverage!"
|
||||
fi
|
||||
if grep -q '#undef SPDK_CONFIG_ASAN' config.h && [ "$valgrind" = "" ]; then
|
||||
echo "WARN: neither valgrind nor ASAN is enabled!"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo
|
||||
|
Loading…
Reference in New Issue
Block a user