test: imfamy: Allow broken images

If ping succeed but fail to check if netconf port is open,
the testsystem will hang forever.

This will allow totally broken images to be loaded at the device.
This commit is contained in:
Mattias Walström
2025-11-06 13:39:52 +01:00
parent 20673c3a84
commit 357950b782
+4 -7
View File
@@ -1,11 +1,8 @@
import socket
def tcp_port_is_open(host, port):
def tcp_port_is_open(host, port, timeout=3):
try:
ai = socket.getaddrinfo(host, port, 0, 0, socket.SOL_TCP)
sock = socket.socket(ai[0][0], ai[0][1], 0)
sock.connect(ai[0][4])
sock.close()
return True
except Exception:
with socket.create_connection((host, port), timeout=timeout):
return True
except (socket.timeout, OSError):
return False