Commit e05b717f authored by Jason Madden's avatar Jason Madden

Fix sendmsg/recvmsg tests on OS X.

parent 7b3f3501
......@@ -50,9 +50,6 @@ class _wrefsocket(_socket.socket):
__slots__ = ("__weakref__", )
_closedsocket = _wrefsocket()
_closedsocket.close()
class socket(object):
"""
......@@ -243,7 +240,21 @@ class socket(object):
self.hub.cancel_wait(self._read_event, cancel_wait_ex)
self.hub.cancel_wait(self._write_event, cancel_wait_ex)
_ss.close(self._sock)
self._sock = _closedsocket
# Break any references to the underlying socket object. Tested
# by test__refcount. (Why does this matter?). Be sure to
# preserve our same family/type/proto if possible (if we
# don't, we can get TypeError instead of OSError; see
# test_socket.SendmsgUDP6Test.testSendmsgAfterClose)... but
# this isn't always possible (see test_socket.test_unknown_socket_family_repr)
# TODO: Can we use a simpler proxy, like _socket2 does?
try:
self._sock = self._gevent_sock_class(self.family, self.type, self.proto)
except OSError:
pass
else:
_ss.close(self._sock)
def close(self):
# This function should not reference any globals. See Python issue #808164.
......
......@@ -396,6 +396,13 @@ if sys.version_info[:2] >= (3, 4):
]
if sys.platform == 'darwin':
disabled_tests += [
# These raise "OSError: 12 Cannot allocate memory" on both
# patched and unpatched runs
'test_socket.RecvmsgSCMRightsStreamTest.testFDPassEmpty',
]
if sys.version_info[:2] == (3, 4):
disabled_tests += [
# These are all expecting that a signal (sigalarm) that
......@@ -413,6 +420,8 @@ if sys.version_info[:2] >= (3, 4):
'test_socket.InterruptedRecvTimeoutTest.testInterruptedRecvfromTimeout',
'test_socket.InterruptedRecvTimeoutTest.testInterruptedSendTimeout',
'test_socket.InterruptedRecvTimeoutTest.testInterruptedSendtoTimeout',
'test_socket.InterruptedRecvTimeoutTest.testInterruptedRecvmsgTimeout',
'test_socket.InterruptedSendTimeoutTest.testInterruptedSendmsgTimeout',
]
if os.environ.get('TRAVIS') == 'true':
......@@ -454,6 +463,10 @@ if sys.version_info[:2] >= (3, 5):
def disable_tests_in_source(source, name):
if name.startswith('./'):
# turn "./test_socket.py" (used for auto-complete) into "test_socket.py"
name = name[2:]
my_disabled_tests = [x for x in disabled_tests if x.startswith(name + '.')]
if not my_disabled_tests:
return source
......@@ -462,4 +475,5 @@ def disable_tests_in_source(source, name):
testcase = test.split('.')[-1]
source, n = re.subn(testcase, 'XXX' + testcase, source)
print('Removed %s (%d)' % (testcase, n), file=sys.stderr)
return source
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