kadler / cpython

The Python programming language
https://www.python.org/
Other
2 stars 2 forks source link

Test failures in test_asyncio #30

Open kadler opened 3 years ago

kadler commented 3 years ago
======================================================================
FAIL: test_create_datagram_endpoint_sockopts (test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/QOpenSys/jenkins/workspace/cpython_sem-fix/Lib/test/test_asyncio/test_base_events.py", line 1781, in test_create_datagram_endpoint_sockopts
    self.assertFalse(
AssertionError: 1 is not false

======================================================================
FAIL: test_create_server_reuse_port (test.test_asyncio.test_events.PollEventLoopTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/QOpenSys/jenkins/workspace/cpython_sem-fix/Lib/test/test_asyncio/test_events.py", line 817, in test_create_server_reuse_port
    self.assertFalse(
AssertionError: 1 is not false

======================================================================
FAIL: test_create_server_reuse_port (test.test_asyncio.test_events.SelectEventLoopTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/QOpenSys/jenkins/workspace/cpython_sem-fix/Lib/test/test_asyncio/test_events.py", line 817, in test_create_server_reuse_port
    self.assertFalse(
AssertionError: 1 is not false
abmusse commented 3 years ago

SLIC maps SO_REUSEPORT to SO_REUSEADDR

This behavior can be seen from the repl:

>>> import socket
>>> sock = socket.socket()
>>> sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
0
>>> sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)
0
>>> sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
>>> sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
1
>>> sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)
1

and vice versa

>>> import socket
>>> sock = socket.socket()
>>> sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
0
>>> sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)
0
>>> sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
>>> sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)
1
>>> sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
1

test_create_datagram_endpoint_sockopts (test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests)

Sets reuse_port=True and then asserts SO_REUSEADDR is false aka 0. Well since SO_REUSEPORT gets set to 1 so does SO_REUSEADDR on IBM i.

test_create_server_reuse_port

within socket.create_server tries to set the SO_REUSEADDR option which in turn enables SO_REUSEPORT. So the assert within the test case fails here expecting SO_REUSEPORT to be false we in reality its set on by enables SO_REUSEADDR in socket.creat_server

abmusse commented 3 years ago

@kadler

To work around these assertion failures should add conditionals for IBM i that assert that opposite of the failures?

abmusse commented 3 years ago

https://github.com/kadler/cpython/commit/4179691af862dd2f15fd41be0de2dffad8eab136