2019-05-06 09:36:15 +00:00
|
|
|
function xtrace_disable() {
|
2019-12-13 16:12:58 +00:00
|
|
|
if [ "$XTRACE_DISABLED" != "yes" ]; then
|
|
|
|
PREV_BASH_OPTS="$-"
|
|
|
|
if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then
|
|
|
|
XTRACE_DISABLED="yes"
|
|
|
|
fi
|
|
|
|
set +x
|
2019-12-30 19:19:46 +00:00
|
|
|
elif [ -z $XTRACE_NESTING_LEVEL ]; then
|
|
|
|
XTRACE_NESTING_LEVEL=1
|
|
|
|
else
|
|
|
|
XTRACE_NESTING_LEVEL=$((++XTRACE_NESTING_LEVEL))
|
2019-12-13 16:12:58 +00:00
|
|
|
fi
|
2019-05-06 09:36:15 +00:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:09:51 +00:00
|
|
|
xtrace_disable
|
|
|
|
set -e
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
2019-05-06 10:03:53 +00:00
|
|
|
# Dummy function to be called after restoring xtrace just so that it appears in the
|
|
|
|
# xtrace log. This way we can consistently track when xtrace is enabled/disabled.
|
|
|
|
function xtrace_enable() {
|
|
|
|
# We have to do something inside a function in bash, and calling any command
|
|
|
|
# (even `:`) will produce an xtrace entry, so we just define another function.
|
|
|
|
function xtrace_dummy() { :; }
|
|
|
|
}
|
|
|
|
|
2019-05-13 14:09:51 +00:00
|
|
|
# Keep it as alias to avoid xtrace_enable backtrace always pointing to xtrace_restore.
|
|
|
|
# xtrace_enable will appear as called directly from the user script, from the same line
|
|
|
|
# that "called" xtrace_restore.
|
2019-12-30 19:19:46 +00:00
|
|
|
alias xtrace_restore=\
|
|
|
|
'if [ -z $XTRACE_NESTING_LEVEL ]; then
|
|
|
|
if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then
|
|
|
|
XTRACE_DISABLED="no"; PREV_BASH_OPTS=""; set -x; xtrace_enable;
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
XTRACE_NESTING_LEVEL=$((--XTRACE_NESTING_LEVEL));
|
|
|
|
if [ $XTRACE_NESTING_LEVEL -eq "0" ]; then
|
|
|
|
unset XTRACE_NESTING_LEVEL
|
|
|
|
fi
|
|
|
|
fi'
|
2017-11-15 18:43:15 +00:00
|
|
|
|
2018-01-04 17:08:03 +00:00
|
|
|
: ${RUN_NIGHTLY:=0}
|
|
|
|
export RUN_NIGHTLY
|
2016-03-23 20:34:31 +00:00
|
|
|
|
2018-03-15 18:40:13 +00:00
|
|
|
: ${RUN_NIGHTLY_FAILING:=0}
|
|
|
|
export RUN_NIGHTLY_FAILING
|
|
|
|
|
2017-05-02 00:34:15 +00:00
|
|
|
# Set defaults for missing test config options
|
2019-02-07 12:22:12 +00:00
|
|
|
: ${SPDK_BUILD_DOC=0}; export SPDK_BUILD_DOC
|
2019-11-07 09:06:41 +00:00
|
|
|
: ${SPDK_BUILD_PACKAGE=0}; export SPDK_BUILD_PACKAGE
|
2019-02-07 12:22:12 +00:00
|
|
|
: ${SPDK_BUILD_SHARED_OBJECT=0}; export SPDK_BUILD_SHARED_OBJECT
|
|
|
|
: ${SPDK_RUN_VALGRIND=0}; export SPDK_RUN_VALGRIND
|
|
|
|
: ${SPDK_RUN_FUNCTIONAL_TEST=0}; export SPDK_RUN_FUNCTIONAL_TEST
|
|
|
|
: ${SPDK_TEST_UNITTEST=0}; export SPDK_TEST_UNITTEST
|
2019-12-19 15:57:30 +00:00
|
|
|
: ${SPDK_TEST_AUTOBUILD=0}; export SPDK_TEST_AUTOBUILD
|
2019-02-07 12:22:12 +00:00
|
|
|
: ${SPDK_TEST_ISAL=0}; export SPDK_TEST_ISAL
|
|
|
|
: ${SPDK_TEST_ISCSI=0}; export SPDK_TEST_ISCSI
|
|
|
|
: ${SPDK_TEST_ISCSI_INITIATOR=0}; export SPDK_TEST_ISCSI_INITIATOR
|
|
|
|
: ${SPDK_TEST_NVME=0}; export SPDK_TEST_NVME
|
|
|
|
: ${SPDK_TEST_NVME_CLI=0}; export SPDK_TEST_NVME_CLI
|
2019-10-24 18:11:51 +00:00
|
|
|
: ${SPDK_TEST_NVME_CUSE=0}; export SPDK_TEST_NVME_CUSE
|
2019-02-07 12:22:12 +00:00
|
|
|
: ${SPDK_TEST_NVMF=0}; export SPDK_TEST_NVMF
|
2019-07-08 01:19:56 +00:00
|
|
|
: ${SPDK_TEST_NVMF_TRANSPORT="rdma"}; export SPDK_TEST_NVMF_TRANSPORT
|
2019-02-07 12:22:12 +00:00
|
|
|
: ${SPDK_TEST_RBD=0}; export SPDK_TEST_RBD
|
|
|
|
: ${SPDK_TEST_VHOST=0}; export SPDK_TEST_VHOST
|
|
|
|
: ${SPDK_TEST_BLOCKDEV=0}; export SPDK_TEST_BLOCKDEV
|
|
|
|
: ${SPDK_TEST_IOAT=0}; export SPDK_TEST_IOAT
|
|
|
|
: ${SPDK_TEST_EVENT=0}; export SPDK_TEST_EVENT
|
|
|
|
: ${SPDK_TEST_BLOBFS=0}; export SPDK_TEST_BLOBFS
|
|
|
|
: ${SPDK_TEST_VHOST_INIT=0}; export SPDK_TEST_VHOST_INIT
|
|
|
|
: ${SPDK_TEST_PMDK=0}; export SPDK_TEST_PMDK
|
|
|
|
: ${SPDK_TEST_LVOL=0}; export SPDK_TEST_LVOL
|
|
|
|
: ${SPDK_TEST_JSON=0}; export SPDK_TEST_JSON
|
|
|
|
: ${SPDK_TEST_REDUCE=0}; export SPDK_TEST_REDUCE
|
2018-09-26 07:57:32 +00:00
|
|
|
: ${SPDK_TEST_VPP=0}; export SPDK_TEST_VPP
|
2019-02-07 12:22:12 +00:00
|
|
|
: ${SPDK_RUN_ASAN=0}; export SPDK_RUN_ASAN
|
|
|
|
: ${SPDK_RUN_UBSAN=0}; export SPDK_RUN_UBSAN
|
|
|
|
: ${SPDK_RUN_INSTALLED_DPDK=0}; export SPDK_RUN_INSTALLED_DPDK
|
2019-05-15 22:23:36 +00:00
|
|
|
: ${SPDK_RUN_NON_ROOT=0}; export SPDK_RUN_NON_ROOT
|
2019-02-07 12:22:12 +00:00
|
|
|
: ${SPDK_TEST_CRYPTO=0}; export SPDK_TEST_CRYPTO
|
2018-10-29 12:17:34 +00:00
|
|
|
: ${SPDK_TEST_FTL=0}; export SPDK_TEST_FTL
|
2019-02-07 12:22:12 +00:00
|
|
|
: ${SPDK_TEST_OCF=0}; export SPDK_TEST_OCF
|
2019-01-29 09:54:46 +00:00
|
|
|
: ${SPDK_TEST_FTL_EXTENDED=0}; export SPDK_TEST_FTL_EXTENDED
|
2019-06-27 14:49:26 +00:00
|
|
|
: ${SPDK_TEST_VMD=0}; export SPDK_TEST_VMD
|
2019-10-22 15:12:35 +00:00
|
|
|
: ${SPDK_TEST_OPAL=0}; export SPDK_TEST_OPAL
|
2019-05-09 10:50:26 +00:00
|
|
|
: ${SPDK_AUTOTEST_X=true}; export SPDK_AUTOTEST_X
|
2017-05-02 00:34:15 +00:00
|
|
|
|
2019-05-21 08:31:17 +00:00
|
|
|
# Export PYTHONPATH with addition of RPC framework. New scripts can be created
|
|
|
|
# specific use cases for tests.
|
|
|
|
export PYTHONPATH=$PYTHONPATH:$rootdir/scripts
|
|
|
|
|
2019-09-30 11:08:39 +00:00
|
|
|
# Don't create Python .pyc files. When running with sudo these will be
|
|
|
|
# created with root ownership and can cause problems when cleaning the repository.
|
|
|
|
export PYTHONDONTWRITEBYTECODE=1
|
|
|
|
|
2019-05-22 23:26:52 +00:00
|
|
|
# Export flag to skip the known bug that exists in librados
|
|
|
|
# Bug is reported on ceph bug tracker with number 24078
|
|
|
|
export ASAN_OPTIONS=new_delete_type_mismatch=0
|
|
|
|
export UBSAN_OPTIONS='halt_on_error=1:print_stacktrace=1:abort_on_error=1'
|
|
|
|
|
2019-06-03 12:32:57 +00:00
|
|
|
# Export LeakSanitizer option to use suppression file in order to prevent false positives
|
|
|
|
# and known leaks in external executables or libraries from showing up.
|
|
|
|
asan_suppression_file="/var/tmp/asan_suppression_file"
|
|
|
|
sudo rm -rf "$asan_suppression_file"
|
2019-11-18 11:32:48 +00:00
|
|
|
cat << EOL >> "$asan_suppression_file"
|
2019-06-03 12:32:57 +00:00
|
|
|
# ASAN has some bugs around thread_local variables. We have a destructor in place
|
|
|
|
# to free the thread contexts, but ASAN complains about the leak before those
|
|
|
|
# destructors have a chance to run. So suppress this one specific leak using
|
|
|
|
# LSAN_OPTIONS.
|
2019-11-18 11:32:48 +00:00
|
|
|
leak:spdk_fs_alloc_thread_ctx
|
2019-06-03 12:32:57 +00:00
|
|
|
|
2019-05-30 07:29:06 +00:00
|
|
|
# Suppress known leaks in fio project
|
2019-11-18 11:32:48 +00:00
|
|
|
leak:/usr/src/fio/parse.c
|
|
|
|
leak:/usr/src/fio/iolog.c
|
|
|
|
leak:/usr/src/fio/init.c
|
|
|
|
leak:fio_memalign
|
|
|
|
leak:spdk_fio_io_u_init
|
2019-05-30 07:29:06 +00:00
|
|
|
|
2019-06-04 07:29:59 +00:00
|
|
|
# Suppress leaks in libiscsi
|
2019-11-18 11:32:48 +00:00
|
|
|
leak:libiscsi.so
|
|
|
|
EOL
|
2019-06-04 07:29:59 +00:00
|
|
|
|
2019-11-19 15:00:51 +00:00
|
|
|
# Suppress leaks in libfuse3
|
|
|
|
echo "leak:libfuse3.so" >> "$asan_suppression_file"
|
|
|
|
|
2019-06-03 12:32:57 +00:00
|
|
|
export LSAN_OPTIONS=suppressions="$asan_suppression_file"
|
|
|
|
|
2019-05-22 23:26:52 +00:00
|
|
|
export DEFAULT_RPC_ADDR="/var/tmp/spdk.sock"
|
|
|
|
|
2018-06-22 09:16:10 +00:00
|
|
|
if [ -z "$DEPENDENCY_DIR" ]; then
|
|
|
|
export DEPENDENCY_DIR=/home/sys_sgsw
|
|
|
|
else
|
|
|
|
export DEPENDENCY_DIR
|
|
|
|
fi
|
|
|
|
|
2017-07-11 16:56:52 +00:00
|
|
|
# pass our valgrind desire on to unittest.sh
|
|
|
|
if [ $SPDK_RUN_VALGRIND -eq 0 ]; then
|
|
|
|
export valgrind=''
|
|
|
|
fi
|
|
|
|
|
2019-05-22 23:26:52 +00:00
|
|
|
if [ "$(uname -s)" = "Linux" ]; then
|
2019-09-03 20:40:14 +00:00
|
|
|
MAKE="make"
|
2019-05-22 23:26:52 +00:00
|
|
|
MAKEFLAGS=${MAKEFLAGS:--j$(nproc)}
|
|
|
|
DPDK_LINUX_DIR=/usr/share/dpdk/x86_64-default-linuxapp-gcc
|
|
|
|
if [ -d $DPDK_LINUX_DIR ] && [ $SPDK_RUN_INSTALLED_DPDK -eq 1 ]; then
|
|
|
|
WITH_DPDK_DIR=$DPDK_LINUX_DIR
|
|
|
|
fi
|
|
|
|
# Override the default HUGEMEM in scripts/setup.sh to allocate 8GB in hugepages.
|
|
|
|
export HUGEMEM=8192
|
|
|
|
elif [ "$(uname -s)" = "FreeBSD" ]; then
|
2019-09-03 20:40:14 +00:00
|
|
|
MAKE="gmake"
|
2019-07-04 12:52:35 +00:00
|
|
|
MAKEFLAGS=${MAKEFLAGS:--j$(sysctl -a | grep -E -i 'hw.ncpu' | awk '{print $2}')}
|
2019-05-22 23:26:52 +00:00
|
|
|
DPDK_FREEBSD_DIR=/usr/local/share/dpdk/x86_64-native-bsdapp-clang
|
|
|
|
if [ -d $DPDK_FREEBSD_DIR ] && [ $SPDK_RUN_INSTALLED_DPDK -eq 1 ]; then
|
|
|
|
WITH_DPDK_DIR=$DPDK_FREEBSD_DIR
|
|
|
|
fi
|
|
|
|
# FreeBSD runs a much more limited set of tests, so keep the default 2GB.
|
|
|
|
export HUGEMEM=2048
|
|
|
|
else
|
|
|
|
echo "Unknown OS \"$(uname -s)\""
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-03-30 19:06:49 +00:00
|
|
|
config_params='--enable-debug --enable-werror'
|
2015-10-22 18:26:21 +00:00
|
|
|
|
2018-07-18 19:08:17 +00:00
|
|
|
if echo -e "#include <libunwind.h>\nint main(int argc, char *argv[]) {return 0;}\n" | \
|
|
|
|
gcc -o /dev/null -lunwind -x c - 2>/dev/null; then
|
2018-09-10 14:08:25 +00:00
|
|
|
config_params+=' --enable-log-bt'
|
2018-07-18 19:08:17 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
# for options with dependencies but no test flag, set them here
|
|
|
|
if [ -f /usr/include/infiniband/verbs.h ]; then
|
|
|
|
config_params+=' --with-rdma'
|
2018-11-02 00:00:24 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ -d /usr/src/fio ]; then
|
|
|
|
config_params+=' --with-fio=/usr/src/fio'
|
2019-05-09 07:39:39 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ -d ${DEPENDENCY_DIR}/vtune_codes ]; then
|
|
|
|
config_params+=' --with-vtune='${DEPENDENCY_DIR}'/vtune_codes'
|
2019-05-09 07:39:39 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ -d /usr/include/iscsi ]; then
|
2019-06-12 07:48:32 +00:00
|
|
|
libiscsi_version=$(grep LIBISCSI_API_VERSION /usr/include/iscsi/iscsi.h | head -1 | awk '{print $3}' | awk -F '(' '{print $2}' | awk -F ')' '{print $1}')
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ $libiscsi_version -ge 20150621 ]; then
|
|
|
|
config_params+=' --with-iscsi-initiator'
|
|
|
|
fi
|
2019-05-09 08:54:40 +00:00
|
|
|
fi
|
2015-10-03 00:11:56 +00:00
|
|
|
|
2019-10-24 18:11:51 +00:00
|
|
|
if [ $SPDK_TEST_NVME_CUSE -eq 1 ]; then
|
|
|
|
config_params+=' --with-nvme-cuse'
|
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
# for options with both dependencies and a test flag, set them here
|
|
|
|
if [ -f /usr/include/libpmemblk.h ] && [ $SPDK_TEST_PMDK -eq 1 ]; then
|
|
|
|
config_params+=' --with-pmdk'
|
2017-05-08 22:07:13 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ -f /usr/include/libpmem.h ] && [ $SPDK_TEST_REDUCE -eq 1 ]; then
|
|
|
|
if [ $SPDK_TEST_ISAL -eq 1 ]; then
|
|
|
|
config_params+=' --with-reduce'
|
|
|
|
else
|
|
|
|
echo "reduce not enabled because isal is not enabled."
|
|
|
|
fi
|
2016-06-06 21:44:30 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ -d /usr/include/rbd ] && [ -d /usr/include/rados ] && [ $SPDK_TEST_RBD -eq 1 ]; then
|
2020-01-08 17:19:49 +00:00
|
|
|
config_params+=' --with-rbd'
|
2017-09-29 08:49:51 +00:00
|
|
|
fi
|
|
|
|
|
2018-09-26 07:57:32 +00:00
|
|
|
if [ $SPDK_TEST_VPP -eq 1 ]; then
|
2019-06-19 14:14:50 +00:00
|
|
|
VPP_PATH="/usr/local/src/vpp-19.04/build-root/install-vpp_debug-native/vpp/"
|
2018-09-26 07:57:32 +00:00
|
|
|
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${VPP_PATH}/lib/
|
|
|
|
export PATH=${PATH}:${VPP_PATH}/bin/
|
|
|
|
config_params+=" --with-vpp=${VPP_PATH}"
|
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
# for options with no required dependencies, just test flags, set them here
|
|
|
|
if [ $SPDK_TEST_CRYPTO -eq 1 ]; then
|
|
|
|
config_params+=' --with-crypto'
|
2018-09-21 14:37:54 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ $SPDK_TEST_OCF -eq 1 ]; then
|
|
|
|
config_params+=" --with-ocf"
|
2017-03-30 19:06:49 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ $SPDK_RUN_UBSAN -eq 1 ]; then
|
|
|
|
config_params+=' --enable-ubsan'
|
2017-12-20 20:20:11 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ $SPDK_RUN_ASAN -eq 1 ]; then
|
|
|
|
config_params+=' --enable-asan'
|
2017-03-30 19:06:49 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
if [ "$(uname -s)" = "Linux" ]; then
|
|
|
|
config_params+=' --enable-coverage'
|
2018-07-10 16:32:30 +00:00
|
|
|
fi
|
|
|
|
|
2019-01-21 09:05:59 +00:00
|
|
|
if [ $SPDK_TEST_ISAL -eq 0 ]; then
|
|
|
|
config_params+=' --without-isal'
|
|
|
|
fi
|
|
|
|
|
2019-10-08 12:28:49 +00:00
|
|
|
if [ $SPDK_TEST_BLOBFS -eq 1 ]; then
|
|
|
|
if [[ -d /usr/include/fuse3 ]] && [[ -d /usr/local/include/fuse3 ]]; then
|
|
|
|
config_params+=' --with-fuse'
|
|
|
|
else
|
|
|
|
echo "FUSE not enabled because libfuse3 is not installed."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-05-20 22:29:45 +00:00
|
|
|
# By default, --with-dpdk is not set meaning the SPDK build will use the DPDK submodule.
|
|
|
|
# If a DPDK installation is found in a well-known location though, WITH_DPDK_DIR will be
|
|
|
|
# set which will override the default and use that DPDK installation instead.
|
2019-07-25 13:01:09 +00:00
|
|
|
if [ -n "$WITH_DPDK_DIR" ]; then
|
2019-05-20 22:29:45 +00:00
|
|
|
config_params+=" --with-dpdk=$WITH_DPDK_DIR"
|
2018-10-15 20:46:41 +00:00
|
|
|
fi
|
|
|
|
|
2017-03-30 19:06:49 +00:00
|
|
|
export config_params
|
|
|
|
|
2015-10-09 00:22:39 +00:00
|
|
|
if [ -z "$output_dir" ]; then
|
|
|
|
if [ -z "$rootdir" ] || [ ! -d "$rootdir/../output" ]; then
|
|
|
|
output_dir=.
|
|
|
|
else
|
|
|
|
output_dir=$rootdir/../output
|
|
|
|
fi
|
|
|
|
export output_dir
|
2015-09-21 15:52:41 +00:00
|
|
|
fi
|
|
|
|
|
2019-05-23 14:54:25 +00:00
|
|
|
TEST_MODE=
|
|
|
|
for i in "$@"; do
|
|
|
|
case "$i" in
|
|
|
|
--iso)
|
|
|
|
TEST_MODE=iso
|
|
|
|
;;
|
|
|
|
--transport=*)
|
|
|
|
TEST_TRANSPORT="${i#*=}"
|
|
|
|
;;
|
|
|
|
--sock=*)
|
|
|
|
TEST_SOCK="${i#*=}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
function timing() {
|
|
|
|
direction="$1"
|
|
|
|
testname="$2"
|
|
|
|
|
|
|
|
now=$(date +%s)
|
|
|
|
|
|
|
|
if [ "$direction" = "enter" ]; then
|
2015-10-08 19:40:44 +00:00
|
|
|
export timing_stack="${timing_stack};${now}"
|
|
|
|
export test_stack="${test_stack};${testname}"
|
2015-09-21 15:52:41 +00:00
|
|
|
else
|
2019-05-16 05:31:51 +00:00
|
|
|
touch "$output_dir/timing.txt"
|
2015-10-08 19:40:44 +00:00
|
|
|
child_time=$(grep "^${test_stack:1};" $output_dir/timing.txt | awk '{s+=$2} END {print s}')
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2015-10-08 19:40:44 +00:00
|
|
|
start_time=$(echo "$timing_stack" | sed -e 's@^.*;@@')
|
|
|
|
timing_stack=$(echo "$timing_stack" | sed -e 's@;[^;]*$@@')
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2015-10-08 19:40:44 +00:00
|
|
|
elapsed=$((now - start_time - child_time))
|
|
|
|
echo "${test_stack:1} $elapsed" >> $output_dir/timing.txt
|
|
|
|
|
|
|
|
test_stack=$(echo "$test_stack" | sed -e 's@;[^;]*$@@')
|
2015-09-21 15:52:41 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function timing_enter() {
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_disable
|
2015-09-21 15:52:41 +00:00
|
|
|
timing "enter" "$1"
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_restore
|
2015-09-21 15:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function timing_exit() {
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_disable
|
2015-09-21 15:52:41 +00:00
|
|
|
timing "exit" "$1"
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_restore
|
2015-09-21 15:52:41 +00:00
|
|
|
}
|
|
|
|
|
2015-10-08 19:40:44 +00:00
|
|
|
function timing_finish() {
|
|
|
|
flamegraph='/usr/local/FlameGraph/flamegraph.pl'
|
|
|
|
if [ -x "$flamegraph" ]; then
|
|
|
|
"$flamegraph" \
|
|
|
|
--title 'Build Timing' \
|
|
|
|
--nametype 'Step:' \
|
|
|
|
--countname seconds \
|
|
|
|
$output_dir/timing.txt \
|
|
|
|
>$output_dir/timing.svg
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-12-18 21:20:41 +00:00
|
|
|
function create_test_list() {
|
2019-12-05 23:21:48 +00:00
|
|
|
grep -rshI --exclude="autotest_common.sh" \
|
|
|
|
--exclude="$rootdir/test/common/autotest_common.sh" \
|
|
|
|
-e "run_test " $rootdir | grep -v "#" \
|
|
|
|
| sed 's/^.*run_test/run_test/' | awk '{print $2}' | \
|
|
|
|
sed 's/\"//g' | sort > $output_dir/all_tests.txt || true
|
2017-12-18 21:20:41 +00:00
|
|
|
}
|
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
function process_core() {
|
|
|
|
ret=0
|
2019-10-08 10:22:47 +00:00
|
|
|
while IFS= read -r -d '' core;
|
|
|
|
do
|
2015-12-02 20:10:54 +00:00
|
|
|
exe=$(eu-readelf -n "$core" | grep psargs | sed "s/.*psargs: \([^ \'\" ]*\).*/\1/")
|
2018-08-02 11:34:59 +00:00
|
|
|
if [[ ! -f "$exe" ]]; then
|
|
|
|
exe=$(eu-readelf -n "$core" | grep -oP -m1 "$exe.+")
|
|
|
|
fi
|
2015-09-21 15:52:41 +00:00
|
|
|
echo "exe for $core is $exe"
|
2019-07-25 13:01:09 +00:00
|
|
|
if [[ -n "$exe" ]]; then
|
2019-05-06 07:05:31 +00:00
|
|
|
if hash gdb &>/dev/null; then
|
2017-06-06 23:13:29 +00:00
|
|
|
gdb -batch -ex "thread apply all bt full" $exe $core
|
2015-09-21 15:52:41 +00:00
|
|
|
fi
|
|
|
|
cp $exe $output_dir
|
|
|
|
fi
|
|
|
|
mv $core $output_dir
|
|
|
|
chmod a+r $output_dir/$core
|
|
|
|
ret=1
|
2019-10-08 10:22:47 +00:00
|
|
|
done < <(find . -type f \( -name 'core\.?[0-9]*' -o -name '*.core' \) -print0)
|
2015-09-21 15:52:41 +00:00
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
2018-09-10 07:32:09 +00:00
|
|
|
function process_shm() {
|
|
|
|
type=$1
|
|
|
|
id=$2
|
|
|
|
if [ "$type" = "--pid" ]; then
|
|
|
|
id="pid${id}"
|
|
|
|
elif [ "$type" = "--id" ]; then
|
|
|
|
id="${id}"
|
|
|
|
else
|
|
|
|
echo "Please specify to search for pid or shared memory id."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
shm_files=$(find /dev/shm -name "*.${id}" -printf "%f\n")
|
|
|
|
|
|
|
|
if [[ -z $shm_files ]]; then
|
|
|
|
echo "SHM File for specified PID or shared memory id: ${id} not found!"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
for n in $shm_files; do
|
|
|
|
tar -C /dev/shm/ -cvzf $output_dir/${n}_shm.tar.gz ${n}
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
function waitforlisten() {
|
2017-11-09 23:33:29 +00:00
|
|
|
# $1 = process pid
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-11-09 14:05:23 +00:00
|
|
|
local rpc_addr="${2:-$DEFAULT_RPC_ADDR}"
|
2017-11-20 17:54:53 +00:00
|
|
|
|
|
|
|
echo "Waiting for process to start up and listen on UNIX domain socket $rpc_addr..."
|
2017-11-09 23:33:29 +00:00
|
|
|
# turn off trace for this loop
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_disable
|
2018-11-09 14:05:23 +00:00
|
|
|
local ret=0
|
2018-11-13 19:48:17 +00:00
|
|
|
local i
|
|
|
|
for (( i = 40; i != 0; i-- )); do
|
2017-11-09 23:33:29 +00:00
|
|
|
# if the process is no longer running, then exit the script
|
|
|
|
# since it means the application crashed
|
|
|
|
if ! kill -s 0 $1; then
|
2018-11-13 19:48:17 +00:00
|
|
|
echo "ERROR: process (pid: $1) is no longer running"
|
2018-11-09 14:05:23 +00:00
|
|
|
ret=1
|
|
|
|
break
|
2017-11-09 23:33:29 +00:00
|
|
|
fi
|
2018-04-25 16:16:08 +00:00
|
|
|
|
2019-06-11 06:53:10 +00:00
|
|
|
if $rootdir/scripts/rpc.py -t 1 -s "$rpc_addr" rpc_get_methods &>/dev/null; then
|
|
|
|
break
|
2018-04-25 16:16:08 +00:00
|
|
|
fi
|
|
|
|
|
2018-11-13 19:48:17 +00:00
|
|
|
sleep 0.5
|
2016-08-03 21:37:16 +00:00
|
|
|
done
|
2018-11-09 14:05:23 +00:00
|
|
|
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_restore
|
2018-11-13 19:48:17 +00:00
|
|
|
if (( i == 0 )); then
|
|
|
|
echo "ERROR: timeout while waiting for process (pid: $1) to start listening on '$rpc_addr'"
|
|
|
|
ret=1
|
2018-11-09 14:05:23 +00:00
|
|
|
fi
|
2018-11-13 19:48:17 +00:00
|
|
|
return $ret
|
2016-08-03 21:37:16 +00:00
|
|
|
}
|
|
|
|
|
2017-11-03 18:22:05 +00:00
|
|
|
function waitfornbd() {
|
2018-11-20 11:20:35 +00:00
|
|
|
local nbd_name=$1
|
|
|
|
local i
|
2017-07-06 02:41:57 +00:00
|
|
|
|
2017-11-03 18:22:05 +00:00
|
|
|
for ((i=1; i<=20; i++)); do
|
|
|
|
if grep -q -w $nbd_name /proc/partitions; then
|
2017-11-06 18:33:48 +00:00
|
|
|
break
|
|
|
|
else
|
|
|
|
sleep 0.1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# The nbd device is now recognized as a block device, but there can be
|
|
|
|
# a small delay before we can start I/O to that block device. So loop
|
|
|
|
# here trying to read the first block of the nbd block device to a temp
|
|
|
|
# file. Note that dd returns success when reading an empty file, so we
|
|
|
|
# need to check the size of the output file instead.
|
|
|
|
for ((i=1; i<=20; i++)); do
|
|
|
|
dd if=/dev/$nbd_name of=/tmp/nbdtest bs=4096 count=1 iflag=direct
|
2019-06-12 07:48:32 +00:00
|
|
|
size=$(stat -c %s /tmp/nbdtest)
|
2017-11-06 18:33:48 +00:00
|
|
|
rm -f /tmp/nbdtest
|
|
|
|
if [ "$size" != "0" ]; then
|
2017-07-06 02:41:57 +00:00
|
|
|
return 0
|
|
|
|
else
|
|
|
|
sleep 0.1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2019-05-28 21:51:56 +00:00
|
|
|
function waitforbdev() {
|
|
|
|
local bdev_name=$1
|
|
|
|
local i
|
|
|
|
|
|
|
|
for ((i=1; i<=20; i++)); do
|
2019-09-26 18:43:14 +00:00
|
|
|
if $rpc_py bdev_get_bdevs | jq -r '.[] .name' | grep -qw $bdev_name; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if $rpc_py bdev_get_bdevs | jq -r '.[] .aliases' | grep -qw $bdev_name; then
|
2019-05-28 21:51:56 +00:00
|
|
|
return 0
|
|
|
|
fi
|
2019-09-26 18:43:14 +00:00
|
|
|
|
|
|
|
sleep 0.1
|
2019-05-28 21:51:56 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2016-06-07 15:49:44 +00:00
|
|
|
function killprocess() {
|
|
|
|
# $1 = process pid
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-09-12 07:58:28 +00:00
|
|
|
if kill -0 $1; then
|
2019-05-15 22:23:36 +00:00
|
|
|
if [ "$(ps --no-headers -o comm= $1)" = "sudo" ]; then
|
|
|
|
# kill the child process, which is the actual app
|
|
|
|
# (assume $1 has just one child)
|
2019-10-24 13:58:04 +00:00
|
|
|
local child
|
|
|
|
child="$(pgrep -P $1)"
|
2019-05-15 22:23:36 +00:00
|
|
|
echo "killing process with pid $child"
|
|
|
|
kill $child
|
|
|
|
else
|
|
|
|
echo "killing process with pid $1"
|
|
|
|
kill $1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# wait for the process regardless if its the dummy sudo one
|
|
|
|
# or the actual app - it should terminate anyway
|
2018-09-12 07:58:28 +00:00
|
|
|
wait $1
|
2019-11-29 21:18:36 +00:00
|
|
|
else
|
|
|
|
# the process is not there anymore
|
|
|
|
echo "Process with pid $1 is not found"
|
|
|
|
exit 1
|
2018-09-12 07:58:28 +00:00
|
|
|
fi
|
2016-06-07 15:49:44 +00:00
|
|
|
}
|
2016-07-21 22:54:23 +00:00
|
|
|
|
2016-08-03 21:37:16 +00:00
|
|
|
function iscsicleanup() {
|
|
|
|
echo "Cleaning up iSCSI connection"
|
|
|
|
iscsiadm -m node --logout || true
|
|
|
|
iscsiadm -m node -o delete || true
|
|
|
|
}
|
|
|
|
|
|
|
|
function stop_iscsi_service() {
|
|
|
|
if cat /etc/*-release | grep Ubuntu; then
|
|
|
|
service open-iscsi stop
|
|
|
|
else
|
|
|
|
service iscsid stop
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function start_iscsi_service() {
|
|
|
|
if cat /etc/*-release | grep Ubuntu; then
|
|
|
|
service open-iscsi start
|
|
|
|
else
|
|
|
|
service iscsid start
|
|
|
|
fi
|
|
|
|
}
|
2016-10-06 16:57:09 +00:00
|
|
|
|
2016-11-16 18:18:40 +00:00
|
|
|
function rbd_setup() {
|
2018-04-16 13:12:23 +00:00
|
|
|
# $1 = monitor ip address
|
2018-04-25 16:16:08 +00:00
|
|
|
# $2 = name of the namespace
|
2018-04-16 13:12:23 +00:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "No monitor IP address provided for ceph"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-04-25 16:16:08 +00:00
|
|
|
if [ -n "$2" ]; then
|
|
|
|
if ip netns list | grep "$2"; then
|
|
|
|
NS_CMD="ip netns exec $2"
|
|
|
|
else
|
|
|
|
echo "No namespace $2 exists"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2018-04-16 13:12:23 +00:00
|
|
|
|
2017-08-09 00:21:24 +00:00
|
|
|
if hash ceph; then
|
2018-03-28 21:47:11 +00:00
|
|
|
export PG_NUM=128
|
2017-07-19 23:22:38 +00:00
|
|
|
export RBD_POOL=rbd
|
|
|
|
export RBD_NAME=foo
|
2018-12-18 09:58:17 +00:00
|
|
|
$NS_CMD $rootdir/scripts/ceph/stop.sh || true
|
2018-04-25 16:16:08 +00:00
|
|
|
$NS_CMD $rootdir/scripts/ceph/start.sh $1
|
2018-03-28 21:47:11 +00:00
|
|
|
|
2018-04-25 16:16:08 +00:00
|
|
|
$NS_CMD ceph osd pool create $RBD_POOL $PG_NUM || true
|
|
|
|
$NS_CMD rbd create $RBD_NAME --size 1000
|
2016-11-16 18:18:40 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function rbd_cleanup() {
|
2017-08-09 00:21:24 +00:00
|
|
|
if hash ceph; then
|
2018-02-27 17:30:22 +00:00
|
|
|
$rootdir/scripts/ceph/stop.sh || true
|
2019-03-28 19:12:42 +00:00
|
|
|
rm -f /var/tmp/ceph_raw.img
|
2016-11-16 18:18:40 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-05-25 03:58:35 +00:00
|
|
|
function start_stub() {
|
2018-04-17 00:34:01 +00:00
|
|
|
# Disable ASLR for multi-process testing. SPDK does support using DPDK multi-process,
|
2018-06-21 08:15:17 +00:00
|
|
|
# but ASLR can still be unreliable in some cases.
|
|
|
|
# We will reenable it again after multi-process testing is complete in kill_stub()
|
2018-04-17 00:34:01 +00:00
|
|
|
echo 0 > /proc/sys/kernel/randomize_va_space
|
2017-05-25 03:58:35 +00:00
|
|
|
$rootdir/test/app/stub/stub $1 &
|
|
|
|
stubpid=$!
|
|
|
|
echo Waiting for stub to ready for secondary processes...
|
2017-05-25 22:26:18 +00:00
|
|
|
while ! [ -e /var/run/spdk_stub0 ]; do
|
|
|
|
sleep 1s
|
2017-05-25 03:58:35 +00:00
|
|
|
done
|
|
|
|
echo done.
|
|
|
|
}
|
|
|
|
|
|
|
|
function kill_stub() {
|
2019-05-02 08:18:13 +00:00
|
|
|
kill $1 $stubpid
|
2017-06-30 14:48:53 +00:00
|
|
|
wait $stubpid
|
2017-06-22 06:30:02 +00:00
|
|
|
rm -f /var/run/spdk_stub0
|
2018-04-17 00:34:01 +00:00
|
|
|
# Re-enable ASLR now that we are done with multi-process testing
|
|
|
|
# Note: "1" enables ASLR w/o randomizing data segments, "2" adds data segment
|
|
|
|
# randomizing and is the default on all recent Linux kernels
|
|
|
|
echo 2 > /proc/sys/kernel/randomize_va_space
|
2017-05-25 03:58:35 +00:00
|
|
|
}
|
|
|
|
|
2016-10-06 16:57:09 +00:00
|
|
|
function run_test() {
|
2019-12-19 23:03:30 +00:00
|
|
|
if [ $# -le 1 ]; then
|
2019-12-04 20:05:32 +00:00
|
|
|
echo "Not enough parameters"
|
2019-12-19 23:03:30 +00:00
|
|
|
echo "usage: run_test test_name test_script [script_params]"
|
2019-12-04 20:05:32 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_disable
|
2019-12-04 19:39:14 +00:00
|
|
|
local test_name="$1"
|
|
|
|
shift
|
2019-12-04 20:47:50 +00:00
|
|
|
|
|
|
|
timing_enter $test_name
|
2016-10-06 16:57:09 +00:00
|
|
|
echo "************************************"
|
2019-12-19 23:03:30 +00:00
|
|
|
echo "START TEST $test_name"
|
2016-10-06 16:57:09 +00:00
|
|
|
echo "************************************"
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_restore
|
2016-12-07 02:21:23 +00:00
|
|
|
time "$@"
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_disable
|
2016-10-06 16:57:09 +00:00
|
|
|
echo "************************************"
|
2019-12-19 23:03:30 +00:00
|
|
|
echo "END TEST $test_name"
|
2016-10-06 16:57:09 +00:00
|
|
|
echo "************************************"
|
2019-12-04 20:47:50 +00:00
|
|
|
|
2019-12-05 23:21:48 +00:00
|
|
|
echo "$test_name" >> $output_dir/test_completions.txt
|
2019-12-04 20:47:50 +00:00
|
|
|
timing_exit $test_name
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_restore
|
2016-10-06 16:57:09 +00:00
|
|
|
}
|
2017-02-20 19:32:49 +00:00
|
|
|
|
|
|
|
function print_backtrace() {
|
2018-08-29 16:01:10 +00:00
|
|
|
# if errexit is not enabled, don't print a backtrace
|
|
|
|
[[ "$-" =~ e ]] || return 0
|
|
|
|
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_disable
|
2017-02-20 19:32:49 +00:00
|
|
|
echo "========== Backtrace start: =========="
|
|
|
|
echo ""
|
|
|
|
for i in $(seq 1 $((${#FUNCNAME[@]} - 1))); do
|
|
|
|
local func="${FUNCNAME[$i]}"
|
|
|
|
local line_nr="${BASH_LINENO[$((i - 1))]}"
|
2017-10-25 19:32:37 +00:00
|
|
|
local src="${BASH_SOURCE[$i]}"
|
2017-02-20 19:32:49 +00:00
|
|
|
echo "in $src:$line_nr -> $func()"
|
|
|
|
echo " ..."
|
2019-08-30 09:20:40 +00:00
|
|
|
nl -w 4 -ba -nln $src | grep -B 5 -A 5 "^${line_nr}[^0-9]" | \
|
2017-03-08 19:46:31 +00:00
|
|
|
sed "s/^/ /g" | sed "s/^ $line_nr /=> $line_nr /g"
|
2017-02-20 19:32:49 +00:00
|
|
|
echo " ..."
|
|
|
|
done
|
|
|
|
echo ""
|
|
|
|
echo "========== Backtrace end =========="
|
2019-05-06 09:36:15 +00:00
|
|
|
xtrace_restore
|
2017-02-20 19:32:49 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-07-17 07:45:46 +00:00
|
|
|
function part_dev_by_gpt () {
|
2018-02-01 18:36:49 +00:00
|
|
|
if [ $(uname -s) = Linux ] && hash sgdisk && modprobe nbd; then
|
2017-07-17 07:45:46 +00:00
|
|
|
conf=$1
|
|
|
|
devname=$2
|
|
|
|
rootdir=$3
|
2017-08-11 22:06:17 +00:00
|
|
|
operation=$4
|
2017-12-11 06:56:40 +00:00
|
|
|
local nbd_path=/dev/nbd0
|
|
|
|
local rpc_server=/var/tmp/spdk-gpt-bdevs.sock
|
2017-07-17 07:45:46 +00:00
|
|
|
|
|
|
|
if [ ! -e $conf ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2017-08-11 22:06:17 +00:00
|
|
|
if [ -z "$operation" ]; then
|
|
|
|
operation="create"
|
|
|
|
fi
|
|
|
|
|
2017-07-17 07:45:46 +00:00
|
|
|
cp $conf ${conf}.gpt
|
|
|
|
echo "[Gpt]" >> ${conf}.gpt
|
|
|
|
echo " Disable Yes" >> ${conf}.gpt
|
|
|
|
|
2017-12-11 06:56:40 +00:00
|
|
|
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 -c ${conf}.gpt &
|
2017-07-17 07:45:46 +00:00
|
|
|
nbd_pid=$!
|
|
|
|
echo "Process nbd pid: $nbd_pid"
|
2017-12-11 06:56:40 +00:00
|
|
|
waitforlisten $nbd_pid $rpc_server
|
|
|
|
|
2019-09-18 00:21:26 +00:00
|
|
|
# Start bdev as an nbd device
|
2018-11-20 11:20:35 +00:00
|
|
|
nbd_start_disks "$rpc_server" $devname $nbd_path
|
2017-12-11 06:56:40 +00:00
|
|
|
|
|
|
|
waitfornbd ${nbd_path:5}
|
2017-11-03 18:22:05 +00:00
|
|
|
|
|
|
|
if [ "$operation" = create ]; then
|
2017-12-11 06:56:40 +00:00
|
|
|
parted -s $nbd_path mklabel gpt mkpart first '0%' '50%' mkpart second '50%' '100%'
|
2017-11-29 16:18:30 +00:00
|
|
|
|
2017-11-03 18:22:05 +00:00
|
|
|
# change the GUID to SPDK GUID value
|
2019-08-16 16:45:58 +00:00
|
|
|
SPDK_GPT_GUID=$(grep SPDK_GPT_PART_TYPE_GUID $rootdir/module/bdev/gpt/gpt.h \
|
2017-11-29 16:18:30 +00:00
|
|
|
| awk -F "(" '{ print $2}' | sed 's/)//g' \
|
2019-06-12 07:48:32 +00:00
|
|
|
| awk -F ", " '{ print $1 "-" $2 "-" $3 "-" $4 "-" $5}' | sed 's/0x//g')
|
2017-12-11 06:56:40 +00:00
|
|
|
sgdisk -t 1:$SPDK_GPT_GUID $nbd_path
|
|
|
|
sgdisk -t 2:$SPDK_GPT_GUID $nbd_path
|
2017-11-03 18:22:05 +00:00
|
|
|
elif [ "$operation" = reset ]; then
|
|
|
|
# clear the partition table
|
2017-12-11 06:56:40 +00:00
|
|
|
dd if=/dev/zero of=$nbd_path bs=4096 count=8 oflag=direct
|
2017-07-17 07:45:46 +00:00
|
|
|
fi
|
2017-11-03 18:22:05 +00:00
|
|
|
|
2018-11-20 11:20:35 +00:00
|
|
|
nbd_stop_disks "$rpc_server" $nbd_path
|
2018-07-23 01:39:50 +00:00
|
|
|
|
2017-07-17 07:45:46 +00:00
|
|
|
killprocess $nbd_pid
|
|
|
|
rm -f ${conf}.gpt
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-07-20 14:11:47 +00:00
|
|
|
function discover_bdevs()
|
|
|
|
{
|
|
|
|
local rootdir=$1
|
|
|
|
local config_file=$2
|
2017-12-04 21:30:34 +00:00
|
|
|
local rpc_server=/var/tmp/spdk-discover-bdevs.sock
|
2017-07-20 14:11:47 +00:00
|
|
|
|
|
|
|
if [ ! -e $config_file ]; then
|
|
|
|
echo "Invalid Configuration File: $config_file"
|
2019-10-28 12:23:22 +00:00
|
|
|
return 1
|
2017-07-20 14:11:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Start the bdev service to query for the list of available
|
|
|
|
# bdevs.
|
2018-10-15 21:38:49 +00:00
|
|
|
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 \
|
2018-03-19 12:40:58 +00:00
|
|
|
-c $config_file &>/dev/null &
|
2017-07-20 14:11:47 +00:00
|
|
|
stubpid=$!
|
|
|
|
while ! [ -e /var/run/spdk_bdev0 ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
# Get all of the bdevs
|
2017-11-20 17:28:59 +00:00
|
|
|
if [ -z "$rpc_server" ]; then
|
2019-09-11 09:29:55 +00:00
|
|
|
$rootdir/scripts/rpc.py bdev_get_bdevs
|
2017-09-12 13:47:30 +00:00
|
|
|
else
|
2019-09-11 09:29:55 +00:00
|
|
|
$rootdir/scripts/rpc.py -s "$rpc_server" bdev_get_bdevs
|
2017-09-12 13:47:30 +00:00
|
|
|
fi
|
2017-07-20 14:11:47 +00:00
|
|
|
|
|
|
|
# Shut down the bdev service
|
|
|
|
kill $stubpid
|
|
|
|
wait $stubpid
|
|
|
|
rm -f /var/run/spdk_bdev0
|
|
|
|
}
|
|
|
|
|
2019-12-19 14:17:49 +00:00
|
|
|
function waitforserial()
|
|
|
|
{
|
|
|
|
local i=0
|
|
|
|
local nvme_device_counter=1
|
|
|
|
if [[ -n "$2" ]]; then
|
|
|
|
nvme_device_counter=$2
|
|
|
|
fi
|
|
|
|
|
|
|
|
while [ $(lsblk -l -o NAME,SERIAL | grep -c $1) -lt $nvme_device_counter ]; do
|
|
|
|
[ $i -lt 15 ] || break
|
|
|
|
i=$((i+1))
|
|
|
|
echo "Waiting for devices"
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $(lsblk -l -o NAME,SERIAL | grep -c $1) -lt $nvme_device_counter ]]; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
function waitforserial_disconnect()
|
|
|
|
{
|
|
|
|
local i=0
|
|
|
|
while lsblk -o NAME,SERIAL | grep -q -w $1; do
|
|
|
|
[ $i -lt 15 ] || break
|
|
|
|
i=$((i+1))
|
|
|
|
echo "Waiting for disconnect devices"
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
if lsblk -l -o NAME | grep -q -w $1; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2018-04-16 20:28:16 +00:00
|
|
|
function waitforblk()
|
|
|
|
{
|
|
|
|
local i=0
|
|
|
|
while ! lsblk -l -o NAME | grep -q -w $1; do
|
|
|
|
[ $i -lt 15 ] || break
|
2019-08-05 13:43:47 +00:00
|
|
|
i=$((i+1))
|
2018-04-16 20:28:16 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
if ! lsblk -l -o NAME | grep -q -w $1; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-02-04 22:23:06 +00:00
|
|
|
function waitforblk_disconnect()
|
|
|
|
{
|
|
|
|
local i=0
|
|
|
|
while lsblk -l -o NAME | grep -q -w $1; do
|
|
|
|
[ $i -lt 15 ] || break
|
2019-08-05 13:43:47 +00:00
|
|
|
i=$((i+1))
|
2019-02-04 22:23:06 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
if lsblk -l -o NAME | grep -q -w $1; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-05-01 21:51:54 +00:00
|
|
|
function waitforfile()
|
|
|
|
{
|
|
|
|
local i=0
|
2019-06-17 07:23:20 +00:00
|
|
|
while [ ! -e $1 ]; do
|
2019-05-01 21:51:54 +00:00
|
|
|
[ $i -lt 200 ] || break
|
2019-08-05 13:43:47 +00:00
|
|
|
i=$((i+1))
|
2019-05-01 21:51:54 +00:00
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
|
2019-06-17 07:23:20 +00:00
|
|
|
if [ ! -e $1 ]; then
|
2019-05-01 21:51:54 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-07-14 23:31:43 +00:00
|
|
|
function fio_config_gen()
|
|
|
|
{
|
|
|
|
local config_file=$1
|
|
|
|
local workload=$2
|
2019-10-16 17:38:26 +00:00
|
|
|
local bdev_type=$3
|
|
|
|
local fio_dir="/usr/src/fio"
|
2017-07-14 23:31:43 +00:00
|
|
|
|
|
|
|
if [ -e "$config_file" ]; then
|
|
|
|
echo "Configuration File Already Exists!: $config_file"
|
2019-10-28 12:23:22 +00:00
|
|
|
return 1
|
2017-07-14 23:31:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$workload" ]; then
|
|
|
|
workload=randrw
|
|
|
|
fi
|
|
|
|
|
|
|
|
touch $1
|
|
|
|
|
|
|
|
cat > $1 << EOL
|
|
|
|
[global]
|
|
|
|
thread=1
|
|
|
|
group_reporting=1
|
|
|
|
direct=1
|
|
|
|
norandommap=1
|
|
|
|
percentile_list=50:99:99.9:99.99:99.999
|
|
|
|
time_based=1
|
|
|
|
ramp_time=0
|
|
|
|
EOL
|
|
|
|
|
|
|
|
if [ "$workload" == "verify" ]; then
|
2019-11-18 11:32:48 +00:00
|
|
|
cat <<- EOL >> $config_file
|
|
|
|
verify=sha1
|
|
|
|
verify_backlog=1024
|
|
|
|
rw=randwrite
|
|
|
|
EOL
|
2019-10-16 17:38:26 +00:00
|
|
|
|
|
|
|
# To avoid potential data race issue due to the AIO device
|
|
|
|
# flush mechanism, add the flag to serialize the writes.
|
|
|
|
# This is to fix the intermittent IO failure issue of #935
|
|
|
|
if [ "$bdev_type" == "AIO" ]; then
|
|
|
|
if [[ $($fio_dir/fio --version) == *"fio-3"* ]]; then
|
|
|
|
echo "serialize_overlap=1" >> $config_file
|
|
|
|
fi
|
|
|
|
fi
|
2017-07-19 21:55:03 +00:00
|
|
|
elif [ "$workload" == "trim" ]; then
|
|
|
|
echo "rw=trimwrite" >> $config_file
|
2017-07-14 23:31:43 +00:00
|
|
|
else
|
|
|
|
echo "rw=$workload" >> $config_file
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function fio_config_add_job()
|
|
|
|
{
|
|
|
|
config_file=$1
|
|
|
|
filename=$2
|
|
|
|
|
|
|
|
if [ ! -e "$config_file" ]; then
|
|
|
|
echo "Configuration File Doesn't Exist: $config_file"
|
2019-10-28 12:23:22 +00:00
|
|
|
return 1
|
2017-07-14 23:31:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$filename" ]; then
|
|
|
|
echo "No filename provided"
|
2019-10-28 12:23:22 +00:00
|
|
|
return 1
|
2017-07-14 23:31:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "[job_$filename]" >> $config_file
|
|
|
|
echo "filename=$filename" >> $config_file
|
|
|
|
}
|
|
|
|
|
2019-05-30 06:59:51 +00:00
|
|
|
function fio_bdev()
|
|
|
|
{
|
|
|
|
# Setup fio binary cmd line
|
|
|
|
local fio_dir="/usr/src/fio"
|
|
|
|
local bdev_plugin="$rootdir/examples/bdev/fio_plugin/fio_plugin"
|
|
|
|
|
2019-05-30 07:29:06 +00:00
|
|
|
# Preload AddressSanitizer library to fio if fio_plugin was compiled with it
|
2019-10-24 13:58:04 +00:00
|
|
|
local asan_lib
|
|
|
|
asan_lib=$(ldd $bdev_plugin | grep libasan | awk '{print $3}')
|
2019-05-30 07:29:06 +00:00
|
|
|
|
2019-10-07 11:06:21 +00:00
|
|
|
LD_PRELOAD="$asan_lib $bdev_plugin" "$fio_dir"/fio "$@"
|
2019-05-30 06:59:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function fio_nvme()
|
|
|
|
{
|
|
|
|
# Setup fio binary cmd line
|
|
|
|
local fio_dir="/usr/src/fio"
|
|
|
|
local nvme_plugin="$rootdir/examples/nvme/fio_plugin/fio_plugin"
|
|
|
|
|
2019-05-30 07:29:06 +00:00
|
|
|
# Preload AddressSanitizer library to fio if fio_plugin was compiled with it
|
|
|
|
asan_lib=$(ldd $nvme_plugin | grep libasan | awk '{print $3}')
|
|
|
|
|
2019-10-07 11:06:21 +00:00
|
|
|
LD_PRELOAD="$asan_lib $nvme_plugin" "$fio_dir"/fio "$@"
|
2019-05-30 06:59:51 +00:00
|
|
|
}
|
|
|
|
|
2017-12-08 14:56:31 +00:00
|
|
|
function get_lvs_free_mb()
|
|
|
|
{
|
|
|
|
local lvs_uuid=$1
|
2019-10-24 13:58:04 +00:00
|
|
|
local lvs_info
|
|
|
|
local fc
|
|
|
|
local cs
|
|
|
|
lvs_info=$($rpc_py bdev_lvol_get_lvstores)
|
|
|
|
fc=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .free_clusters" <<< "$lvs_info")
|
|
|
|
cs=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .cluster_size" <<< "$lvs_info")
|
2017-12-08 14:56:31 +00:00
|
|
|
|
|
|
|
# Change to MB's
|
|
|
|
free_mb=$((fc*cs/1024/1024))
|
|
|
|
echo "$free_mb"
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_bdev_size()
|
|
|
|
{
|
|
|
|
local bdev_name=$1
|
2019-10-24 13:58:04 +00:00
|
|
|
local bdev_info
|
|
|
|
local bs
|
|
|
|
local nb
|
|
|
|
bdev_info=$($rpc_py bdev_get_bdevs -b $bdev_name)
|
|
|
|
bs=$(jq ".[] .block_size" <<< "$bdev_info")
|
|
|
|
nb=$(jq ".[] .num_blocks" <<< "$bdev_info")
|
2017-12-08 14:56:31 +00:00
|
|
|
|
|
|
|
# Change to MB's
|
|
|
|
bdev_size=$((bs*nb/1024/1024))
|
|
|
|
echo "$bdev_size"
|
|
|
|
}
|
|
|
|
|
2018-02-28 16:42:12 +00:00
|
|
|
function autotest_cleanup()
|
|
|
|
{
|
|
|
|
$rootdir/scripts/setup.sh reset
|
2018-09-10 07:32:09 +00:00
|
|
|
$rootdir/scripts/setup.sh cleanup
|
2018-10-09 18:26:27 +00:00
|
|
|
if [ $(uname -s) = "Linux" ]; then
|
|
|
|
if grep -q '#define SPDK_CONFIG_IGB_UIO_DRIVER 1' $rootdir/include/spdk/config.h; then
|
|
|
|
rmmod igb_uio
|
|
|
|
else
|
|
|
|
modprobe -r uio_pci_generic
|
|
|
|
fi
|
|
|
|
fi
|
2019-06-03 12:32:57 +00:00
|
|
|
rm -rf "$asan_suppression_file"
|
2018-02-28 16:42:12 +00:00
|
|
|
}
|
|
|
|
|
2018-04-26 23:46:08 +00:00
|
|
|
function freebsd_update_contigmem_mod()
|
|
|
|
{
|
2019-06-12 07:48:32 +00:00
|
|
|
if [ $(uname) = FreeBSD ]; then
|
2018-04-26 23:46:08 +00:00
|
|
|
kldunload contigmem.ko || true
|
2019-07-25 13:01:09 +00:00
|
|
|
if [ -n "$WITH_DPDK_DIR" ]; then
|
2018-10-11 09:02:15 +00:00
|
|
|
echo "Warning: SPDK only works on FreeBSD with patches that only exist in SPDK's dpdk submodule"
|
|
|
|
cp -f "$WITH_DPDK_DIR/kmod/contigmem.ko" /boot/modules/
|
|
|
|
cp -f "$WITH_DPDK_DIR/kmod/contigmem.ko" /boot/kernel/
|
|
|
|
else
|
|
|
|
cp -f "$rootdir/dpdk/build/kmod/contigmem.ko" /boot/modules/
|
|
|
|
cp -f "$rootdir/dpdk/build/kmod/contigmem.ko" /boot/kernel/
|
|
|
|
fi
|
2018-04-26 23:46:08 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-08-12 13:24:30 +00:00
|
|
|
function get_nvme_name_from_bdf {
|
|
|
|
blkname=()
|
|
|
|
|
|
|
|
nvme_devs=$(lsblk -d --output NAME | grep "^nvme") || true
|
|
|
|
if [ -z "$nvme_devs" ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
for dev in $nvme_devs; do
|
|
|
|
link_name=$(readlink /sys/block/$dev/device/device) || true
|
|
|
|
if [ -z "$link_name" ]; then
|
|
|
|
link_name=$(readlink /sys/block/$dev/device)
|
|
|
|
fi
|
|
|
|
bdf=$(basename "$link_name")
|
|
|
|
if [ "$bdf" = "$1" ]; then
|
|
|
|
blkname+=($dev)
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
printf '%s\n' "${blkname[@]}"
|
|
|
|
}
|
|
|
|
|
2019-10-22 15:12:35 +00:00
|
|
|
function opal_revert_cleanup {
|
|
|
|
$rootdir/app/spdk_tgt/spdk_tgt &
|
|
|
|
spdk_tgt_pid=$!
|
|
|
|
waitforlisten $spdk_tgt_pid
|
|
|
|
|
|
|
|
# OPAL test only runs on the first NVMe device
|
|
|
|
# So we just revert the first one here
|
|
|
|
bdf=$($rootdir/scripts/gen_nvme.sh --json | jq -r '.config[].params | select(.name=="Nvme0").traddr')
|
|
|
|
$rootdir/scripts/rpc.py bdev_nvme_attach_controller -b "nvme0" -t "pcie" -a $bdf
|
2019-11-19 19:09:25 +00:00
|
|
|
# Ignore if this fails.
|
|
|
|
$rootdir/scripts/rpc.py bdev_nvme_opal_revert -b nvme0 -p test || true
|
2019-10-22 15:12:35 +00:00
|
|
|
|
|
|
|
killprocess $spdk_tgt_pid
|
|
|
|
}
|
|
|
|
|
2017-02-20 19:32:49 +00:00
|
|
|
set -o errtrace
|
|
|
|
trap "trap - ERR; print_backtrace >&2" ERR
|
2019-05-09 10:50:26 +00:00
|
|
|
|
|
|
|
PS4=' \t \$ '
|
|
|
|
if $SPDK_AUTOTEST_X; then
|
2019-12-30 19:19:46 +00:00
|
|
|
# explicitly enable xtraces, overriding any tracking information.
|
|
|
|
unset XTRACE_DISABLED
|
|
|
|
unset XTRACE_NESTING_LEVEL
|
2019-05-09 10:50:26 +00:00
|
|
|
set -x
|
|
|
|
xtrace_enable
|
|
|
|
else
|
|
|
|
xtrace_restore
|
|
|
|
fi
|