From 63edfc395eeb7f2f69a801bfd164f46f812ee9c9 Mon Sep 17 00:00:00 2001 From: Michael Felt Date: Wed, 19 Jun 2019 14:39:37 +0000 Subject: [PATCH] Fix test_socket for AIX --- Lib/test/test_socket.py | 20 ++++++++++++------- .../2018-08-14-20-50-07.bpo-11192.g7TwYm.rst | 5 +++++ 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2018-08-14-20-50-07.bpo-11192.g7TwYm.rst diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 43929b355e6b12..52fcbb91a2ac63 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -12,6 +12,7 @@ import queue import sys import os +import platform import array import contextlib from weakref import proxy @@ -38,6 +39,7 @@ MAIN_TIMEOUT = 60.0 VSOCKPORT = 1234 +AIX = platform.system() == "AIX" try: import _socket @@ -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') @@ -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', @@ -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] @@ -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] @@ -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 @@ -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( @@ -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 @@ -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): @@ -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): diff --git a/Misc/NEWS.d/next/Tests/2018-08-14-20-50-07.bpo-11192.g7TwYm.rst b/Misc/NEWS.d/next/Tests/2018-08-14-20-50-07.bpo-11192.g7TwYm.rst new file mode 100644 index 00000000000000..5422a70953579d --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2018-08-14-20-50-07.bpo-11192.g7TwYm.rst @@ -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