mirror of
https://github.com/containers/podman.git
synced 2025-05-21 00:56:36 +08:00
test/system: Use port_is_free() from wait_for_port()
Currently, wait_for_port() duplicates the check logic implemented by port_is_free(). Add an optional argument to port_is_free(), representing the bound address to check, and call it, dropping the direct check in wait_for_port(). Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
@ -316,8 +316,10 @@ function random_free_port_range() {
|
||||
}
|
||||
|
||||
function port_is_free() {
|
||||
local port=${1?Usage: port_is_free PORT}
|
||||
! { exec {unused_fd}<> /dev/tcp/127.0.0.1/$port; } &>/dev/null
|
||||
local port=${1?Usage: port_is_free PORT [ADDRESS]}
|
||||
local address="${2:-127.0.0.1}"
|
||||
|
||||
! { exec {unused_fd}<> /dev/tcp/"${address}"/$port; } &>/dev/null
|
||||
}
|
||||
|
||||
###################
|
||||
@ -330,7 +332,7 @@ function wait_for_port() {
|
||||
|
||||
# Wait
|
||||
while [ $_timeout -gt 0 ]; do
|
||||
{ exec {unused_fd}<> /dev/tcp/$host/$port; } &>/dev/null && return
|
||||
port_is_free ${port} "${host}" && return
|
||||
sleep 1
|
||||
_timeout=$(( $_timeout - 1 ))
|
||||
done
|
||||
|
Reference in New Issue
Block a user