test/system: Add, use tcp_port_probe() to check for listeners rather than binds
_test_skopeo_credential_sharing() used port_is_free() to check if a port has no active listeners. With the new implementation, this is not equivalent anymore: a port might be in TIME_WAIT, so it's not free, but the listener might be long gone. Add tcp_port_probe() to check if there's an active listener on a given port, and use it in _test_skopeo_credential_sharing(). Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
348c3f2833
commit
cb8c9af5d3
|
@ -344,7 +344,7 @@ function _test_skopeo_credential_sharing() {
|
|||
fi
|
||||
|
||||
# Make sure socket is closed
|
||||
if ! port_is_free $PODMAN_LOGIN_REGISTRY_PORT; then
|
||||
if tcp_port_probe $PODMAN_LOGIN_REGISTRY_PORT; then
|
||||
die "Socket still seems open"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -286,3 +286,12 @@ function wait_for_port() {
|
|||
|
||||
die "Timed out waiting for $host:$port"
|
||||
}
|
||||
|
||||
# tcp_port_probe() - Check if a TCP port has an active listener
|
||||
# $1: Port number
|
||||
# $2: Optional address, 0.0.0.0 by default
|
||||
function tcp_port_probe() {
|
||||
local address="${2:-0.0.0.0}"
|
||||
|
||||
: | nc "${address}" "${1}"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue