summaryrefslogtreecommitdiff
path: root/scripts/TestUtil.py
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-03-24 11:45:18 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-03-24 11:45:18 +0100
commit06a08ecf28e205277336a97a6173db7ccbed1adc (patch)
treea369a5044a63f8cdba9e7c0a461e24ae344486b4 /scripts/TestUtil.py
parentMerge branch 'R3_3_branch' (diff)
parentBug 3924: slice2py missing from VC60 installer (diff)
downloadice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.bz2
ice-06a08ecf28e205277336a97a6173db7ccbed1adc.tar.xz
ice-06a08ecf28e205277336a97a6173db7ccbed1adc.zip
Merge commit 'origin/R3_3_branch'
Conflicts: CHANGES cpp/demo/Freeze/backup/.depend cpp/demo/Freeze/bench/.depend cpp/demo/Freeze/casino/.depend cpp/demo/Freeze/customEvictor/.depend cpp/demo/Freeze/library/.depend cpp/demo/Freeze/phonebook/.depend cpp/demo/Freeze/transform/.depend cpp/demo/Glacier2/callback/.depend cpp/demo/Glacier2/chat/.depend cpp/demo/Ice/async/.depend cpp/demo/Ice/bidir/.depend cpp/demo/Ice/callback/.depend cpp/demo/Ice/converter/.depend cpp/demo/Ice/hello/.depend cpp/demo/Ice/invoke/.depend cpp/demo/Ice/latency/.depend cpp/demo/Ice/minimal/.depend cpp/demo/Ice/multicast/.depend cpp/demo/Ice/nested/.depend cpp/demo/Ice/nrvo/.depend cpp/demo/Ice/session/.depend cpp/demo/Ice/throughput/.depend cpp/demo/Ice/value/.depend cpp/demo/IceBox/hello/.depend cpp/demo/IceGrid/allocate/.depend cpp/demo/IceGrid/icebox/.depend cpp/demo/IceGrid/replication/.depend cpp/demo/IceGrid/sessionActivation/.depend cpp/demo/IceGrid/simple/.depend cpp/demo/IceStorm/clock/.depend cpp/demo/IceStorm/counter/.depend cpp/demo/IceStorm/replicated/.depend cpp/demo/IceStorm/replicated2/.depend cpp/demo/book/freeze_filesystem/.depend cpp/demo/book/lifecycle/.depend cpp/demo/book/printer/.depend cpp/demo/book/simple_filesystem/.depend cpp/src/Freeze/.depend cpp/src/FreezeScript/.depend cpp/src/Ice/.depend cpp/src/Ice/UdpTransceiver.cpp cpp/src/Ice/UdpTransceiver.h cpp/src/IceBox/.depend cpp/src/IceGrid/.depend cpp/src/IceGridLib/.depend cpp/src/IcePatch2/.depend cpp/src/IceStorm/.depend cpp/src/slice2freeze/.depend cpp/test/Freeze/complex/.depend cpp/test/Freeze/dbmap/.depend cpp/test/Freeze/evictor/.depend cpp/test/Freeze/oldevictor/.depend cpp/test/FreezeScript/dbmap/.depend cpp/test/FreezeScript/evictor/.depend cpp/test/Glacier2/attack/.depend cpp/test/Glacier2/dynamicFiltering/.depend cpp/test/Glacier2/router/.depend cpp/test/Glacier2/sessionControl/.depend cpp/test/Glacier2/ssl/.depend cpp/test/Glacier2/staticFiltering/.depend cpp/test/Ice/adapterDeactivation/.depend cpp/test/Ice/background/.depend cpp/test/Ice/binding/.depend cpp/test/Ice/checksum/.depend cpp/test/Ice/checksum/server/.depend cpp/test/Ice/custom/.depend cpp/test/Ice/exceptions/.depend cpp/test/Ice/facets/.depend cpp/test/Ice/faultTolerance/.depend cpp/test/Ice/gc/.depend cpp/test/Ice/hold/.depend cpp/test/Ice/inheritance/.depend cpp/test/Ice/interceptor/.depend cpp/test/Ice/location/.depend cpp/test/Ice/objects/.depend cpp/test/Ice/operations/.depend cpp/test/Ice/proxy/.depend cpp/test/Ice/retry/.depend cpp/test/Ice/servantLocator/.depend cpp/test/Ice/slicing/exceptions/.depend cpp/test/Ice/slicing/objects/.depend cpp/test/Ice/stream/.depend cpp/test/Ice/stringConverter/.depend cpp/test/Ice/timeout/.depend cpp/test/Ice/udp/.depend cpp/test/IceBox/configuration/.depend cpp/test/IceGrid/activation/.depend cpp/test/IceGrid/allocation/.depend cpp/test/IceGrid/deployer/.depend cpp/test/IceGrid/distribution/.depend cpp/test/IceGrid/replicaGroup/.depend cpp/test/IceGrid/replication/.depend cpp/test/IceGrid/session/.depend cpp/test/IceGrid/simple/.depend cpp/test/IceGrid/update/.depend cpp/test/IceSSL/configuration/.depend cpp/test/IceStorm/federation/.depend cpp/test/IceStorm/federation2/.depend cpp/test/IceStorm/rep1/.depend cpp/test/IceStorm/repgrid/.depend cpp/test/IceStorm/repstress/.depend cpp/test/IceStorm/single/.depend cpp/test/IceStorm/stress/.depend cpp/test/Slice/keyword/.depend cs/src/Ice/Instance.cs cs/src/IceSSL/ConnectorI.cs java/demo/book/simple_filesystem/Filesystem/DirectoryI.java java/demo/book/simple_filesystem/Filesystem/FileI.java java/src/IceInternal/TcpConnector.java java/src/IceSSL/ConnectorI.java py/modules/IcePy/.depend rb/src/IceRuby/.depend
Diffstat (limited to 'scripts/TestUtil.py')
-rwxr-xr-xscripts/TestUtil.py183
1 files changed, 108 insertions, 75 deletions
diff --git a/scripts/TestUtil.py b/scripts/TestUtil.py
index cb4de97bcc7..079ea227dd0 100755
--- a/scripts/TestUtil.py
+++ b/scripts/TestUtil.py
@@ -25,6 +25,7 @@ java2 = False # Use Java 2 jar file from binary distribution
javaCmd = "java" # Default java loader
valgrind = False # Set to True to use valgrind for C++ executables.
tracefile = None
+printenv = False
cross = []
def isCygwin():
@@ -104,13 +105,33 @@ toplevel = path[0]
def sanitize(cp):
np = ""
for p in cp.split(os.pathsep):
- if p == "classes":
+ if os.path.normpath(p) == "classes":
continue
if len(np) > 0:
np = np + os.pathsep
np = np + p
return np
+def dumpenv(env, lang):
+ if env == None:
+ env = os.environ
+ vars = ["PATH", "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH", "SHLIB_PATH", "LIBPATH", "LD_LIBRARY_PATH_64"]
+ if lang == None:
+ vars.extend(["CLASSPATH", "MONO_PATH", "PYTHONPATH", "RUBYLIB"])
+ elif lang == "cpp":
+ pass
+ elif lang == "java":
+ vars.append("CLASSPATH")
+ elif lang == "cs":
+ vars.append("MONO_PATH")
+ elif lang == "py":
+ vars.append("PYTHONPATH")
+ elif lang == "rb":
+ vars.append("RUBYLIB")
+ for i in vars:
+ if i in env:
+ print "%s=%s" % (i, env[i])
+
def configurePaths():
if iceHome:
print "*** using Ice installation from " + iceHome,
@@ -165,46 +186,50 @@ def configurePaths():
# On Windows, C# assemblies are found thanks to the .exe.config files.
#
if not isWin32():
- os.environ["MONO_PATH"] = os.path.join(getIceDir("cs"), "bin") + os.pathsep + os.getenv("MONO_PATH", "")
+ addPathToEnv("MONO_PATH", os.path.join(getIceDir("cs"), "bin"))
#
# On Windows x64, set PYTHONPATH to python/x64.
#
pythonDir = os.path.join(getIceDir("py"), "python")
if isWin32() and x64:
- os.environ["PYTHONPATH"] = os.path.join(pythonDir, "x64") + os.pathsep + os.getenv("PYTHONPATH", "")
+ addPathToEnv("PYTHONPATH", os.path.join(pythonDir, "x64"))
else:
- os.environ["PYTHONPATH"] = pythonDir + os.pathsep + os.getenv("PYTHONPATH", "")
+ addPathToEnv("PYTHONPATH", pythonDir)
- rubyDir = os.path.join(getIceDir("rb"), "ruby")
- os.environ["RUBYLIB"] = rubyDir + os.pathsep + os.getenv("RUBYLIB", "")
+ addPathToEnv("RUBYLIB", os.path.join(getIceDir("rb"), "ruby"))
def addLdPath(libpath, env = None):
if env is None:
env = os.environ
if isWin32():
- env["PATH"] = libpath + os.pathsep + env.get("PATH", "")
+ addPathToEnv("PATH", libpath, env)
elif isHpUx():
- env["SHLIB_PATH"] = libpath + os.pathsep + env.get("SHLIB_PATH", "")
- env["LD_LIBRARY_PATH"] = libpath + os.pathsep + env.get("LD_LIBRARY_PATH", "")
+ addPathToEnv("SHLIB_PATH", libpath, env)
+ addPathToEnv("LD_LIBRARY_PATH", libpath, env)
elif isDarwin():
- env["DYLD_LIBRARY_PATH"] = libpath + os.pathsep + env.get("DYLD_LIBRARY_PATH", "")
+ addPathToEnv("DYLD_LIBRARY_PATH", libpath, env)
elif isAIX():
- env["LIBPATH"] = libpath + os.pathsep + env.get("LIBPATH", "")
+ addPathToEnv("LIBPATH", libpath, env)
else:
- env["LD_LIBRARY_PATH"] = libpath + os.pathsep + env.get("LD_LIBRARY_PATH", "")
- env["LD_LIBRARY_PATH_64"] = libpath + os.pathsep + env.get("LD_LIBRARY_PATH_64", "")
+ addPathToEnv("LD_LIBRARY_PATH", libpath, env)
+ addPathToEnv("LD_LIBRARY_PATH_64", libpath, env)
return env
-def addClasspath(dir, env = None):
+def addClasspath(path, env = None):
+ return addPathToEnv("CLASSPATH", path, env)
+
+def addPathToEnv(variable, path, env = None):
if env is None:
env = os.environ
- env["CLASSPATH"] = dir + os.pathsep + env.get("CLASSPATH", "")
+ if not env.has_key(variable):
+ env[variable] = path
+ else:
+ env[variable] = path + os.pathsep + env.get(variable)
return env
# List of supported cross languages test.
-crossTests = [
- "Ice/adapterDeactivation",
+crossTests = [ "Ice/adapterDeactivation",
"Ice/background",
"Ice/binding",
"Ice/checksum",
@@ -241,11 +266,13 @@ def run(tests, root = False):
--serialize Run with connection serialization.
--continue Keep running when a test fails
--ipv6 Use IPv6 addresses.
+ --no-ipv6 Don't use IPv6 addresses.
--ice-home=<path> Use the binary distribution from the given path.
--x64 Binary distribution is 64-bit.
--java2 Use Java 2 jar file.
--cross=lang Run cross language test.
--script Generate a script to run the tests.
+ --env Print important environment variables
"""
sys.exit(2)
@@ -253,7 +280,7 @@ def run(tests, root = False):
opts, args = getopt.getopt(sys.argv[1:], "lr:R:",
["start=", "start-after=", "filter=", "rfilter=", "all", "all-cross", "loop",
"debug", "protocol=", "compress", "valgrind", "host=", "serialize", "continue",
- "ipv6", "ice-home=", "cross=", "x64", "script", "java2"])
+ "ipv6", "no-ipv6", "ice-home=", "cross=", "x64", "script", "java2", "env"])
except getopt.GetoptError:
usage()
@@ -266,6 +293,7 @@ def run(tests, root = False):
allCross = False
arg = ""
script = False
+ noipv6 = False
filters = []
for o, a in opts:
@@ -288,6 +316,8 @@ def run(tests, root = False):
cross.append(a)
elif o == "--all" :
all = True
+ elif o == "--no-ipv6" :
+ noipv6 = True
elif o == "--all-cross" :
allCross = True
elif o in '--start':
@@ -302,7 +332,7 @@ def run(tests, root = False):
sys.exit(1)
if o in ( "--cross", "--protocol", "--host", "--debug", "--compress", "--valgrind", "--serialize", "--ipv6", \
- "--ice-home", "--x64", "--java2"):
+ "--ice-home", "--x64", "--java2", "--env"):
arg += " " + o
if len(a) > 0:
arg += " " + a
@@ -324,17 +354,19 @@ def run(tests, root = False):
a = '--protocol=tcp --compress %s' % arg
expanded.append([ (test, a, config) for test,config in tests if "core" in config])
- a = "--ipv6 --protocol=tcp %s" % arg
- expanded.append([ (test, a, config) for test,config in tests if "core" in config])
+ if not noipv6:
+ a = "--ipv6 --protocol=tcp %s" % arg
+ expanded.append([ (test, a, config) for test,config in tests if "core" in config])
- a = "--ipv6 --protocol=ssl %s" % arg
- expanded.append([ (test, a, config) for test,config in tests if "core" in config])
+ a = "--ipv6 --protocol=ssl %s" % arg
+ expanded.append([ (test, a, config) for test,config in tests if "core" in config])
a = "--protocol=tcp %s" % arg
expanded.append([ (test, a, config) for test,config in tests if "service" in config])
- a = "--protocol=ssl --ipv6 %s" % arg
- expanded.append([ (test, a, config) for test,config in tests if "service" in config])
+ if not noipv6:
+ a = "--protocol=ssl --ipv6 %s" % arg
+ expanded.append([ (test, a, config) for test,config in tests if "service" in config])
a = "--protocol=tcp --serialize %s" % arg
expanded.append([ (test, a, config) for test,config in tests if "stress" in config])
@@ -575,11 +607,6 @@ def getDefaultMapping():
else:
raise "cannot determine mapping"
-def getTestEnv():
- env = {}
- env["certsdir"] = os.path.abspath(os.path.join(toplevel, "certs"))
- return env
-
class DriverConfig:
lang = None
protocol = None
@@ -635,11 +662,8 @@ def argsToDict(argumentString, results):
results[current] = None
return results
-def getCommandLine(exe, config, env=None):
+def getCommandLine(exe, config):
- if not env:
- env = getTestEnv()
-
#
# Command lines are built up from the items in the components
# sequence, which is initialized with command line options common to
@@ -659,8 +683,10 @@ def getCommandLine(exe, config, env=None):
# configuration.
#
if config.protocol == "ssl":
- components.append(sslConfigTree[config.lang]["plugin"] % env)
- components.append(sslConfigTree[config.lang][config.type] % env)
+ sslenv = {}
+ sslenv["certsdir"] = os.path.abspath(os.path.join(toplevel, "certs"))
+ components.append(sslConfigTree[config.lang]["plugin"] % sslenv)
+ components.append(sslConfigTree[config.lang][config.type] % sslenv)
if config.compress:
components.append("--Ice.Override.Compress=1")
@@ -767,19 +793,21 @@ def isDebug():
return debug
import Expect
-def spawn(cmd, env = None, cwd = None):
+def spawn(cmd, env = None, cwd = None, startReader = True,lang=None):
if debug:
print "(%s)" % cmd,
- return Expect.Expect(cmd, env = env, logfile=tracefile, cwd = cwd)
+ if printenv:
+ dumpenv(env, lang)
+ return Expect.Expect(cmd, startReader = startReader, env = env, logfile=tracefile, cwd = cwd)
-def spawnClient(cmd, env = None, cwd = None, echo = True):
- client = spawn(cmd, env, cwd)
+def spawnClient(cmd, env = None, cwd = None, echo = True, startReader = True,lang=None):
+ client = spawn(cmd, env, cwd, startReader = startReader,lang = lang)
if echo:
client.trace()
return client
-def spawnServer(cmd, env = None, cwd = None, count = 1, adapter = None, echo = True):
- server = spawn(cmd, env, cwd)
+def spawnServer(cmd, env = None, cwd = None, count = 1, adapter = None, echo = True, lang=None):
+ server = spawn(cmd, env, cwd, lang=lang)
if adapter:
server.expect("%s ready\n" % adapter)
else:
@@ -805,7 +833,6 @@ def getMirrorDir(base, mapping):
raise "cannot find language dir"
return os.path.join(before, mapping, *after)
-
def clientServerTest(additionalServerOptions = "", additionalClientOptions = "",
server = None, client = None, serverenv = None, clientenv = None):
if server is None:
@@ -827,11 +854,7 @@ def clientServerTest(additionalServerOptions = "", additionalClientOptions = "",
server = os.path.join(serverdir, server)
if serverenv is None:
- serverenv = copy.deepcopy(os.environ)
- if lang == "cpp":
- addLdPath(os.path.join(serverdir), serverenv)
- elif lang == "java":
- addClasspath(os.path.join(serverdir, "classes"), serverenv)
+ serverenv = getTestEnv(lang, serverdir)
global cross
if len(cross) == 0:
@@ -858,18 +881,14 @@ def clientServerTest(additionalServerOptions = "", additionalClientOptions = "",
client = os.path.join(clientdir, client)
if clientenv is None:
- clientenv = copy.deepcopy(os.environ)
- if clientLang == "cpp":
- addLdPath(os.path.join(clientdir), clientenv)
- elif clientLang == "java":
- addClasspath(os.path.join(clientdir, "classes"), clientenv)
+ clientenv = getTestEnv(clientLang, clientdir)
print "starting " + serverDesc + "...",
serverCfg = DriverConfig("server")
if lang in ["rb", "php"]:
serverCfg.lang = "cpp"
server = getCommandLine(server, serverCfg) + " " + additionalServerOptions
- serverProc = spawnServer(server, env = serverenv)
+ serverProc = spawnServer(server, env = serverenv, lang=serverCfg.lang)
print "ok"
if lang == "php":
@@ -880,8 +899,9 @@ def clientServerTest(additionalServerOptions = "", additionalClientOptions = "",
else:
print "starting %s %s ..." % (clientLang, clientDesc),
client = getCommandLine(client, clientCfg) + " " + additionalClientOptions
- clientProc = spawnClient(client, env = clientenv)
+ clientProc = spawnClient(client, env = clientenv, startReader = False, lang=clientCfg.lang)
print "ok"
+ clientProc.startReader()
clientProc.waitTestSuccess()
serverProc.waitTestSuccess()
@@ -896,51 +916,52 @@ def collocatedTest(additionalOptions = ""):
collocated = getDefaultCollocatedFile()
if lang != "java" and lang != "javae":
collocated = os.path.join(testdir, collocated)
- if lang == "cpp":
- env = copy.deepcopy(os.environ)
- addLdPath(os.path.join(testdir), env)
- else:
- env = None
- else:
- env = copy.deepcopy(os.environ)
- addClasspath(os.path.join(testdir, "classes"), env)
+
+ env = getTestEnv(lang, testdir)
print "starting collocated...",
collocated = getCommandLine(collocated, DriverConfig("colloc")) + ' ' + additionalOptions
- collocatedProc = spawnClient(collocated, env = env)
+ collocatedProc = spawnClient(collocated, env = env, startReader = False, lang=lang)
print "ok"
+ collocatedProc.startReader()
collocatedProc.waitTestSuccess()
def cleanDbDir(path):
for filename in [ os.path.join(path, f) for f in os.listdir(path) if f != ".gitignore" and f != "DB_CONFIG" ]:
os.remove(filename)
-def startClient(exe, args = "", config=None, env=None, echo = True):
+def startClient(exe, args = "", config=None, env=None, echo = True, startReader = True):
if config == None:
config = DriverConfig("client")
- cmd = getCommandLine(exe, config, env) + ' ' + args
+ if env == None:
+ env = getTestEnv(getDefaultMapping(), os.getcwd())
+ cmd = getCommandLine(exe, config) + ' ' + args
if config.lang == "php":
writePhpIni("php.ini", "tmp.ini")
+ return spawnClient(cmd, env = env, echo = echo, startReader = startReader, lang=config.lang)
- return spawnClient(cmd, echo = echo)
-
-def startServer(exe, args = "", config=None, env=None, adapter = None, count = 1, echo = False):
+def startServer(exe, args = "", config=None, env=None, adapter = None, count = 1, echo = True):
if config == None:
config = DriverConfig("server")
- cmd = getCommandLine(exe, config, env) + ' ' + args
- return spawnServer(cmd, adapter = adapter, count = count, echo = echo)
+ if env == None:
+ env = getTestEnv(getDefaultMapping(), os.getcwd())
+ cmd = getCommandLine(exe, config) + ' ' + args
+ return spawnServer(cmd, env = env, adapter = adapter, count = count, echo = echo,lang=config.lang)
def startColloc(exe, args, config=None, env=None):
if config == None:
config = DriverConfig("colloc")
- cmd = getCommandLine(exe, config, env) + ' ' + args
- return spawnClient(cmd)
+ if env == None:
+ env = getTestEnv(lang, testdir)
+ cmd = getCommandLine(exe, config) + ' ' + args
+ return spawnClient(cmd, env = env, lang=config.lang)
def simpleTest(exe, options = ""):
print "starting client...",
command = exe + ' ' + options
- client = spawnClient(command)
+ client = spawnClient(command, startReader = False, lang=getDefaultMapping())
print "ok"
+ client.startReader()
client.waitTestSuccess()
def getCppBinDir():
@@ -957,6 +978,14 @@ def getCppBinDir():
binDir = os.path.join(binDir, "x64")
return binDir
+def getTestEnv(lang, testdir):
+ env = os.environ.copy()
+ if lang == "cpp":
+ addLdPath(os.path.join(testdir), env)
+ elif lang == "java":
+ addClasspath(os.path.join(testdir, "classes"), env)
+ return env;
+
def getTestName():
lang = getDefaultMapping()
here = os.getcwd().split(os.sep)
@@ -985,6 +1014,7 @@ def processCmdLine():
--ice-home=<path> Use the binary distribution from the given path.
--x64 Binary distribution is 64-bit.
--java2 Use Java 2 jar file.
+ --env Print important environment variables.
--cross=lang Run cross language test.
"""
sys.exit(2)
@@ -992,7 +1022,7 @@ def processCmdLine():
try:
opts, args = getopt.getopt(
sys.argv[1:], "", ["debug", "trace=", "protocol=", "compress", "valgrind", "host=", "serialize", "ipv6", \
- "ice-home=", "x64", "cross=", "java2"])
+ "ice-home=", "x64", "cross=", "java2", "env"])
except getopt.GetoptError:
usage()
@@ -1051,6 +1081,9 @@ def processCmdLine():
elif o == "--debug":
global debug
debug = True
+ elif o == "--env":
+ global printenv
+ printenv = True
elif o == "--protocol":
if a not in ( "ssl", "tcp"):
usage()