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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# $Id$
import time
import imp
import sys
import inc_const as const
from inc_cfg import *
# Load configuration
cfg_file = imp.load_source("cfg_file", sys.argv[2])
# Check media flow between ua1 and ua2
def check_media(ua1, ua2):
ua1.send("#")
ua1.send("1122")
ua2.expect(const.RX_DTMF + "1")
ua2.expect(const.RX_DTMF + "1")
ua2.expect(const.RX_DTMF + "2")
ua2.expect(const.RX_DTMF + "2")
# Test body function
def test_func(t, user_data):
callee = t.process[0]
caller = t.process[1]
# if have_reg then wait for couple of seconds for PUBLISH
# to complete (just in case pUBLISH is used)
if callee.inst_param.have_reg:
time.sleep(1)
if caller.inst_param.have_reg:
time.sleep(1)
# Caller making call
caller.send("m")
caller.send(t.inst_params[0].uri)
caller.expect(const.STATE_CALLING)
# Callee waits for call and answers with 180/Ringing
time.sleep(1)
callee.expect(const.EVENT_INCOMING_CALL)
callee.send("a")
callee.send("180")
callee.expect("SIP/2.0 180")
caller.expect("SIP/2.0 180")
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# Callee answers with 200/OK
callee.send("a")
callee.send("200")
# Wait until call is connected in both endpoints
time.sleep(1)
caller.expect(const.STATE_CONFIRMED)
callee.expect(const.STATE_CONFIRMED)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
time.sleep(1)
caller.sync_stdout()
callee.sync_stdout()
# Test that media is okay
time.sleep(2)
check_media(caller, callee)
check_media(callee, caller)
# Hold call by caller
caller.send("H")
caller.sync_stdout()
caller.expect(const.MEDIA_HOLD)
callee.expect(const.MEDIA_HOLD)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# Release hold
time.sleep(2)
caller.send("v")
caller.sync_stdout()
callee.expect(const.MEDIA_ACTIVE)
caller.expect(const.MEDIA_ACTIVE)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# Test that media is okay
check_media(caller, callee)
check_media(callee, caller)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# Hold call by callee
callee.send("H")
callee.sync_stdout()
caller.expect(const.MEDIA_HOLD)
callee.expect(const.MEDIA_HOLD)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# Release hold
time.sleep(2)
callee.send("v")
callee.sync_stdout()
caller.expect(const.MEDIA_ACTIVE)
callee.expect(const.MEDIA_ACTIVE)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# Test that media is okay
check_media(caller, callee)
check_media(callee, caller)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# UPDATE (by caller)
caller.send("U")
caller.sync_stdout()
callee.expect(const.MEDIA_ACTIVE)
caller.expect(const.MEDIA_ACTIVE)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# Test that media is okay
time.sleep(2)
check_media(caller, callee)
check_media(callee, caller)
# UPDATE (by callee)
callee.send("U")
callee.sync_stdout()
caller.expect(const.MEDIA_ACTIVE)
callee.expect(const.MEDIA_ACTIVE)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# Test that media is okay
time.sleep(2)
check_media(caller, callee)
check_media(callee, caller)
# Hangup call
time.sleep(1)
caller.send("h")
caller.sync_stdout()
# Wait until calls are cleared in both endpoints
caller.expect(const.STATE_DISCONNECTED)
callee.expect(const.STATE_DISCONNECTED)
# Here where it all comes together
test = cfg_file.test_param
test.test_func = test_func
|