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 12source "$1" 13source "$rootdir/test/common/autotest_common.sh" 14source "$rootdir/test/nvmf/common.sh" 15 16if [ $EUID -ne 0 ]; then 17 echo "$0 must be run as root" 18 exit 1 19fi 20 21if [ $(uname -s) = Linux ]; then 22 # set core_pattern to a known value to avoid ABRT, systemd-coredump, etc. 23 echo "core" > /proc/sys/kernel/core_pattern 24 25 # make sure nbd (network block device) driver is loaded if it is available 26 # this ensures that when tests need to use nbd, it will be fully initialized 27 modprobe nbd || true 28fi 29 30trap "process_core; autotest_cleanup; exit 1" SIGINT SIGTERM EXIT 31 32timing_enter autotest 33 34create_test_list 35 36src=$(readlink -f $(dirname $0)) 37out=$PWD 38cd $src 39 40./scripts/setup.sh status 41 42freebsd_update_contigmem_mod 43 44if hash lcov; then 45 # setup output dir for unittest.sh 46 export UT_COVERAGE=$out/ut_coverage 47 export LCOV_OPTS=" 48 --rc lcov_branch_coverage=1 49 --rc lcov_function_coverage=1 50 --rc genhtml_branch_coverage=1 51 --rc genhtml_function_coverage=1 52 --rc genhtml_legend=1 53 --rc geninfo_all_blocks=1 54 " 55 export LCOV="lcov $LCOV_OPTS --no-external" 56 # Print lcov version to log 57 $LCOV -v 58 # zero out coverage data 59 $LCOV -q -c -i -t "Baseline" -d $src -o cov_base.info 60fi 61 62# Make sure the disks are clean (no leftover partition tables) 63timing_enter cleanup 64# Remove old domain socket pathname just in case 65rm -f /var/tmp/spdk*.sock 66 67# Load the kernel driver 68./scripts/setup.sh reset 69 70# Let the kernel discover any filesystems or partitions 71sleep 10 72 73if [ $(uname -s) = Linux ]; then 74 # OCSSD devices drivers don't support IO issues by kernel so 75 # detect OCSSD devices and blacklist them (unbind from any driver). 76 # If test scripts want to use this device it needs to do this explicitly. 77 # 78 # If some OCSSD device is bound to other driver than nvme we won't be able to 79 # discover if it is OCSSD or not so load the kernel driver first. 80 81 82 for dev in $(find /dev -maxdepth 1 -regex '/dev/nvme[0-9]+'); do 83 # Send Open Channel 2.0 Geometry opcode "0xe2" - not supported by NVMe device. 84 if nvme admin-passthru $dev --namespace-id=1 --data-len=4096 --opcode=0xe2 --read >/dev/null; then 85 bdf="$(basename $(readlink -e /sys/class/nvme/${dev#/dev/}/device))" 86 echo "INFO: blacklisting OCSSD device: $dev ($bdf)" 87 PCI_BLACKLIST+=" $bdf" 88 OCSSD_PCI_DEVICES+=" $bdf" 89 fi 90 done 91 92 export OCSSD_PCI_DEVICES 93 94 # Now, bind blacklisted devices to pci-stub module. This will prevent 95 # automatic grabbing these devices when we add device/vendor ID to 96 # proper driver. 97 if [[ -n "$PCI_BLACKLIST" ]]; then 98 PCI_WHITELIST="$PCI_BLACKLIST" \ 99 PCI_BLACKLIST="" \ 100 DRIVER_OVERRIDE="pci-stub" \ 101 ./scripts/setup.sh 102 103 # Export our blacklist so it will take effect during next setup.sh 104 export PCI_BLACKLIST 105 fi 106fi 107 108# Delete all leftover lvols and gpt partitions 109# Matches both /dev/nvmeXnY on Linux and /dev/nvmeXnsY on BSD 110# Filter out nvme with partitions - the "p*" suffix 111for dev in $(ls /dev/nvme*n* | grep -v p || true); do 112 dd if=/dev/zero of="$dev" bs=1M count=1 113done 114 115sync 116 117timing_exit cleanup 118 119# set up huge pages 120timing_enter afterboot 121./scripts/setup.sh 122timing_exit afterboot 123 124timing_enter nvmf_setup 125rdma_device_init 126timing_exit nvmf_setup 127 128if [[ $SPDK_TEST_CRYPTO -eq 1 || $SPDK_TEST_REDUCE -eq 1 ]]; then 129 if grep -q '#define SPDK_CONFIG_IGB_UIO_DRIVER 1' $rootdir/include/spdk/config.h; then 130 ./scripts/qat_setup.sh igb_uio 131 else 132 ./scripts/qat_setup.sh 133 fi 134fi 135 136##################### 137# Unit Tests 138##################### 139 140if [ $SPDK_TEST_UNITTEST -eq 1 ]; then 141 timing_enter unittest 142 run_test suite ./test/unit/unittest.sh 143 report_test_completion "unittest" 144 timing_exit unittest 145fi 146 147 148if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then 149 timing_enter lib 150 151 run_test suite test/env/env.sh 152 run_test suite test/rpc_client/rpc_client.sh 153 run_test suite ./test/json_config/json_config.sh 154 155 if [ $SPDK_TEST_BLOCKDEV -eq 1 ]; then 156 run_test suite test/bdev/blockdev.sh 157 if [[ $RUN_NIGHTLY -eq 1 ]]; then 158 run_test suite test/bdev/bdev_raid.sh 159 fi 160 fi 161 162 if [ $SPDK_TEST_JSON -eq 1 ]; then 163 run_test suite test/config_converter/test_converter.sh 164 fi 165 166 if [ $SPDK_TEST_EVENT -eq 1 ]; then 167 run_test suite test/event/event.sh 168 fi 169 170 if [ $SPDK_TEST_NVME -eq 1 ]; then 171 run_test suite test/nvme/nvme.sh 172 if [ $SPDK_TEST_NVME_CLI -eq 1 ]; then 173 run_test suite test/nvme/spdk_nvme_cli.sh 174 fi 175 # Only test hotplug without ASAN enabled. Since if it is 176 # enabled, it catches SEGV earlier than our handler which 177 # breaks the hotplug logic. 178 # Temporary workaround for issue #542, annotated for no VM image. 179 #if [ $SPDK_RUN_ASAN -eq 0 ]; then 180 # run_test suite test/nvme/hotplug.sh intel 181 #fi 182 fi 183 184 if [ $SPDK_TEST_IOAT -eq 1 ]; then 185 run_test suite test/ioat/ioat.sh 186 fi 187 188 timing_exit lib 189 190 if [ $SPDK_TEST_ISCSI -eq 1 ]; then 191 run_test suite ./test/iscsi_tgt/iscsi_tgt.sh posix 192 run_test suite ./test/spdkcli/iscsi.sh 193 194 # Run raid spdkcli test under iSCSI since blockdev tests run on systems that can't run spdkcli yet 195 run_test suite test/spdkcli/raid.sh 196 fi 197 198 if [ $SPDK_TEST_VPP -eq 1 ]; then 199 run_test suite ./test/iscsi_tgt/iscsi_tgt.sh vpp 200 fi 201 202 if [ $SPDK_TEST_BLOBFS -eq 1 ]; then 203 run_test suite ./test/blobfs/rocksdb/rocksdb.sh 204 run_test suite ./test/blobstore/blobstore.sh 205 fi 206 207 if [ $SPDK_TEST_NVMF -eq 1 ]; then 208 run_test suite ./test/nvmf/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT 209 run_test suite ./test/spdkcli/nvmf.sh 210 fi 211 212 if [ $SPDK_TEST_VHOST -eq 1 ]; then 213 run_test suite ./test/vhost/vhost.sh 214 report_test_completion "vhost" 215 fi 216 217 if [ $SPDK_TEST_LVOL -eq 1 ]; then 218 timing_enter lvol 219 run_test suite ./test/lvol/lvol.sh --test-cases=all 220 run_test suite ./test/blobstore/blob_io_wait/blob_io_wait.sh 221 report_test_completion "lvol" 222 timing_exit lvol 223 fi 224 225 if [ $SPDK_TEST_VHOST_INIT -eq 1 ]; then 226 timing_enter vhost_initiator 227 run_test suite ./test/vhost/initiator/blockdev.sh 228 run_test suite ./test/spdkcli/virtio.sh 229 run_test suite ./test/vhost/shared/shared.sh 230 run_test suite ./test/vhost/fuzz/fuzz.sh 231 report_test_completion "vhost_initiator" 232 timing_exit vhost_initiator 233 fi 234 235 if [ $SPDK_TEST_PMDK -eq 1 ]; then 236 run_test suite ./test/pmem/pmem.sh -x 237 run_test suite ./test/spdkcli/pmem.sh 238 fi 239 240 if [ $SPDK_TEST_RBD -eq 1 ]; then 241 run_test suite ./test/spdkcli/rbd.sh 242 fi 243 244 if [ $SPDK_TEST_OCF -eq 1 ]; then 245 run_test suite ./test/ocf/ocf.sh 246 fi 247 248 if [ $SPDK_TEST_BDEV_FTL -eq 1 ]; then 249 run_test suite ./test/ftl/ftl.sh 250 fi 251 252 if [ $SPDK_TEST_VMD -eq 1 ]; then 253 run_test suite ./test/vmd/vmd.sh 254 fi 255 256 if [ $SPDK_TEST_REDUCE -eq 1 ]; then 257 run_test suite ./test/compress/compress.sh 258 fi 259fi 260 261timing_enter cleanup 262autotest_cleanup 263timing_exit cleanup 264 265timing_exit autotest 266chmod a+r $output_dir/timing.txt 267 268trap - SIGINT SIGTERM EXIT 269 270# catch any stray core files 271process_core 272 273if hash lcov; then 274 # generate coverage data and combine with baseline 275 $LCOV -q -c -d $src -t "$(hostname)" -o cov_test.info 276 $LCOV -q -a cov_base.info -a cov_test.info -o $out/cov_total.info 277 $LCOV -q -r $out/cov_total.info '*/dpdk/*' -o $out/cov_total.info 278 $LCOV -q -r $out/cov_total.info '/usr/*' -o $out/cov_total.info 279 git clean -f "*.gcda" 280 rm -f cov_base.info cov_test.info OLD_STDOUT OLD_STDERR 281fi 282