summaryrefslogtreecommitdiffstats
path: root/tests/functions-common
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functions-common')
-rw-r--r--tests/functions-common17
1 files changed, 17 insertions, 0 deletions
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
+}