test/nvme.sh: add support for older kernel versions

the sysfs for NVMe drives on some older versions of the linux kernel
differs slightly from the latest kernel versions. This patch adds a
fallback to support those older kernel versions.

Change-Id: I2787e0d15d310ce1f264b0a303f53e48525a9a1d
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/391983
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Seth Howell 2017-12-15 11:54:25 -07:00 committed by Jim Harris
parent f6465006d7
commit 102746245e

View File

@ -17,7 +17,11 @@ function get_nvme_name_from_bdf {
fi fi
nvme_devs=`lsblk -d --output NAME | grep "^nvme"` nvme_devs=`lsblk -d --output NAME | grep "^nvme"`
for dev in $nvme_devs; do for dev in $nvme_devs; do
bdf=$(basename $(readlink /sys/block/$dev/device/device)) link_name=$(readlink /sys/block/$dev/device/device) || true
if [ -z "$link_name" ]; then
link_name=$(readlink /sys/block/$dev/device)
fi
bdf=$(basename "$link_name")
if [ "$bdf" = "$1" ]; then if [ "$bdf" = "$1" ]; then
eval "$2=$dev" eval "$2=$dev"
return return