X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Ffunctions-common;h=08d489e5d59a94afd1262ab94b772e28c0aa0f8d;hb=c9d0d2c9fc16f2e989444bc4d7d8fab8060433ba;hp=db2565a3d6a1444c82ee8b7854fdf2757fdc30b1;hpb=ee4ef36ad0d93ecce542429d49ea368b39940ef9;p=doctor.git diff --git a/tests/functions-common b/tests/functions-common index db2565a3..08d489e5 100644 --- a/tests/functions-common +++ b/tests/functions-common @@ -70,3 +70,20 @@ function die_if_not_set { $xtrace } +# Wait until the condition is met. +# wait_until condition timeout interval +function wait_until { + local condition="$1" + local timeout=$2 + local interval=$3 + + while eval ${condition} + do + sleep ${interval} + timeout=$((${timeout} - ${interval})) + if [[ ${timeout} < 0 ]]; then + err $LINENO "timed out ($condition)..." + return 1 + fi + done +}