Skip to content
Closed
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
20 changes: 13 additions & 7 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import queue
import sys
import os
import platform
import array
import contextlib
from weakref import proxy
Expand All @@ -38,6 +39,7 @@
MAIN_TIMEOUT = 60.0

VSOCKPORT = 1234
AIX = platform.system() == "AIX"

try:
import _socket
Expand Down Expand Up @@ -1100,7 +1102,7 @@ def testIPv4toString(self):
self.assertEqual(b'\x01\x02\x03\x04', f('1.2.3.4'))
self.assertEqual(b'\xff\xff\xff\xff', f('255.255.255.255'))
# bpo-29972: inet_pton() doesn't fail on AIX
if not sys.platform.startswith('aix'):
if not AIX:
assertInvalid(f, '0.0.0.')
assertInvalid(f, '300.0.0.0')
assertInvalid(f, 'a.0.0.0')
Expand Down Expand Up @@ -1157,10 +1159,10 @@ def testIPv6toString(self):
assertInvalid('1::abc::')
assertInvalid('1::abc::def')
assertInvalid('1:2:3:4:5:6')
assertInvalid('1:2:3:4:5:6:')
assertInvalid('1:2:3:4:5:6:7:8:0')
# bpo-29972: inet_pton() doesn't fail on AIX
if not sys.platform.startswith('aix'):
assertInvalid('1:2:3:4:5:6:')
if not AIX:
assertInvalid('1:2:3:4:5:6:7:8:')

self.assertEqual(b'\x00' * 12 + b'\xfe\x2a\x17\x40',
Expand Down Expand Up @@ -1609,6 +1611,7 @@ def test_getaddrinfo_ipv6_basic(self):
@unittest.skipUnless(
hasattr(socket, 'if_nameindex'),
'if_nameindex is not supported')
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
def test_getaddrinfo_ipv6_scopeid_symbolic(self):
# Just pick up any network interface (Linux, Mac OS X)
(ifindex, test_interface) = socket.if_nameindex()[0]
Expand Down Expand Up @@ -1642,6 +1645,7 @@ def test_getaddrinfo_ipv6_scopeid_numeric(self):
@unittest.skipUnless(
hasattr(socket, 'if_nameindex'),
'if_nameindex is not supported')
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
def test_getnameinfo_ipv6_scopeid_symbolic(self):
# Just pick up any network interface.
(ifindex, test_interface) = socket.if_nameindex()[0]
Expand All @@ -1650,8 +1654,7 @@ def test_getnameinfo_ipv6_scopeid_symbolic(self):
self.assertEqual(nameinfo, ('ff02::1de:c0:face:8d%' + test_interface, '1234'))

@unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.')
@unittest.skipUnless(
sys.platform == 'win32',
@unittest.skipUnless( sys.platform == 'win32',
'Numeric scope id does not work or undocumented')
def test_getnameinfo_ipv6_scopeid_numeric(self):
# Also works on Linux (undocumented), but does not work on Mac OS X
Expand Down Expand Up @@ -3166,7 +3169,7 @@ def testFDPassSeparate(self):

@testFDPassSeparate.client_skip
@unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958")
@unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397")
@unittest.skipIf(AIX, "skipping, see issue #22397")
def _testFDPassSeparate(self):
fd0, fd1 = self.newFDs(2)
self.assertEqual(
Expand All @@ -3179,7 +3182,7 @@ def _testFDPassSeparate(self):
len(MSG))

@unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958")
@unittest.skipIf(sys.platform.startswith("aix"), "skipping, see issue #22397")
@unittest.skipIf(AIX, "skipping, see issue #22397")
@requireAttrs(socket, "CMSG_SPACE")
def testFDPassSeparateMinSpace(self):
# Pass two FDs in two separate arrays, receiving them into the
Expand Down Expand Up @@ -3915,11 +3918,13 @@ class SendrecvmsgSCTPStreamTestBase(SendrecvmsgSCTPFlagsBase,

@requireAttrs(socket.socket, "sendmsg")
@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP")
@unittest.skipIf(AIX, "IPPROTO_SCTP: [Errno 62] Protocol not supported on AIX")
class SendmsgSCTPStreamTest(SendmsgStreamTests, SendrecvmsgSCTPStreamTestBase):
pass

@requireAttrs(socket.socket, "recvmsg")
@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP")
@unittest.skipIf(AIX, "IPPROTO_SCTP: [Errno 62] Protocol not supported on AIX")
class RecvmsgSCTPStreamTest(RecvmsgTests, RecvmsgGenericStreamTests,
SendrecvmsgSCTPStreamTestBase):

Expand All @@ -3933,6 +3938,7 @@ def testRecvmsgEOF(self):

@requireAttrs(socket.socket, "recvmsg_into")
@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP")
@unittest.skipIf(AIX, "IPPROTO_SCTP: [Errno 62] Protocol not supported on AIX")
class RecvmsgIntoSCTPStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests,
SendrecvmsgSCTPStreamTestBase):

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fix `test_socket` on AIX
AIX 6.1 and later IPv6 zone id supports only supported by inet_pton6_zone()
Switch to runtime-based platform.system() to establish current platform
rather than build-time based sys.platform()
Patch by M. Felt