summaryrefslogtreecommitdiff
path: root/cppe/config/TestUtil.py
diff options
context:
space:
mode:
Diffstat (limited to 'cppe/config/TestUtil.py')
-rwxr-xr-xcppe/config/TestUtil.py297
1 files changed, 0 insertions, 297 deletions
diff --git a/cppe/config/TestUtil.py b/cppe/config/TestUtil.py
deleted file mode 100755
index 53bfe9b33d9..00000000000
--- a/cppe/config/TestUtil.py
+++ /dev/null
@@ -1,297 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice-E is licensed to you under the terms described in the
-# ICEE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-#
-# Set blocking to 1 in case you want to run the tests in
-# blocking mode.
-#
-
-blocking = 0
-#blocking = 1
-
-#
-# If you don't set "host" below, then the IceE library will try to find
-# out the IP address of this host. For the IceE test suite, it's best
-# 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!
-#
-
-import sys, os, re, getopt
-
-def usage():
- print "usage: " + sys.argv[0] + " --host host --blocking"
- sys.exit(2)
-try:
- opts, args = getopt.getopt(sys.argv[1:], "", ["host=", "blocking"])
-except getopt.GetoptError:
- usage()
-
-for o, a in opts:
- if o == "--blocking":
- blocking = 1
- if o == "--host":
- host = a
-
-def getIceVersion():
-
- config = open(os.path.join(toplevel, "include", "IceE", "Config.h"), "r")
- return re.search("ICE_STRING_VERSION \"([0-9\.]*)\"", config.read()).group(1)
-
-def getIceSoVersion():
-
- config = open(os.path.join(toplevel, "include", "IceE", "Config.h"), "r")
- intVersion = int(re.search("ICE_INT_VERSION ([0-9]*)", config.read()).group(1))
- majorVersion = intVersion / 10000
- minorVersion = intVersion / 100 - 100 * majorVersion
- return '%d' % (majorVersion * 10 + minorVersion)
-
-def isCygwin():
-
- # The substring on sys.platform is required because some cygwin
- # versions return variations like "cygwin_nt-4.01".
- return sys.platform[:6] == "cygwin"
-
-def isWin32():
-
- return sys.platform == "win32" or isCygwin()
-
-def isWin9x():
-
- if isWin32():
- return not (os.environ.has_key("OS") and os.environ["OS"] == "Windows_NT")
- else:
- return 0
-
-def isSolaris():
-
- return sys.platform == "sunos5"
-
-def isHpUx():
-
- return sys.platform == "hp-ux11"
-
-def isAIX():
- return sys.platform in ['aix4', 'aix5']
-
-def isDarwin():
-
- return sys.platform == "darwin"
-
-serverPids = []
-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:
- pass # Ignore errors, such as non-existing processes.
- else:
- try:
- os.kill(pid, 9)
- except:
- pass # Ignore errors, such as non-existing processes.
-
- serverPids = []
-
-def getServerPid(serverPipe):
-
- output = serverPipe.readline().strip()
-
- if not output:
- print "failed!"
- killServers()
- sys.exit(1)
-
- serverPids.append(int(output))
-
-def getAdapterReady(serverPipe):
-
- output = serverPipe.readline().strip()
-
- if not output:
- print "failed!"
- killServers()
- sys.exit(1)
-
-def waitServiceReady(pipe, token):
-
- while 1:
-
- output = pipe.readline().strip()
-
- if not output:
- print "failed!"
- sys.exit(1)
-
- if output == token + " ready":
- break
-
-def printOutputFromPipe(pipe):
-
- while 1:
-
- c = pipe.read(1)
-
- if c == "":
- break
-
- os.write(1, c)
-
-for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
- toplevel = os.path.normpath(toplevel)
- if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")):
- break
-else:
- raise "can't find toplevel directory!"
-
-if isWin32():
- if isCygwin():
- os.environ["PATH"] = os.path.join(toplevel, "bin") + ":" + os.getenv("PATH", "")
- else:
- os.environ["PATH"] = os.path.join(toplevel, "bin") + ";" + os.getenv("PATH", "")
-elif isHpUx():
- os.environ["SHLIB_PATH"] = os.path.join(toplevel, "lib") + ":" + os.getenv("SHLIB_PATH", "")
-elif isDarwin():
- os.environ["DYLD_LIBRARY_PATH"] = os.path.join(toplevel, "lib") + ":" + os.getenv("DYLD_LIBRARY_PATH", "")
-elif isAIX():
- os.environ["LIBPATH"] = os.path.join(toplevel, "lib") + ":" + os.getenv("LIBPATH", "")
-else:
- os.environ["LD_LIBRARY_PATH"] = os.path.join(toplevel, "lib") + ":" + os.getenv("LD_LIBRARY_PATH", "")
- os.environ["LD_LIBRARY_PATH_64"] = os.path.join(toplevel, "lib") + ":" + os.getenv("LD_LIBRARY_PATH_64", "")
-
-clientProtocol = ""
-serverProtocol = ""
-clientServerProtocol = ""
-
-if blocking:
- clientProtocol += " --Ice.Blocking"
- serverProtocol += " --Ice.Blocking"
- clientServerProtocol += " --Ice.Blocking"
-
-if host != "":
- defaultHost = " --Ice.Default.Host=" + host
-else:
- defaultHost = ""
-
-commonClientOptions = " --Ice.NullHandleAbort --Ice.Warn.Connections"
-
-commonServerOptions = " --Ice.PrintProcessId --Ice.PrintAdapterReady --Ice.NullHandleAbort" + \
- " --Ice.Warn.Connections"
-
-clientOptions = clientProtocol + defaultHost + commonClientOptions
-serverOptions = serverProtocol + defaultHost + commonServerOptions
-clientServerOptions = clientServerProtocol + defaultHost + commonServerOptions
-collocatedOptions = clientServerProtocol + defaultHost
-
-def clientServerTestWithOptionsAndNames(name, additionalServerOptions, additionalClientOptions, \
- serverName, clientName):
-
- testdir = os.path.join(toplevel, "test", name)
- server = os.path.join(testdir, serverName)
- client = os.path.join(testdir, clientName)
-
- print "starting " + serverName + "...",
- serverPipe = os.popen(server + serverOptions + additionalServerOptions + " 2>&1")
- getServerPid(serverPipe)
- getAdapterReady(serverPipe)
- print "ok"
-
- print "starting " + clientName + "...",
- clientPipe = os.popen(client + clientOptions + additionalClientOptions + " 2>&1")
- print "ok"
-
- printOutputFromPipe(clientPipe)
-
- clientStatus = clientPipe.close()
- serverStatus = serverPipe.close()
-
- if clientStatus or serverStatus:
- killServers()
- sys.exit(1)
-
-def clientServerTestWithOptions(name, additionalServerOptions, additionalClientOptions):
-
- clientServerTestWithOptionsAndNames(name, additionalServerOptions, additionalClientOptions, "server", "client")
-
-def clientServerTest(name):
-
- clientServerTestWithOptions(name, "", "")
-
-def mixedClientServerTestWithOptions(name, additionalServerOptions, additionalClientOptions):
-
- testdir = os.path.join(toplevel, "test", name)
- server = os.path.join(testdir, "server")
- client = os.path.join(testdir, "client")
-
- print "starting server...",
- serverPipe = os.popen(server + clientServerOptions + additionalServerOptions + " 2>&1")
- getServerPid(serverPipe)
- getAdapterReady(serverPipe)
- print "ok"
-
- print "starting client...",
- clientPipe = os.popen(client + clientServerOptions + additionalClientOptions + " 2>&1")
- getServerPid(clientPipe)
- getAdapterReady(clientPipe)
- print "ok"
-
- printOutputFromPipe(clientPipe)
-
- clientStatus = clientPipe.close()
- serverStatus = serverPipe.close()
-
- if clientStatus or serverStatus:
- killServers()
- sys.exit(1)
-
-def mixedClientServerTest(name):
-
- mixedClientServerTestWithOptions(name, "", "")
-
-def collocatedTestWithOptions(name, additionalOptions):
-
- testdir = os.path.join(toplevel, "test", name)
- collocated = os.path.join(testdir, "collocated")
-
- print "starting collocated...",
- collocatedPipe = os.popen(collocated + collocatedOptions + additionalOptions + " 2>&1")
- print "ok"
-
- printOutputFromPipe(collocatedPipe)
-
- collocatedStatus = collocatedPipe.close()
-
- if collocatedStatus:
- killServers()
- sys.exit(1)
-
-def collocatedTest(name):
-
- collocatedTestWithOptions(name, "")
-
-def cleanDbDir(path):
- for filename in [ os.path.join(path, f) for f in os.listdir(path) if f != ".gitignore"]:
- os.remove(filename)