Commit 5661459f authored by Michael Felt's avatar Michael Felt Committed by Nick Coghlan

bpo-11192: Skip unsupported cases in test_socket on AIX (GH-8954)

* 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
parent 56edf3a4
...@@ -12,6 +12,7 @@ import traceback ...@@ -12,6 +12,7 @@ import traceback
import queue import queue
import sys import sys
import os import os
import platform
import array import array
import contextlib import contextlib
from weakref import proxy from weakref import proxy
...@@ -39,6 +40,7 @@ MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8') ...@@ -39,6 +40,7 @@ MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8')
MAIN_TIMEOUT = 60.0 MAIN_TIMEOUT = 60.0
VSOCKPORT = 1234 VSOCKPORT = 1234
AIX = platform.system() == "AIX"
try: try:
import _socket import _socket
...@@ -1116,7 +1118,7 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -1116,7 +1118,7 @@ class GeneralModuleTests(unittest.TestCase):
self.assertEqual(b'\x01\x02\x03\x04', f('1.2.3.4')) self.assertEqual(b'\x01\x02\x03\x04', f('1.2.3.4'))
self.assertEqual(b'\xff\xff\xff\xff', f('255.255.255.255')) self.assertEqual(b'\xff\xff\xff\xff', f('255.255.255.255'))
# bpo-29972: inet_pton() doesn't fail on AIX # 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, '0.0.0.')
assertInvalid(f, '300.0.0.0') assertInvalid(f, '300.0.0.0')
assertInvalid(f, 'a.0.0.0') assertInvalid(f, 'a.0.0.0')
...@@ -1173,10 +1175,10 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -1173,10 +1175,10 @@ class GeneralModuleTests(unittest.TestCase):
assertInvalid('1::abc::') assertInvalid('1::abc::')
assertInvalid('1::abc::def') 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:')
assertInvalid('1:2:3:4:5:6:7:8:0') assertInvalid('1:2:3:4:5:6:7:8:0')
# bpo-29972: inet_pton() doesn't fail on AIX # bpo-29972: inet_pton() doesn't fail on AIX
if not sys.platform.startswith('aix'): if not AIX:
assertInvalid('1:2:3:4:5:6:')
assertInvalid('1:2:3:4:5:6:7:8:') assertInvalid('1:2:3:4:5:6:7:8:')
self.assertEqual(b'\x00' * 12 + b'\xfe\x2a\x17\x40', self.assertEqual(b'\x00' * 12 + b'\xfe\x2a\x17\x40',
...@@ -1625,6 +1627,7 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -1625,6 +1627,7 @@ class GeneralModuleTests(unittest.TestCase):
@unittest.skipUnless( @unittest.skipUnless(
hasattr(socket, 'if_nameindex'), hasattr(socket, 'if_nameindex'),
'if_nameindex is not supported') 'if_nameindex is not supported')
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
def test_getaddrinfo_ipv6_scopeid_symbolic(self): def test_getaddrinfo_ipv6_scopeid_symbolic(self):
# Just pick up any network interface (Linux, Mac OS X) # Just pick up any network interface (Linux, Mac OS X)
(ifindex, test_interface) = socket.if_nameindex()[0] (ifindex, test_interface) = socket.if_nameindex()[0]
...@@ -1658,6 +1661,7 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -1658,6 +1661,7 @@ class GeneralModuleTests(unittest.TestCase):
@unittest.skipUnless( @unittest.skipUnless(
hasattr(socket, 'if_nameindex'), hasattr(socket, 'if_nameindex'),
'if_nameindex is not supported') 'if_nameindex is not supported')
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
def test_getnameinfo_ipv6_scopeid_symbolic(self): def test_getnameinfo_ipv6_scopeid_symbolic(self):
# Just pick up any network interface. # Just pick up any network interface.
(ifindex, test_interface) = socket.if_nameindex()[0] (ifindex, test_interface) = socket.if_nameindex()[0]
...@@ -1666,8 +1670,7 @@ class GeneralModuleTests(unittest.TestCase): ...@@ -1666,8 +1670,7 @@ class GeneralModuleTests(unittest.TestCase):
self.assertEqual(nameinfo, ('ff02::1de:c0:face:8d%' + test_interface, '1234')) self.assertEqual(nameinfo, ('ff02::1de:c0:face:8d%' + test_interface, '1234'))
@unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.') @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.')
@unittest.skipUnless( @unittest.skipUnless( sys.platform == 'win32',
sys.platform == 'win32',
'Numeric scope id does not work or undocumented') 'Numeric scope id does not work or undocumented')
def test_getnameinfo_ipv6_scopeid_numeric(self): def test_getnameinfo_ipv6_scopeid_numeric(self):
# Also works on Linux (undocumented), but does not work on Mac OS X # Also works on Linux (undocumented), but does not work on Mac OS X
...@@ -3238,7 +3241,7 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase): ...@@ -3238,7 +3241,7 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase):
self.createAndSendFDs(1) self.createAndSendFDs(1)
@unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @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") @requireAttrs(socket, "CMSG_SPACE")
def testFDPassSeparate(self): def testFDPassSeparate(self):
# Pass two FDs in two separate arrays. Arrays may be combined # Pass two FDs in two separate arrays. Arrays may be combined
...@@ -3249,7 +3252,7 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase): ...@@ -3249,7 +3252,7 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase):
@testFDPassSeparate.client_skip @testFDPassSeparate.client_skip
@unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @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): def _testFDPassSeparate(self):
fd0, fd1 = self.newFDs(2) fd0, fd1 = self.newFDs(2)
self.assertEqual( self.assertEqual(
...@@ -3262,7 +3265,7 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase): ...@@ -3262,7 +3265,7 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase):
len(MSG)) len(MSG))
@unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @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") @requireAttrs(socket, "CMSG_SPACE")
def testFDPassSeparateMinSpace(self): def testFDPassSeparateMinSpace(self):
# Pass two FDs in two separate arrays, receiving them into the # Pass two FDs in two separate arrays, receiving them into the
...@@ -3276,7 +3279,7 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase): ...@@ -3276,7 +3279,7 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase):
@testFDPassSeparateMinSpace.client_skip @testFDPassSeparateMinSpace.client_skip
@unittest.skipIf(sys.platform == "darwin", "skipping, see issue #12958") @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): def _testFDPassSeparateMinSpace(self):
fd0, fd1 = self.newFDs(2) fd0, fd1 = self.newFDs(2)
self.assertEqual( self.assertEqual(
...@@ -3997,11 +4000,13 @@ class SendrecvmsgSCTPStreamTestBase(SendrecvmsgSCTPFlagsBase, ...@@ -3997,11 +4000,13 @@ class SendrecvmsgSCTPStreamTestBase(SendrecvmsgSCTPFlagsBase,
pass pass
@requireAttrs(socket.socket, "sendmsg") @requireAttrs(socket.socket, "sendmsg")
@unittest.skipIf(AIX, "IPPROTO_SCTP: [Errno 62] Protocol not supported on AIX")
@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") @requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP")
class SendmsgSCTPStreamTest(SendmsgStreamTests, SendrecvmsgSCTPStreamTestBase): class SendmsgSCTPStreamTest(SendmsgStreamTests, SendrecvmsgSCTPStreamTestBase):
pass pass
@requireAttrs(socket.socket, "recvmsg") @requireAttrs(socket.socket, "recvmsg")
@unittest.skipIf(AIX, "IPPROTO_SCTP: [Errno 62] Protocol not supported on AIX")
@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") @requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP")
class RecvmsgSCTPStreamTest(RecvmsgTests, RecvmsgGenericStreamTests, class RecvmsgSCTPStreamTest(RecvmsgTests, RecvmsgGenericStreamTests,
SendrecvmsgSCTPStreamTestBase): SendrecvmsgSCTPStreamTestBase):
...@@ -4015,6 +4020,7 @@ class RecvmsgSCTPStreamTest(RecvmsgTests, RecvmsgGenericStreamTests, ...@@ -4015,6 +4020,7 @@ class RecvmsgSCTPStreamTest(RecvmsgTests, RecvmsgGenericStreamTests,
self.skipTest("sporadic ENOTCONN (kernel issue?) - see issue #13876") self.skipTest("sporadic ENOTCONN (kernel issue?) - see issue #13876")
@requireAttrs(socket.socket, "recvmsg_into") @requireAttrs(socket.socket, "recvmsg_into")
@unittest.skipIf(AIX, "IPPROTO_SCTP: [Errno 62] Protocol not supported on AIX")
@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") @requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP")
class RecvmsgIntoSCTPStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests, class RecvmsgIntoSCTPStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests,
SendrecvmsgSCTPStreamTestBase): SendrecvmsgSCTPStreamTestBase):
......
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()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment