script: add waitforbdev

The purpose is to control the time for test instead
of using sleep 1 or sheep 5when waiting for the ready
of bdevs.

Change-Id: I0319bcc270257612077da42024217d532cbc34e3
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/368264
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Ziye Yang 2017-07-06 10:41:57 +08:00 committed by Jim Harris
parent 5d12c41586
commit f8c1454824

View File

@ -194,6 +194,21 @@ function waitforlisten() {
set -x
}
function waitforbdev() {
bdev_name=$1
rpc_py=$2
for ((i=1; i<=10; i++)); do
if [ ! -z "`$rpc_py get_bdevs | grep $bdev_name`" ]; then
return 0
else
sleep 0.1
fi
done
return 1
}
function killprocess() {
# $1 = process pid
if [ -z "$1" ]; then