From 975e4614966bd296e2a13902cb8073e3e93dcdb4 Mon Sep 17 00:00:00 2001 From: paul luse Date: Tue, 28 May 2019 17:51:56 -0400 Subject: [PATCH] test/autotest_common: add new function waitforbdev() Waits up to 2 seconds for a bdev to arrive, if not returns error. In the next patch in this series this is used and seems like a good general function. Change-Id: I3402f34f3dad3d7373973dc785520a5c4e58cd14 Signed-off-by: paul luse Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456091 Reviewed-by: Jim Harris Reviewed-by: Darek Stojaczyk Tested-by: SPDK CI Jenkins --- test/common/autotest_common.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 06e5b3867..b3042f377 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -416,6 +416,21 @@ function waitfornbd() { return 1 } +function waitforbdev() { + local bdev_name=$1 + local i + + for ((i=1; i<=20; i++)); do + if ! $rpc_py get_bdevs | jq -r '.[] .name' | grep -qw $bdev_name; then + sleep 0.1 + else + return 0 + fi + done + + return 1 +} + function killprocess() { # $1 = process pid if [ -z "$1" ]; then