diff options
138 files changed, 6073 insertions, 18 deletions
diff --git a/cpp/allDemos.py b/cpp/allDemos.py new file mode 100755 index 00000000000..f894bd08ce7 --- /dev/null +++ b/cpp/allDemos.py @@ -0,0 +1,146 @@ +#!/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 = [ "IceUtil/workqueue", + "Ice/async", + "Ice/bidir", + "Ice/callback", + "Ice/converter", + "Ice/hello", + "Ice/invoke", + "Ice/latency", + "Ice/minimal", + "Ice/nested", + "Ice/session", + "Ice/throughput", + "Ice/value", + "IceBox/hello", + "IceStorm/clock", + "IceStorm/counter", + "IceStorm/replicated", + "IceGrid/simple", + "IceGrid/allocate", + "IceGrid/sessionActivation", + "IceGrid/replication", + "Glacier2/chat", + "Glacier2/callback", + "Freeze/bench", + "Freeze/customEvictor", + "Freeze/phonebook", + "Freeze/library", + "Freeze/backup", + "book/freeze_filesystem", + "book/simple_filesystem", + "book/printer", + "book/lifecycle", + ] + +# +# 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/cpp/demo/Freeze/backup/expect.py b/cpp/demo/Freeze/backup/expect.py new file mode 100755 index 00000000000..1b37cdc5718 --- /dev/null +++ b/cpp/demo/Freeze/backup/expect.py @@ -0,0 +1,108 @@ +#!/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 signal, time + +print "cleaning databases...", +sys.stdout.flush() +os.system('rm -fr db.save') +demoscript.Util.cleanDbDir("db/data") +demoscript.Util.cleanDbDir("db/logs") +os.system('rm -fr db/__*') +for d in os.listdir('.'): + if d.startswith('hotbackup'): + os.system('rm -rf %s' % (d)) +print "ok" + +client = demoscript.Util.spawn('./client') + +print "populating map...", +sys.stdout.flush() +client.expect('Updating map', timeout=60) +time.sleep(3) # Let the client do some work for a bit. +print "ok" + + +print "performing full backup...", +sys.stdout.flush() +backup = demoscript.Util.spawn('./backup full') +backup.expect('hot backup started', timeout=30) +backup.expect(pexpect.EOF, timeout=30) +assert backup.wait() == 0 +print "ok" + +print "sleeping 5s...", +sys.stdout.flush() +time.sleep(5) +print "ok" + +print "performing incremental backup...", +sys.stdout.flush() +backup = demoscript.Util.spawn('./backup incremental') +backup.expect('hot backup started', timeout=30) +backup.expect(pexpect.EOF, timeout=30) +print "ok" + +print "sleeping 30s...", +sys.stdout.flush() +time.sleep(30) +print "ok" + +assert os.path.isdir('hotbackup') + +print "killing client with SIGTERM...", +sys.stdout.flush() +client.kill(signal.SIGTERM) +client.expect(pexpect.EOF, timeout=30) +assert client.wait() != 0 +print "ok" + +print "Client output: ", +print "%s " % (client.before) + +print "restarting client...", +sys.stdout.flush() +os.system('rm -fr db/data/* db/logs/* db/__*') +os.system('cp -Rp hotbackup/* db') +sys.stdout.flush() + +rclient = demoscript.Util.spawn('./client') +rclient.expect('(.*)Updating map', timeout=60) +assert rclient.match.group(1).find('Creating new map') == -1 +print "ok" + +print "sleeping 5s...", +sys.stdout.flush() +time.sleep(5) +print "ok" + +print "killing client with SIGTERM...", +rclient.kill(signal.SIGTERM) +rclient.expect(pexpect.EOF, timeout=30) +assert rclient.wait() != 0 +print "ok" + +print "Restarted client output:", +print "%s " % (rclient.before) diff --git a/cpp/demo/Freeze/bench/Client.cpp b/cpp/demo/Freeze/bench/Client.cpp index 4d5154e2959..916e9938c48 100644 --- a/cpp/demo/Freeze/bench/Client.cpp +++ b/cpp/demo/Freeze/bench/Client.cpp @@ -802,7 +802,7 @@ TestApp::run(int argc, char* argv[]) IntIntMapReadTest<IntIntMap>("IntIntMap"); #endif - cout <<"IntIntMap with index(read test)" << endl; + cout <<"IntIntMap with index (read test)" << endl; #if defined(_MSC_VER) && (_MSC_VER < 1310) { IndexedIntIntMap* dummy = 0; diff --git a/cpp/demo/Freeze/bench/expect.py b/cpp/demo/Freeze/bench/expect.py new file mode 100755 index 00000000000..fa0e0ea8e41 --- /dev/null +++ b/cpp/demo/Freeze/bench/expect.py @@ -0,0 +1,34 @@ +#!/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.Freeze.bench + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +client = demoscript.Util.spawn('./client') +demoscript.Freeze.bench.run(client) diff --git a/cpp/demo/Freeze/customEvictor/expect.py b/cpp/demo/Freeze/customEvictor/expect.py new file mode 100755 index 00000000000..ff7ddf43115 --- /dev/null +++ b/cpp/demo/Freeze/customEvictor/expect.py @@ -0,0 +1,59 @@ +#!/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, signal + +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 + +if demoscript.Util.isDarwin(): + print "This demo is not supported under MacOS." + sys.exit(0) + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +print "testing IceUtl::Cache evictor" +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect(".* ready", timeout=120) + +client = demoscript.Util.spawn('./client') +client.expect(pexpect.EOF, timeout=200) +print client.before + +server.kill(signal.SIGINT) +server.expect(pexpect.EOF, timeout=60) +assert server.wait() == 0 + +print "testing simple evictor" +server = demoscript.Util.spawn('./server simple --Ice.PrintAdapterReady') +server.expect(".* ready") + +client = demoscript.Util.spawn('./client') +client.expect(pexpect.EOF, timeout=200) +assert client.wait() == 0 +print client.before + +server.kill(signal.SIGINT) +server.expect(pexpect.EOF, timeout=60) +assert server.wait() == 0 diff --git a/cpp/demo/Freeze/library/expect.py b/cpp/demo/Freeze/library/expect.py new file mode 100755 index 00000000000..4e75062933c --- /dev/null +++ b/cpp/demo/Freeze/library/expect.py @@ -0,0 +1,62 @@ +#!/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.Freeze.library + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') +client.expect('>>> ') + +demoscript.Freeze.library.run(client, server) + +client.sendline('shutdown') +server.expect(pexpect.EOF) +assert server.wait() == 0 + +client.sendline('exit') +client.expect(pexpect.EOF) +assert server.wait() == 0 + +print "running with collocated server" + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('./collocated --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') +server.expect('>>> ') + +demoscript.Freeze.library.run(server, server) + +server.sendline('exit') +server.expect(pexpect.EOF) +assert server.wait() == 0 diff --git a/cpp/demo/Freeze/phonebook/expect.py b/cpp/demo/Freeze/phonebook/expect.py new file mode 100755 index 00000000000..1bf5b900509 --- /dev/null +++ b/cpp/demo/Freeze/phonebook/expect.py @@ -0,0 +1,59 @@ +#!/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.Freeze.phonebook + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') +client.expect('>>> ') + +demoscript.Freeze.phonebook.run(client, server) + +client.sendline('shutdown') +server.expect(pexpect.EOF) + +client.sendline('exit') +client.expect(pexpect.EOF) + +print "running with collocated server" + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('./collocated --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') +server.expect('>>> ') + +demoscript.Freeze.phonebook.run(server, server) + +server.sendline('exit') +server.expect(pexpect.EOF) diff --git a/cpp/demo/Glacier2/callback/expect.py b/cpp/demo/Glacier2/callback/expect.py new file mode 100755 index 00000000000..19db7e98914 --- /dev/null +++ b/cpp/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +sessionserver = demoscript.Util.spawn('./sessionserver --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('./client') + +demoscript.Glacier2.callback.run(client, server, sessionserver, glacier2) diff --git a/cpp/demo/Glacier2/chat/expect.py b/cpp/demo/Glacier2/chat/expect.py new file mode 100755 index 00000000000..b78f32706c2 --- /dev/null +++ b/cpp/demo/Glacier2/chat/expect.py @@ -0,0 +1,71 @@ +#!/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') + +glacier2 = demoscript.Util.spawn('glacier2router --Ice.Config=config.glacier2 --Ice.PrintAdapterReady') +glacier2.expect('Glacier2.Client ready') +glacier2.expect('Glacier2.Server ready') + +print "starting client 1...", +sys.stdout.flush() +client1 = demoscript.Util.spawn('./client') +client1.expect('user id:') +client1.sendline("foo") +client1.expect('password:') +client1.sendline("foo") +print "ok" + +print "starting client 2...", +sys.stdout.flush() +client2 = demoscript.Util.spawn('./client') +client2.expect('user id:') +client2.sendline("bar") +client2.expect('password:') +client2.sendline("bar") + +client1.expect("bar has entered the chat room") +print "ok" + +print "testing chat...", +sys.stdout.flush() +client1.sendline("hi") +client1.expect("foo says: hi") +client2.expect("foo says: hi") + +client2.sendline("hello") +client2.expect("bar says: hello") +client1.expect("bar says: hello") + +client1.sendline("/quit") +client1.expect(pexpect.EOF) +assert client1.wait() == 0 +client2.expect("foo has left the chat room") + +client2.sendline("/quit") +client2.expect(pexpect.EOF) +assert client2.wait() == 0 +print "ok" diff --git a/cpp/demo/Ice/async/expect.py b/cpp/demo/Ice/async/expect.py new file mode 100755 index 00000000000..d5f6cf69b56 --- /dev/null +++ b/cpp/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') +client.expect('.*==>') + +demoscript.Ice.async.run(client, server) diff --git a/cpp/demo/Ice/bidir/expect.py b/cpp/demo/Ice/bidir/expect.py new file mode 100755 index 00000000000..58cbc023aab --- /dev/null +++ b/cpp/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') + +demoscript.Ice.bidir.run('./client', server) diff --git a/cpp/demo/Ice/callback/expect.py b/cpp/demo/Ice/callback/expect.py new file mode 100755 index 00000000000..ff556c54954 --- /dev/null +++ b/cpp/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') +client.expect('.*==>') + +demoscript.Ice.callback.run(client, server) diff --git a/cpp/demo/Ice/converter/expect.py b/cpp/demo/Ice/converter/expect.py new file mode 100755 index 00000000000..f6f31af7378 --- /dev/null +++ b/cpp/demo/Ice/converter/expect.py @@ -0,0 +1,51 @@ +#!/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') +client.expect('.*==>') + +print "testing with conversion... ", +sys.stdout.flush() +client.sendline('u') +server.expect('Received \\(UTF-8\\): "Bonne journ\\\\351e"') +client.expect('Received \\(LATIN-1\\): "Bonne journ\\\\303\\\\251e"') +print "ok" + +print "testing without conversion... ", +client.sendline('t') +server.expect('Received \\(UTF-8\\): "Bonne journ\\\\303\\\\251e"') +client.expect('Received \\(LATIN-1\\): "Bonne journ\\\\351e"') +print "ok" + +client.sendline('s') +server.expect(pexpect.EOF) +assert server.wait() == 0 + +client.sendline('x') +client.expect(pexpect.EOF) +assert client.wait() == 0 diff --git a/cpp/demo/Ice/hello/expect.py b/cpp/demo/Ice/hello/expect.py new file mode 100755 index 00000000000..ccfe9c90ab4 --- /dev/null +++ b/cpp/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') +client.expect('.*==>') + +demoscript.Ice.hello.run(client, server) diff --git a/cpp/demo/Ice/invoke/expect.py b/cpp/demo/Ice/invoke/expect.py new file mode 100755 index 00000000000..7ac50f77917 --- /dev/null +++ b/cpp/demo/Ice/invoke/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.invoke + +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') +client.expect('.*==>') + +demoscript.Ice.invoke.run(client, server) diff --git a/cpp/demo/Ice/latency/expect.py b/cpp/demo/Ice/latency/expect.py new file mode 100755 index 00000000000..24bdb1e2e31 --- /dev/null +++ b/cpp/demo/Ice/latency/expect.py @@ -0,0 +1,37 @@ +#!/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing ping... ", +sys.stdout.flush() +client = demoscript.Util.spawn('./client') +client.expect(pexpect.EOF, timeout=100) +assert client.wait() == 0 +print "ok" + +print client.before diff --git a/cpp/demo/Ice/minimal/expect.py b/cpp/demo/Ice/minimal/expect.py new file mode 100755 index 00000000000..e4246cbf6d6 --- /dev/null +++ b/cpp/demo/Ice/minimal/expect.py @@ -0,0 +1,41 @@ +#!/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 signal + +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('./client') +client.expect(pexpect.EOF) +assert client.wait() == 0 +server.expect('Hello World!') +print "ok" + +server.kill(signal.SIGINT) +server.expect(pexpect.EOF) +assert server.wait() == 0 diff --git a/cpp/demo/Ice/nested/expect.py b/cpp/demo/Ice/nested/expect.py new file mode 100755 index 00000000000..0d4434fb857 --- /dev/null +++ b/cpp/demo/Ice/nested/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.nested + +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client --Ice.Override.Timeout=2000') +client.expect('.*for exit:') + +demoscript.Ice.nested.run(client, server) diff --git a/cpp/demo/Ice/session/expect.py b/cpp/demo/Ice/session/expect.py new file mode 100755 index 00000000000..7093707b625 --- /dev/null +++ b/cpp/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') + +demoscript.Ice.session.run('./client', server) diff --git a/cpp/demo/Ice/throughput/expect.py b/cpp/demo/Ice/throughput/expect.py new file mode 100755 index 00000000000..262a3b92f56 --- /dev/null +++ b/cpp/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') + +demoscript.Ice.throughput.run(client, server) diff --git a/cpp/demo/Ice/value/expect.py b/cpp/demo/Ice/value/expect.py new file mode 100755 index 00000000000..039264a9e1a --- /dev/null +++ b/cpp/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('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') + +demoscript.Ice.value.run(client, server) diff --git a/cpp/demo/IceBox/hello/expect.py b/cpp/demo/IceBox/hello/expect.py new file mode 100755 index 00000000000..2c0f7ce07cf --- /dev/null +++ b/cpp/demo/IceBox/hello/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.IceBox.hello + +if demoscript.Util.defaultHost: + args = ' --IceBox.UseSharedCommunicator.IceStorm=1' +else: + args = '' + +# TODO: This doesn't setup LD_LIBRARY_PATH +server = demoscript.Util.spawn('%s --Ice.Config=config.icebox --Ice.PrintAdapterReady %s' % (demoscript.Util.getIceBox(), args)) +server.expect('.* ready') +client = demoscript.Util.spawn('./client') +client.expect('.*==>') + +demoscript.IceBox.hello.run(client, server) diff --git a/cpp/demo/IceGrid/allocate/expect.py b/cpp/demo/IceGrid/allocate/expect.py new file mode 100755 index 00000000000..6755f0d69e1 --- /dev/null +++ b/cpp/demo/IceGrid/allocate/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.allocate + +demoscript.IceGrid.allocate.run('./client') diff --git a/cpp/demo/IceGrid/replication/expect.py b/cpp/demo/IceGrid/replication/expect.py new file mode 100755 index 00000000000..5921f418b7f --- /dev/null +++ b/cpp/demo/IceGrid/replication/expect.py @@ -0,0 +1,115 @@ +#!/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 signal + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db/master") +demoscript.Util.cleanDbDir("db/node1") +demoscript.Util.cleanDbDir("db/node2") +demoscript.Util.cleanDbDir("db/replica1") +demoscript.Util.cleanDbDir("db/replica2") +print "ok" + +if demoscript.Util.defaultHost: + args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' +else: + args = '' + +print "starting icegridnodes...", +sys.stdout.flush() +master = demoscript.Util.spawn('icegridregistry --Ice.Config=config.master --Ice.PrintAdapterReady --Ice.StdErr= --Ice.StdOut=') +master.expect('IceGrid.Registry.Internal ready\r{1,2}\nIceGrid.Registry.Server ready\r{1,2}\nIceGrid.Registry.Client ready') +replica1 = demoscript.Util.spawn('icegridregistry --Ice.Config=config.replica1 --Ice.PrintAdapterReady --Ice.StdErr= --Ice.StdOut=') +replica1.expect('IceGrid.Registry.Server ready\r{1,2}\nIceGrid.Registry.Client ready') +replica2 = demoscript.Util.spawn('icegridregistry --Ice.Config=config.replica2 --Ice.PrintAdapterReady --Ice.StdErr= --Ice.StdOut=') +replica2.expect('IceGrid.Registry.Server ready\r{1,2}\nIceGrid.Registry.Client ready') +node1 = demoscript.Util.spawn('icegridnode --Ice.Config=config.node1 --Ice.PrintAdapterReady --Ice.StdErr= --Ice.StdOut= %s' % (args)) +node1.expect('IceGrid.Node ready') +node2 = demoscript.Util.spawn('icegridnode --Ice.Config=config.node2 --Ice.PrintAdapterReady --Ice.StdErr= --Ice.StdOut= %s' % (args)) +node2.expect('IceGrid.Node ready') +print "ok" + +print "deploying application...", +sys.stdout.flush() +admin = demoscript.Util.spawn('icegridadmin --Ice.Config=config.client') +admin.expect('>>>') +admin.sendline("application add \'application.xml\'") +admin.expect('>>>') +print "ok" + +def runtest(): + client = demoscript.Util.spawn('./client') + client.expect('iterations:') + client.sendline('5') + client.expect('\(in ms\):') + client.sendline('0') + for i in range(1, 5): + client.expect("Hello World!") + client.sendline('x') + client.kill(signal.SIGINT) + + client.expect(pexpect.EOF, timeout=1) + assert client.wait() == 0 + +print "testing client...", +sys.stdout.flush() +runtest() +print "ok" + +print "testing replication...", +sys.stdout.flush() +admin.sendline('registry shutdown Replica1') +admin.expect('>>>') +replica1.expect(pexpect.EOF) +assert replica1.wait() == 0 +runtest() +admin.sendline('registry shutdown Replica2') +admin.expect('>>>') +replica2.expect(pexpect.EOF) +assert replica2.wait() == 0 +runtest() +print "ok" + +admin.sendline('node shutdown node1') +admin.expect('>>>') +node1.expect(pexpect.EOF) +assert node1.wait() == 0 + +admin.sendline('node shutdown node2') +admin.expect('>>>') +node2.expect(pexpect.EOF) +assert node2.wait() == 0 + +admin.sendline('registry shutdown Master') +admin.expect('>>>') +master.expect(pexpect.EOF) +assert master.wait() == 0 + +admin.sendline('exit') +admin.expect(pexpect.EOF) +assert admin.wait() == 0 diff --git a/cpp/demo/IceGrid/sessionActivation/expect.py b/cpp/demo/IceGrid/sessionActivation/expect.py new file mode 100755 index 00000000000..da0dfced31a --- /dev/null +++ b/cpp/demo/IceGrid/sessionActivation/expect.py @@ -0,0 +1,29 @@ +#!/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.sessionActivation + +demoscript.IceGrid.sessionActivation.run('./client') + diff --git a/cpp/demo/IceGrid/simple/expect.py b/cpp/demo/IceGrid/simple/expect.py new file mode 100755 index 00000000000..2bc8048ca31 --- /dev/null +++ b/cpp/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('./client') diff --git a/cpp/demo/IceStorm/clock/expect.py b/cpp/demo/IceStorm/clock/expect.py new file mode 100755 index 00000000000..b303c340957 --- /dev/null +++ b/cpp/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('./subscriber', './publisher') diff --git a/cpp/demo/IceStorm/counter/expect.py b/cpp/demo/IceStorm/counter/expect.py new file mode 100755 index 00000000000..95c7cf9285a --- /dev/null +++ b/cpp/demo/IceStorm/counter/expect.py @@ -0,0 +1,90 @@ +#!/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 signal + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +if demoscript.Util.defaultHost: + args = ' --IceBox.UseSharedCommunicator.IceStorm=1' +else: + args = '' + +icestorm = demoscript.Util.spawn('%s --Ice.Config=config.icebox --Ice.PrintAdapterReady %s' % (demoscript.Util.getIceBox(), args)) +icestorm.expect('.* ready') + +print "testing single client...", +sys.stdout.flush() +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client1 = demoscript.Util.spawn('./client') +client1.expect('init: 0') +client1.sendline('i') +client1.expect('int: 1 total: 1') +print "ok" + +print "testing second client...", +sys.stdout.flush() +client2 = demoscript.Util.spawn('./client') +client2.expect('init: 1') +client2.sendline('i') +client1.expect('int: 1 total: 2') +client2.expect('int: 1 total: 2') +print "ok" + +print "testing third client...", +client3 = demoscript.Util.spawn('./client') +client3.expect('init: 2') +client3.sendline('d') +client1.expect('int: -1 total: 1') +client2.expect('int: -1 total: 1') +client3.expect('int: -1 total: 1') +print "ok" + +print "testing removing client...", +client3.sendline('x') +client3.expect(pexpect.EOF) +assert client3.wait() == 0 + +client2.sendline('d') +client1.expect('int: -1 total: 0') +client2.expect('int: -1 total: 0') +client1.sendline('x') +client1.expect(pexpect.EOF) +assert client1.wait() == 0 +client2.sendline('x') +client2.expect(pexpect.EOF) +assert client2.wait() == 0 +print "ok" + +admin = demoscript.Util.spawn('iceboxadmin --Ice.Config=config.icebox shutdown') +admin.expect(pexpect.EOF) +assert admin.wait() == 0 +icestorm.expect(pexpect.EOF) +assert icestorm.wait() == 0 diff --git a/cpp/demo/IceStorm/replicated/expect.py b/cpp/demo/IceStorm/replicated/expect.py new file mode 100755 index 00000000000..3f6869b0b90 --- /dev/null +++ b/cpp/demo/IceStorm/replicated/expect.py @@ -0,0 +1,106 @@ +#!/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 time, signal + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db/node") +demoscript.Util.cleanDbDir("db/registry") +print "ok" + +if demoscript.Util.defaultHost: + args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' +else: + args = '' + +print "starting icegridnode...", +sys.stdout.flush() +node = demoscript.Util.spawn('icegridnode --Ice.Config=config.grid --Ice.PrintAdapterReady %s' % (args)) +node.expect('IceGrid.Registry.Internal ready\r{1,2}\nIceGrid.Registry.Server ready\r{1,2}\nIceGrid.Registry.Client ready\r{1,2}\nIceGrid.Node ready') +print "ok" + +print "deploying application...", +sys.stdout.flush() +admin = demoscript.Util.spawn('icegridadmin --Ice.Config=config.grid') +admin.expect('>>>') +admin.sendline("application add \'application.xml\'") +admin.expect('>>>') +print "ok" + +print "testing pub/sub...", +sys.stdout.flush() +sub = demoscript.Util.spawn('./subscriber --Ice.PrintAdapterReady') +sub.expect('.* ready') + +node.expect('Subscribe:.*Subscribe:.*Subscribe:') + +pub = demoscript.Util.spawn('./publisher') + +time.sleep(3) +sub.expect('[0-9][0-9]/[0-9][0-9].*\r{1,2}\n[0-9][0-9]/[0-9][0-9]') +print "ok" + +print "testing replication...", +sys.stdout.flush() +# Start killing off the servers +admin.sendline('server disable DemoIceStorm-1') +admin.expect('>>>') +admin.sendline('server stop DemoIceStorm-1') +admin.expect('>>>') + +time.sleep(3) +sub.expect('[0-9][0-9]/[0-9][0-9].*\r{1,2}\n[0-9][0-9]/[0-9][0-9]') + +admin.sendline('server disable DemoIceStorm-2') +admin.expect('>>>') +admin.sendline('server stop DemoIceStorm-2') +admin.expect('>>>') + +time.sleep(3) +sub.expect('[0-9][0-9]/[0-9][0-9].*\r{1,2}\n[0-9][0-9]/[0-9][0-9]') + +admin.sendline('server disable DemoIceStorm-3') +admin.expect('>>>') +admin.sendline('server stop DemoIceStorm-3') +admin.expect('>>>') + +pub.expect('Ice::NoEndpointException') +pub.expect(pexpect.EOF) +assert pub.wait() != 0 + +sub.kill(signal.SIGINT) +sub.expect('NoEndpointException') +sub.expect(pexpect.EOF) +assert sub.wait() != 0 +print "ok" + +admin.sendline('registry shutdown Master') +admin.sendline('exit') +admin.expect(pexpect.EOF) +assert admin.wait() == 0 +node.expect(pexpect.EOF) +assert node.wait() == 0 diff --git a/cpp/demo/IceUtil/workqueue/expect.py b/cpp/demo/IceUtil/workqueue/expect.py new file mode 100755 index 00000000000..31f2c87ddfe --- /dev/null +++ b/cpp/demo/IceUtil/workqueue/expect.py @@ -0,0 +1,40 @@ +#!/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('./workqueue') +server.expect('Pushing work items') + +print "testing...", +sys.stdout.flush() +server.expect('work item: item1') +server.expect('work item: item2') +server.expect('work item: item3') +server.expect('work item: item4') +server.expect('work item: item5') +server.expect(pexpect.EOF, timeout=10) +assert server.wait() == 0 +print "ok" diff --git a/cpp/demo/book/freeze_filesystem/expect.py b/cpp/demo/book/freeze_filesystem/expect.py new file mode 100755 index 00000000000..d44c2014af3 --- /dev/null +++ b/cpp/demo/book/freeze_filesystem/expect.py @@ -0,0 +1,37 @@ +#!/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.book.freeze_filesystem + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') + +demoscript.book.freeze_filesystem.run(client, server) diff --git a/cpp/demo/book/lifecycle/expect.py b/cpp/demo/book/lifecycle/expect.py new file mode 100755 index 00000000000..94f8c96dd43 --- /dev/null +++ b/cpp/demo/book/lifecycle/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.book.lifecycle + +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('./client') + +demoscript.book.lifecycle.run(client, server) diff --git a/cpp/demo/book/printer/expect.py b/cpp/demo/book/printer/expect.py new file mode 100755 index 00000000000..2325f6f7917 --- /dev/null +++ b/cpp/demo/book/printer/expect.py @@ -0,0 +1,41 @@ +#!/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 signal + +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('./client') +client.expect(pexpect.EOF) +assert client.wait() == 0 +server.expect('Hello World!') +print "ok" +server.kill(signal.SIGINT) +server.expect(pexpect.EOF) +# This server doesn't exit with a non-zero exit status. +assert server.wait() != 0 diff --git a/cpp/demo/book/simple_filesystem/expect.py b/cpp/demo/book/simple_filesystem/expect.py new file mode 100755 index 00000000000..238ed5c45c7 --- /dev/null +++ b/cpp/demo/book/simple_filesystem/expect.py @@ -0,0 +1,40 @@ +#!/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 signal + +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('./client') +client.expect('Contents of root directory:\r{1,2}\n.*Down to a sunless sea.') +client.expect(pexpect.EOF) +assert client.wait() == 0 +print "ok" +server.kill(signal.SIGINT) +server.expect(pexpect.EOF) +assert server.wait() == 0 diff --git a/cs/allDemos.py b/cs/allDemos.py new file mode 100755 index 00000000000..9dc7a42dc29 --- /dev/null +++ b/cs/allDemos.py @@ -0,0 +1,132 @@ +#!/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/invoke", + "Ice/latency", + "Ice/minimal", + "Ice/nested", + "Ice/session", + "Ice/throughput", + "Ice/value", + "IceBox/hello", + "IceStorm/clock", + "IceGrid/simple", + "Glacier2/callback", + "book/simple_filesystem", + "book/printer", + "book/lifecycle", + ] + +# +# 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/cs/demo/Glacier2/callback/CallbackI.cs b/cs/demo/Glacier2/callback/CallbackI.cs index 20d05798817..1a1d307855e 100644 --- a/cs/demo/Glacier2/callback/CallbackI.cs +++ b/cs/demo/Glacier2/callback/CallbackI.cs @@ -14,7 +14,7 @@ public sealed class CallbackI : CallbackDisp_ { public override void initiateCallback(CallbackReceiverPrx proxy, Ice.Current current) { - Console.WriteLine("initiating callback"); + Console.WriteLine("initiating callback to: " + current.adapter.getCommunicator().proxyToString(proxy)); try { proxy.callback(current.ctx); diff --git a/cs/demo/Glacier2/callback/expect.py b/cs/demo/Glacier2/callback/expect.py new file mode 100755 index 00000000000..2eee49d32b1 --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') +sessionserver = demoscript.Util.spawn('%ssessionserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +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('%sclient.exe' % (demoscript.Util.mono())) + +demoscript.Glacier2.callback.run(client, server, sessionserver, glacier2) diff --git a/cs/demo/Ice/async/Client.cs b/cs/demo/Ice/async/Client.cs index ea7ab3aed85..e1149f464fe 100644 --- a/cs/demo/Ice/async/Client.cs +++ b/cs/demo/Ice/async/Client.cs @@ -22,7 +22,7 @@ public class Client : Ice.Application { if(ex is RequestCanceledException) { - Console.Error.WriteLine("Request canceled"); + Console.Error.WriteLine("RequestCanceledException"); } else { diff --git a/cs/demo/Ice/async/expect.py b/cs/demo/Ice/async/expect.py new file mode 100755 index 00000000000..2076b186786 --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) +client.expect('.*==>') + +demoscript.Ice.async.run(client, server) diff --git a/cs/demo/Ice/bidir/expect.py b/cs/demo/Ice/bidir/expect.py new file mode 100755 index 00000000000..ef7f0c7bab2 --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') + +demoscript.Ice.bidir.run('%sclient.exe' % (demoscript.Util.mono()), server) diff --git a/cs/demo/Ice/callback/expect.py b/cs/demo/Ice/callback/expect.py new file mode 100755 index 00000000000..8c55b78350e --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) +client.expect('.*==>') + +demoscript.Ice.callback.run(client, server) diff --git a/cs/demo/Ice/hello/expect.py b/cs/demo/Ice/hello/expect.py new file mode 100755 index 00000000000..02143df5c15 --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) +client.expect('.*==>') + +demoscript.Ice.hello.run(client, server) diff --git a/cs/demo/Ice/invoke/expect.py b/cs/demo/Ice/invoke/expect.py new file mode 100755 index 00000000000..2645e7ca4c1 --- /dev/null +++ b/cs/demo/Ice/invoke/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.invoke + +server = demoscript.Util.spawn('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) +client.expect('.*==>') + +demoscript.Ice.invoke.run(client, server) diff --git a/cs/demo/Ice/latency/expect.py b/cs/demo/Ice/latency/expect.py new file mode 100755 index 00000000000..9e6e7d8bbb6 --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') + +print "testing ping... ", +sys.stdout.flush() +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) +client.expect(pexpect.EOF, timeout=100) +print "ok" + +print client.before diff --git a/cs/demo/Ice/minimal/expect.py b/cs/demo/Ice/minimal/expect.py new file mode 100755 index 00000000000..16ea852d00a --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) +client.expect(pexpect.EOF) +server.expect('Hello World!') +print "ok" diff --git a/cs/demo/Ice/nested/expect.py b/cs/demo/Ice/nested/expect.py new file mode 100755 index 00000000000..726b0d8f750 --- /dev/null +++ b/cs/demo/Ice/nested/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.nested + +server = demoscript.Util.spawn('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') +client = demoscript.Util.spawn('%sclient.exe --Ice.Override.Timeout=2000' % (demoscript.Util.mono())) +client.expect('.*for exit:') + +demoscript.Ice.nested.run(client, server) diff --git a/cs/demo/Ice/session/expect.py b/cs/demo/Ice/session/expect.py new file mode 100755 index 00000000000..fc50eb8a1d8 --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') + +demoscript.Ice.session.run('%sclient.exe' % (demoscript.Util.mono()), server) diff --git a/cs/demo/Ice/throughput/expect.py b/cs/demo/Ice/throughput/expect.py new file mode 100755 index 00000000000..80adfff8442 --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) + +demoscript.Ice.throughput.run(client, server) diff --git a/cs/demo/Ice/value/Client.cs b/cs/demo/Ice/value/Client.cs index 9d877701c53..3818ef3692b 100755 --- a/cs/demo/Ice/value/Client.cs +++ b/cs/demo/Ice/value/Client.cs @@ -92,7 +92,7 @@ public class Client : Ice.Application Console.In.ReadLine(); Printer derivedAsBase = initial.getDerivedPrinter(); - Console.Out.WriteLine("The type ID of the received object is \"" + derivedAsBase.ice_id() + "\""); + Console.Out.WriteLine("==> The type ID of the received object is \"" + derivedAsBase.ice_id() + "\""); Debug.Assert(derivedAsBase.ice_id().Equals("::Demo::Printer")); Console.Out.WriteLine(); @@ -108,7 +108,7 @@ public class Client : Ice.Application DerivedPrinter derived = (DerivedPrinter)derivedAsBase; Console.Out.WriteLine("==> class cast to derived object succeded"); - Console.Out.WriteLine("The type ID of the received object is \"" + derived.ice_id() + "\""); + Console.Out.WriteLine("==> The type ID of the received object is \"" + derived.ice_id() + "\""); Console.Out.WriteLine(); Console.Out.WriteLine("Let's print the message contained in the derived object, and"); diff --git a/cs/demo/Ice/value/expect.py b/cs/demo/Ice/value/expect.py new file mode 100755 index 00000000000..096ad9e882d --- /dev/null +++ b/cs/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) + +demoscript.Ice.value.run(client, server) diff --git a/cs/demo/IceBox/hello/expect.py b/cs/demo/IceBox/hello/expect.py new file mode 100755 index 00000000000..ff1c5590278 --- /dev/null +++ b/cs/demo/IceBox/hello/expect.py @@ -0,0 +1,50 @@ +#!/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.IceBox.hello + +if demoscript.Util.defaultHost: + args = ' --IceBox.UseSharedCommunicator.IceStorm=1' +else: + args = '' + +iceboxnet = "iceboxnet.exe" +if len(demoscript.Util.mono()) > 0: + prefix = [ "../../..", "/usr" ] + if os.environ.has_key("ICE_HOME"): + prefix.append(os.environ["ICE_HOME"]) + for p in prefix: + path = os.path.join(p, "bin", iceboxnet) + if os.path.exists(path): + iceboxnet = path + break +# TODO: This doesn't setup LD_LIBRARY_PATH +server = demoscript.Util.spawn('%s%s --Ice.Config=config.icebox --Ice.PrintAdapterReady %s' % ( + demoscript.Util.mono(), iceboxnet, args)) +server.expect('.* ready') +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) +client.expect('.*==>') + +demoscript.IceBox.hello.run(client, server) diff --git a/cs/demo/IceGrid/simple/expect.py b/cs/demo/IceGrid/simple/expect.py new file mode 100755 index 00000000000..c36b0b735d8 --- /dev/null +++ b/cs/demo/IceGrid/simple/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.IceGrid.simple + +if demoscript.Util.isWin32(): + demoscript.IceGrid.simple.run('%sclient.exe' % (demoscript.Util.mono())) +else: + print "Not supported yet with mono!" + diff --git a/cs/demo/IceStorm/clock/expect.py b/cs/demo/IceStorm/clock/expect.py new file mode 100755 index 00000000000..62ae936ef3b --- /dev/null +++ b/cs/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('%ssubscriber.exe' % (demoscript.Util.mono()), '%spublisher.exe' % (demoscript.Util.mono())) diff --git a/cs/demo/book/lifecycle/expect.py b/cs/demo/book/lifecycle/expect.py new file mode 100755 index 00000000000..0f4dd41c438 --- /dev/null +++ b/cs/demo/book/lifecycle/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.book.lifecycle + +server = demoscript.Util.spawn('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') + +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) + +demoscript.book.lifecycle.run(client, server) diff --git a/cs/demo/book/lifecycle/generated/.gitignore b/cs/demo/book/lifecycle/generated/.gitignore new file mode 100644 index 00000000000..39af5887579 --- /dev/null +++ b/cs/demo/book/lifecycle/generated/.gitignore @@ -0,0 +1 @@ +# Dummy file, so that git retains this otherwise empty directory. diff --git a/cs/demo/book/printer/expect.py b/cs/demo/book/printer/expect.py new file mode 100755 index 00000000000..16ea852d00a --- /dev/null +++ b/cs/demo/book/printer/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) +client.expect(pexpect.EOF) +server.expect('Hello World!') +print "ok" diff --git a/cs/demo/book/simple_filesystem/expect.py b/cs/demo/book/simple_filesystem/expect.py new file mode 100755 index 00000000000..9a48e980e25 --- /dev/null +++ b/cs/demo/book/simple_filesystem/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('%sserver.exe --Ice.PrintAdapterReady' % (demoscript.Util.mono())) +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('%sclient.exe' % (demoscript.Util.mono())) +client.expect('Contents of root directory:\r{1,2}\n.*Down to a sunless sea.') +client.expect(pexpect.EOF) +print "ok" diff --git a/demoscript/Freeze/__init__.py b/demoscript/Freeze/__init__.py new file mode 100644 index 00000000000..74d403bf72e --- /dev/null +++ b/demoscript/Freeze/__init__.py @@ -0,0 +1,8 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** diff --git a/demoscript/Freeze/bench.py b/demoscript/Freeze/bench.py new file mode 100755 index 00000000000..67934186d87 --- /dev/null +++ b/demoscript/Freeze/bench.py @@ -0,0 +1,68 @@ +#!/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 + +def run(client, isJava=False): + if isJava: + client.expect('IntIntMap \\(Collections API\\)') + print "IntIntMap (Collections API):" + client.expect('IntIntMap \\(Fast API\\)', timeout=200) + print "%s " % (client.before) + + print "IntIntMap (Fast API):" + client.expect('IntIntMap with index \\(Collections API\\)', timeout=200) + print "%s " % (client.before) + + print "IntIntMap with index (Collections API):" + client.expect('IntIntMap with index \\(Fast API\\)', timeout=200) + print "%s " % (client.before) + + print "IntIntMap with index (Fast API):" + client.expect('Struct1Struct2Map', timeout=200) + print "%s " % (client.before) + else: + client.expect('IntIntMap') + print "IntIntMap:" + client.expect('IntIntMap with index', timeout=200) + print "%s " % (client.before) + + print "IntIntMap with index:" + client.expect('Struct1Struct2Map', timeout=200) + print "%s " % (client.before) + + print "Struct1Struct2Map:" + client.expect('Struct1Struct2Map with index', timeout=200) + print "%s " % (client.before) + + print "Struct1Struct2Map with index:" + client.expect('Struct1Class1Map', timeout=200) + print "%s " % (client.before) + + print "Struct1Class1Map:" + client.expect('Struct1Class1Map with index', timeout=200) + print "%s " % (client.before) + + print "Struct1Class1Map with index:" + client.expect('Struct1ObjectMap', timeout=200) + print "%s " % (client.before) + + print "Struct1ObjectMap:" + client.expect('IntIntMap \\(read test\\)', timeout=200) + print "%s " % (client.before) + + print "IntIntMap (read test):" + client.expect('IntIntMap with index \\(read test\\)', timeout=200) + print "%s " % (client.before) + + print "IntIntMap with index (read test):" + client.expect(pexpect.EOF, timeout=200) + assert client.wait() == 0 + print "%s " % (client.before) diff --git a/demoscript/Freeze/library.py b/demoscript/Freeze/library.py new file mode 100755 index 00000000000..9212c18138f --- /dev/null +++ b/demoscript/Freeze/library.py @@ -0,0 +1,149 @@ +#!/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 + +def dequote(s): + cur = 0 + end = len(s) + havequote = False + quote = None + items = [] + while cur < len(s): + if not quote: + if s[cur] == "'" or s[cur] == '"': + quote = s[cur] + start = cur+1 + else: + if s[cur] == quote: + items.append(s[start:cur]) + quote = None + cur = cur + 1 + return items + +def mkregexp(s): + s = s.replace('(', '\\(') + s = s.replace(')', '\\)') + s = s.replace('.', '\\.') + s = s.replace('+', '\\+') + s = s.replace('*', '\\*') + return s + +def run(client, server): + print "populating database... ", + sys.stdout.flush() + f = open("books", "r") + books = [] + for l in f: + client.sendline(l) + #server.expect('added object') + client.expect('added new book') + isbn, title, author = dequote(l) + books.append((isbn, title, author)) + print "ok" + + byauthor = {} + for b in books: + isbn, title, author = b + if not byauthor.has_key(author): + byauthor[author] = [] + byauthor[author].append(b) + + print "testing isbn... ", + sys.stdout.flush() + for b in books: + isbn, title, author = b + client.sendline('isbn %s' %(isbn)) + #server.expect('locate found') + #server.expect('locate found') + client.expect('current book is:') + client.expect('isbn: %s' %(isbn)) + client.expect('title: %s' %(mkregexp(title))) + client.expect('authors: %s' %(author)) + client.sendline('isbn 1000') + client.expect('no book with that') + print "ok" + + print "testing authors... ", + sys.stdout.flush() + for a, bl in byauthor.iteritems(): + client.sendline('authors "%s"' %(a)) + client.expect('number of books found: ([0-9]+)') + n = int(client.match.group(1)) + assert len(bl) == n + for i in range(0, n): + #server.expect('locate found') + # Consume evicting messages otherwise its possible to get + # hangs. + #try: + #server.expect('evicting', timeout=0) + #except pexpect.TIMEOUT: + #pass + client.expect('current book is:') + client.expect('isbn: ([a-zA-Z0-9]+)') + findisbn = client.match.group(1) + nbl = [] + for b in bl: + isbn, title, author = b + if not findisbn: + nbl.append(b) + if isbn == findisbn: + findisbn = None + client.expect('title: %s' %(mkregexp(title))) + client.expect('authors: %s' %(author)) + bl = nbl + assert not findisbn + client.sendline('next') + client.expect('no current book') + assert len(bl) == 0 + client.sendline('authors foo') + client.expect('number of books found: 0') + client.expect('no current book') + print "ok" + + print "testing rent/return... ", + sys.stdout.flush() + isbn, title, author = books[0] + client.sendline('isbn %s' % (isbn)) + #server.expect('locate') + client.expect('current book is:.*isbn.*\r{1,2}\ntitle.*\r{1,2}\nauthors') + client.sendline('rent matthew') + #server.expect('locate') + client.expect("the book is now rented by `matthew'") + client.sendline('current') + #server.expect('locate') + client.expect('rented: matthew') + client.sendline('rent john') + #server.expect('locate') + client.expect('the book has already been rented') + client.sendline('return') + #server.expect('locate') + client.expect('the book has been returned') + client.sendline('current') + try: + client.expect('rented:', timeout=2) + except pexpect.TIMEOUT: + pass + print "ok" + + print "testing remove... ", + sys.stdout.flush() + isbn, title, author = books[0] + client.sendline('isbn %s' % (isbn)) + #server.expect('locate') + client.expect('current book is:.*isbn.*\r{1,2}\ntitle.*\r{1,2}\nauthors') + client.sendline('remove') + #server.expect('locate') + #server.expect('removed') + client.expect('removed current book') + client.sendline('remove') + #server.expect(['locate could not find', 'locate found.*but it was dead or destroyed']) + client.expect('current book no longer exists') + print "ok" diff --git a/demoscript/Freeze/phonebook.py b/demoscript/Freeze/phonebook.py new file mode 100755 index 00000000000..a2d14bf2d14 --- /dev/null +++ b/demoscript/Freeze/phonebook.py @@ -0,0 +1,90 @@ +#!/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 + +def dequote(s): + cur = 0 + end = len(s) + havequote = False + quote = None + items = [] + while cur < len(s): + if not quote: + if s[cur] == "'" or s[cur] == '"': + quote = s[cur] + start = cur+1 + else: + if s[cur] == quote: + items.append(s[start:cur]) + quote = None + cur = cur + 1 + return items + +def mkregexp(s): + s = s.replace('(', '\\(') + s = s.replace(')', '\\)') + s = s.replace('.', '\\.') + s = s.replace('+', '\\+') + s = s.replace('*', '\\*') + return s + +def run(client, server): + print "populating database... ", + sys.stdout.flush() + f = open("contacts", "r") + for l in f: + client.sendline(l) + try: + client.expect('\r{1,2}\n', timeout=0) + except pexpect.TIMEOUT: + pass + try: + while True: + client.expect('\r{1,2}\n', timeout=1) + except pexpect.TIMEOUT: + pass + print "ok" + + print "testing...", + sys.stdout.flush() + client.sendline('find "Doe, John"') + client.expect('number of contacts found: 3') + client.sendline('next') + client.expect('current contact is') + client.sendline('next') + client.expect('current contact is') + client.sendline('next') + client.expect('no current contact') + client.sendline('find "Mustermann, Manfred"') + client.expect('number of contacts found: 1') + client.sendline('next') + client.expect('no current contact') + client.sendline('find "Mustermann, Manfred"') + client.expect('number of contacts found: 1') + client.sendline('address "foo bar"') + client.expect('changed address') + client.sendline('current') + client.expect('address: foo bar') + client.sendline('name foo') + client.expect('changed name') + client.sendline('current') + client.expect('name: foo') + client.sendline('find "Mustermann, Manfred"') + client.expect('number of contacts found: 0') + client.sendline('find foo') + client.expect('number of contacts found: 1') + client.sendline('remove') + client.expect('removed current contact') + client.sendline('remove') + client.expect('current contact no longer exists') + client.sendline('find foo') + client.expect('number of contacts found: 0') + print "ok" diff --git a/demoscript/Glacier2/__init__.py b/demoscript/Glacier2/__init__.py new file mode 100644 index 00000000000..74d403bf72e --- /dev/null +++ b/demoscript/Glacier2/__init__.py @@ -0,0 +1,8 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** diff --git a/demoscript/Glacier2/callback.py b/demoscript/Glacier2/callback.py new file mode 100755 index 00000000000..f9a387d6482 --- /dev/null +++ b/demoscript/Glacier2/callback.py @@ -0,0 +1,79 @@ +#!/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, time + +def run(client, server, sessionserver, glacier2): + print "testing ", + sys.stdout.flush() + client.expect('user id:') + client.sendline("foo") + client.expect('password:') + client.sendline("foo") + + sessionserver.expect('verified user') + sessionserver.expect('creating session') + + client.expect("==>") + + print "twoway", + sys.stdout.flush() + client.sendline('t') + server.expect('initiating callback to') + client.expect('received callback') + glacier2.expect('_fwd/t \\]') + + print "oneway", + sys.stdout.flush() + client.sendline('o') + server.expect('initiating callback to') + client.expect('received callback') + glacier2.expect('_fwd/o \\]') + + print "batch", + sys.stdout.flush() + client.sendline('O') + try: + server.expect('initiating callback to', timeout=1) + except pexpect.TIMEOUT: + pass + client.sendline('O') + client.sendline('f') + glacier2.expect('_fwd/O \\]') + print "ok" + + print "testing override context field...", + sys.stdout.flush() + client.sendline('v') + client.sendline('t') + server.expect('initiating callback to') + client.expect('received callback') + glacier2.expect('_fwd/t, _ovrd/some_value') + print "ok" + + print "testing fake category...", + sys.stdout.flush() + client.sendline('v') + client.sendline('F') + client.sendline('t') + server.expect('initiating callback to.*fake.*ObjectNotExistException') + glacier2.expect('_fwd/t, _ovrd/some_value') + try: + client.expect('received callback', timeout=1) + except pexpect.TIMEOUT: + pass + print "ok" + + print "testing session timeout...", + sys.stdout.flush() + time.sleep(6) + glacier2.expect('expiring session') + sessionserver.expect('destroying session for user') + print "ok" diff --git a/demoscript/Ice/__init__.py b/demoscript/Ice/__init__.py new file mode 100644 index 00000000000..74d403bf72e --- /dev/null +++ b/demoscript/Ice/__init__.py @@ -0,0 +1,8 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** diff --git a/demoscript/Ice/async.py b/demoscript/Ice/async.py new file mode 100755 index 00000000000..aa1449db294 --- /dev/null +++ b/demoscript/Ice/async.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 + +def run(client, server): + print "testing client... ", + sys.stdout.flush() + client.sendline('i') + server.expect('Hello World!') + client.sendline('d') + try: + server.expect('Hello World!', timeout=1) + except pexpect.TIMEOUT: + pass + client.sendline('i') + server.expect('Hello World!') + server.expect('Hello World!') + print "ok" + + print "testing shutdown... ", + sys.stdout.flush() + client.sendline('d') + client.sendline('s') + server.expect(pexpect.EOF) + assert server.wait() == 0 + + client.expect('RequestCanceledException') + client.sendline('x') + client.expect(pexpect.EOF) + assert client.wait() == 0 + print "ok" diff --git a/demoscript/Ice/bidir.py b/demoscript/Ice/bidir.py new file mode 100755 index 00000000000..1ec7a13c5ce --- /dev/null +++ b/demoscript/Ice/bidir.py @@ -0,0 +1,37 @@ +#!/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, signal, demoscript + +def run(clientStr, server): + print "adding client 1... ", + sys.stdout.flush() + client1 = demoscript.Util.spawn(clientStr) + server.expect('adding client') + client1.expect('received callback #1') + print "ok" + + print "adding client 2... ", + sys.stdout.flush() + client2 = demoscript.Util.spawn(clientStr) + server.expect('adding client') + client1.expect('received callback #') + client2.expect('received callback #') + print "ok" + + print "removing client 2...", + client2.kill(signal.SIGINT) + server.expect('removing client') + client1.expect('received callback #') + print "ok" + print "removing client 1...", + client1.kill(signal.SIGINT) + server.expect('removing client') + print "ok" diff --git a/demoscript/Ice/callback.py b/demoscript/Ice/callback.py new file mode 100755 index 00000000000..c90d048c06d --- /dev/null +++ b/demoscript/Ice/callback.py @@ -0,0 +1,74 @@ +#!/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 + +def runtests(client, server, secure): + print "testing twoway", + sys.stdout.flush() + client.sendline('t') + server.expect('initiating callback') + client.expect('received callback') + print "oneway", + sys.stdout.flush() + client.sendline('o') + server.expect('initiating callback') + client.expect('received callback') + if not secure: + print "datagram", + sys.stdout.flush() + client.sendline('d') + server.expect('initiating callback') + client.expect('received callback') + print "... ok" + + print "testing batch oneway", + sys.stdout.flush() + client.sendline('O') + try: + server.expect('initiating callback', timeout=1) + except pexpect.TIMEOUT: + pass + client.sendline('O') + client.sendline('f') + server.expect('initiating callback') + client.expect('received callback') + server.expect('initiating callback') + client.expect('received callback') + if not secure: + print "datagram", + sys.stdout.flush() + client.sendline('D') + try: + server.expect('initiating callback', timeout=1) + except pexpect.TIMEOUT: + pass + client.sendline('D') + client.sendline('f') + server.expect('initiating callback') + client.expect('received callback') + server.expect('initiating callback') + client.expect('received callback') + print "... ok" + +def run(client, server): + runtests(client, server, False) + + print "repeating tests with SSL" + client.sendline('S') + runtests(client, server, True) + + client.sendline('s') + server.expect(pexpect.EOF) + assert server.wait() == 0 + + client.sendline('x') + client.expect(pexpect.EOF) + assert client.wait() == 0 diff --git a/demoscript/Ice/hello.py b/demoscript/Ice/hello.py new file mode 100644 index 00000000000..243eb0abf65 --- /dev/null +++ b/demoscript/Ice/hello.py @@ -0,0 +1,83 @@ +#!/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 + +def runtests(client, server, secure): + print "testing twoway", + sys.stdout.flush() + client.sendline('t') + server.expect('Hello World!') + print "oneway", + sys.stdout.flush() + client.sendline('o') + server.expect('Hello World!') + if not secure: + print "datagram", + sys.stdout.flush() + client.sendline('d') + server.expect('Hello World!') + print "... ok" + + print "testing batch oneway", + sys.stdout.flush() + client.sendline('O') + try: + server.expect('Hello World!', timeout=1) + except pexpect.TIMEOUT: + pass + client.sendline('O') + client.sendline('f') + server.expect('Hello World!') + server.expect('Hello World!') + if not secure: + print "datagram", + sys.stdout.flush() + client.sendline('D') + try: + server.expect('Hello World!', timeout=1) + except pexpect.TIMEOUT: + pass + client.sendline('D') + client.sendline('f') + server.expect('Hello World!') + server.expect('Hello World!') + print "... ok" + + print "testing timeout...", + sys.stdout.flush() + client.sendline('T') + client.sendline('P') + client.sendline('t') + client.expect('.*TimeoutException.*') + server.expect('Hello World!') + server.expect('Hello World!') # second because op is idempotent + client.sendline('P') + client.sendline('t') + server.expect('Hello World!') + client.sendline('T') + print "ok" + +def run(client, server): + runtests(client, server, False) + + print "repeating tests with SSL" + + client.sendline('S') + + runtests(client, server, True) + + client.sendline('s') + server.expect(pexpect.EOF) + assert server.wait() == 0 + + client.sendline('x') + client.expect(pexpect.EOF) + assert client.wait() == 0 diff --git a/demoscript/Ice/invoke.py b/demoscript/Ice/invoke.py new file mode 100755 index 00000000000..60c5392633d --- /dev/null +++ b/demoscript/Ice/invoke.py @@ -0,0 +1,44 @@ +#!/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 + +def run(client, server): + print "testing...", + sys.stdout.flush() + client.sendline('1') + server.expect("Printing string `The streaming API works!'") + client.sendline('2') + server.expect("Printing string sequence \\{'The', 'streaming', 'API', 'works!'\\}"); + client.sendline('3') + server.expect("Printing dictionary \\{") + i = server.expect(["API=works!", "The=streaming"]) + j = server.expect(["API=works!", "The=streaming"]) + assert i != j + server.expect("\\}") + client.sendline('4') + server.expect("Printing enum green") + client.sendline('5') + server.expect("Printing struct: name=red, value=red") + client.sendline('6') + server.expect("Printing struct sequence: \\{red=red, green=green, blue=blue\\}") + client.sendline('7') + server.expect("Printing class: s\\.name=blue, s\\.value=blue") + client.sendline('8') + client.expect("Got string `hello' and class: s\\.name=green, s\\.value=green") + print "ok" + + client.sendline('s') + server.expect(pexpect.EOF) + assert server.wait() == 0 + + client.sendline('x') + client.expect(pexpect.EOF) + assert client.wait() == 0 diff --git a/demoscript/Ice/nested.py b/demoscript/Ice/nested.py new file mode 100755 index 00000000000..155d9818b03 --- /dev/null +++ b/demoscript/Ice/nested.py @@ -0,0 +1,43 @@ +#!/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, signal + +def run(client, server): + print "testing nested...", + sys.stdout.flush() + client.sendline('1') + server.expect('1') + client.expect('.*for exit:') + client.sendline('2') + server.expect('2') + client.expect('1\r{1,2}\n.*for exit:') + client.sendline('3') + server.expect('3\r{1,2}\n1') + client.expect('2\r{1,2}\n.*for exit:') + print "ok" + + print "testing blocking...", + sys.stdout.flush() + client.sendline('21') # This will cause a block. + server.expect('\r{1,2}\n'.join(['13', '11', '9', '7', '5', '3'])) + client.expect('\r{1,2}\n'.join(['12', '10', '8', '6', '4', '2'])) + client.expect('TimeoutException', timeout=3000) + server.expect('TimeoutException', timeout=3000) + print "ok" + + client.sendline('x') + client.expect(pexpect.EOF) + assert client.wait() == 0 + + server.kill(signal.SIGINT) + server.expect(pexpect.EOF) + status = server.wait() + assert status == 0 or status == 130 or server.signalstatus == signal.SIGINT diff --git a/demoscript/Ice/session.py b/demoscript/Ice/session.py new file mode 100755 index 00000000000..1a5691552c2 --- /dev/null +++ b/demoscript/Ice/session.py @@ -0,0 +1,55 @@ +#!/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, demoscript + +def run(clientStr, server): + client = demoscript.Util.spawn(clientStr) + client.expect('==>') + client.sendline('foo') + + print "testing session creation...", + sys.stdout.flush() + server.expect('The session foo is now created.') + client.sendline('c') + client.sendline('0') + server.expect("Hello object #0 for session `foo' says:\r{1,2}\nHello foo!") + client.sendline('1') + client.expect('Index is too high') + client.sendline('x') + client.expect(pexpect.EOF) + assert client.wait() == 0 + server.expect("The session foo is now destroyed.") + print "ok" + + print "testing session cleanup...", + sys.stdout.flush() + client = demoscript.Util.spawn(clientStr) + client.expect('==>') + client.sendline('foo') + server.expect('The session foo is now created.') + client.sendline('c') + client.sendline('t') + client.expect(pexpect.EOF) + assert client.wait() == 0 + server.expect("The session foo is now destroyed.\r{1,2}\n.*The session foo has timed out.", timeout=25) + print "ok" + + client = demoscript.Util.spawn(clientStr) + client.expect('==>') + client.sendline('foo') + server.expect('The session foo is now created.') + client.sendline('s') + server.expect(pexpect.EOF) + assert server.wait() == 0 + + client.sendline('x') + client.expect(pexpect.EOF) + assert client.wait() == 0 diff --git a/demoscript/Ice/throughput.py b/demoscript/Ice/throughput.py new file mode 100755 index 00000000000..a9c3c968c08 --- /dev/null +++ b/demoscript/Ice/throughput.py @@ -0,0 +1,61 @@ +#!/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, demoscript + +def runseries(client): + client.expect('==> ', timeout=240) + client.sendline('t') + client.expect('t') + + client.expect('==> ', timeout=240) + print "twoway: %s " % (client.before) + + client.sendline('o') + + client.expect('o') + client.expect('==> ', timeout=240) + print "oneway: %s " % (client.before) + + client.sendline('r') + client.expect('r') + + client.expect('==> ', timeout=240) + print "receive: %s" % (client.before) + client.sendline('e') + client.expect('e') + + client.expect('==> ', timeout=240) + print "echo: %s" % (client.before) + +def run(client, server): + print "testing bytes" + runseries(client) + + if not demoscript.Util.fast: + print "testing strings" + client.sendline('2') + runseries(client) + + print "testing structs with string... " + client.sendline('3') + runseries(client) + + print "testing structs with two ints and double... " + client.sendline('4') + runseries(client) + + client.sendline('s') + server.expect(pexpect.EOF) + assert server.wait() == 0 + + client.sendline('x') + client.expect(pexpect.EOF) + assert client.wait() == 0 diff --git a/demoscript/Ice/value.py b/demoscript/Ice/value.py new file mode 100755 index 00000000000..9abacc8b3e1 --- /dev/null +++ b/demoscript/Ice/value.py @@ -0,0 +1,48 @@ +#!/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 + +def run(client, server, ruby = False): + print "testing...", + sys.stdout.flush() + client.expect('press enter') + client.sendline('') + client.expect('==> a message 4 u.*press enter') + client.sendline('') + if not ruby: + client.expect('NoObjectFactoryException.*press enter') + client.sendline('') + client.expect('==> Ice rulez!.*press enter') + client.sendline('') + client.expect('==> !zelur ecI.*press enter') + client.sendline('') + client.expect('press enter') + server.expect('!zelur ecI') + client.sendline('') + if ruby: + client.expect('==> The type ID of the received object is "::Demo::DerivedPrinter".*press enter') + client.sendline('') + client.expect('==> undefined method') + client.sendline('') + else: + client.expect('==> The type ID of the received object is "::Demo::Printer".*press enter') + client.sendline('') + client.expect('==> The type ID of the received object is "::Demo::DerivedPrinter".*press enter') + client.sendline('') + client.expect('==> a derived message 4 u\r{1,2}\n==> A DERIVED MESSAGE 4 U.*press enter') + client.sendline('') + client.expect('==> a derived message 4 u\r{1,2}\n==> A DERIVED MESSAGE 4 U') + print "ok" + + server.expect(pexpect.EOF) + assert server.wait() == 0 + client.expect(pexpect.EOF) + assert client.wait() == 0 diff --git a/demoscript/IceBox/__init__.py b/demoscript/IceBox/__init__.py new file mode 100644 index 00000000000..74d403bf72e --- /dev/null +++ b/demoscript/IceBox/__init__.py @@ -0,0 +1,8 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** diff --git a/demoscript/IceBox/hello.py b/demoscript/IceBox/hello.py new file mode 100755 index 00000000000..b58d75ecbf1 --- /dev/null +++ b/demoscript/IceBox/hello.py @@ -0,0 +1,73 @@ +#!/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, demoscript + +def runtests(client, server, secure): + print "testing twoway", + sys.stdout.flush() + client.sendline('t') + server.expect('Hello World!') + print "oneway", + sys.stdout.flush() + client.sendline('o') + server.expect('Hello World!') + if not secure: + print "datagram", + sys.stdout.flush() + client.sendline('d') + server.expect('Hello World!') + print "... ok" + + print "testing batch oneway", + sys.stdout.flush() + client.sendline('O') + try: + server.expect('Hello World!', timeout=1) + except pexpect.TIMEOUT: + pass + client.sendline('O') + client.sendline('f') + server.expect('Hello World!') + server.expect('Hello World!') + if not secure: + print "datagram", + sys.stdout.flush() + client.sendline('D') + try: + server.expect('Hello World!', timeout=1) + except pexpect.TIMEOUT: + pass + client.sendline('D') + client.sendline('f') + server.expect('Hello World!') + server.expect('Hello World!') + print "... ok" + +def run(client, server): + runtests(client, server, False) + + print "repeating tests with SSL" + + client.sendline('S') + + runtests(client, server, True) + + client.sendline('x') + client.expect(pexpect.EOF) + assert client.wait() == 0 + + admin = demoscript.Util.spawn('iceboxadmin --IceBox.InstanceName=DemoIceBox --IceBox.ServiceManager.Endpoints="tcp -p 9998:ssl -p 9999" shutdown') + + admin.expect(pexpect.EOF) + assert admin.wait() == 0 + + server.expect(pexpect.EOF) + assert server.wait() == 0 diff --git a/demoscript/IceGrid/__init__.py b/demoscript/IceGrid/__init__.py new file mode 100644 index 00000000000..74d403bf72e --- /dev/null +++ b/demoscript/IceGrid/__init__.py @@ -0,0 +1,8 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** diff --git a/demoscript/IceGrid/allocate.py b/demoscript/IceGrid/allocate.py new file mode 100755 index 00000000000..25e08e20819 --- /dev/null +++ b/demoscript/IceGrid/allocate.py @@ -0,0 +1,140 @@ +#!/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, demoscript + +def run(clientCmd): + print "cleaning databases...", + sys.stdout.flush() + demoscript.Util.cleanDbDir("db/node") + demoscript.Util.cleanDbDir("db/registry") + print "ok" + + if demoscript.Util.defaultHost: + args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' + else: + args = '' + + print "starting icegridnode...", + sys.stdout.flush() + node = demoscript.Util.spawn('icegridnode --Ice.Config=config.grid --Ice.PrintAdapterReady %s' % (args)) + node.expect('IceGrid.Registry.Internal ready\r{1,2}\nIceGrid.Registry.Server ready\r{1,2}\nIceGrid.Registry.Client ready\r{1,2}\nIceGrid.Node ready') + print "ok" + + print "deploying application...", + sys.stdout.flush() + admin = demoscript.Util.spawn('icegridadmin --Ice.Config=config.grid') + admin.expect('>>>') + admin.sendline("application add \'application-single.xml\'") + admin.expect('>>>') + print "ok" + + print "testing client...", + sys.stdout.flush() + client1 = demoscript.Util.spawn(clientCmd) + client1.expect('user id:') + client1.sendline('foo') + client1.expect('password:') + client1.sendline('foo') + + client2 = demoscript.Util.spawn(clientCmd) + client2.expect('user id:') + client2.sendline('foo') + client2.expect('password:') + client2.sendline('foo') + + node.expect('activating server') + client1.expect('==>') + client2.expect(pexpect.TIMEOUT, timeout = 0) + + client1.sendline('t') + node.expect('says Hello World!') + client2.expect(pexpect.TIMEOUT, timeout = 0) + client1.sendline('x') + client1.expect(pexpect.EOF, timeout=1) + assert client1.wait() == 0 + + client2.expect('==>') + client2.sendline('t') + node.expect('says Hello World!') + client2.sendline('s') + node.expect('detected termination of server') + client2.sendline('x') + client2.expect(pexpect.EOF, timeout=1) + assert client2.wait() == 0 + print "ok" + + print "deploying multiple...", + sys.stdout.flush() + admin.sendline("application update \'application-multiple.xml\'") + admin.expect('>>>') + print "ok" + + print "testing client...", + sys.stdout.flush() + client1 = demoscript.Util.spawn(clientCmd) + client1.expect('user id:') + client1.sendline('foo') + client1.expect('password:') + client1.sendline('foo') + + client2 = demoscript.Util.spawn(clientCmd) + client2.expect('user id:') + client2.sendline('foo') + client2.expect('password:') + client2.sendline('foo') + + client3 = demoscript.Util.spawn(clientCmd) + client3.expect('user id:') + client3.sendline('foo') + client3.expect('password:') + client3.sendline('foo') + + node.expect('activating server') + client1.expect('==>') + client2.expect('==>') + client3.expect(pexpect.TIMEOUT, timeout = 0) + + client1.sendline('t') + node.expect('says Hello World!') + client2.sendline('t') + node.expect('says Hello World!') + client3.expect(pexpect.TIMEOUT, timeout = 0) + + client1.sendline('x') + client1.expect(pexpect.EOF, timeout=1) + assert client1.wait() == 0 + + client3.expect('==>') + client3.sendline('t') + node.expect('says Hello World!') + client2.sendline('t') + node.expect('says Hello World!') + + client2.sendline('s') + node.expect('detected termination of server') + client2.sendline('x') + client2.expect(pexpect.EOF, timeout=1) + assert client2.wait() == 0 + + client3.sendline('s') + node.expect('detected termination of server') + client3.sendline('x') + client3.expect(pexpect.EOF, timeout=1) + assert client3.wait() == 0 + + print "ok" + + admin.sendline('registry shutdown Master') + admin.sendline('exit') + admin.expect(pexpect.EOF) + assert admin.wait() == 0 + node.expect(pexpect.EOF) + assert node.wait() == 0 diff --git a/demoscript/IceGrid/sessionActivation.py b/demoscript/IceGrid/sessionActivation.py new file mode 100755 index 00000000000..d0d2609162b --- /dev/null +++ b/demoscript/IceGrid/sessionActivation.py @@ -0,0 +1,77 @@ +#!/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, demoscript + +def run(clientCmd): + print "cleaning databases...", + sys.stdout.flush() + demoscript.Util.cleanDbDir("db/node") + demoscript.Util.cleanDbDir("db/registry") + print "ok" + + if demoscript.Util.defaultHost: + args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' + else: + args = '' + + print "starting icegridnode...", + sys.stdout.flush() + node = demoscript.Util.spawn('icegridnode --Ice.Config=config.grid --Ice.PrintAdapterReady %s' % (args)) + node.expect('IceGrid.Registry.Internal ready\r{1,2}\nIceGrid.Registry.Server ready\r{1,2}\nIceGrid.Registry.Client ready\r{1,2}\nIceGrid.Node ready') + print "ok" + + print "deploying application...", + sys.stdout.flush() + admin = demoscript.Util.spawn('icegridadmin --Ice.Config=config.grid') + admin.expect('>>>') + admin.sendline("application add \'application.xml\'") + admin.expect('>>>') + print "ok" + + print "testing client...", + sys.stdout.flush() + + client = demoscript.Util.spawn(clientCmd) + client.expect('user id:') + client.sendline('foo') + client.expect('password:') + client.sendline('foo') + node.expect('activating server') + client.expect('==>') + client.sendline('t') + node.expect('says Hello World!') + client.sendline('x') + client.expect(pexpect.EOF, timeout=1) + assert client.wait() == 0 + node.expect('detected termination of server') + + client = demoscript.Util.spawn(clientCmd) + client.expect('user id:') + client.sendline('foo') + client.expect('password:') + client.sendline('foo') + node.expect('activating server') + client.expect('==>') + client.sendline('t') + node.expect('says Hello World!') + client.sendline('x') + client.expect(pexpect.EOF, timeout=1) + assert client.wait() == 0 + node.expect('detected termination of server') + + print "ok" + + admin.sendline('registry shutdown Master') + admin.sendline('exit') + admin.expect(pexpect.EOF) + assert admin.wait() == 0 + node.expect(pexpect.EOF) + assert node.wait() == 0 diff --git a/demoscript/IceGrid/simple.py b/demoscript/IceGrid/simple.py new file mode 100755 index 00000000000..c40b38385b7 --- /dev/null +++ b/demoscript/IceGrid/simple.py @@ -0,0 +1,129 @@ +#!/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, demoscript + +def run(clientStr): + print "cleaning databases...", + sys.stdout.flush() + demoscript.Util.cleanDbDir("db/node") + demoscript.Util.cleanDbDir("db/registry") + print "ok" + + if demoscript.Util.defaultHost: + args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' + else: + args = '' + + print "starting icegridnode...", + sys.stdout.flush() + node = demoscript.Util.spawn('icegridnode --Ice.Config=config.grid --Ice.PrintAdapterReady %s' % (args)) + node.expect('IceGrid.Registry.Internal ready\r{1,2}\nIceGrid.Registry.Server ready\r{1,2}\nIceGrid.Registry.Client ready\r{1,2}\nIceGrid.Node ready') + print "ok" + + print "deploying application...", + sys.stdout.flush() + admin = demoscript.Util.spawn('icegridadmin --Ice.Config=config.grid') + admin.expect('>>>') + admin.sendline("application add \'application.xml\'") + admin.expect('>>>') + print "ok" + + print "testing client...", + sys.stdout.flush() + client = demoscript.Util.spawn(clientStr) + client.expect('==>') + client.sendline('t') + node.expect("SimpleServer says Hello World!") + client.sendline('t') + node.expect("SimpleServer says Hello World!") + client.sendline('s') + node.expect("detected termination of.*SimpleServer") + client.sendline('x') + + client.expect(pexpect.EOF, timeout=1) + assert client.wait() == 0 + print "ok" + + print "deploying template...", + sys.stdout.flush() + admin.sendline("application update \'application_with_template.xml\'") + admin.expect('>>>') + print "ok" + + print "testing client...", + sys.stdout.flush() + client = demoscript.Util.spawn(clientStr) + client.expect('==>') + client.sendline('t') + node.expect("SimpleServer-[123] says Hello World!") + client.sendline('t') + node.expect("SimpleServer-[123] says Hello World!") + client.sendline('s') + node.expect("detected termination of.*SimpleServer-[123]") + client.sendline('x') + + client.expect(pexpect.EOF, timeout=1) + assert client.wait() == 0 + print "ok" + + print "deploying replicated version...", + sys.stdout.flush() + admin.sendline("application update \'application_with_replication.xml\'") + admin.expect('>>> ') + print "ok" + + print "testing client...", + sys.stdout.flush() + + client = demoscript.Util.spawn(clientStr + ' --Ice.Default.Host=127.0.0.1') + client.expect('==>') + client.sendline('t') + node.expect("SimpleServer-1 says Hello World!") + client.sendline('t') + node.expect("SimpleServer-1 says Hello World!") + client.sendline('s') + node.expect("detected termination of.*SimpleServer-1") + client.sendline('x') + client.expect(pexpect.EOF, timeout=1) + assert client.wait() == 0 + + client = demoscript.Util.spawn(clientStr + ' --Ice.Default.Host=127.0.0.1') + client.expect('==>') + client.sendline('t') + node.expect("SimpleServer-2 says Hello World!") + client.sendline('t') + node.expect("SimpleServer-2 says Hello World!") + client.sendline('s') + node.expect("detected termination of.*SimpleServer-2") + client.sendline('x') + client.expect(pexpect.EOF, timeout=1) + assert client.wait() == 0 + + client = demoscript.Util.spawn(clientStr + ' --Ice.Default.Host=127.0.0.1') + client.expect('==>') + client.sendline('t') + node.expect("SimpleServer-3 says Hello World!") + client.sendline('t') + node.expect("SimpleServer-3 says Hello World!") + client.sendline('s') + node.expect("detected termination of.*SimpleServer-3") + client.sendline('x') + client.expect(pexpect.EOF, timeout=1) + assert client.wait() == 0 + + print "ok" + + admin.sendline('registry shutdown Master') + admin.sendline('exit') + admin.expect(pexpect.EOF) + assert admin.wait() == 0 + node.expect(pexpect.EOF) + assert node.wait() == 0 diff --git a/demoscript/IceStorm/__init__.py b/demoscript/IceStorm/__init__.py new file mode 100644 index 00000000000..74d403bf72e --- /dev/null +++ b/demoscript/IceStorm/__init__.py @@ -0,0 +1,8 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** diff --git a/demoscript/IceStorm/clock.py b/demoscript/IceStorm/clock.py new file mode 100755 index 00000000000..e941fad7647 --- /dev/null +++ b/demoscript/IceStorm/clock.py @@ -0,0 +1,69 @@ +#!/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, time, signal, demoscript + +def runtest(icestorm, subCmd, subargs, pubCmd, pubargs): + print "testing pub%s/sub%s..." % (pubargs, subargs), + sys.stdout.flush() + sub = demoscript.Util.spawn('%s --Ice.PrintAdapterReady %s' %(subCmd, subargs)) + sub.expect('.* ready') + + icestorm.expect('Subscribe:') + + pub = demoscript.Util.spawn('%s %s' %(pubCmd, pubargs)) + + pub.expect('publishing tick events') + time.sleep(3) + sub.expect('[0-9][0-9]/[0-9][0-9].*\r{1,2}\n[0-9][0-9]/[0-9][0-9]') + + pub.kill(signal.SIGINT) + pub.expect(pexpect.EOF) + status = pub.wait() + assert status == 0 or status == 130 or pub.signalstatus == signal.SIGINT + + sub.kill(signal.SIGINT) + sub.expect(pexpect.EOF) + status = sub.wait() + assert status == 0 or status == 130 or sub.signalstatus == signal.SIGINT + try: + icestorm.expect('Unsubscribe:') + except pexpect.TIMEOUT: + print "(Wait for Unsubscribe failed, expected for Mono)", + print "ok" + +def run(subCmd, pubCmd): + print "cleaning databases...", + sys.stdout.flush() + demoscript.Util.cleanDbDir("db") + print "ok" + + if demoscript.Util.defaultHost: + args = ' --IceBox.UseSharedCommunicator.IceStorm=1' + else: + args = '' + + icestorm = demoscript.Util.spawn('%s --Ice.Config=config.icebox --Ice.PrintAdapterReady %s' % (demoscript.Util.getIceBox(), args)) + icestorm.expect('.* ready') + + runtest(icestorm, subCmd, "", pubCmd, "") + + subargs = [" --oneway", " --twoway", " --datagram", " --twoway", " --ordered", " --batch"] + for s in subargs: + runtest(icestorm, subCmd, s, pubCmd, "") + pubargs = [" --oneway", " --datagram", " --twoway" ] + for s in pubargs: + runtest(icestorm, subCmd, "", pubCmd, s) + + admin = demoscript.Util.spawn('iceboxadmin --Ice.Config=config.icebox shutdown') + admin.expect(pexpect.EOF) + assert admin.wait() == 0 + icestorm.expect(pexpect.EOF) + assert icestorm.wait() == 0 diff --git a/demoscript/Util.py b/demoscript/Util.py new file mode 100644 index 00000000000..85e14b4cd98 --- /dev/null +++ b/demoscript/Util.py @@ -0,0 +1,123 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** + +# +# Timeout after the initial spawn. +# +initialTimeout = 10 +# +# Default timeout on subsequent expect calls. +# +defaultTimeout = 5 + +# +# Default value of --Ice.Default.Host +# +host = "127.0.0.1" + +# +# Echo the commands. +# +debug = False + +import sys, getopt, pexpect, os + +def usage(): + print "usage: " + sys.argv[0] + " --fast --trace --debug --host host --mode=[debug|release]" + sys.exit(2) +try: + opts, args = getopt.getopt(sys.argv[1:], "", ["fast", "trace", "debug", "host=", "mode="]) +except getopt.GetoptError: + usage() + +fast = False +trace = False +mode = 'release' +for o, a in opts: + if o == "--debug": + debug = True + if o == "--trace": + trace = True + if o == "--host": + host = a + if o == "--fast": + 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 host != "": + defaultHost = " --Ice.Default.Host=%s" % (host) +else: + defaultHost = None + +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 isDarwin(): + return sys.platform == "darwin" + +def mono(): + if isWin32(): + return "" + else: + return "mono " + +def getIceBox(): + if isWin32(): + if mode == 'release': + return "icebox" + else: + return "iceboxd" + return "icebox" + +# Automatically adds default host, and uses our default timeout for +# expect. +class spawn(pexpect.spawn): + def __init__(self, command): + if defaultHost: + command = '%s %s' % (command, defaultHost) + if debug: + print '(%s)' % (command) + self.expectFirst = True + if trace: + logfile = sys.stdout + else: + logfile = None + 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 cleanDbDir(path): + for filename in [ os.path.join(path, f) for f in os.listdir(path) if f != ".gitignore"]: + if os.path.isdir(filename): + cleanDbDir(filename) + try: + os.rmdir(filename) + except OSError: + # This might fail if the directory is empty (because + # it itself contains a .gitignore file. + pass + else: + os.remove(filename) diff --git a/demoscript/__init__.py b/demoscript/__init__.py new file mode 100644 index 00000000000..74d403bf72e --- /dev/null +++ b/demoscript/__init__.py @@ -0,0 +1,8 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** diff --git a/demoscript/book/__init__.py b/demoscript/book/__init__.py new file mode 100644 index 00000000000..74d403bf72e --- /dev/null +++ b/demoscript/book/__init__.py @@ -0,0 +1,8 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** diff --git a/demoscript/book/freeze_filesystem.py b/demoscript/book/freeze_filesystem.py new file mode 100755 index 00000000000..131e5b557aa --- /dev/null +++ b/demoscript/book/freeze_filesystem.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 + +def run(client, server): + print "testing...", + sys.stdout.flush() + client.expect('Created README') + server.expect('added') + client.expect('Contents of filesystem:') + server.expect('locate') + client.expect('Contents of file') + server.expect('locate') + client.expect('Down to a sunless sea') + server.expect('locate') + i = client.expect(['Destroying Coleridge', 'Destroying README']) + server.expect('removed object') + j = client.expect(['Destroying Coleridge', 'Destroying README']) + assert i != j + server.expect('removed object') + client.expect(pexpect.EOF) + assert client.wait() == 0 + print "ok" diff --git a/demoscript/book/lifecycle.py b/demoscript/book/lifecycle.py new file mode 100755 index 00000000000..97baf28396f --- /dev/null +++ b/demoscript/book/lifecycle.py @@ -0,0 +1,167 @@ +#!/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 + +def run(client, server): + print "testing...", + sys.stdout.flush() + client.expect('>') + client.sendline('pwd') + client.expect('pwd') + client.expect('/\r{1,2}\n>') + + client.sendline('cd x') + client.expect('cd x') + client.expect('`x\': no such directory') + client.expect('\r{1,2}\n>') + + client.sendline('cd') + client.expect('cd') + client.expect('\r{1,2}\n>') + + client.sendline('pwd') + client.expect('pwd') + client.expect('/\r{1,2}\n>') + + client.sendline('mkfile a') + client.expect('mkfile a') + client.expect('\r{1,2}\n>') + + client.sendline('cd a') + client.expect('cd a') + client.expect('`a\': not a directory') + client.expect('\r{1,2}\n>') + + client.sendline('mkdir a') + client.expect('mkdir a') + client.expect('`a\' exists already') + client.expect('\r{1,2}\n>') + + client.sendline('mkdir b') + client.expect('mkdir b') + client.expect('\r{1,2}\n>') + + client.sendline('cd b') + client.expect('cd b') + client.expect('\r{1,2}\n>') + + client.sendline('pwd') + client.expect('pwd') + client.expect('/b\r{1,2}\n>') + + client.sendline('cd') + client.expect('cd') + client.expect('\r{1,2}\n>') + + client.sendline('pwd') + client.expect('pwd') + client.expect('/\r{1,2}\n>') + + client.sendline('cd b') + client.expect('cd b') + client.expect('\r{1,2}\n>') + + client.sendline('pwd') + client.expect('pwd') + client.expect('/b\r{1,2}\n>') + + client.sendline('cd /') + client.expect('cd /') + client.expect('\r{1,2}\n>') + + client.sendline('pwd') + client.expect('pwd') + client.expect('/\r{1,2}\n>') + + client.sendline('ls') + client.expect('ls\r{1,2}\n') + i = client.expect(['a \(file\)', 'b \(directory\)']) + j = client.expect(['a \(file\)', 'b \(directory\)']) + assert i != j + client.expect('\r{1,2}\n>') + + client.sendline('lr') + client.expect('lr\r{1,2}\n') + i = client.expect(['a \(file\)', 'b \(directory\)']) + j = client.expect(['a \(file\)', 'b \(directory\)']) + assert i != j + client.expect('\r{1,2}\n>') + + client.sendline('cd b') + client.expect('cd b\r{1,2}\n>') + + client.sendline('mkdir c') + client.expect('mkdir c\r{1,2}\n>') + + client.sendline('cd c') + client.expect('cd c\r{1,2}\n>') + + client.sendline('pwd') + client.expect('pwd') + client.expect('/b/c\r{1,2}\n>') + + client.sendline('cd /') + client.expect('cd /\r{1,2}\n>') + + client.sendline('lr') + client.expect('lr\r{1,2}\n') + i = client.expect(['a \(file\)', 'b \(directory\)']) + if i == 1: + client.expect('c \(directory\):') + client.expect('a \(file\)') + else: + client.expect('b \(directory\)') + client.expect('\tc \(directory\):') + + client.sendline('mkfile c') + client.expect('mkfile c\r{1,2}\n>') + + client.sendline('write c blah c') + client.expect('write c blah c\r{1,2}\n>') + + client.sendline('cat c') + client.expect('cat c\r{1,2}\n') + client.expect('blah\r{1,2}\n') + client.expect('c') + client.expect('\r{1,2}\n>') + + client.sendline('rm b') + client.expect('rm b\r{1,2}\n') + client.expect('cannot remove `b\': Cannot destroy non-empty directory') + client.expect('\r{1,2}\n>') + + client.sendline('cd b') + client.expect('cd b') + client.expect('\r{1,2}\n>') + + client.sendline('rm *') + client.expect('rm \*') + client.expect('\r{1,2}\n>') + + client.sendline('ls') + client.expect('ls\r{1,2}\n>') + + client.sendline('cd ..') + client.expect('cd \.\.\r{1,2}\n>') + + client.sendline('rm b') + client.expect('rm b\r{1,2}\n>') + + client.sendline('rm a c') + client.expect('rm a c\r{1,2}\n>') + + client.sendline('ls') + client.expect('ls\r{1,2}\n>') + + client.sendline('exit') + client.expect(pexpect.EOF) + assert client.wait() == 0 + print "ok" diff --git a/java/allDemos.py b/java/allDemos.py new file mode 100755 index 00000000000..c00db1f5ec7 --- /dev/null +++ b/java/allDemos.py @@ -0,0 +1,136 @@ +#!/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/invoke", + "Ice/latency", + "Ice/minimal", + "Ice/nested", + "Ice/session", + "Ice/throughput", + "Ice/value", + "IceBox/hello", + "IceStorm/clock", + "IceGrid/simple", + "Glacier2/callback", + "Freeze/bench", + "Freeze/phonebook", + "Freeze/library", + "book/freeze_filesystem", + "book/simple_filesystem", + "book/printer", + "book/lifecycle", + ] + +# +# 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/java/demo/Freeze/bench/Client.java b/java/demo/Freeze/bench/Client.java index b068da7e429..241094c10d5 100644 --- a/java/demo/Freeze/bench/Client.java +++ b/java/demo/Freeze/bench/Client.java @@ -565,15 +565,14 @@ class TestApp extends Ice.Application System.out.println("Struct1Class1Map with index"); Struct1Class1MapTest(new IndexedStruct1Class1Map(_connection, "IndexedStruct1Class1", true)); + System.out.println("Struct1ObjectMap"); + Struct1ObjectMapTest(new Struct1ObjectMap(_connection, "Struct1Object", true)); + System.out.println("IntIntMap (read test)"); IntIntMapReadTest(new IntIntMap(_connection, "IntIntMap", true)); - System.out.println("IntIntMap (read test with index)"); + System.out.println("IntIntMap with index (read test)"); IntIntMapReadTest(new IndexedIntIntMap(_connection, "IndexedIntIntMap", true)); - - - System.out.println("Struct1ObjectMap"); - Struct1ObjectMapTest(new Struct1ObjectMap(_connection, "Struct1Object", true)); _connection.close(); diff --git a/java/demo/Freeze/bench/expect.py b/java/demo/Freeze/bench/expect.py new file mode 100755 index 00000000000..62fc63560bd --- /dev/null +++ b/java/demo/Freeze/bench/expect.py @@ -0,0 +1,34 @@ +#!/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.Freeze.bench + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +client = demoscript.Util.spawn('java Client') +demoscript.Freeze.bench.run(client, True) diff --git a/java/demo/Freeze/library/expect.py b/java/demo/Freeze/library/expect.py new file mode 100755 index 00000000000..5d2857ed36f --- /dev/null +++ b/java/demo/Freeze/library/expect.py @@ -0,0 +1,59 @@ +#!/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.Freeze.library + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('java Server --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') +client.expect('>>> ') + +demoscript.Freeze.library.run(client, server) + +client.sendline('shutdown') +server.expect(pexpect.EOF) + +client.sendline('exit') +client.expect(pexpect.EOF) + +print "running with collocated server" + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('java Collocated --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') +server.expect('>>> ') + +demoscript.Freeze.library.run(server, server) + +server.sendline('exit') +server.expect(pexpect.EOF) diff --git a/java/demo/Freeze/phonebook/expect.py b/java/demo/Freeze/phonebook/expect.py new file mode 100755 index 00000000000..24478230ef2 --- /dev/null +++ b/java/demo/Freeze/phonebook/expect.py @@ -0,0 +1,59 @@ +#!/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.Freeze.phonebook + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('java Server --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') +client.expect('>>> ') + +demoscript.Freeze.phonebook.run(client, server) + +client.sendline('shutdown') +server.expect(pexpect.EOF) + +client.sendline('exit') +client.expect(pexpect.EOF) + +print "running with collocated server" + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('java Collocated --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') +server.expect('>>> ') + +demoscript.Freeze.phonebook.run(server, server) + +server.sendline('exit') +server.expect(pexpect.EOF) diff --git a/java/demo/Glacier2/callback/CallbackI.java b/java/demo/Glacier2/callback/CallbackI.java index 5165a6e7431..1d9d9ebaffc 100644 --- a/java/demo/Glacier2/callback/CallbackI.java +++ b/java/demo/Glacier2/callback/CallbackI.java @@ -14,7 +14,7 @@ public final class CallbackI extends _CallbackDisp public void initiateCallback(CallbackReceiverPrx proxy, Ice.Current current) { - System.out.println("initiating callback"); + System.out.println("initiating callback to: " + current.adapter.getCommunicator().proxyToString(proxy)); try { proxy.callback(current.ctx); diff --git a/java/demo/Glacier2/callback/expect.py b/java/demo/Glacier2/callback/expect.py new file mode 100755 index 00000000000..9dbce11fd23 --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +sessionserver = demoscript.Util.spawn('java SessionServer --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('java Client') + +demoscript.Glacier2.callback.run(client, server, sessionserver, glacier2) diff --git a/java/demo/Ice/async/Client.java b/java/demo/Ice/async/Client.java index a5a0a513120..4d2a8c37027 100644 --- a/java/demo/Ice/async/Client.java +++ b/java/demo/Ice/async/Client.java @@ -43,7 +43,7 @@ public class Client extends Ice.Application { if(ex instanceof Demo.RequestCanceledException) { - System.out.println("Request canceled"); + System.out.println("Demo.RequestCanceledException"); } else { diff --git a/java/demo/Ice/async/WorkQueue.java b/java/demo/Ice/async/WorkQueue.java index cbe528e77d8..bc18061058a 100644 --- a/java/demo/Ice/async/WorkQueue.java +++ b/java/demo/Ice/async/WorkQueue.java @@ -68,15 +68,12 @@ public class WorkQueue extends Thread // // Throw exception for any outstanding requests. // - - /* java.util.Iterator p = _callbacks.iterator(); while(p.hasNext()) { CallbackEntry entry = (CallbackEntry)p.next(); entry.cb.ice_exception(new RequestCanceledException()); } - */ } public synchronized void diff --git a/java/demo/Ice/async/expect.py b/java/demo/Ice/async/expect.py new file mode 100755 index 00000000000..d73e4621e13 --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') +client.expect('.*==>') + +demoscript.Ice.async.run(client, server) diff --git a/java/demo/Ice/bidir/expect.py b/java/demo/Ice/bidir/expect.py new file mode 100755 index 00000000000..ff01bfe35ee --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') + +demoscript.Ice.bidir.run('java Client', server) diff --git a/java/demo/Ice/callback/expect.py b/java/demo/Ice/callback/expect.py new file mode 100755 index 00000000000..14f081015a9 --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') +client.expect('.*==>') + +demoscript.Ice.callback.run(client, server) diff --git a/java/demo/Ice/hello/expect.py b/java/demo/Ice/hello/expect.py new file mode 100755 index 00000000000..93456cdb1e3 --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') +client.expect('.*==>') + +demoscript.Ice.hello.run(client, server) diff --git a/java/demo/Ice/invoke/expect.py b/java/demo/Ice/invoke/expect.py new file mode 100755 index 00000000000..ffc15fca24b --- /dev/null +++ b/java/demo/Ice/invoke/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.invoke + +server = demoscript.Util.spawn('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') +client.expect('.*==>') + +demoscript.Ice.invoke.run(client, server) diff --git a/java/demo/Ice/latency/expect.py b/java/demo/Ice/latency/expect.py new file mode 100755 index 00000000000..ad2238080b5 --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing ping... ", +sys.stdout.flush() +client = demoscript.Util.spawn('java Client') +client.expect(pexpect.EOF, timeout=100) +print "ok" + +print client.before diff --git a/java/demo/Ice/minimal/expect.py b/java/demo/Ice/minimal/expect.py new file mode 100755 index 00000000000..4c8b8587e1c --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('java Client') +client.expect(pexpect.EOF) +server.expect('Hello World!') +print "ok" diff --git a/java/demo/Ice/nested/expect.py b/java/demo/Ice/nested/expect.py new file mode 100755 index 00000000000..aa22978a03d --- /dev/null +++ b/java/demo/Ice/nested/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.nested + +server = demoscript.Util.spawn('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client --Ice.Override.Timeout=2000') +client.expect('.*for exit:') + +demoscript.Ice.nested.run(client, server) diff --git a/java/demo/Ice/session/expect.py b/java/demo/Ice/session/expect.py new file mode 100755 index 00000000000..4dc9fb4ad8f --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') + +demoscript.Ice.session.run('java Client', server) diff --git a/java/demo/Ice/throughput/expect.py b/java/demo/Ice/throughput/expect.py new file mode 100755 index 00000000000..93080e49963 --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') + +demoscript.Ice.throughput.run(client, server) diff --git a/java/demo/Ice/value/Client.java b/java/demo/Ice/value/Client.java index 831e424ebfa..f677b16e737 100644 --- a/java/demo/Ice/value/Client.java +++ b/java/demo/Ice/value/Client.java @@ -130,7 +130,7 @@ public class Client extends Ice.Application readline(in); Printer derivedAsBase = initial.getDerivedPrinter(); - System.out.println("The type ID of the received object is \"" + derivedAsBase.ice_id() + "\""); + System.out.println("==> The type ID of the received object is \"" + derivedAsBase.ice_id() + "\""); assert(derivedAsBase.ice_id().equals("::Demo::Printer")); System.out.println(); @@ -146,7 +146,7 @@ public class Client extends Ice.Application DerivedPrinter derived = (Demo.DerivedPrinter)derivedAsBase; System.out.println("==> class cast to derived object succeded"); - System.out.println("The type ID of the received object is \"" + derived.ice_id() + "\""); + System.out.println("==> The type ID of the received object is \"" + derived.ice_id() + "\""); System.out.println(); System.out.println("Let's print the message contained in the derived object, and"); diff --git a/java/demo/Ice/value/expect.py b/java/demo/Ice/value/expect.py new file mode 100755 index 00000000000..08e704db4a9 --- /dev/null +++ b/java/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') + +demoscript.Ice.value.run(client, server) diff --git a/java/demo/IceBox/hello/expect.py b/java/demo/IceBox/hello/expect.py new file mode 100755 index 00000000000..e2956143bb3 --- /dev/null +++ b/java/demo/IceBox/hello/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.IceBox.hello + +if demoscript.Util.defaultHost: + args = ' --IceBox.UseSharedCommunicator.IceStorm=1' +else: + args = '' + +# TODO: This doesn't setup LD_LIBRARY_PATH +server = demoscript.Util.spawn('java IceBox.Server --Ice.Config=config.icebox --Ice.PrintAdapterReady %s' % (args)) +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') +client.expect('.*==>') + +demoscript.IceBox.hello.run(client, server) diff --git a/java/demo/IceGrid/simple/expect.py b/java/demo/IceGrid/simple/expect.py new file mode 100755 index 00000000000..636803a397f --- /dev/null +++ b/java/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('java Client') diff --git a/java/demo/IceStorm/clock/expect.py b/java/demo/IceStorm/clock/expect.py new file mode 100755 index 00000000000..811a29a10c5 --- /dev/null +++ b/java/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('java Subscriber', 'java Publisher') diff --git a/java/demo/book/build.xml b/java/demo/book/build.xml index a0528b779af..9fcf488fa84 100644 --- a/java/demo/book/build.xml +++ b/java/demo/book/build.xml @@ -15,6 +15,7 @@ <ant dir="printer"/> <ant dir="simple_filesystem"/> <ant dir="freeze_filesystem"/> + <ant dir="lifecycle"/> </target> <target name="clean"> @@ -22,6 +23,7 @@ <ant dir="simple_filesystem" target="clean"/> <ant dir="lifecycle" target="clean"/> <ant dir="freeze_filesystem" target="clean"/> + <ant dir="lifecycle" target="clean"/> </target> </project> diff --git a/java/demo/book/freeze_filesystem/expect.py b/java/demo/book/freeze_filesystem/expect.py new file mode 100755 index 00000000000..f9b89181272 --- /dev/null +++ b/java/demo/book/freeze_filesystem/expect.py @@ -0,0 +1,37 @@ +#!/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.book.freeze_filesystem + +print "cleaning databases...", +sys.stdout.flush() +demoscript.Util.cleanDbDir("db") +print "ok" + +server = demoscript.Util.spawn('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') + +demoscript.book.freeze_filesystem.run(client, server) diff --git a/java/demo/book/lifecycle/expect.py b/java/demo/book/lifecycle/expect.py new file mode 100755 index 00000000000..8b925342444 --- /dev/null +++ b/java/demo/book/lifecycle/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.book.lifecycle + +server = demoscript.Util.spawn('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') +client = demoscript.Util.spawn('java Client') + +demoscript.book.lifecycle.run(client, server) diff --git a/java/demo/book/printer/expect.py b/java/demo/book/printer/expect.py new file mode 100755 index 00000000000..4c8b8587e1c --- /dev/null +++ b/java/demo/book/printer/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('java Client') +client.expect(pexpect.EOF) +server.expect('Hello World!') +print "ok" diff --git a/java/demo/book/simple_filesystem/expect.py b/java/demo/book/simple_filesystem/expect.py new file mode 100755 index 00000000000..6d50ebcc6d0 --- /dev/null +++ b/java/demo/book/simple_filesystem/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('java Server --Ice.PrintAdapterReady') +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('java Client') +client.expect('Contents of root directory:\r{1,2}\n.*Down to a sunless sea.') +client.expect(pexpect.EOF) +print "ok" 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') diff --git a/rb/allDemos.py b/rb/allDemos.py new file mode 100755 index 00000000000..1aa0d5529ef --- /dev/null +++ b/rb/allDemos.py @@ -0,0 +1,122 @@ +#!/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/hello", + "Ice/latency", + "Ice/minimal", + "Ice/session", + "Ice/throughput", + "Ice/value", + "book/printer", + "book/simple_filesystem", + ] + +# +# 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/rb/demo/Ice/hello/expect.py b/rb/demo/Ice/hello/expect.py new file mode 100755 index 00000000000..376f9174d4d --- /dev/null +++ b/rb/demo/Ice/hello/expect.py @@ -0,0 +1,45 @@ +#!/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 + +if os.path.exists("../../../../cpp"): + iceHome = "../../../../cpp" +elif os.path.exists("../../../demo"): + iceHome = "../../../" +else: + print "Cannot find C++ demos" + sys.exit(1) + +import demoscript.Util +import demoscript.Ice.hello + +cwd = os.getcwd() +os.chdir('%s/demo/Ice/hello' % (iceHome)) +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +os.chdir(cwd) + +client = demoscript.Util.spawn('ruby Client.rb') +client.expect('.*==>') + +demoscript.Ice.hello.run(client, server) diff --git a/rb/demo/Ice/latency/expect.py b/rb/demo/Ice/latency/expect.py new file mode 100755 index 00000000000..aef1f7bc49b --- /dev/null +++ b/rb/demo/Ice/latency/expect.py @@ -0,0 +1,47 @@ +#!/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 + +if os.path.exists("../../../../cpp"): + iceHome = "../../../../cpp" +elif os.path.exists("../../../demo"): + iceHome = "../../../" +else: + print "Cannot find C++ demos" + sys.exit(1) + +import demoscript.Util + +cwd = os.getcwd() +os.chdir('%s/demo/Ice/latency' % (iceHome)) +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +os.chdir(cwd) + +print "testing ping... ", +sys.stdout.flush() +client = demoscript.Util.spawn('ruby Client.rb') +client.expect(pexpect.EOF, timeout=100) +print "ok" + +print client.before diff --git a/rb/demo/Ice/minimal/expect.py b/rb/demo/Ice/minimal/expect.py new file mode 100755 index 00000000000..e5eab79a826 --- /dev/null +++ b/rb/demo/Ice/minimal/expect.py @@ -0,0 +1,46 @@ +#!/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 + +if os.path.exists("../../../../cpp"): + iceHome = "../../../../cpp" +elif os.path.exists("../../../demo"): + iceHome = "../../../" +else: + print "Cannot find C++ demos" + sys.exit(1) + +import demoscript.Util + +cwd = os.getcwd() +os.chdir('%s/demo/Ice/minimal' % (iceHome)) +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +os.chdir(cwd) + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('ruby Client.rb') +client.expect(pexpect.EOF) +server.expect('Hello World!') +print "ok" diff --git a/rb/demo/Ice/session/expect.py b/rb/demo/Ice/session/expect.py new file mode 100755 index 00000000000..875566184c2 --- /dev/null +++ b/rb/demo/Ice/session/expect.py @@ -0,0 +1,42 @@ +#!/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 + +if os.path.exists("../../../../cpp"): + iceHome = "../../../../cpp" +elif os.path.exists("../../../demo"): + iceHome = "../../../" +else: + print "Cannot find C++ demos" + sys.exit(1) + +import demoscript.Util +import demoscript.Ice.session + +cwd = os.getcwd() +os.chdir('%s/demo/Ice/session' % (iceHome)) +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +os.chdir(cwd) + +demoscript.Ice.session.run('ruby Client.rb', server) diff --git a/rb/demo/Ice/throughput/expect.py b/rb/demo/Ice/throughput/expect.py new file mode 100755 index 00000000000..26bfa905f32 --- /dev/null +++ b/rb/demo/Ice/throughput/expect.py @@ -0,0 +1,44 @@ +#!/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 + +if os.path.exists("../../../../cpp"): + iceHome = "../../../../cpp" +elif os.path.exists("../../../demo"): + iceHome = "../../../" +else: + print "Cannot find C++ demos" + sys.exit(1) + +import demoscript.Util +import demoscript.Ice.throughput + +cwd = os.getcwd() +os.chdir('%s/demo/Ice/throughput' % (iceHome)) +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +os.chdir(cwd) + +client = demoscript.Util.spawn('ruby Client.rb') + +demoscript.Ice.throughput.run(client, server) diff --git a/rb/demo/Ice/value/expect.py b/rb/demo/Ice/value/expect.py new file mode 100755 index 00000000000..e7b42628cd8 --- /dev/null +++ b/rb/demo/Ice/value/expect.py @@ -0,0 +1,44 @@ +#!/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 + +if os.path.exists("../../../../cpp"): + iceHome = "../../../../cpp" +elif os.path.exists("../../../demo"): + iceHome = "../../../" +else: + print "Cannot find C++ demos" + sys.exit(1) + +import demoscript.Util +import demoscript.Ice.value + +cwd = os.getcwd() +os.chdir('%s/demo/Ice/value' % (iceHome)) +server = demoscript.Util.spawn('./server --Ice.PrintAdapterReady') +server.expect('.* ready') +os.chdir(cwd) + +client = demoscript.Util.spawn('ruby Client.rb') + +demoscript.Ice.value.run(client, server, ruby=True) diff --git a/rb/demo/book/printer/expect.py b/rb/demo/book/printer/expect.py new file mode 100755 index 00000000000..0376b379b33 --- /dev/null +++ b/rb/demo/book/printer/expect.py @@ -0,0 +1,43 @@ +#!/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 + +if os.path.exists("../../../../cpp"): + iceHome = "../../../../cpp" +elif os.path.exists("../../../demo"): + iceHome = "../../../" +else: + print "Cannot find C++ demos" + sys.exit(1) + +import demoscript.Util + +server = demoscript.Util.spawn('%s/demo/book/printer/server --Ice.PrintAdapterReady' % (iceHome)) +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('ruby Client.rb') +client.expect(pexpect.EOF) +server.expect('Hello World!') +print "ok" diff --git a/rb/demo/book/simple_filesystem/expect.py b/rb/demo/book/simple_filesystem/expect.py new file mode 100755 index 00000000000..559d65ddbf1 --- /dev/null +++ b/rb/demo/book/simple_filesystem/expect.py @@ -0,0 +1,43 @@ +#!/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 + +if os.path.exists("../../../../cpp"): + iceHome = "../../../../cpp" +elif os.path.exists("../../../demo"): + iceHome = "../../../" +else: + print "Cannot find C++ demos" + sys.exit(1) + +import demoscript.Util + +server = demoscript.Util.spawn('%s/demo/book/simple_filesystem/server --Ice.PrintAdapterReady' % (iceHome)) +server.expect('.* ready') + +print "testing...", +sys.stdout.flush() +client = demoscript.Util.spawn('ruby Client.rb') +client.expect('Contents of root directory:\r{1,2}\n.*Down to a sunless sea.') +client.expect(pexpect.EOF) +print "ok" |