mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 13:01:10 +02:00
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 <damien@micropython.org>
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user