From 357950b7820b4539761a8bd6426e0336007881af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Thu, 6 Nov 2025 13:39:52 +0100 Subject: [PATCH] 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. --- test/infamy/netutil.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/infamy/netutil.py b/test/infamy/netutil.py index 115d6e94..cdc9a552 100644 --- a/test/infamy/netutil.py +++ b/test/infamy/netutil.py @@ -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