Lines Matching +full:storage +full:- +full:target
2 # SPDX-License-Identifier: BSD-3-Clause
15 # unset'ing foo[-1] under older Bash (4.2 -> Centos7) won't work, hence the dance
16 unset -v "X_STACK[${#X_STACK[@]} - 1 < 0 ? 0 : ${#X_STACK[@]} - 1]" # pop
18 set -x
25 if [[ -n ${BASH_XTRACEFD:-} && -e /proc/self/fd/$BASH_XTRACEFD ]]; then
27 exec {BASH_XTRACEFD}>&-
34 set -e
35 shopt -s nullglob
36 shopt -s extglob
37 shopt -s inherit_errexit
39 if [ -z "${output_dir:-}" ]; then
40 mkdir -p "$rootdir/../output"
44 if [[ -e $rootdir/test/common/build_config.sh ]]; then
46 elif [[ -e $rootdir/mk/config.mk ]]; then
168 # Comma-separated list of fuzzer targets matching test/fuzz/llvm/$target
182 export DPDK_LIB_DIR="${SPDK_RUN_EXTERNAL_DPDK:-$rootdir/dpdk/build}/lib"
183 export VFIO_LIB_DIR="$rootdir/build/libvfio-user/usr/local/lib"
205 rm -rf "$asan_suppression_file" 2> /dev/null || sudo rm -rf "$asan_suppression_file"
220 # Suppress leaks in gperftools-libs from fio
230 # Suppress leaks in accel-config
248 if [ -z "${DEPENDENCY_DIR:-}" ]; then
258 # for vhost, vfio-user tests
259 export QEMU_BIN=${QEMU_BIN:-}
260 export VFIO_QEMU_BIN=${VFIO_QEMU_BIN:-}
262 export AR_TOOL=$rootdir/scripts/ar-xnvme-fixer
265 export UNBIND_ENTIRE_IOMMU_GROUP=${UNBIND_ENTIRE_IOMMU_GROUP:-no}
270 [[ $CC == *clang* || $SPDK_TEST_FUZZER -eq 1 ]] && _LCOV=$_LCOV_LLVM
272 _lcov_opt[_LCOV_LLVM]="--gcov-tool $rootdir/test/fuzz/llvm/llvm-gcov.sh"
278 if [ $SPDK_RUN_VALGRIND -eq 0 ]; then
282 unset -v "${!DEBUGINFOD_@}"
285 if [ "$(uname -s)" = "Linux" ]; then
286 HUGEMEM=${HUGEMEM:-4096}
290 MAKEFLAGS=${MAKEFLAGS:--j$(nproc)}
291 elif [ "$(uname -s)" = "FreeBSD" ]; then
293 MAKEFLAGS=${MAKEFLAGS:--j$(sysctl -a | grep -E -i 'hw.ncpu' | awk '{print $2}')}
295 HUGEMEM=${HUGEMEM:-2048}
296 elif [ "$(uname -s)" = "Windows" ]; then
298 MAKEFLAGS=${MAKEFLAGS:--j$(nproc)}
300 HUGEMEM=${HUGEMEM:-2048}
302 echo "Unknown OS \"$(uname -s)\""
312 --iso)
315 --transport=*)
318 --sock=*)
321 --no-hugepages)
322 NO_HUGE=(--no-huge -s 1024)
324 --interrupt-mode)
331 if [[ -z ${RPC_PIPE_PID:-} ]] || ! kill -0 "$RPC_PIPE_PID" &> /dev/null; then
334 coproc RPC_PIPE { PYTHONPATH="$PYTHONPATH" "$rootdir/scripts/rpc.py" --server; }
341 [[ -v testdir ]] || return 0
346 local -A mounts fss sizes avails uses
351 storage_fallback=$(mktemp -udt spdk.XXXXXX)
358 if [[ -n ${ADD_TEST_STORAGE:-} ]]; then
363 if [[ -n ${DEDICATED_TEST_STORAGE:-} ]]; then
368 mkdir -p "${storage_candidates[@]}"
370 # add some headroom - 64M
373 while read -r source fs size use avail _ mount; do
377 done < <(df -T | grep -v Filesystem)
379 printf '* Looking for test storage...\n' >&2
383 # FreeBSD's df is lacking the --output arg
384 # mount=$(df --output=target "$target_dir" | grep -v "Mounted on")
392 # For in-memory fs, and / make sure our requested size won't fill most of the space.
401 printf '* Found test storage at %s\n' "$SPDK_TEST_STORAGE" >&2
404 printf '* Test storage is not available\n'
410 config_params='--enable-debug --enable-werror'
413 if [ -f /usr/include/infiniband/verbs.h ]; then
414 config_params+=' --with-rdma'
417 if [ $SPDK_TEST_USDT -eq 1 ]; then
418 config_params+=" --with-usdt"
421 case "$(uname -s)" in
422 FreeBSD) [[ $(sysctl -n hw.model) == Intel* ]] ;;
425 esac && config_params+=" --with-idxd" || config_params+=" --without-idxd"
427 if [[ -d $CONFIG_FIO_SOURCE_DIR ]]; then
428 config_params+=" --with-fio=$CONFIG_FIO_SOURCE_DIR"
431 if [ -d ${DEPENDENCY_DIR}/vtune_codes ]; then
432 config_params+=' --with-vtune='${DEPENDENCY_DIR}'/vtune_codes'
435 if [ -d /usr/include/iscsi ]; then
436 [[ $(< /usr/include/iscsi/iscsi.h) =~ "define LIBISCSI_API_VERSION ("([0-9]+)")" ]] \
439 config_params+=' --with-iscsi-initiator'
443 if [[ $SPDK_TEST_UNITTEST -eq 0 &&
444 $SPDK_TEST_SCANBUILD -eq 0 && -z ${SPDK_TEST_AUTOBUILD:-} ]]; then
445 config_params+=' --disable-unit-tests'
448 if [ -f /usr/include/libpmem.h ] && [ $SPDK_TEST_VBDEV_COMPRESS -eq 1 ]; then
449 if ge "$(nasm --version | awk '{print $3}')" 2.14 && [[ $SPDK_TEST_ISAL -eq 1 ]]; then
450 config_params+=' --with-vbdev-compress --with-dpdk-compressdev'
454 if [ -d /usr/include/rbd ] && [ -d /usr/include/rados ] && [ $SPDK_TEST_RBD -eq 1 ]; then
455 config_params+=' --with-rbd'
459 if [ $SPDK_TEST_CRYPTO -eq 1 ]; then
460 config_params+=' --with-crypto'
463 if [ $SPDK_TEST_OCF -eq 1 ]; then
464 config_params+=" --with-ocf"
467 if [ $SPDK_RUN_UBSAN -eq 1 ]; then
468 config_params+=' --enable-ubsan'
471 if [ $SPDK_RUN_ASAN -eq 1 ]; then
472 config_params+=' --enable-asan'
475 config_params+=' --enable-coverage'
477 if [ $SPDK_TEST_BLOBFS -eq 1 ]; then
478 if [[ -d /usr/include/fuse3 ]] || [[ -d /usr/local/include/fuse3 ]]; then
479 config_params+=' --with-fuse'
483 if [[ -f /usr/include/liburing/io_uring.h && -f /usr/include/linux/ublk_cmd.h ]]; then
484 config_params+=' --with-ublk'
487 if [ $SPDK_TEST_RAID -eq 1 ]; then
488 config_params+=' --with-raid5f'
491 if [ $SPDK_TEST_VFIOUSER -eq 1 ] || [ $SPDK_TEST_VFIOUSER_QEMU -eq 1 ] || [ $SPDK_TEST_SMA -eq 1 ]; then
492 config_params+=' --with-vfio-user'
496 if [ -f /usr/include/liburing/io_uring.h ] && [ $SPDK_TEST_URING -eq 1 ]; then
497 config_params+=' --with-uring'
500 if [ -n "${SPDK_RUN_EXTERNAL_DPDK:-}" ]; then
501 config_params+=" --with-dpdk=$SPDK_RUN_EXTERNAL_DPDK"
504 if [[ $SPDK_TEST_SMA -eq 1 ]]; then
505 config_params+=' --with-sma'
506 config_params+=' --with-crypto'
509 if [ -f /usr/include/daos.h ] && [ $SPDK_TEST_DAOS -eq 1 ]; then
510 config_params+=' --with-daos'
514 if [[ $SPDK_TEST_XNVME -eq 1 ]]; then
515 config_params+=' --with-xnvme'
518 if [[ $SPDK_TEST_FUZZER -eq 1 ]]; then
522 if [[ $SPDK_TEST_NVMF_MDNS -eq 1 ]]; then
523 config_params+=' --with-avahi'
526 if [[ $SPDK_JSONRPC_GO_CLIENT -eq 1 ]]; then
527 config_params+=' --with-golang'
535 local -A fuzzer_targets_to_config=()
536 local config target
538 fuzzer_targets_to_config["vfio"]="--with-vfio-user"
539 for target in $(get_fuzzer_targets); do
540 [[ -n ${fuzzer_targets_to_config["$target"]:-} ]] || continue
541 config+=("${fuzzer_targets_to_config["$target"]}")
552 if [[ -n ${SPDK_TEST_FUZZER_TARGET:-} ]]; then
553 IFS="," read -ra fuzzers <<< "$SPDK_TEST_FUZZER_TARGET"
570 elif [[ ! -t 0 ]]; then
571 mapfile -t stdin <&0
578 while read -t "${RPC_PIPE_TIMEOUT:-15}" -ru $RPC_PIPE_OUTPUT rsp; do
597 local -gA jq_out=()
625 [[ -v $elems ]] || return 1
633 while read -r elem val; do
635 done < <(rpc_cmd "$@" | jq -jr "$jq")
644 case "$(type -t "$arg")" in
646 file) arg=$(type -P "$arg") && [[ -x $arg ]] ;;
658 # - return false if command exit successfully
659 # - return false if command exit after receiving a core signal (FIXME: or any signal?)
660 # - return true if command exit with an error
674 elif [[ -n ${EXIT_STATUS:-} ]] && ((es != EXIT_STATUS)); then
689 export timing_stack="${timing_stack:-};${now}"
690 export test_stack="${test_stack:-};${testname}"
695 start_time=$(echo "$timing_stack" | sed -e 's@^.*;@@')
696 timing_stack=$(echo "$timing_stack" | sed -e 's@;[^;]*$@@')
698 elapsed=$((now - start_time - child_time))
701 test_stack=$(echo "$test_stack" | sed -e 's@;[^;]*$@@')
706 # The use-case here is this: ts=$(timing_cmd echo bar). Since stdout is always redirected
711 [[ -t 0 ]] && exec {cmd_out}>&0 || exec {cmd_out}> /dev/null
716 # catch only output from the time builtin - output from the actual cmd would be still visible,
738 [[ -e $output_dir/timing.txt ]] || return 0
741 [[ -x "$flamegraph" ]] || return 1
744 --title 'Build Timing' \
745 --nametype 'Step:' \
746 --countname seconds \
754 completion=$(grep -shI -d skip --include="*.sh" -e "run_test " $rootdir/*)
756 completion+=$'\n'$(grep -rshI --include="*.sh" --exclude="*autotest_common.sh" -e "run_test " $rootdir/test)
757 printf "%s" "$completion" | grep -v "#" \
764 gdb -q --batch \
765 -ex 'handle SIGHUP nostop pass' \
766 -ex 'handle SIGQUIT nostop pass' \
767 -ex 'handle SIGPIPE nostop pass' \
768 -ex 'handle SIGALRM nostop pass' \
769 -ex 'handle SIGTERM nostop pass' \
770 -ex 'handle SIGUSR1 nostop pass' \
771 -ex 'handle SIGUSR2 nostop pass' \
772 -ex 'handle SIGCHLD nostop pass' \
773 -ex 'set print thread-events off' \
774 -ex 'cont' \
775 -ex 'thread apply all bt' \
776 -ex 'quit' \
777 --tty=/dev/stdout \
778 -p $1
797 chmod -R a+r "$output_dir/coredumps"
800 cat <<- BT
805 --
814 if [ "$type" = "--pid" ]; then
818 shm_files=$(find /dev/shm -name "*.${id}" -printf "%f\n")
820 if [[ -z ${shm_files:-} ]]; then
825 tar -C /dev/shm/ -cvzf $output_dir/${n}_shm.tar.gz ${n}
831 # $1 - process pid
832 # $2 - rpc address (optional)
833 # $3 - max retries (optional)
835 if [ -z "${1:-}" ]; then
839 local rpc_addr="${2:-$DEFAULT_RPC_ADDR}"
840 local max_retries=${3:-100}
847 for ((i = max_retries; i != 0; i--)); do
850 if ! kill -s 0 $1; then
856 if $rootdir/scripts/rpc.py -t 1 -s "$rpc_addr" rpc_get_methods &> /dev/null; then
876 if grep -q -w $nbd_name /proc/partitions; then
890 size=$(stat -c %s "$SPDK_TEST_STORAGE/nbdtest")
891 rm -f "$SPDK_TEST_STORAGE/nbdtest"
906 [[ -z ${bdev_timeout:-} ]] && bdev_timeout=2000 # ms
910 if $rpc_py bdev_get_bdevs -b $bdev_name -t $bdev_timeout; then
919 local max=${2:-10}
920 while ((max--)); do
936 force=-F
938 force=-f
942 if [ $i -ge 15 ]; then
954 if [ -z "${1:-}" ]; then
958 if kill -0 $1; then
960 process_name=$(ps --no-headers -o comm= $1)
962 process_name=$(ps -c -o command $1 | tail -1)
968 child="$(pgrep -P $1)"
977 # or the actual app - it should terminate anyway
987 iscsiadm -m node --logout || true
988 iscsiadm -m node -o delete || true
989 rm -rf /var/lib/iscsi/nodes/*
993 if cat /etc/*-release | grep Ubuntu; then
994 service open-iscsi stop
1001 if cat /etc/*-release | grep Ubuntu; then
1002 service open-iscsi start
1011 if [ -z "${1:-}" ]; then
1015 if [ -n "${2:-}" ]; then
1032 $NS_CMD rbd create $RBD_NAME --size 1000
1039 rm -f /var/tmp/ceph_raw.img
1046 if [ -z "${1:-}" ]; then
1050 if [ -z "${2:-}" ]; then
1055 dmg pool create --size=10G $1 || true
1056 daos container create --type=POSIX --label=$2 $1 || true
1060 local pool=${1:-testpool}
1061 local cont=${2:-testcont}
1063 daos container destroy -f $pool $cont || true
1064 sudo dmg pool destroy -f $pool || true
1068 # Disable ASLR for multi-process testing. SPDK does support using DPDK multi-process,
1070 # We will re-enable it again after multi-process testing is complete in kill_stub().
1077 while ! [ -e /var/run/spdk_stub0 ]; do
1079 [[ -e /proc/$stubpid ]] || return 1
1093 if [[ -e /proc/$stubpid ]]; then
1097 rm -f /var/run/spdk_stub0
1098 # Re-enable ASLR now that we are done with multi-process testing
1101 echo "${_randomize_va_space:-2}" > /proc/sys/kernel/randomize_va_space
1105 if [ $# -le 1 ]; then
1115 if [ -n "${test_domain:-}" ]; then
1137 if [ -n "$test_domain" ]; then
1141 if [ -z "${test_domain:-}" ]; then
1157 [[ "$-" =~ e ]] || return 0
1168 local line_nr="${BASH_LINENO[$((i - 1))]}"
1172 if [[ -f $src ]]; then
1173 bt=$(nl -w 4 -ba -nln $src | grep -B 5 -A 5 "^${line_nr}[^0-9]" \
1182 cmdline[argc--]="[\"$arg\"]"
1187 echo "in $src:$line_nr -> $func($(
1189 printf '%s\n' "${cmdline[*]:-[]}"
1192 echo "${bt:-backtrace unavailable}"
1204 if [[ -n "${2:-}" ]]; then
1211 nvme_devices=$(lsblk -l -o NAME,SERIAL | grep -c "$1")
1224 while lsblk -o NAME,SERIAL | grep -q -w $1; do
1225 [ $i -lt 15 ] || break
1231 if lsblk -l -o NAME,SERIAL | grep -q -w $1; then
1240 while ! lsblk -l -o NAME | grep -q -w $1; do
1241 [ $i -lt 15 ] || break
1246 if ! lsblk -l -o NAME | grep -q -w $1; then
1255 while lsblk -l -o NAME | grep -q -w $1; do
1256 [ $i -lt 15 ] || break
1261 if lsblk -l -o NAME | grep -q -w $1; then
1270 while [ ! -e $1 ]; do
1271 [ $i -lt 200 ] || break
1276 if [ ! -e $1 ]; then
1290 if [ -e "$config_file" ]; then
1295 if [ -z "${workload:-}" ]; then
1299 if [ -n "$env_context" ]; then
1318 cat <<- EOL >> $config_file
1328 if [[ $($fio_dir/fio --version) == *"fio-3"* ]]; then
1350 if [[ -n "${asan_lib:-}" ]]; then
1386 bdev_info=$($rpc_py bdev_get_bdevs -b $bdev_name)
1415 if [ $(uname -s) = "Linux" ]; then
1416 modprobe -r uio_pci_generic
1418 rm -rf "$asan_suppression_file"
1419 if [[ -n ${old_core_pattern:-} ]]; then
1422 if [[ -e /proc/$udevadm_pid/status ]]; then
1426 local storage_fallback_purge=("${TMPDIR:-/tmp}/spdk."??????)
1429 rm -rf "${storage_fallback_purge[@]}"
1437 grep . /proc/[0-9]*/status
1441 echo l > /proc/sysrq-trigger
1443 echo m > /proc/sysrq-trigger
1445 echo w > /proc/sysrq-trigger
1459 if [ -n "${SPDK_RUN_EXTERNAL_DPDK:-}" ]; then
1460 cp -f "$SPDK_RUN_EXTERNAL_DPDK/kmod/contigmem.ko" /boot/modules/
1461 cp -f "$SPDK_RUN_EXTERNAL_DPDK/kmod/contigmem.ko" /boot/kernel/
1462 cp -f "$SPDK_RUN_EXTERNAL_DPDK/kmod/nic_uio.ko" /boot/modules/
1463 cp -f "$SPDK_RUN_EXTERNAL_DPDK/kmod/nic_uio.ko" /boot/kernel/
1465 cp -f "$rootdir/dpdk/build/kmod/contigmem.ko" /boot/modules/
1466 cp -f "$rootdir/dpdk/build/kmod/contigmem.ko" /boot/kernel/
1467 cp -f "$rootdir/dpdk/build/kmod/nic_uio.ko" /boot/modules/
1468 cp -f "$rootdir/dpdk/build/kmod/nic_uio.ko" /boot/kernel/
1477 if [[ $(uname) = FreeBSD ]] && (($(sysctl -n kern.ipc.maxsockbuf) < 4194304)); then
1487 bdf_sysfs_path=$(readlink -f /sys/class/nvme/nvme* | grep "$1/nvme/nvme")
1488 if [[ -z "${bdf_sysfs_path:-}" ]]; then
1496 # uio-pci-generic or vfio-pci
1499 bdfs=($("$rootdir/scripts/gen_nvme.sh" | jq -r '.config[].params.traddr'))
1526 if [[ -z "${nvme_ctrlr:-}" ]]; then
1531 oacs=$(nvme id-ctrl ${nvme_ctrlr} | grep oacs | cut -d: -f2)
1534 if [[ "$oacs_ns_manage" -ne 0 ]]; then
1540 unvmcap=$(nvme id-ctrl ${nvme_ctrlr} | grep unvmcap | cut -d: -f2)
1541 if [[ "$unvmcap" -eq 0 ]]; then
1545 tnvmcap=$(nvme id-ctrl ${nvme_ctrlr} | grep tnvmcap | cut -d: -f2)
1546 cntlid=$(nvme id-ctrl ${nvme_ctrlr} | grep cntlid | cut -d: -f2)
1551 nvme detach-ns ${nvme_ctrlr} -n 0xffffffff -c $cntlid || true
1552 nvme delete-ns ${nvme_ctrlr} -n 0xffffffff || true
1553 nvme create-ns ${nvme_ctrlr} -s ${size} -c ${size} -b ${blksize}
1554 nvme attach-ns ${nvme_ctrlr} -n 1 -c $cntlid
1578 mapfile -t bdfs < <(get_nvme_bdfs_by_id 0x0a54)
1579 if [[ -z ${bdfs[0]:-} ]]; then
1589 $rootdir/scripts/rpc.py bdev_nvme_attach_controller -b "nvme"${bdf_id} -t "pcie" -a ${bdf}
1591 $rootdir/scripts/rpc.py bdev_nvme_opal_revert -b "nvme"${bdf_id} -p test || true
1599 while read -r file; do
1600 cat <<- FILE
1601 --- $file ---
1603 --- $file ---
1605 rm -f "$file"
1606 done < <(find "$@" -type f | sort -u)
1610 case "$(uname -s)" in
1611 Linux) # ps -e -opid,exe <- not supported under {centos7,rocky8}'s procps-ng
1613 for pid in /proc/[0-9]*; do
1619 FreeeBSD) procstat -ab | awk '{print $1, $4}' ;;
1623 exec_files() { file "$@" | awk -F: '/ELF.+executable/{print $1}'; }
1629 mapfile -t test_bins < <(find "$rootdir"/test/{app,env,event,nvme} -type f)
1630 mapfile -t bins < <(
1632 readlink -f "$SPDK_BIN_DIR/"* "$SPDK_EXAMPLE_DIR/"*
1636 mapfile -t spdk_procs < <(get_proc_paths | grep -E "$(
1643 mapfile -t spdk_pids < <(printf '%s\n' "${spdk_procs[@]}" | awk '{print $1}')
1645 kill -SIGKILL "${spdk_pids[@]}" 2> /dev/null || :
1652 [[ -e /sys/block/$device/queue/zoned ]] || return 1
1657 local -gA zoned_devs=()
1658 local -A zoned_ctrls=()
1667 # like that from all the other non-zns test suites.
1688 while read -r _pid; do
1690 done < <(jobs -pr)
1695 # Define temp storage for all the tests. Look for 2GB at minimum
1696 set_test_storage "${TEST_MIN_STORAGE_SIZE:-$((1 << 31))}"
1698 set -o errtrace
1699 shopt -s extdebug
1700 trap "trap - ERR; print_backtrace >&2" ERR
1702 PS4=' \t ${test_domain:-} -- ${BASH_SOURCE#${BASH_SOURCE%/*/*}/}@${LINENO} -- \$ '
1711 if lt "$(lcov --version | awk '{print $NF}')" 2; then
1712 lcov_rc_opt="--rc lcov_branch_coverage=1 --rc lcov_function_coverage=1"
1714 lcov_rc_opt="--rc branch_coverage=1 --rc function_coverage=1"
1718 --rc genhtml_branch_coverage=1
1719 --rc genhtml_function_coverage=1
1720 --rc genhtml_legend=1
1721 --rc geninfo_all_blocks=1
1722 --rc geninfo_unexecuted_blocks=1