1#!/usr/bin/env bash 2 3testdir=$(readlink -f $(dirname $0)) 4rootdir=$(readlink -f $testdir/../../..) 5rpc_py=$rootdir/scripts/rpc.py 6 7source $rootdir/test/common/autotest_common.sh 8source $rootdir/test/nvmf/common.sh 9 10null_bdev_size=1024 11null_block_size=512 12null_bdev=null0 13nvme_bdev=nvme0 14 15if [ "$TEST_TRANSPORT" != "tcp" ]; then 16 echo "This test can only be executed with TCP for now" 17 exit 0 18fi 19 20nvmftestinit 21nvmfappstart -m 0x1 22 23# First create a null bdev and expose it over NVMeoF 24$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS 25$rpc_py bdev_null_create $null_bdev $null_bdev_size $null_block_size 26$rpc_py bdev_wait_for_examine 27$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode0 -a 28$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode0 $null_bdev 29$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode0 -t $TEST_TRANSPORT \ 30 -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT 31 32# Then attach NVMe bdev by connecting back to itself, with the target app running on a single core. 33# This verifies that the initialization is completely asynchronous, as each blocking call would 34# stall the application. 35$rpc_py bdev_nvme_attach_controller -b $nvme_bdev -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \ 36 -f ipv4 -s $NVMF_PORT -n nqn.2016-06.io.spdk:cnode0 37 38# Make sure the bdev was created successfully 39$rpc_py bdev_get_bdevs -b ${nvme_bdev}n1 40 41# Make sure the reset is also asynchronous 42$rpc_py bdev_nvme_reset_controller $nvme_bdev 43 44# And that the bdev is still available after a reset 45$rpc_py bdev_get_bdevs -b ${nvme_bdev}n1 46 47# Finally, detach the controller to verify the detach path 48$rpc_py bdev_nvme_detach_controller $nvme_bdev 49 50trap - SIGINT SIGTERM EXIT 51nvmftestfini 52