diff options
Diffstat (limited to 'tests/extmod/select_poll_eintr.py')
-rw-r--r-- | tests/extmod/select_poll_eintr.py | 16 |
1 files 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) |