diff options
author | Charles-François Natali <cf.natali@gmail.com> | 2013-08-29 17:26:37 (GMT) |
---|---|---|
committer | Charles-François Natali <cf.natali@gmail.com> | 2013-08-29 17:26:37 (GMT) |
commit | e33d5b0bc8b4eeb2a3072757c83d6efc30e28599 (patch) | |
tree | c282f71d3bd8b1cfd9d890c489cfbb6f27fa2a70 | |
parent | 50254c57cd7a562441b7ff385d59c0255301f3ff (diff) | |
parent | 5fd2642adb3874a4e6efc72a0782f4e98e7c6ad0 (diff) | |
download | cpython-e33d5b0bc8b4eeb2a3072757c83d6efc30e28599.zip cpython-e33d5b0bc8b4eeb2a3072757c83d6efc30e28599.tar.gz cpython-e33d5b0bc8b4eeb2a3072757c83d6efc30e28599.tar.bz2 |
Merge.
-rw-r--r-- | Lib/test/support/__init__.py | 10 | ||||
-rw-r--r-- | Lib/test/test_socket.py | 7 |
2 files changed, 12 insertions, 5 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 9f378fd..956fe98 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -603,8 +603,14 @@ IPV6_ENABLED = _is_ipv6_enabled() # Windows limit seems to be around 512 B, and many Unix kernels have a # 64 KiB pipe buffer size or 16 * PAGE_SIZE: take a few megs to be sure. # (see issue #17835 for a discussion of this number). -PIPE_MAX_SIZE = 4 *1024 * 1024 + 1 - +PIPE_MAX_SIZE = 4 * 1024 * 1024 + 1 + +# A constant likely larger than the underlying OS socket buffer size, to make +# writes blocking. +# The socket buffer sizes can usually be tuned system-wide (e.g. through sysctl +# on Linux), or on a per-socket basis (SO_SNDBUF/SO_RCVBUF). See issue #18643 +# for a discussion of this number). +SOCK_MAX_SIZE = 16 * 1024 * 1024 + 1 # decorator for skipping tests on non-IEEE 754 platforms requires_IEEE_754 = unittest.skipUnless( diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 9567090..b95e1ab 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1210,11 +1210,12 @@ class GeneralModuleTests(unittest.TestCase): c.settimeout(1.5) with self.assertRaises(ZeroDivisionError): signal.alarm(1) - c.sendall(b"x" * (1024**2)) + c.sendall(b"x" * support.SOCK_MAX_SIZE) if with_timeout: signal.signal(signal.SIGALRM, ok_handler) signal.alarm(1) - self.assertRaises(socket.timeout, c.sendall, b"x" * (1024**2)) + self.assertRaises(socket.timeout, c.sendall, + b"x" * support.SOCK_MAX_SIZE) finally: signal.alarm(0) signal.signal(signal.SIGALRM, old_alarm) @@ -4047,7 +4048,7 @@ class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase): self.serv_skipped = None self.serv_conn.setblocking(False) # Try to saturate the socket buffer pipe with repeated large writes. - BIG = b"x" * (1024 ** 2) + BIG = b"x" * support.SOCK_MAX_SIZE LIMIT = 10 # The first write() succeeds since a chunk of data can be buffered n = self.write_file.write(BIG) |