From: <pj...@us...> - 2008-11-17 20:06:56
|
Revision: 5584 http://jython.svn.sourceforge.net/jython/?rev=5584&view=rev Author: pjenvey Date: 2008-11-17 20:06:51 +0000 (Mon, 17 Nov 2008) Log Message: ----------- relax the test ensuring SO_{RCV,SND}BUF matches the *exact* value we set it to after a connection was established. only for the BSDs, but we may not want to assume this anywhere Modified Paths: -------------- trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2008-11-17 20:05:55 UTC (rev 5583) +++ trunk/jython/Lib/test/test_socket.py 2008-11-17 20:06:51 UTC (rev 5584) @@ -7,6 +7,7 @@ import errno import Queue +import platform import select import socket import struct @@ -20,6 +21,8 @@ HOST = 'localhost' MSG = 'Michael Gilfix was here\n' EIGHT_BIT_MSG = 'Bh\xed Al\xe1in \xd3 Cinn\xe9ide anseo\n' +os_name = platform.java_ver()[3][0] +is_bsd = os_name == 'Mac OS X' or 'BSD' in os_name try: True @@ -548,6 +551,7 @@ sock.close() def _testTCPClientOption(self, option, values): + sock = None try: # First listen on a server socket, so that the connection won't be refused. server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -560,12 +564,21 @@ # First bind, so that the SO_REUSEADDR setting propagates sock.bind( (HOST, PORT+1) ) sock.connect( (HOST, PORT) ) - self.failUnlessEqual(sock.getsockopt(socket.SOL_SOCKET, option), values[-1], \ - "Option value '%s'='%s' did not propagate to implementation socket" % (option, values[-1])) + msg = "Option value '%s'='%s' did not propagate to implementation socket" % (option, values[-1]) + if is_bsd and option in (socket.SO_RCVBUF, socket.SO_SNDBUF): + # XXX: there's no guarantee that bufsize will be the + # exact setsockopt value, particularly after + # establishing a connection. seems it will be *at least* + # the values we test (which are rather small) on + # BSDs. may need to relax this on other platforms also + self.assert_(sock.getsockopt(socket.SOL_SOCKET, option) >= values[-1], msg) + else: + self.failUnlessEqual(sock.getsockopt(socket.SOL_SOCKET, option), values[-1], msg) self._testSetAndGetOption(sock, option, values) finally: server_sock.close() - sock.close() + if sock: + sock.close() def _testTCPServerOption(self, option, values): try: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |