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