diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-08-15 13:59:55 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-08-15 13:59:55 -0230 |
commit | 1d265d0027c43825a0dd9567589758713a27452c (patch) | |
tree | 207e11aba123ed504311ba5b988b79d151852704 /cpp | |
parent | Added missing file (diff) | |
download | ice-1d265d0027c43825a0dd9567589758713a27452c.tar.bz2 ice-1d265d0027c43825a0dd9567589758713a27452c.tar.xz ice-1d265d0027c43825a0dd9567589758713a27452c.zip |
Added expect scripts
Diffstat (limited to 'cpp')
34 files changed, 1652 insertions, 1 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 |