summaryrefslogtreecommitdiff
path: root/demoscript/Ice/bidir.py
blob: 583a4c48e4fb9f4620bbae67095a096c84049419 (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
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2012 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, signal
from demoscript import Util
import Expect

def run(clientStr, server):
    sys.stdout.write("adding client 1... ")
    sys.stdout.flush()
    client1 = Util.spawn(clientStr)
    server.expect('adding client')
    client1.expect('received callback #1')
    print("ok")

    sys.stdout.write("adding client 2... ")
    sys.stdout.flush()
    client2 = Util.spawn(clientStr)
    server.expect('adding client')
    client1.expect('received callback #')
    client2.expect('received callback #')
    print("ok")

    sys.stdout.write("removing client 2... ")
    sys.stdout.flush()
    client2.kill(signal.SIGINT)
    client2.waitTestSuccess(timeout=20)
    server.expect('removing client')
    client1.expect('received callback #')
    print("ok")

    sys.stdout.write("removing client 1... ")
    sys.stdout.flush()
    client1.kill(signal.SIGINT)
    client1.waitTestSuccess()
    server.expect('removing client')

    server.kill(signal.SIGINT)
    server.waitTestSuccess(timeout=30)

    print("ok")