summaryrefslogtreecommitdiff
path: root/demoscript/IceStorm/clock.py
blob: 5633a98daf1a406a46e5a8ad11b8cc8e24c789e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2010 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 sys, time, signal
from demoscript import *
from scripts import Expect

def runtest(icestorm, subCmd, subargs, pubCmd, pubargs):
    print "testing pub%s/sub%s..." % (pubargs, subargs),
    sys.stdout.flush()
    sub = Util.spawn('%s --Ice.PrintAdapterReady %s' %(subCmd, subargs))
    sub.expect('.* ready')

    icestorm.expect('subscribeAndGetPublisher:')

    pub = Util.spawn('%s %s' %(pubCmd, pubargs))

    pub.expect('publishing tick events')
    time.sleep(3)
    sub.expect('[0-9][0-9]/[0-9][0-9].*\n[0-9][0-9]/[0-9][0-9]')

    pub.kill(signal.SIGINT)
    pub.waitTestSuccess()

    sub.kill(signal.SIGINT)
    sub.waitTestSuccess()

    if sub.hasInterruptSupport():
        icestorm.expect('unsubscribe:')
    print "ok"

def run(subCmd, pubCmd):
    print "cleaning databases...",
    sys.stdout.flush()
    Util.cleanDbDir("db")
    print "ok"

    if Util.defaultHost:
        args = ' --IceBox.Service.IceStorm="IceStormService,34:createIceStorm --Ice.Config=config.service %s"' % Util.defaultHost
    else:
        args = ''

    icestorm = Util.spawn('%s --Ice.Config=config.icebox --Ice.PrintAdapterReady %s' % (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 = Util.spawn(Util.getIceBoxAdmin() + ' --Ice.Config=config.icebox shutdown')
    admin.waitTestSuccess()
    icestorm.waitTestSuccess()