diff options
author | Matthew Newhook <matthew@zeroc.com> | 2006-06-13 16:42:31 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2006-06-13 16:42:31 +0000 |
commit | 2fbfefbf518fc055c39eacd4afca8b1695331fdc (patch) | |
tree | 1932a493808c82d0e5073804f05ea0a6c146e587 /cpp | |
parent | win fix. (diff) | |
download | ice-2fbfefbf518fc055c39eacd4afca8b1695331fdc.tar.bz2 ice-2fbfefbf518fc055c39eacd4afca8b1695331fdc.tar.xz ice-2fbfefbf518fc055c39eacd4afca8b1695331fdc.zip |
added --debug, --protocol, --host, --compress and --threadPerConnection to
allTests.py and associated run.py scripts.
Diffstat (limited to 'cpp')
-rwxr-xr-x | cpp/allTests.py | 51 | ||||
-rw-r--r-- | cpp/config/TestUtil.py | 106 |
2 files changed, 115 insertions, 42 deletions
diff --git a/cpp/allTests.py b/cpp/allTests.py index 45421ac1586..65cac432ce9 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -18,10 +18,33 @@ for toplevel in [".", "..", "../..", "../../..", "../../../.."]: else: raise "can't find toplevel directory!" -sys.path.append(os.path.join(toplevel, "config")) -import TestUtil +def isCygwin(): -def runTests(tests, num = 0): + # The substring on sys.platform is required because some cygwin + # versions return variations like "cygwin_nt-4.01". + if sys.platform[:6] == "cygwin": + return 1 + else: + return 0 + +def isWin32(): + + if sys.platform == "win32" or isCygwin(): + return 1 + else: + return 0 + + +def isWin9x(): + + if isWin32(): + if os.environ.has_key("OS") and os.environ["OS"] == "Windows_NT": + return 0 + return 1 + else: + return 0 + +def runTests(args, tests, num = 0): # # Run each of the tests. @@ -37,10 +60,10 @@ def runTests(tests, num = 0): print "*** running tests in " + dir, print - if TestUtil.isWin9x(): - status = os.system("python " + os.path.join(dir, "run.py")) + if isWin9x(): + status = os.system("python " + os.path.join(dir, "run.py " + args)) else: - status = os.system(os.path.join(dir, "run.py")) + status = os.system(os.path.join(dir, "run.py " + args)) if status: if(num > 0): @@ -102,17 +125,18 @@ tests = [ \ # # These tests are currently disabled on cygwin # -if TestUtil.isCygwin() == 0: +if isCygwin() == 0: tests += [ \ ] def usage(): - print "usage: " + sys.argv[0] + " [-l] [-r <regex>] [-R <regex>]" + print "usage: " + sys.argv[0] + " -l -r <regex> -R <regex> --debug --protocol protocol --compress --host host --threadPerConnection" sys.exit(2) try: - opts, args = getopt.getopt(sys.argv[1:], "lr:R:") + opts, args = getopt.getopt(sys.argv[1:], "lr:R:", \ + ["debug", "protocol=", "compress", "host=", "threadPerConnection"]) except getopt.GetoptError: usage() @@ -120,6 +144,7 @@ if(args): usage() loop = 0 +args = "" for o, a in opts: if o == "-l": loop = 1 @@ -131,11 +156,15 @@ for o, a in opts: else: def rematch(x): return not regexp.search(x) tests = filter(rematch, tests) + if o in ( "--protocol", "--host" ): + args += " " + o + " " + a + if o in ( "--debug", "--compress", "--threadPerConnection" ): + args += " " + o if loop: num = 1 while 1: - runTests(tests, num) + runTests(args, tests, num) num += 1 else: - runTests(tests) + runTests(args, tests) diff --git a/cpp/config/TestUtil.py b/cpp/config/TestUtil.py index d5e2eacea3f..dd6062f7af8 100644 --- a/cpp/config/TestUtil.py +++ b/cpp/config/TestUtil.py @@ -9,21 +9,22 @@ # # ********************************************************************** +import sys, os, re, errno, getopt +from threading import Thread + # # Set protocol to "ssl" in case you want to run the tests with the SSL # protocol. Otherwise TCP is used. # - +protocol = "" #protocol = "ssl" -protocol = "tcp" # # Set compressed to 1 in case you want to run the tests with # protocol compression. # - -#compress = 0 -compress = 1 +compress = 0 +#compress = 1 # # Set threadPerConnection to 1 in case you want to run the tests in @@ -39,15 +40,36 @@ threadPerConnection = 0 # to set the IP address explicitly to 127.0.0.1. This avoid problems # with incorrect DNS or hostname setups. # - host = "127.0.0.1" # -# Don't change anything below this line! +# To print the commands that are being run. # +debug = 0 +#debug = 1 -import sys, os, re, errno -from threading import Thread +# +# Don't change anything below this line! +# +def usage(): + print "usage: " + sys.argv[0] + " --debug --protocol protocol --compress --host host --threadPerConnection" + sys.exit(2) +try: + opts, args = getopt.getopt(sys.argv[1:], "", ["debug", "protocol=", "compress", "host=", "threadPerConnection"]) +except getopt.GetoptError: + usage() + +for o, a in opts: + if o == "--debug": + debug = 1 + if o == "--protocol": + protocol = a + if o == "--compress": + compress = 1 + if o == "--threadPerConnection": + threadPerConnection = 1 + if o == "--host": + host = a def getIceVersion(): @@ -78,6 +100,7 @@ def isWin32(): else: return 0 + def isWin9x(): if isWin32(): @@ -204,23 +227,33 @@ def getServerPid(pipe): global serverPids global serverThreads - output = pipe.readline().strip() - - if not output: - print "failed!" - killServers() - sys.exit(1) + while 1: + output = pipe.readline().strip() + if not output: + print "failed!" + killServers() + sys.exit(1) + if output.startswith("warning: "): + continue + break - serverPids.append(int(output)) + try: + serverPids.append(int(output)) + except ValueError: + print "Output is not a PID: " + output + raise def ignorePid(pipe): - output = pipe.readline().strip() - - if not output: - print "failed!" - killServers() - sys.exit(1) + while 1: + output = pipe.readline().strip() + if not output: + print "failed!" + killServers() + sys.exit(1) + if output.startswith("warning: "): + continue + break def getAdapterReady(pipe, createThread = True, count = 1): global serverThreads @@ -368,17 +401,19 @@ def clientServerTestWithOptionsAndNames(name, additionalServerOptions, additiona client = os.path.join(testdir, clientName) print "starting " + serverName + "...", - serverCmd = server + serverOptions + additionalServerOptions + " 2>&1" - #print "serverCmd =", serverCmd - serverPipe = os.popen(serverCmd) + serverCmd = server + serverOptions + additionalServerOptions + if debug: + print "(" + serverCmd + ")", + serverPipe = os.popen(serverCmd + " 2>&1") getServerPid(serverPipe) getAdapterReady(serverPipe) print "ok" print "starting " + clientName + "...", - clientCmd = client + clientOptions + additionalClientOptions + " 2>&1" - #print "clientCmd =", clientCmd - clientPipe = os.popen(clientCmd) + clientCmd = client + clientOptions + additionalClientOptions + if debug: + print "(" + clientCmd + ")", + clientPipe = os.popen(clientCmd + " 2>&1") print "ok" printOutputFromPipe(clientPipe) @@ -407,13 +442,19 @@ def mixedClientServerTestWithOptions(name, additionalServerOptions, additionalCl client = os.path.join(testdir, "client") print "starting server...", - serverPipe = os.popen(server + clientServerOptions + additionalServerOptions + " 2>&1") + serverCmd = server + clientServerOptions + additionalServerOptions + if debug: + print "(" + serverCmd + ")", + serverPipe = os.popen(serverCmd + " 2>&1") getServerPid(serverPipe) getAdapterReady(serverPipe) print "ok" print "starting client...", - clientPipe = os.popen(client + clientServerOptions + additionalClientOptions + " 2>&1") + clientCmd = client + clientServerOptions + additionalClientOptions + if debug: + print "(" + clientCmd + ")", + clientPipe = os.popen(clientCmd + " 2>&1") ignorePid(clientPipe) getAdapterReady(clientPipe, False) print "ok" @@ -440,7 +481,10 @@ def collocatedTestWithOptions(name, additionalOptions): collocated = os.path.join(testdir, "collocated") print "starting collocated...", - collocatedPipe = os.popen(collocated + collocatedOptions + additionalOptions + " 2>&1") + command = collocated + collocatedOptions + additionalOptions + if debug: + print "(" + command + ")", + collocatedPipe = os.popen(command + " 2>&1") print "ok" printOutputFromPipe(collocatedPipe) |