test: move get_nvme_name_from_bdf function to autotest_common.sh
This function is useful for each test which use nvme device, so it will be easier to keep it in autotest_common.sh file instead of including also nvme.sh in each test. Signed-off-by: Marcin Dziegielewski <marcin.dziegielewski@intel.com> Change-Id: Ic2e186826211725b95f3ec3b455d23f43ea41b8f Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464691 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
1e82ec0640
commit
28f4299fe7
@ -828,6 +828,27 @@ function freebsd_update_contigmem_mod()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_nvme_name_from_bdf {
|
||||||
|
blkname=()
|
||||||
|
|
||||||
|
nvme_devs=$(lsblk -d --output NAME | grep "^nvme") || true
|
||||||
|
if [ -z "$nvme_devs" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
for dev in $nvme_devs; do
|
||||||
|
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
|
||||||
|
blkname+=($dev)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
printf '%s\n' "${blkname[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
set -o errtrace
|
set -o errtrace
|
||||||
trap "trap - ERR; print_backtrace >&2" ERR
|
trap "trap - ERR; print_backtrace >&2" ERR
|
||||||
|
|
||||||
|
@ -5,27 +5,6 @@ rootdir=$(readlink -f $testdir/../..)
|
|||||||
source $rootdir/scripts/common.sh
|
source $rootdir/scripts/common.sh
|
||||||
source $rootdir/test/common/autotest_common.sh
|
source $rootdir/test/common/autotest_common.sh
|
||||||
|
|
||||||
function get_nvme_name_from_bdf {
|
|
||||||
blkname=()
|
|
||||||
|
|
||||||
nvme_devs=$(lsblk -d --output NAME | grep "^nvme") || true
|
|
||||||
if [ -z "$nvme_devs" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
for dev in $nvme_devs; do
|
|
||||||
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
|
|
||||||
blkname+=($dev)
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
printf '%s\n' "${blkname[@]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
timing_enter nvme
|
timing_enter nvme
|
||||||
|
|
||||||
if [ $(uname) = Linux ]; then
|
if [ $(uname) = Linux ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user