1#!/usr/bin/env bash 2 3testdir=$(readlink -f $(dirname $0)) 4rootdir=$(readlink -f $testdir/../../..) 5source $rootdir/test/common/autotest_common.sh 6source $rootdir/test/nvmf/common.sh 7 8if [ -z "${DEPENDENCY_DIR}" ]; then 9 echo DEPENDENCY_DIR not defined! 10 exit 1 11fi 12 13MALLOC_BDEV_SIZE=64 14MALLOC_BLOCK_SIZE=512 15 16devs=() 17 18nvmftestinit 19nvmfappstart -m 0xF 20 21$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 22 23$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0 24$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc1 25 26$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL -d SPDK_Controller1 -i 291 27$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0 28$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 29$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT 30$rpc_py nvmf_subsystem_add_listener discovery -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT 31 32nvme discover -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s "$NVMF_PORT" 33devs=($(get_nvme_devs)) nvme_num_before_connection=${#devs[@]} 34nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" 35 36waitforserial $NVMF_SERIAL 2 37if [[ -z $(get_nvme_devs) ]]; then 38 echo "Could not find any nvme devices to work with, aborting the test" >&2 39 exit 1 40fi 41 42for ctrl in "${nvmes[@]}"; do 43 nvme id-ctrl $ctrl 44 nvme smart-log $ctrl 45 nvme_model=$(nvme id-ctrl $ctrl | grep -w mn | sed 's/^.*: //' | sed 's/ *$//') 46 if [ "$nvme_model" != "SPDK_Controller1" ]; then 47 echo "Wrong model number for controller" $nvme_model 48 exit 1 49 fi 50 nvme_cntlid=$(nvme id-ctrl $ctrl | grep -w cntlid | sed 's/^.*: //' | sed 's/ *$//') 51 if [ "$nvme_cntlid" != "0x123" ]; then 52 echo "Wrong controller ID for controller" $nvme_model 53 exit 1 54 fi 55done 56 57for ns in "${nvmes[@]}"; do 58 nvme id-ns $ns 59done 60 61devs=($(get_nvme_devs)) nvme_num=${#devs[@]} 62nvme disconnect -n "nqn.2016-06.io.spdk:cnode1" 63waitforserial_disconnect "$NVMF_SERIAL" 64if ((nvme_num <= nvme_num_before_connection)); then 65 echo "nvme-cli connect target devices failed" 66 exit 1 67fi 68 69$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1 70trap - SIGINT SIGTERM EXIT 71 72nvmftestfini 73