Repository navigation
Expand file tree
/
Copy pathalice_main.py
More file actions
104 lines (92 loc) · 3.36 KB
/
Copy pathalice_main.py
File metadata and controls
104 lines (92 loc) · 3.36 KB
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
#!/usr/bin/env python3
#
# Copyright (c) 2015 Sippy Software, Inc. All rights reserved.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import sys, getopt
from sippy.MsgBody import MsgBody
from sippy.SipLogger import SipLogger
from sippy.Core.EventDispatcher import ED2
from .lib.test_config import test_config
body_txt = 'v=0\r\n' + \
'o=- 380960 380960 IN IP4 192.168.22.95\r\n' + \
's=-\r\n' + \
'c=IN IP4 192.168.22.95\r\n' + \
't=0 0\r\n' + \
'm=audio 16474 RTP/AVP 18 0 2 4 8 96 97 98 101\r\n' + \
'a=rtpmap:18 G729a/8000\r\n' + \
'a=rtpmap:0 PCMU/8000\r\n' + \
'a=rtpmap:2 G726-32/8000\r\n' + \
'a=rtpmap:4 G723/8000\r\n' + \
'a=rtpmap:8 PCMA/8000\r\n' + \
'a=rtpmap:96 G726-40/8000\r\n' + \
'a=rtpmap:97 G726-24/8000\r\n' + \
'a=rtpmap:98 G726-16/8000\r\n' + \
'a=rtpmap:101 telephone-event/8000\r\n' + \
'a=fmtp:101 0-15\r\n' + \
'a=ptime:30\r\n' + \
'a=sendrecv\r\n' + \
'\r\n'
def main_func():
global_config = {}
getopts = test_config.getopts + 't:46DsC:'
try:
opts, args = getopt.getopt(sys.argv[1:], getopts)
except getopt.GetoptError:
usage(global_config)
tcfg = test_config(global_config, opts)
tcfg.tests_mightfail = tuple('alice_' + x for x in tcfg.tests_mightfail)
ttype = []
dry_run = False
for o, a in opts:
if o == '-t':
if a != '*':
tcfg.tests = tuple(['alice_' + x for x in a.split(',')])
else:
tcfg.tests = None
continue
if o == '-4':
ttype.append('IP4')
continue
if o == '-6':
ttype.append('IP6')
continue
if o == '-D':
dry_run = True
continue
if o == '-s':
tcfg.signalling_only = True
continue
if len(ttype) > 0:
tcfg.ttype = tuple(ttype)
tcfg.body = MsgBody(body_txt)
tcfg.body.parse()
sl = SipLogger('alice_ua')
global_config['_sip_logger'] = sl
from .lib.alice_testcore import a_test
assert '_sip_address' in tcfg.global_config
acore = a_test(tcfg)
if not dry_run:
ED2.loop()
sys.exit(acore.rval)