Commit 70f7ea3e authored by Michal Berger's avatar Michal Berger Committed by Ben Walker
Browse files

test/nvmf: Simplify get_nvme_devs()

This function was unintentionally including trace lines in its output
by playing with stderr (where -x is redirecting its output by default).
Avoid that by simply listing the devices and doing proper checks from
within the actual test.

Spotted in https://github.com/spdk/spdk/issues/1973



Signed-off-by: default avatarMichal Berger <michalx.berger@intel.com>
Change-Id: If15375aca152aaa49267c9cc51e70fd859685ea1
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8156


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 522faef3
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -507,19 +507,13 @@ function nvme_connect() {
}

function get_nvme_devs() {
	local dev rest
	local dev _

	nvmes=()
	while read -r dev rest; do
	while read -r dev _; do
		if [[ $dev == /dev/nvme* ]]; then
			nvmes+=("$dev")
		fi
		if [[ $1 == print ]]; then
			echo "$dev $rest"
			echo "$dev"
		fi
	done < <(nvme list)
	((${#nvmes[@]})) || return 1
	echo "${#nvmes[@]}" >&2
}

function gen_nvmf_target_json() {
+5 −4
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ MALLOC_BDEV_SIZE=64
MALLOC_BLOCK_SIZE=512

rpc_py="$rootdir/scripts/rpc.py"
devs=()

nvmftestinit
nvmfappstart -m 0xF
@@ -29,11 +30,11 @@ $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1
$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT

nvme discover -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s "$NVMF_PORT"
nvme_num_before_connection=$(get_nvme_devs 2>&1 || echo 0)
devs=($(get_nvme_devs)) nvme_num_before_connection=${#devs[@]}
nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"

waitforserial $NVMF_SERIAL 2
if ! get_nvme_devs print 2> /dev/null; then
if [[ -z $(get_nvme_devs) ]]; then
	echo "Could not find any nvme devices to work with, aborting the test" >&2
	exit 1
fi
@@ -57,9 +58,9 @@ for ns in "${nvmes[@]}"; do
	nvme id-ns $ns
done

nvme_num=$(get_nvme_devs 2>&1)
devs=($(get_nvme_devs)) nvme_num=${#devs[@]}
nvme disconnect -n "nqn.2016-06.io.spdk:cnode1"
if [ $nvme_num -le $nvme_num_before_connection ]; then
if ((nvme_num <= nvme_num_before_connection)); then
	echo "nvme-cli connect target devices failed"
	exit 1
fi