aboutgitcodebugslistschat
path: root/test/lib/util
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-09-26 20:43:36 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-09-29 12:20:44 +0200
commit05a2c7ae3c7bb7bb67ed0294efd9f3151da08aa3 (patch)
tree5b3b95b60b9b34f4d9d12b572ddec211d8cdba69 /test/lib/util
parent8978f6552b8cfae28b9d842db99b01aefb465812 (diff)
downloadpasst-05a2c7ae3c7bb7bb67ed0294efd9f3151da08aa3.tar
passt-05a2c7ae3c7bb7bb67ed0294efd9f3151da08aa3.tar.gz
passt-05a2c7ae3c7bb7bb67ed0294efd9f3151da08aa3.tar.bz2
passt-05a2c7ae3c7bb7bb67ed0294efd9f3151da08aa3.tar.lz
passt-05a2c7ae3c7bb7bb67ed0294efd9f3151da08aa3.tar.xz
passt-05a2c7ae3c7bb7bb67ed0294efd9f3151da08aa3.tar.zst
passt-05a2c7ae3c7bb7bb67ed0294efd9f3151da08aa3.zip
test: Add wait_for() shell helper
Add a shell helper function to wait for some command to succeed - typically a test for something to be done by a background process. Use it in the context code which waits for the guest to respond to ssh-over-vsock connections. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'test/lib/util')
-rwxr-xr-xtest/lib/util8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/lib/util b/test/lib/util
index dee6c8d..c1b3262 100755
--- a/test/lib/util
+++ b/test/lib/util
@@ -123,3 +123,11 @@ get_info_cols() {
__j=$((__j + 1))
done
}
+
+# wait_for() - Retry a command until it succeeds
+# $@: Command to run
+wait_for() {
+ while ! "$@"; do
+ sleep 0.1 || sleep 1
+ done
+}