Files
gvisor-tap-vsock/test-utils/port.go
Luca Stocchi e897a4aa4a test: add basic tests for vfkit
Adds a basic implementation for testing against a vfkit VM. Tests are based on the existing qemu version. It just changes the way the VM gets created/started.

It also adds a func to decompress .gz files as the fcos release for apple hypervisor is raw.gz format

Signed-off-by: Luca Stocchi <lstocchi@redhat.com>
2025-01-09 15:57:22 +01:00

20 lines
339 B
Go

package e2eutils
import (
"net"
"strconv"
)
func IsPortAvailable(port int) bool {
return IsHostPortAvailable("127.0.0.1", port)
}
func IsHostPortAvailable(host string, port int) bool {
listener, err := net.Listen("tcp", net.JoinHostPort(host, strconv.Itoa(port)))
if err != nil {
return false
}
listener.Close()
return true
}