From 168e2c8f66d9cfb8c5212fc236aa645ad8275876 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 30 Jun 2025 11:53:00 +1000 Subject: [PATCH] tests/extmod/select_poll_eintr.py: Skip test if target can't bind. Eg on PYBV10 with THREAD variant, the firmware has both the `_thread` and `socket` modules but no NIC. Signed-off-by: Damien George --- tests/extmod/select_poll_eintr.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/extmod/select_poll_eintr.py b/tests/extmod/select_poll_eintr.py index e1cbc2aaf5..d9e9b31909 100644 --- a/tests/extmod/select_poll_eintr.py +++ b/tests/extmod/select_poll_eintr.py @@ -10,6 +10,18 @@ except (ImportError, AttributeError): print("SKIP") raise SystemExit +# Use a new UDP socket for tests, which should be writable but not readable. +s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +localhost_addr_info = socket.getaddrinfo("127.0.0.1", 8000) +try: + s.bind(localhost_addr_info[0][-1]) +except OSError: + # Target can't bind to localhost. + # Most likely it doesn't have a NIC and the test cannot be run. + s.close() + print("SKIP") + raise SystemExit + def thread_main(): lock.acquire() @@ -26,10 +38,6 @@ lock = _thread.allocate_lock() lock.acquire() _thread.start_new_thread(thread_main, ()) -# Use a new UDP socket for tests, which should be writable but not readable. -s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) -s.bind(socket.getaddrinfo("127.0.0.1", 8000)[0][-1]) - # Create the poller object. poller = select.poll() poller.register(s, select.POLLIN)