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:
parent
8978f6552b
commit
05a2c7ae3c
2 changed files with 9 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue