diff options
author | Guido van Rossum <guido@python.org> | 1997-05-14 21:12:51 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-05-14 21:12:51 (GMT) |
commit | 2b4d2800af0e9251515b7aab114ae6307dd4d475 (patch) | |
tree | c932bb397cf5dea08cfb616c77e796e1a587bf5e | |
parent | 9348bf8388bc791bb475142ffec1cfea06334dce (diff) | |
download | cpython-2b4d2800af0e9251515b7aab114ae6307dd4d475.zip cpython-2b4d2800af0e9251515b7aab114ae6307dd4d475.tar.gz cpython-2b4d2800af0e9251515b7aab114ae6307dd4d475.tar.bz2 |
Suppress fork part of socket test when we can't fork.
-rw-r--r-- | Lib/test/test_socket.py | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 1af1ff1..6ba9a2d 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -8,7 +8,7 @@ # sktobj.shutdown() -from test_support import verbose +from test_support import verbose, TestFailed import socket import os import time @@ -89,39 +89,41 @@ except socket.error: pass +canfork = hasattr(os, 'fork') try: PORT = 50007 - if os.fork(): + if not canfork or os.fork(): # parent is server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(hostname, PORT) s.listen(1) if verbose: print 'parent accepting' - conn, addr = s.accept() - if verbose: - print 'connected by', addr - # couple of interesting tests while we've got a live socket - f = conn.fileno() - if verbose: - print 'fileno:', f - p = conn.getpeername() - if verbose: - print 'peer:', p - n = conn.getsockname() - if verbose: - print 'sockname:', n - f = conn.makefile() - if verbose: - print 'file obj:', f - while 1: - data = conn.recv(1024) - if not data: - break + if canfork: + conn, addr = s.accept() + if verbose: + print 'connected by', addr + # couple of interesting tests while we've got a live socket + f = conn.fileno() if verbose: - print 'received:', data - conn.send(data) - conn.close() + print 'fileno:', f + p = conn.getpeername() + if verbose: + print 'peer:', p + n = conn.getsockname() + if verbose: + print 'sockname:', n + f = conn.makefile() + if verbose: + print 'file obj:', f + while 1: + data = conn.recv(1024) + if not data: + break + if verbose: + print 'received:', data + conn.send(data) + conn.close() else: try: # child is client @@ -138,5 +140,5 @@ try: s.close() finally: os._exit(1) -except socket.error: - pass +except socket.error, msg: + raise TestFailed, msg |