1#!/usr/bin/env bash 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (C) 2015 Intel Corporation 4# All rights reserved. 5# 6 7rootdir=$(readlink -f $(dirname $0)) 8 9# In autotest_common.sh all tests are disabled by default. 10# If the configuration of tests is not provided, no tests will be carried out. 11if [[ ! -f $1 ]]; then 12 echo "ERROR: SPDK test configuration not specified" 13 exit 1 14fi 15 16# Autotest.sh, as part of autorun.sh, runs in a different 17# shell process than autobuild.sh. Use helper file to pass 18# over env variable containing libraries paths. 19if [[ -e /tmp/spdk-ld-path ]]; then 20 source /tmp/spdk-ld-path 21fi 22 23source "$1" 24source "$rootdir/test/common/autotest_common.sh" 25source "$rootdir/test/nvmf/common.sh" 26 27if [ $EUID -ne 0 ]; then 28 echo "$0 must be run as root" 29 exit 1 30fi 31 32if [ $(uname -s) = Linux ]; then 33 old_core_pattern=$(< /proc/sys/kernel/core_pattern) 34 mkdir -p "$output_dir/coredumps" 35 # Set core_pattern to a known value to avoid ABRT, systemd-coredump, etc. 36 # Dump the $output_dir path to a file so collector can pick it up while executing. 37 # We don't set in in the core_pattern command line because of the string length limitation 38 # of 128 bytes. See 'man core 5' for details. 39 echo "|$rootdir/scripts/core-collector.sh %P %s %t" > /proc/sys/kernel/core_pattern 40 echo "$output_dir/coredumps" > "$rootdir/.coredump_path" 41 42 # make sure nbd (network block device) driver is loaded if it is available 43 # this ensures that when tests need to use nbd, it will be fully initialized 44 modprobe nbd || true 45 46 if udevadm=$(type -P udevadm); then 47 "$udevadm" monitor --property &> "$output_dir/udev.log" & 48 udevadm_pid=$! 49 fi 50fi 51 52trap "autotest_cleanup || :; exit 1" SIGINT SIGTERM EXIT 53 54timing_enter autotest 55 56create_test_list 57 58src=$(readlink -f $(dirname $0)) 59out=$output_dir 60cd $src 61 62freebsd_update_contigmem_mod 63 64# lcov takes considerable time to process clang coverage. 65# Disabling lcov allow us to do this. 66# More information: https://github.com/spdk/spdk/issues/1693 67CC_TYPE=$(grep CC_TYPE mk/cc.mk) 68if hash lcov && ! [[ "$CC_TYPE" == *"clang"* ]]; then 69 export LCOV_OPTS=" 70 --rc lcov_branch_coverage=1 71 --rc lcov_function_coverage=1 72 --rc genhtml_branch_coverage=1 73 --rc genhtml_function_coverage=1 74 --rc genhtml_legend=1 75 --rc geninfo_all_blocks=1 76 " 77 export LCOV="lcov $LCOV_OPTS --no-external" 78 # Print lcov version to log 79 $LCOV -v 80 # zero out coverage data 81 $LCOV -q -c -i -t "Baseline" -d $src -o $out/cov_base.info 82fi 83 84# Make sure the disks are clean (no leftover partition tables) 85timing_enter cleanup 86# Remove old domain socket pathname just in case 87rm -f /var/tmp/spdk*.sock 88 89# Load the kernel driver 90$rootdir/scripts/setup.sh reset 91 92get_zoned_devs 93 94if ((${#zoned_devs[@]} > 0)); then 95 # FIXME: For now make sure zoned devices are tested on-demand by 96 # a designated tests instead of falling into any other. The main 97 # concern here are fio workloads where specific configuration 98 # must be in place for it to work with the zoned device. 99 export PCI_BLOCKED="${zoned_devs[*]}" 100 export PCI_ZONED="${zoned_devs[*]}" 101fi 102 103# Delete all leftover lvols and gpt partitions 104# Matches both /dev/nvmeXnY on Linux and /dev/nvmeXnsY on BSD 105# Filter out nvme with partitions - the "p*" suffix 106for dev in $(ls /dev/nvme*n* | grep -v p || true); do 107 # Skip zoned devices as non-sequential IO will always fail 108 [[ -z ${zoned_devs["${dev##*/}"]} ]] || continue 109 if ! block_in_use "$dev"; then 110 dd if=/dev/zero of="$dev" bs=1M count=1 111 fi 112done 113 114sync 115 116if ! xtrace_disable_per_cmd reap_spdk_processes; then 117 echo "WARNING: Lingering SPDK processes were detected. Testing environment may be unstable" >&2 118fi 119 120if [ $(uname -s) = Linux ]; then 121 run_test "setup.sh" "$rootdir/test/setup/test-setup.sh" 122fi 123 124$rootdir/scripts/setup.sh status 125 126if [[ $(uname -s) == Linux ]]; then 127 # Revert NVMe namespaces to default state 128 nvme_namespace_revert 129fi 130 131timing_exit cleanup 132 133# set up huge pages 134timing_enter afterboot 135$rootdir/scripts/setup.sh 136timing_exit afterboot 137 138# Revert existing OPAL to factory settings that may have been left from earlier failed tests. 139# This ensures we won't hit any unexpected failures due to NVMe SSDs being locked. 140opal_revert_cleanup 141 142##################### 143# Unit Tests 144##################### 145 146if [ $SPDK_TEST_UNITTEST -eq 1 ]; then 147 run_test "unittest" $rootdir/test/unit/unittest.sh 148fi 149 150if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then 151 if [[ $SPDK_TEST_CRYPTO -eq 1 || $SPDK_TEST_VBDEV_COMPRESS -eq 1 ]]; then 152 if [[ $SPDK_TEST_USE_IGB_UIO -eq 1 ]]; then 153 $rootdir/scripts/qat_setup.sh igb_uio 154 else 155 $rootdir/scripts/qat_setup.sh 156 fi 157 fi 158 timing_enter lib 159 160 run_test "env" $rootdir/test/env/env.sh 161 run_test "rpc" $rootdir/test/rpc/rpc.sh 162 run_test "rpc_client" $rootdir/test/rpc_client/rpc_client.sh 163 run_test "json_config" $rootdir/test/json_config/json_config.sh 164 run_test "json_config_extra_key" $rootdir/test/json_config/json_config_extra_key.sh 165 run_test "alias_rpc" $rootdir/test/json_config/alias_rpc/alias_rpc.sh 166 run_test "spdkcli_tcp" $rootdir/test/spdkcli/tcp.sh 167 run_test "dpdk_mem_utility" $rootdir/test/dpdk_memory_utility/test_dpdk_mem_info.sh 168 run_test "event" $rootdir/test/event/event.sh 169 run_test "thread" $rootdir/test/thread/thread.sh 170 run_test "accel" $rootdir/test/accel/accel.sh 171 run_test "app_cmdline" $rootdir/test/app/cmdline.sh 172 173 if [ $SPDK_TEST_BLOCKDEV -eq 1 ]; then 174 run_test "blockdev_general" $rootdir/test/bdev/blockdev.sh 175 run_test "bdev_raid" $rootdir/test/bdev/bdev_raid.sh 176 run_test "bdevperf_config" $rootdir/test/bdev/bdevperf/test_config.sh 177 if [[ $(uname -s) == Linux ]]; then 178 run_test "reactor_set_interrupt" $rootdir/test/interrupt/reactor_set_interrupt.sh 179 run_test "reap_unregistered_poller" $rootdir/test/interrupt/reap_unregistered_poller.sh 180 fi 181 fi 182 183 if [[ $(uname -s) == Linux ]]; then 184 if [[ $SPDK_TEST_BLOCKDEV -eq 1 || $SPDK_TEST_URING -eq 1 ]]; then 185 # The crypto job also includes the SPDK_TEST_BLOCKDEV in its configuration hence the 186 # dd tests are executed there as well. However, these tests can take a significant 187 # amount of time to complete (up to 4min) on a physical system leading to a potential 188 # job timeout. Avoid that by skipping these tests - this should not affect the coverage 189 # since dd tests are still run as part of the vg jobs. 190 if [[ $SPDK_TEST_CRYPTO -eq 0 ]]; then 191 run_test "spdk_dd" $rootdir/test/dd/dd.sh 192 fi 193 fi 194 fi 195 196 if [ $SPDK_TEST_NVME -eq 1 ]; then 197 run_test "blockdev_nvme" $rootdir/test/bdev/blockdev.sh "nvme" 198 if [[ $(uname -s) == Linux ]]; then 199 run_test "blockdev_nvme_gpt" $rootdir/test/bdev/blockdev.sh "gpt" 200 fi 201 run_test "nvme" $rootdir/test/nvme/nvme.sh 202 if [[ $SPDK_TEST_NVME_PMR -eq 1 ]]; then 203 run_test "nvme_pmr" $rootdir/test/nvme/nvme_pmr.sh 204 fi 205 if [[ $SPDK_TEST_NVME_SCC -eq 1 ]]; then 206 run_test "nvme_scc" $rootdir/test/nvme/nvme_scc.sh 207 fi 208 if [[ $SPDK_TEST_NVME_BP -eq 1 ]]; then 209 run_test "nvme_bp" $rootdir/test/nvme/nvme_bp.sh 210 fi 211 if [[ $SPDK_TEST_NVME_CUSE -eq 1 ]]; then 212 run_test "nvme_cuse" $rootdir/test/nvme/cuse/nvme_cuse.sh 213 fi 214 if [[ $SPDK_TEST_NVME_CMB -eq 1 ]]; then 215 run_test "nvme_cmb" $rootdir/test/nvme/cmb/cmb.sh 216 fi 217 218 if [[ $SPDK_TEST_NVME_ZNS -eq 1 ]]; then 219 run_test "nvme_zns" $rootdir/test/nvme/zns/zns.sh 220 fi 221 222 run_test "nvme_rpc" $rootdir/test/nvme/nvme_rpc.sh 223 run_test "nvme_rpc_timeouts" $rootdir/test/nvme/nvme_rpc_timeouts.sh 224 # Only test hotplug without ASAN enabled. Since if it is 225 # enabled, it catches SEGV earlier than our handler which 226 # breaks the hotplug logic. 227 if [ $SPDK_RUN_ASAN -eq 0 ] && [ $(uname -s) = Linux ]; then 228 run_test "sw_hotplug" $rootdir/test/nvme/sw_hotplug.sh 229 fi 230 231 if [[ $SPDK_TEST_XNVME -eq 1 ]]; then 232 run_test "nvme_xnvme" $rootdir/test/nvme/xnvme/xnvme.sh 233 run_test "blockdev_xnvme" $rootdir/test/bdev/blockdev.sh "xnvme" 234 # Run ublk with xnvme since they have similar kernel dependencies 235 run_test "ublk" $rootdir/test/ublk/ublk.sh 236 fi 237 fi 238 239 if [ $SPDK_TEST_IOAT -eq 1 ]; then 240 run_test "ioat" $rootdir/test/ioat/ioat.sh 241 fi 242 243 timing_exit lib 244 245 if [ $SPDK_TEST_ISCSI -eq 1 ]; then 246 run_test "iscsi_tgt" $rootdir/test/iscsi_tgt/iscsi_tgt.sh 247 run_test "spdkcli_iscsi" $rootdir/test/spdkcli/iscsi.sh 248 249 # Run raid spdkcli test under iSCSI since blockdev tests run on systems that can't run spdkcli yet 250 run_test "spdkcli_raid" $rootdir/test/spdkcli/raid.sh 251 fi 252 253 if [ $SPDK_TEST_BLOBFS -eq 1 ]; then 254 run_test "rocksdb" $rootdir/test/blobfs/rocksdb/rocksdb.sh 255 run_test "blobstore" $rootdir/test/blobstore/blobstore.sh 256 run_test "blobstore_grow" $rootdir/test/blobstore/blobstore_grow/blobstore_grow.sh 257 run_test "blobfs" $rootdir/test/blobfs/blobfs.sh 258 run_test "hello_blob" $SPDK_EXAMPLE_DIR/hello_blob \ 259 examples/blob/hello_world/hello_blob.json 260 fi 261 262 if [ $SPDK_TEST_NVMF -eq 1 ]; then 263 export NET_TYPE 264 # The NVMe-oF run test cases are split out like this so that the parser that compiles the 265 # list of all tests can properly differentiate them. Please do not merge them into one line. 266 if [ "$SPDK_TEST_NVMF_TRANSPORT" = "rdma" ]; then 267 run_test "nvmf_rdma" $rootdir/test/nvmf/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT 268 run_test "spdkcli_nvmf_rdma" $rootdir/test/spdkcli/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT 269 elif [ "$SPDK_TEST_NVMF_TRANSPORT" = "tcp" ]; then 270 run_test "nvmf_tcp" $rootdir/test/nvmf/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT 271 if [[ $SPDK_TEST_URING -eq 0 ]]; then 272 run_test "spdkcli_nvmf_tcp" $rootdir/test/spdkcli/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT 273 run_test "nvmf_identify_passthru" $rootdir/test/nvmf/target/identify_passthru.sh --transport=$SPDK_TEST_NVMF_TRANSPORT 274 fi 275 run_test "nvmf_dif" $rootdir/test/nvmf/target/dif.sh 276 run_test "nvmf_abort_qd_sizes" $rootdir/test/nvmf/target/abort_qd_sizes.sh 277 elif [ "$SPDK_TEST_NVMF_TRANSPORT" = "fc" ]; then 278 run_test "nvmf_fc" $rootdir/test/nvmf/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT 279 run_test "spdkcli_nvmf_fc" $rootdir/test/spdkcli/nvmf.sh 280 else 281 echo "unknown NVMe transport, please specify rdma, tcp, or fc." 282 exit 1 283 fi 284 fi 285 286 if [ $SPDK_TEST_VHOST -eq 1 ]; then 287 run_test "vhost" $rootdir/test/vhost/vhost.sh 288 fi 289 290 if [ $SPDK_TEST_VFIOUSER_QEMU -eq 1 ]; then 291 run_test "vfio_user_qemu" $rootdir/test/vfio_user/vfio_user.sh 292 fi 293 294 if [ $SPDK_TEST_LVOL -eq 1 ]; then 295 run_test "lvol" $rootdir/test/lvol/lvol.sh 296 run_test "blob_io_wait" $rootdir/test/blobstore/blob_io_wait/blob_io_wait.sh 297 fi 298 299 if [ $SPDK_TEST_VHOST_INIT -eq 1 ]; then 300 timing_enter vhost_initiator 301 run_test "vhost_blockdev" $rootdir/test/vhost/initiator/blockdev.sh 302 run_test "spdkcli_virtio" $rootdir/test/spdkcli/virtio.sh 303 run_test "vhost_shared" $rootdir/test/vhost/shared/shared.sh 304 run_test "vhost_fuzz" $rootdir/test/vhost/fuzz/fuzz.sh 305 timing_exit vhost_initiator 306 fi 307 308 if [ $SPDK_TEST_RBD -eq 1 ]; then 309 run_test "blockdev_rbd" $rootdir/test/bdev/blockdev.sh "rbd" 310 run_test "spdkcli_rbd" $rootdir/test/spdkcli/rbd.sh 311 fi 312 313 if [ $SPDK_TEST_OCF -eq 1 ]; then 314 run_test "ocf" $rootdir/test/ocf/ocf.sh 315 fi 316 317 if [ $SPDK_TEST_FTL -eq 1 ]; then 318 run_test "ftl" $rootdir/test/ftl/ftl.sh 319 fi 320 321 if [ $SPDK_TEST_VMD -eq 1 ]; then 322 run_test "vmd" $rootdir/test/vmd/vmd.sh 323 fi 324 325 if [ $SPDK_TEST_VBDEV_COMPRESS -eq 1 ]; then 326 run_test "compress_compdev" $rootdir/test/compress/compress.sh "compdev" 327 run_test "compress_isal" $rootdir/test/compress/compress.sh "isal" 328 fi 329 330 if [ $SPDK_TEST_OPAL -eq 1 ]; then 331 run_test "nvme_opal" $rootdir/test/nvme/nvme_opal.sh 332 fi 333 334 if [ $SPDK_TEST_CRYPTO -eq 1 ]; then 335 run_test "blockdev_crypto_aesni" $rootdir/test/bdev/blockdev.sh "crypto_aesni" 336 run_test "blockdev_crypto_sw" $rootdir/test/bdev/blockdev.sh "crypto_sw" 337 # Proceed with the test only if QAT devices are in place 338 if [[ $(lspci -d:37c8) ]]; then 339 run_test "blockdev_crypto_qat" $rootdir/test/bdev/blockdev.sh "crypto_qat" 340 fi 341 fi 342 343 if [[ $SPDK_TEST_SCHEDULER -eq 1 ]]; then 344 run_test "scheduler" $rootdir/test/scheduler/scheduler.sh 345 fi 346 347 if [[ $SPDK_TEST_SMA -eq 1 ]]; then 348 run_test "sma" $rootdir/test/sma/sma.sh 349 fi 350 351 if [[ $SPDK_TEST_FUZZER -eq 1 ]]; then 352 run_test "llvm_fuzz" $rootdir/test/fuzz/llvm.sh 353 fi 354 355 if [[ $SPDK_TEST_RAID5 -eq 1 ]]; then 356 run_test "blockdev_raid5f" $rootdir/test/bdev/blockdev.sh "raid5f" 357 fi 358fi 359 360trap - SIGINT SIGTERM EXIT 361 362timing_enter cleanup 363autotest_cleanup 364timing_exit cleanup 365 366timing_exit autotest 367chmod a+r $output_dir/timing.txt 368 369[[ -f "$output_dir/udev.log" ]] && rm -f "$output_dir/udev.log" 370 371if hash lcov && ! [[ "$CC_TYPE" == *"clang"* ]]; then 372 # generate coverage data and combine with baseline 373 $LCOV -q -c -d $src -t "$(hostname)" -o $out/cov_test.info 374 $LCOV -q -a $out/cov_base.info -a $out/cov_test.info -o $out/cov_total.info 375 $LCOV -q -r $out/cov_total.info '*/dpdk/*' -o $out/cov_total.info 376 $LCOV -q -r $out/cov_total.info '/usr/*' -o $out/cov_total.info 377 $LCOV -q -r $out/cov_total.info '*/examples/vmd/*' -o $out/cov_total.info 378 $LCOV -q -r $out/cov_total.info '*/app/spdk_lspci/*' -o $out/cov_total.info 379 $LCOV -q -r $out/cov_total.info '*/app/spdk_top/*' -o $out/cov_total.info 380 owner=$(stat -c "%U" .) 381 sudo -u $owner git clean -f "*.gcda" 382 rm -f cov_base.info cov_test.info OLD_STDOUT OLD_STDERR 383fi 384