summaryrefslogtreecommitdiff
path: root/cs/config/TestUtil.py
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2006-06-07 17:20:35 +0000
committerMatthew Newhook <matthew@zeroc.com>2006-06-07 17:20:35 +0000
commitc8765310900262ea52e85aa86c8e131de82ddd3b (patch)
treedb0faa6d9dea531a83c83a896dd21f5512d515a9 /cs/config/TestUtil.py
parentfixing bug 910: dumpdb does not handle object graphs (diff)
downloadice-c8765310900262ea52e85aa86c8e131de82ddd3b.tar.bz2
ice-c8765310900262ea52e85aa86c8e131de82ddd3b.tar.xz
ice-c8765310900262ea52e85aa86c8e131de82ddd3b.zip
added TrustOnly implementation.
Diffstat (limited to 'cs/config/TestUtil.py')
-rw-r--r--cs/config/TestUtil.py79
1 files changed, 61 insertions, 18 deletions
diff --git a/cs/config/TestUtil.py b/cs/config/TestUtil.py
index 1f0f93652f9..52e13e18456 100644
--- a/cs/config/TestUtil.py
+++ b/cs/config/TestUtil.py
@@ -49,6 +49,7 @@ host = "127.0.0.1"
#
import sys, os, re, errno
+from threading import Thread
def isCygwin():
@@ -71,16 +72,15 @@ def killServers():
global serverPids
- if isCygwin():
- print "killServers(): not implemented for cygwin python."
- return;
-
for pid in serverPids:
if isWin32():
try:
import win32api
handle = win32api.OpenProcess(1, 0, pid)
win32api.TerminateProcess(handle, 0)
+ except ImportError, ex:
+ print "Sorry: you must install the win32all package for killServers to work."
+ return
except:
pass # Ignore errors, such as non-existing processes.
else:
@@ -102,6 +102,15 @@ def getServerPid(serverPipe):
serverPids.append(int(output))
+def ignorePid(serverPipe):
+
+ output = serverPipe.readline().strip()
+
+ if not output:
+ print "failed!"
+ killServers()
+ sys.exit(1)
+
def getAdapterReady(serverPipe):
output = serverPipe.readline().strip()
@@ -144,6 +153,29 @@ def closePipe(pipe):
return status
+class ReaderThread(Thread):
+ def __init__(self, pipe, token):
+ self.pipe = pipe
+ self.token = token
+ Thread.__init__(self)
+
+ def run(self):
+
+ try:
+ while 1:
+ line = self.pipe.readline()
+ if not line: break
+ # supress object adapter ready messages.
+ if line[len(line)-7:len(line)] != " ready\n":
+ print self.token + ": " + line,
+ except IOError:
+ pass
+
+ self.status = closePipe(self.pipe)
+
+ def getStatus(self):
+ return self.status
+
for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
toplevel = os.path.normpath(toplevel)
if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")):
@@ -263,7 +295,7 @@ def clientServerTestWithOptionsAndNames(mono, name, additionalServerOptions, add
client = os.path.join(testdir, clientName)
print createMsg(mono, serverName),
- serverCmd = createCmd(mono, server) + serverOptions + " " + additionalServerOptions
+ serverCmd = createCmd(mono, server) + serverOptions + " " + additionalServerOptions + " 2>&1"
#print "serverCmd=" + serverCmd
serverPipe = os.popen(serverCmd)
getServerPid(serverPipe)
@@ -271,23 +303,29 @@ def clientServerTestWithOptionsAndNames(mono, name, additionalServerOptions, add
print "ok"
print createMsg(mono, clientName),
- clientCmd = createCmd(mono, client) + clientOptions + " " + additionalClientOptions
+ clientCmd = createCmd(mono, client) + clientOptions + " " + additionalClientOptions + " 2>&1"
#print "clientCmd=" + clientCmd
clientPipe = os.popen(clientCmd)
print "ok"
+ serverThread = ReaderThread(serverPipe, "Server")
+ serverThread.start()
printOutputFromPipe(clientPipe)
clientStatus = closePipe(clientPipe)
- serverStatus = closePipe(serverPipe)
+ if clientStatus:
+ killServers()
+
+ serverThread.join()
+ serverStatus = serverThread.getStatus()
if clientStatus or serverStatus:
- killServers()
- sys.exit(1)
+ sys.exit(1)
def clientServerTestWithOptions(mono, name, additionalServerOptions, additionalClientOptions):
- clientServerTestWithOptionsAndNames(mono, name, additionalServerOptions, additionalClientOptions, "server", "client")
+ clientServerTestWithOptionsAndNames(mono, name, additionalServerOptions, additionalClientOptions, "server", \
+ "client")
def clientServerTest(mono, name):
@@ -300,25 +338,30 @@ def mixedClientServerTestWithOptions(mono, name, additionalServerOptions, additi
client = os.path.join(testdir, "client")
print createMsg(mono, "server"),
- serverPipe = os.popen(createCmd(mono, server) + clientServerOptions + " " + additionalServerOptions)
+ serverPipe = os.popen(createCmd(mono, server) + clientServerOptions + " " + additionalServerOptions) + " 2>&1"
getServerPid(serverPipe)
getAdapterReady(serverPipe)
print "ok"
print createMsg(mono, "client"),
- clientPipe = os.popen(createCmd(mono, client) + clientServerOptions + " " + additionalClientOptions)
- getServerPid(clientPipe)
+ clientPipe = os.popen(createCmd(mono, client) + clientServerOptions + " " + additionalClientOptions) + " 2>&1"
+ ignorePid(clientPipe)
getAdapterReady(clientPipe)
print "ok"
+ serverThread = ReaderThread(serverPipe, "Server")
+ serverThread.start()
printOutputFromPipe(clientPipe)
clientStatus = closePipe(clientPipe)
- serverStatus = closePipe(serverPipe)
+ if clientStatus:
+ killServers()
+
+ serverThread.join()
+ serverStatus = serverThread.getStatus()
if clientStatus or serverStatus:
- killServers()
- sys.exit(1)
+ sys.exit(1)
def mixedClientServerTest(mono, name):
@@ -330,7 +373,7 @@ def collocatedTestWithOptions(mono, name, additionalOptions):
collocated = os.path.join(testdir, "collocated")
print createMsg(mono, "collocated"),
- collocatedPipe = os.popen(createCmd(mono, collocated) + collocatedOptions + " " + additionalOptions)
+ collocatedPipe = os.popen(createCmd(mono, collocated) + collocatedOptions + " " + additionalOptions + " 2>&1")
print "ok"
printOutputFromPipe(collocatedPipe)
@@ -351,7 +394,7 @@ def clientTestWithOptions(mono, name, additionalOptions):
client = os.path.join(testdir, "client")
print createMsg(mono, "client"),
- clientPipe = os.popen(createCmd(mono, client) + clientOptions + " " + additionalOptions)
+ clientPipe = os.popen(createCmd(mono, client) + clientOptions + " " + additionalOptions + " 2>&1")
print "ok"
printOutputFromPipe(clientPipe)