test/nvmf: Handle lack of nvme devices in a more graceful way
In case there are no /dev/nvme* devices found, the test will continue regardless trying to pass literal glob strings as an argument to nvme. This, of course, fails, e.g: ci.spdk.io/public_build/autotest-per-patch_7066.html Avoid this by generating list of the nvme devices and abort the test gracefully in case it's empty. Change-Id: I71628aa78a5cfc6c5696f1fc17ed3480d4c642ee Signed-off-by: Michal Berger <michalx.berger@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1392 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
c65b591b7d
commit
f86e25c064
@ -278,3 +278,20 @@ function nvme_connect()
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function get_nvme_devs()
|
||||
{
|
||||
local dev rest
|
||||
|
||||
nvmes=()
|
||||
while read -r dev rest; do
|
||||
if [[ $dev == /dev/nvme* ]]; then
|
||||
nvmes+=("$dev")
|
||||
fi
|
||||
if [[ $1 == print ]]; then
|
||||
echo "$dev $rest"
|
||||
fi
|
||||
done < <(nvme list)
|
||||
(( ${#nvmes[@]} )) || return 1
|
||||
echo "${#nvmes[@]}" >&2
|
||||
}
|
||||
|
@ -33,9 +33,12 @@ $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPOR
|
||||
nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
|
||||
|
||||
waitforserial $NVMF_SERIAL 2
|
||||
nvme list
|
||||
if ! get_nvme_devs print 2>/dev/null; then
|
||||
echo "Could not find any nvme devices to work with, aborting the test" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for ctrl in /dev/nvme?; do
|
||||
for ctrl in "${nvmes[@]}"; do
|
||||
nvme id-ctrl $ctrl
|
||||
nvme smart-log $ctrl
|
||||
nvme_model=$(nvme id-ctrl $ctrl | grep -w mn | sed 's/^.*: //' | sed 's/ *$//')
|
||||
@ -45,7 +48,7 @@ for ctrl in /dev/nvme?; do
|
||||
fi
|
||||
done
|
||||
|
||||
for ns in /dev/nvme?n*; do
|
||||
for ns in "${nvmes[@]}"; do
|
||||
nvme id-ns $ns
|
||||
done
|
||||
|
||||
@ -56,10 +59,10 @@ if [ -d $spdk_nvme_cli ]; then
|
||||
cd $spdk_nvme_cli
|
||||
sed -i 's/shm_id=.*/shm_id=-1/g' spdk.conf
|
||||
./nvme discover -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s "$NVMF_PORT"
|
||||
nvme_num_before_connection=$(nvme list |grep "/dev/nvme"|awk '{print $1}'|wc -l)
|
||||
nvme_num_before_connection=$(get_nvme_devs 2>&1 || echo 0)
|
||||
./nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
|
||||
sleep 1
|
||||
nvme_num=$(nvme list |grep "/dev/nvme"|awk '{print $1}'|wc -l)
|
||||
nvme_num=$(get_nvme_devs 2>&1)
|
||||
./nvme disconnect -n "nqn.2016-06.io.spdk:cnode1"
|
||||
if [ $nvme_num -le $nvme_num_before_connection ]; then
|
||||
echo "spdk/nvme-cli connect target devices failed"
|
||||
|
Loading…
x
Reference in New Issue
Block a user