diff options
author | Matthew Newhook <matthew@zeroc.com> | 2007-08-24 14:41:39 +0800 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2007-08-24 14:41:39 +0800 |
commit | 9ff48829c8669fbef8c7ca6a9b8bab99c77db2f9 (patch) | |
tree | 7fa0a0406be0386a8314b2e8c742f29bf127b70d /demoscript/Util.py | |
parent | Merge branch 'bug1319' (diff) | |
download | ice-9ff48829c8669fbef8c7ca6a9b8bab99c77db2f9.tar.bz2 ice-9ff48829c8669fbef8c7ca6a9b8bab99c77db2f9.tar.xz ice-9ff48829c8669fbef8c7ca6a9b8bab99c77db2f9.zip |
Squashed commit of the following:
commit d74cec9e6c77e70b33883f517b1bb6f97b2ffa5e
Author: Matthew Newhook <matthew@zeroc.com>
Date: Fri Aug 24 14:33:06 2007 +0800
updates.
commit 643b31f979a00ea5397206ca59f20bb58c62660e
Author: Matthew Newhook <matthew@zeroc.com>
Date: Fri Aug 24 14:32:35 2007 +0800
added some .gitignore rules.
commit 1510d38798976753b435f32308e79acd9fcd2722
Author: Matthew Newhook <matthew@zeroc.com>
Date: Fri Aug 24 14:05:10 2007 +0800
removed bogus use of 127.0.0.1
commit 3c91e89b01af20a0dacfdbc1fbeca1c67c796656
Author: Matthew Newhook <matthew@zeroc.com>
Date: Fri Aug 24 14:01:43 2007 +0800
Verify that cygwin python is used under Windows.
commit ff160725c051eedb28a42d9dd69f0d8aa297e522
Author: Matthew Newhook <matthew@zeroc.com>
Date: Fri Aug 24 13:55:03 2007 +0800
bump timeout for the node to terminate. killing the node leaves the servers running under cygwin
commit ec3bddb58e861f906bf39aee1fa818c3e9a50000
Author: Matthew Newhook <matthew@zeroc.com>
Date: Fri Aug 24 13:48:55 2007 +0800
added back accidently removed files.
commit f9ea2f552d7f576ebfa878669925f4184a89257b
Author: Matthew Newhook <matthew@zeroc.com>
Date: Fri Aug 24 13:47:47 2007 +0800
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=2427, http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=2422
commit 8a309ca0036dba7ecbd577edb2d737fa41174a5a
Author: Matthew Newhook <matthew@zeroc.com>
Date: Fri Aug 24 10:06:53 2007 +0800
added ruby support to the expect scripts.
commit 34597c1ee6d80d6754c9e925bd376125dd104a5f
Author: Matthew Newhook <matthew@zeroc.com>
Date: Fri Aug 24 09:26:10 2007 +0800
added pexpect to git repository.
commit 4bd2e1f2b52bcb9906b03ac216db686b8229b545
Author: Matthew Newhook <matthew@zeroc.com>
Date: Thu Aug 23 18:49:51 2007 +0800
numerous UNIX expect script fixes.
commit 25ab4a812f45a6e908d5d2d7ab03e557d79afa9f
Author: Matthew Newhook <matthew@zeroc.com>
Date: Thu Aug 23 16:47:08 2007 +0800
generate configuration files for IceGrid icebox/iceboxd
commit 6bb57bf7ed21d7256963c228aaf0b20657367a47
Author: Matthew Newhook <matthew@zeroc.com>
Date: Thu Aug 23 15:16:55 2007 +0800
added python & C# support to the expect scripts.
commit 08f1a59971ad3a52a4357069554dcc309b2d062b
Author: Matthew Newhook <matthew@zeroc.com>
Date: Wed Aug 22 14:23:53 2007 +0800
java expect scripts complete.
commit 3918f4ff3beea3005001bc55c5502c0825d8b7ea
Author: Matthew Newhook <matthew@zeroc.com>
Date: Wed Aug 22 13:30:31 2007 +0800
first set of expect changes.
Diffstat (limited to 'demoscript/Util.py')
-rw-r--r-- | demoscript/Util.py | 100 |
1 files changed, 87 insertions, 13 deletions
diff --git a/demoscript/Util.py b/demoscript/Util.py index 6ad51faa61c..dcce6928348 100644 --- a/demoscript/Util.py +++ b/demoscript/Util.py @@ -7,6 +7,11 @@ # # ********************************************************************** +import sys +if sys.platform == "win32": + print "demoscript only supports cygwin python under Windows (use /usr/bin/python expect.py)" + sys.exit(1) + # # Timeout after the initial spawn. # @@ -26,7 +31,13 @@ host = "127.0.0.1" # debug = False -import sys, getopt, pexpect, os +# +# The test language. +# +defaultLanguage = None + +import getopt, os, signal +import demoscript.pexpect as pexpect def usage(): print "usage: " + sys.argv[0] + " --fast --trace --debug --host host --mode=[debug|release]" @@ -50,9 +61,8 @@ for o, a in opts: fast = True if o == "--mode": mode = a - if mode != 'debug' or mode != 'release': - print "usage: " + sys.argv[0] + " --trace --debug --host host --mode=[debug|release]" - sys.exit(2) + if mode != 'debug' and mode != 'release': + usage() if host != "": defaultHost = " --Ice.Default.Host=%s" % (host) @@ -64,20 +74,20 @@ def isCygwin(): # versions return variations like "cygwin_nt-4.01". return sys.platform[:6] == "cygwin" -def isWin32(): - return sys.platform == "win32" or isCygwin() - def isDarwin(): return sys.platform == "darwin" -def mono(): - if isWin32(): - return "" +def isMono(): + return not isCygwin() + +def python(): + if isCygwin(): + return "python -u " else: - return "mono " + return "python " def getIceBox(): - if isWin32(): + if isCygwin(): if mode == 'release': return "icebox" else: @@ -87,28 +97,92 @@ def getIceBox(): # Automatically adds default host, and uses our default timeout for # expect. class spawn(pexpect.spawn): - def __init__(self, command): + def __init__(self, command, language = None): if defaultHost: command = '%s %s' % (command, defaultHost) if debug: print '(%s)' % (command) + if not language: + self.language = defaultLanguage + else: + self.language = language self.expectFirst = True if trace: logfile = sys.stdout else: logfile = None + self.sentKill = None + if self.language == "C#": + if isMono(): + command = "mono " + command + else: + command = "./" + command + if self.language == "Python": + command = python() + command pexpect.spawn.__init__(self, command, logfile = logfile) + def expect(self, pattern, timeout = defaultTimeout, searchwindowsize=None): if self.expectFirst and timeout == defaultTimeout: timeout = initialTimeout self.expectFirst = False return pexpect.spawn.expect(self, pattern, timeout, searchwindowsize) + def wait(self): try: return pexpect.spawn.wait(self) except pexpect.ExceptionPexpect, e: return self.exitstatus + def kill(self, sig): + if isCygwin(): + sig = signal.SIGTERM + self.sentKill = sig + return pexpect.spawn.kill(self, sig) + + # status == 0 is normal exit status for C++ + # + # status == 130 is normal exit status for a Java app that was + # SIGINT interrupted. + # + # signalstatus == SIGINT is normal exit status for a mono app, + # or if under cygwin (since cygwin spawned expect apps cannot + # catch SIGINT). + # + def waitTestSuccess(self, exitstatus = 0, timeout = None): + if not timeout: + self.expect(pexpect.EOF) + else: + self.expect(pexpect.EOF, timeout) + status = self.wait() + if self.language == "C++" or self.language == "Python" or self.language == "Ruby" or self.language == "PHP": + if isCygwin() and self.sentKill: + assert self.signalstatus == self.sentKill + else: + assert status == exitstatus + elif self.language == "C#": + if isMono() or isCygwin() and self.sentKill: + assert self.signalstatus == self.sentKill + else: + assert status == exitstatus + elif self.language == "Java": + if self.sentKill: + if isCygwin(): + assert self.signalstatus == self.sentKill + else: + if self.sentKill == signal.SIGINT: + assert status == 130 + else: + assert False + else: + assert status == exitstatus + else: + # Unknown language + print "Warning: unknown language" + if not self.sentKill: + assert status == exitstatus + else: + assert status == exitstatus or status == 130 or self.signalstatus == self.sentKill + def cleanDbDir(path): for filename in [ os.path.join(path, f) for f in os.listdir(path) if f != ".gitignore" and f != "DB_CONFIG"]: if os.path.isdir(filename): |