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