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