diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-08-15 13:59:55 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-08-15 13:59:55 -0230 |
commit | 1d265d0027c43825a0dd9567589758713a27452c (patch) | |
tree | 207e11aba123ed504311ba5b988b79d151852704 /py | |
parent | Added missing file (diff) | |
download | ice-1d265d0027c43825a0dd9567589758713a27452c.tar.bz2 ice-1d265d0027c43825a0dd9567589758713a27452c.tar.xz ice-1d265d0027c43825a0dd9567589758713a27452c.zip |
Added expect scripts
Diffstat (limited to 'py')
-rwxr-xr-x | py/allDemos.py | 126 | ||||
-rwxr-xr-x | py/demo/Glacier2/callback/expect.py | 39 | ||||
-rw-r--r-- | py/demo/Ice/async/Client.py | 2 | ||||
-rwxr-xr-x | py/demo/Ice/async/expect.py | 33 | ||||
-rwxr-xr-x | py/demo/Ice/bidir/expect.py | 31 | ||||
-rwxr-xr-x | py/demo/Ice/callback/expect.py | 33 | ||||
-rwxr-xr-x | py/demo/Ice/hello/expect.py | 33 | ||||
-rwxr-xr-x | py/demo/Ice/latency/expect.py | 36 | ||||
-rwxr-xr-x | py/demo/Ice/minimal/expect.py | 35 | ||||
-rwxr-xr-x | py/demo/Ice/session/expect.py | 31 | ||||
-rwxr-xr-x | py/demo/Ice/throughput/expect.py | 32 | ||||
-rwxr-xr-x | py/demo/Ice/value/expect.py | 32 | ||||
-rwxr-xr-x | py/demo/IceGrid/simple/expect.py | 28 | ||||
-rwxr-xr-x | py/demo/IceStorm/clock/expect.py | 28 |
14 files changed, 518 insertions, 1 deletions
diff --git a/py/allDemos.py b/py/allDemos.py new file mode 100755 index 00000000000..84f0cb4c359 --- /dev/null +++ b/py/allDemos.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys, getopt + +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 runDemos(args, demos, num = 0): + rootPath = "demo" + if not os.path.exists(rootPath): + rootPath = "." + + if not os.path.exists(os.path.join(rootPath, os.path.normpath(demos[0]))): + print "Unable to locate first demo. Check directory structure and location of scripts" + sys.exit(1) + + # + # Run each of the demos. + # + for i in demos: + + i = os.path.normpath(i) + dir = os.path.join(rootPath, i) + + print + if(num > 0): + print "[" + str(num) + "]", + print "*** running demo in " + dir, + print + + status = os.system("cd %s ; %s %s" % (dir, "./expect.py", args)) + + if status: + if(num > 0): + print "[" + str(num) + "]", + print "test in " + dir + " failed with exit status", status, + sys.exit(status) + +# +# List of all basic demos. +# +demos = [ "Ice/async", + "Ice/bidir", + "Ice/callback", + "Ice/hello", + "Ice/latency", + "Ice/minimal", + "Ice/session", + "Ice/throughput", + "Ice/value", + "IceStorm/clock", + "IceGrid/simple", + "Glacier2/callback", + ] + +# +# These demos are currently disabled on cygwin +# +if isCygwin() == 0: + demos += [ ] + +def usage(): + print "usage: " + sys.argv[0] + " --fast --trace --start=<demo> -l -r <regex> -R <regex> --debug --host host" + sys.exit(2) + +try: + opts, args = getopt.getopt(sys.argv[1:], "lr:R:", ["start=", "fast", "trace", "debug", "host="]) +except getopt.GetoptError: + usage() + +if(args): + usage() + +loop = 0 +args = "" +for o, a in opts: + if o == "-l": + loop = 1 + if o == "-r" or o == '-R': + import re + regexp = re.compile(a) + if o == '-r': + def rematch(x): return regexp.search(x) + else: + def rematch(x): return not regexp.search(x) + demos = filter(rematch, demos) + if o == "--protocol": + if a not in ( "ssl", "tcp"): + usage() + args += " " + o + " " + a + if o == "--host" : + args += " " + o + " " + a + if o in ( "--fast", "--trace", "--debug"): + args += " " + o + if o == '--start': + import re + regexp = re.compile(a) + found = False + nt = [] + for t in demos: + if not found and regexp.search(t): + found = True + if found: + nt.append(t) + if len(nt) == 0: + print "test %s not found. no demos to run" % (a) + sys.exit(2) + demos = nt + +if loop: + num = 1 + while 1: + runDemos(args, demos, num) + num += 1 +else: + runDemos(args, demos) diff --git a/py/demo/Glacier2/callback/expect.py b/py/demo/Glacier2/callback/expect.py new file mode 100755 index 00000000000..285057f29cb --- /dev/null +++ b/py/demo/Glacier2/callback/expect.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Glacier2.callback + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') +sessionserver = demoscript.Util.spawn('python SessionServer.py --Ice.PrintAdapterReady') +sessionserver.expect('.* ready') + +glacier2 = demoscript.Util.spawn('glacier2router --Ice.Config=config.glacier2 --Ice.PrintAdapterReady --Glacier2.SessionTimeout=5') +glacier2.expect('Glacier2.Client ready') +glacier2.expect('Glacier2.Server ready') + +client = demoscript.Util.spawn('python Client.py') + +demoscript.Glacier2.callback.run(client, server, sessionserver, glacier2) diff --git a/py/demo/Ice/async/Client.py b/py/demo/Ice/async/Client.py index 2c371dafc62..0c3f1e2782e 100644 --- a/py/demo/Ice/async/Client.py +++ b/py/demo/Ice/async/Client.py @@ -19,7 +19,7 @@ class AMI_Hello_sayHelloI: def ice_exception(self, ex): if isinstance(ex, Demo.RequestCanceledException): - print "Request canceled" + print "Demo.RequestCanceledException" else: print "sayHello AMI call failed:" print ex diff --git a/py/demo/Ice/async/expect.py b/py/demo/Ice/async/expect.py new file mode 100755 index 00000000000..ce0a966abc1 --- /dev/null +++ b/py/demo/Ice/async/expect.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.async + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('python Client.py') +client.expect('.*==>') + +demoscript.Ice.async.run(client, server) diff --git a/py/demo/Ice/bidir/expect.py b/py/demo/Ice/bidir/expect.py new file mode 100755 index 00000000000..f6c334e7b48 --- /dev/null +++ b/py/demo/Ice/bidir/expect.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.bidir + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') + +demoscript.Ice.bidir.run('python Client.py', server) diff --git a/py/demo/Ice/callback/expect.py b/py/demo/Ice/callback/expect.py new file mode 100755 index 00000000000..6007be0875a --- /dev/null +++ b/py/demo/Ice/callback/expect.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.callback + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('python Client.py') +client.expect('.*==>') + +demoscript.Ice.callback.run(client, server) diff --git a/py/demo/Ice/hello/expect.py b/py/demo/Ice/hello/expect.py new file mode 100755 index 00000000000..1a4f44aa191 --- /dev/null +++ b/py/demo/Ice/hello/expect.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.hello + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('python Client.py') +client.expect('.*==>') + +demoscript.Ice.hello.run(client, server) diff --git a/py/demo/Ice/latency/expect.py b/py/demo/Ice/latency/expect.py new file mode 100755 index 00000000000..7061ffb74cd --- /dev/null +++ b/py/demo/Ice/latency/expect.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing ping... ", +sys.stdout.flush() +client = demoscript.Util.spawn('python Client.py') +client.expect(pexpect.EOF, timeout=100) +print "ok" + +print client.before diff --git a/py/demo/Ice/minimal/expect.py b/py/demo/Ice/minimal/expect.py new file mode 100755 index 00000000000..dbb25da3afa --- /dev/null +++ b/py/demo/Ice/minimal/expect.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('python Client.py') +client.expect(pexpect.EOF) +server.expect('Hello World!') +print "ok" diff --git a/py/demo/Ice/session/expect.py b/py/demo/Ice/session/expect.py new file mode 100755 index 00000000000..4ba4f2fab34 --- /dev/null +++ b/py/demo/Ice/session/expect.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.session + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') + +demoscript.Ice.session.run('python Client.py', server) diff --git a/py/demo/Ice/throughput/expect.py b/py/demo/Ice/throughput/expect.py new file mode 100755 index 00000000000..c0876f71727 --- /dev/null +++ b/py/demo/Ice/throughput/expect.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.throughput + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('python Client.py') + +demoscript.Ice.throughput.run(client, server) diff --git a/py/demo/Ice/value/expect.py b/py/demo/Ice/value/expect.py new file mode 100755 index 00000000000..6620a8b41d4 --- /dev/null +++ b/py/demo/Ice/value/expect.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.Ice.value + +server = demoscript.Util.spawn('python Server.py --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('python Client.py') + +demoscript.Ice.value.run(client, server) diff --git a/py/demo/IceGrid/simple/expect.py b/py/demo/IceGrid/simple/expect.py new file mode 100755 index 00000000000..7894164e7c2 --- /dev/null +++ b/py/demo/IceGrid/simple/expect.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.IceGrid.simple + +demoscript.IceGrid.simple.run('python Client.py') diff --git a/py/demo/IceStorm/clock/expect.py b/py/demo/IceStorm/clock/expect.py new file mode 100755 index 00000000000..5e7f91c4f6f --- /dev/null +++ b/py/demo/IceStorm/clock/expect.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import pexpect, sys, os + +try: + import demoscript +except ImportError: + for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "demoscript")): + break + else: + raise "can't find toplevel directory!" + sys.path.append(os.path.join(toplevel)) + import demoscript + +import demoscript.Util +import demoscript.IceStorm.clock + +demoscript.IceStorm.clock.run('python Subscriber.py', 'python Publisher.py') |