mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Merged revisions 61038,61042-61045,61047,61050,61053,61055-61056,61061-61062,61066,61068,61070,61083,61085,61092-61097,61103-61108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r61105 | andrew.kuchling | 2008-02-28 15:03:03 +0100 (Thu, 28 Feb 2008) | 1 line #2169: make generated HTML more valid ........ r61106 | jeffrey.yasskin | 2008-02-28 19:03:15 +0100 (Thu, 28 Feb 2008) | 4 lines Prevent SocketServer.ForkingMixIn from waiting on child processes that it didn't create, in most cases. When there are max_children handlers running, it will still wait for any child process, not just handler processes. ........ r61107 | raymond.hettinger | 2008-02-28 20:41:24 +0100 (Thu, 28 Feb 2008) | 1 line Document impending updates to itertools. ........ r61108 | martin.v.loewis | 2008-02-28 20:44:22 +0100 (Thu, 28 Feb 2008) | 1 line Add 2.6aN uuids. ........
This commit is contained in:
parent
9e7f1d2e96
commit
70e7ea23f1
5 changed files with 99 additions and 33 deletions
|
@ -2,6 +2,7 @@
|
|||
Test suite for SocketServer.py.
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
import errno
|
||||
import imp
|
||||
import os
|
||||
|
@ -109,6 +110,18 @@ class ServerThread(threading.Thread):
|
|||
if verbose: print("thread: done")
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def simple_subprocess(testcase):
|
||||
pid = os.fork()
|
||||
if pid == 0:
|
||||
# Don't throw an exception; it would be caught by the test harness.
|
||||
os._exit(72)
|
||||
yield None
|
||||
pid2, status = os.waitpid(pid, 0)
|
||||
testcase.assertEquals(pid2, pid)
|
||||
testcase.assertEquals(72 << 8, status)
|
||||
|
||||
|
||||
class SocketServerTest(unittest.TestCase):
|
||||
"""Test all socket servers."""
|
||||
|
||||
|
@ -211,10 +224,11 @@ class SocketServerTest(unittest.TestCase):
|
|||
self.stream_examine)
|
||||
|
||||
if HAVE_FORKING:
|
||||
def test_ThreadingTCPServer(self):
|
||||
self.run_server(SocketServer.ForkingTCPServer,
|
||||
SocketServer.StreamRequestHandler,
|
||||
self.stream_examine)
|
||||
def test_ForkingTCPServer(self):
|
||||
with simple_subprocess(self):
|
||||
self.run_server(SocketServer.ForkingTCPServer,
|
||||
SocketServer.StreamRequestHandler,
|
||||
self.stream_examine)
|
||||
|
||||
if HAVE_UNIX_SOCKETS:
|
||||
def test_UnixStreamServer(self):
|
||||
|
@ -229,9 +243,10 @@ class SocketServerTest(unittest.TestCase):
|
|||
|
||||
if HAVE_FORKING:
|
||||
def test_ForkingUnixStreamServer(self):
|
||||
self.run_server(ForkingUnixStreamServer,
|
||||
SocketServer.StreamRequestHandler,
|
||||
self.stream_examine)
|
||||
with simple_subprocess(self):
|
||||
self.run_server(ForkingUnixStreamServer,
|
||||
SocketServer.StreamRequestHandler,
|
||||
self.stream_examine)
|
||||
|
||||
def test_UDPServer(self):
|
||||
self.run_server(SocketServer.UDPServer,
|
||||
|
@ -245,9 +260,10 @@ class SocketServerTest(unittest.TestCase):
|
|||
|
||||
if HAVE_FORKING:
|
||||
def test_ForkingUDPServer(self):
|
||||
self.run_server(SocketServer.ForkingUDPServer,
|
||||
SocketServer.DatagramRequestHandler,
|
||||
self.dgram_examine)
|
||||
with simple_subprocess(self):
|
||||
self.run_server(SocketServer.ForkingUDPServer,
|
||||
SocketServer.DatagramRequestHandler,
|
||||
self.dgram_examine)
|
||||
|
||||
# Alas, on Linux (at least) recvfrom() doesn't return a meaningful
|
||||
# client address so this cannot work:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue