1
0
mirror of https://passt.top/passt synced 2024-07-01 23:42:41 +00:00

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>
This commit is contained in:
David Gibson 2022-09-26 20:43:36 +10:00 committed by Stefano Brivio
parent 8978f6552b
commit 05a2c7ae3c
2 changed files with 9 additions and 3 deletions

View File

@ -63,9 +63,7 @@ EOF
echo "ssh -F ${__ssh} ${__name}" > "${__enter}"
# Wait for the guest to be booted and accepting connections
while ! ssh -F "${__ssh}" "${__name}" :; do
sleep 0.1
done
wait_for ssh -F "${__ssh}" "${__name}" :
}
# context_teardown() - Remove a context (leave log files intact)

View File

@ -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
}