Skip to content

Add _socket constants from CPython 3.10 #3840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,8 @@ def test_sock_ioctl(self):
@unittest.skipUnless(os.name == "nt", "Windows specific")
@unittest.skipUnless(hasattr(socket, 'SIO_LOOPBACK_FAST_PATH'),
'Loopback fast path support required for this test')
# TODO: RUSTPYTHON, AttributeError: 'socket' object has no attribute 'ioctl'
@unittest.expectedFailure
def test_sio_loopback_fast_path(self):
s = socket.socket()
self.addCleanup(s.close)
Expand Down Expand Up @@ -1733,6 +1735,10 @@ def test_socket_consistent_sock_type(self):
s.setblocking(False)
self.assertEqual(s.type, socket.SOCK_STREAM)

# TODO: RUSTPYTHON, AssertionError: 526337 != <SocketKind.SOCK_STREAM: 1>
if sys.platform == "linux":
test_socket_consistent_sock_type = unittest.expectedFailure(test_socket_consistent_sock_type)

def test_unknown_socket_family_repr(self):
# Test that when created with a family that's not one of the known
# AF_*/SOCK_* constants, socket.family just returns the number.
Expand Down Expand Up @@ -1873,6 +1879,8 @@ def testCrucialConstants(self):

@unittest.skipUnless(hasattr(socket, "CAN_BCM"),
'socket.CAN_BCM required for this test.')
# TODO: RUSTPYTHON, AttributeError: module 'socket' has no attribute 'CAN_BCM_TX_SETUP'
@unittest.expectedFailure
def testBCMConstants(self):
socket.CAN_BCM

Expand Down Expand Up @@ -1913,12 +1921,16 @@ def testCreateBCMSocket(self):
with socket.socket(socket.PF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM) as s:
pass

# TODO: RUSTPYTHON, OSError: bind(): bad family
@unittest.expectedFailure
def testBindAny(self):
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
address = ('', )
s.bind(address)
self.assertEqual(s.getsockname(), address)

# TODO: RUSTPYTHON, AssertionError: "interface name too long" does not match "bind(): bad family"
@unittest.expectedFailure
def testTooLongInterfaceName(self):
# most systems limit IFNAMSIZ to 16, take 1024 to be sure
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
Expand Down Expand Up @@ -4377,6 +4389,8 @@ def testSetBlocking_overflow(self):
@unittest.skipUnless(hasattr(socket, 'SOCK_NONBLOCK'),
'test needs socket.SOCK_NONBLOCK')
@support.requires_linux_version(2, 6, 28)
# TODO: RUSTPYTHON, AssertionError: None != 0
@unittest.expectedFailure
def testInitNonBlocking(self):
# create a socket with SOCK_NONBLOCK
self.serv.close()
Expand Down Expand Up @@ -5395,6 +5409,8 @@ class InheritanceTest(unittest.TestCase):
@unittest.skipUnless(hasattr(socket, "SOCK_CLOEXEC"),
"SOCK_CLOEXEC not defined")
@support.requires_linux_version(2, 6, 28)
# TODO: RUSTPYTHON, AssertionError: 524289 != <SocketKind.SOCK_STREAM: 1>
@unittest.expectedFailure
def test_SOCK_CLOEXEC(self):
with socket.socket(socket.AF_INET,
socket.SOCK_STREAM | socket.SOCK_CLOEXEC) as s:
Expand Down Expand Up @@ -5487,6 +5503,8 @@ def checkNonblock(self, s, nonblock=True, timeout=0.0):
self.assertTrue(s.getblocking())

@support.requires_linux_version(2, 6, 28)
# TODO: RUSTPYTHON, AssertionError: 2049 != <SocketKind.SOCK_STREAM: 1>
@unittest.expectedFailure
def test_SOCK_NONBLOCK(self):
# a lot of it seems silly and redundant, but I wanted to test that
# changing back and forth worked ok
Expand Down Expand Up @@ -5910,6 +5928,8 @@ def create_alg(self, typ, name):
# bpo-31705: On kernel older than 4.5, sendto() failed with ENOKEY,
# at least on ppc64le architecture
@support.requires_linux_version(4, 5)
# TODO: RUSTPYTHON, OSError: bind(): bad family
@unittest.expectedFailure
def test_sha256(self):
expected = bytes.fromhex("ba7816bf8f01cfea414140de5dae2223b00361a396"
"177a9cb410ff61f20015ad")
Expand All @@ -5927,6 +5947,8 @@ def test_sha256(self):
op.send(b'')
self.assertEqual(op.recv(512), expected)

# TODO: RUSTPYTHON, OSError: bind(): bad family
@unittest.expectedFailure
def test_hmac_sha1(self):
expected = bytes.fromhex("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79")
with self.create_alg('hash', 'hmac(sha1)') as algo:
Expand All @@ -5939,6 +5961,8 @@ def test_hmac_sha1(self):
# Although it should work with 3.19 and newer the test blocks on
# Ubuntu 15.10 with Kernel 4.2.0-19.
@support.requires_linux_version(4, 3)
# TODO: RUSTPYTHON, OSError: bind(): bad family
@unittest.expectedFailure
def test_aes_cbc(self):
key = bytes.fromhex('06a9214036b8a15b512e03d534120006')
iv = bytes.fromhex('3dafba429d9eb430b422da802c9fac41')
Expand Down Expand Up @@ -5980,6 +6004,8 @@ def test_aes_cbc(self):
self.assertEqual(dec, msg * multiplier)

@support.requires_linux_version(4, 9) # see issue29324
# TODO: RUSTPYTHON, OSError: bind(): bad family
@unittest.expectedFailure
def test_aead_aes_gcm(self):
key = bytes.fromhex('c939cc13397c1d37de6ae0e1cb7c423c')
iv = bytes.fromhex('b3d8cc017cbb89b39e0f67e2')
Expand Down Expand Up @@ -6043,6 +6069,8 @@ def test_aead_aes_gcm(self):
self.assertEqual(plain, res[assoclen:])

@support.requires_linux_version(4, 3) # see test_aes_cbc
# TODO: RUSTPYTHON, OSError: bind(): bad family
@unittest.expectedFailure
def test_drbg_pr_sha256(self):
# deterministic random bit generator, prediction resistance, sha256
with self.create_alg('rng', 'drbg_pr_sha256') as algo:
Expand All @@ -6053,6 +6081,8 @@ def test_drbg_pr_sha256(self):
rn = op.recv(32)
self.assertEqual(len(rn), 32)

# TODO: RUSTPYTHON, AttributeError: 'socket' object has no attribute 'sendmsg_afalg'
@unittest.expectedFailure
def test_sendmsg_afalg_args(self):
sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
with sock:
Expand All @@ -6071,6 +6101,8 @@ def test_sendmsg_afalg_args(self):
with self.assertRaises(TypeError):
sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=-1)

# TODO: RUSTPYTHON, OSError: bind(): bad family
@unittest.expectedFailure
def test_length_restriction(self):
# bpo-35050, off-by-one error in length check
sock = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
Expand Down
Loading