summaryrefslogtreecommitdiff
path: root/demoscript/Ice/multicast.py
blob: deec2b0510e58fe7e654d3d6a5fc0dec876651ad (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-2009 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 *
from scripts import Expect

def runClient(clientCmd, server1, server2):
    client = Util.spawn(clientCmd)
    received = False
    try:
        server1.expect('Hello World!')
        received = True
    except Expect.TIMEOUT:
        pass
    try:
        server2.expect('Hello World!')
        received = True
    except Expect.TIMEOUT:
        pass
    if not received:
        raise Expect.TIMEOUT
    client.waitTestSuccess()

def runDemo(clientCmd, serverCmd):
    server1 = Util.spawn(serverCmd + ' --Ice.PrintAdapterReady')
    server1.expect('Discover ready')
    server1.expect('Hello ready')

    server2 = Util.spawn(serverCmd + ' --Ice.PrintAdapterReady')
    server2.expect('Discover ready')
    server2.expect('Hello ready')

    runClient(clientCmd, server1, server2)
    runClient(clientCmd, server1, server2)
    runClient(clientCmd, server1, server2)

    server1.kill(signal.SIGINT)
    server1.waitTestSuccess()

    server2.kill(signal.SIGINT)
    server2.waitTestSuccess()

def run(clientCmd, serverCmd):
    print "testing multicast discovery (Ipv4)...",
    sys.stdout.flush()
    runDemo(clientCmd, serverCmd)
    print "ok"

    if Util.getMapping() == "java" and Util.isWin32():
        print "skipping testing multicast discovery (IPv6) under windows...",
    else:
        print "testing multicast discovery (IPv6)...",
        sys.stdout.flush()
        serverCmd += ' --Ice.IPv6=1 --Discover.Endpoints="udp -h \\"ff01::1:1\\" -p 10000"'
        clientCmd += ' --Ice.IPv6=1 --Discover.Proxy="discover:udp -h \\"ff01::1:1\\" -p 10000"'
        runDemo(clientCmd, serverCmd)
    print "ok"