Skip to content

Commit

Permalink
bpo-11192: Skip unsupported cases in test_socket on AIX (GH-8954)
Browse files Browse the repository at this point in the history
* use platform.system() as runtime test, rather than sys.platform() build-time test
* IPv6 zone id support on AIX is limited to inet_pton6_zone(), so skip related
  getaddrinfo() and getnameinfo() tests as not supported
  • Loading branch information
aixtools authored and ncoghlan committed Dec 26, 2018
1 parent 56edf3a commit 5661459
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
24 changes: 15 additions & 9 deletions Lib/test/test_socket.py
Expand Up @@ -12,6 +12,7 @@
import queue
import sys
import os
import platform
import array
import contextlib
from weakref import proxy
Expand Down Expand Up @@ -39,6 +40,7 @@
MAIN_TIMEOUT = 60.0

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

try:
import _socket
Expand Down Expand Up @@ -1116,7 +1118,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 @@ -1173,10 +1175,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 @@ -1625,6 +1627,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 @@ -1658,6 +1661,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 @@ -1666,8 +1670,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 @@ -3238,7 +3241,7 @@ def _testFDPassCMSG_LEN(self):
self.createAndSendFDs(1)

@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 testFDPassSeparate(self):
# Pass two FDs in two separate arrays. Arrays may be combined
Expand All @@ -3249,7 +3252,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 @@ -3262,7 +3265,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 All @@ -3276,7 +3279,7 @@ def testFDPassSeparateMinSpace(self):

@testFDPassSeparateMinSpace.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 _testFDPassSeparateMinSpace(self):
fd0, fd1 = self.newFDs(2)
self.assertEqual(
Expand Down Expand Up @@ -3997,11 +4000,13 @@ class SendrecvmsgSCTPStreamTestBase(SendrecvmsgSCTPFlagsBase,
pass

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

@requireAttrs(socket.socket, "recvmsg")
@unittest.skipIf(AIX, "IPPROTO_SCTP: [Errno 62] Protocol not supported on AIX")
@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP")
class RecvmsgSCTPStreamTest(RecvmsgTests, RecvmsgGenericStreamTests,
SendrecvmsgSCTPStreamTestBase):
Expand All @@ -4015,6 +4020,7 @@ def testRecvmsgEOF(self):
self.skipTest("sporadic ENOTCONN (kernel issue?) - see issue #13876")

@requireAttrs(socket.socket, "recvmsg_into")
@unittest.skipIf(AIX, "IPPROTO_SCTP: [Errno 62] Protocol not supported on AIX")
@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP")
class RecvmsgIntoSCTPStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests,
SendrecvmsgSCTPStreamTestBase):
Expand Down
@@ -0,0 +1,4 @@
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()

0 comments on commit 5661459

Please sign in to comment.