blob: 88b169c528523772605ac2cb991ae4543c5c120f [file] [log] [blame]
Nanang Izzuddinf810f952008-06-18 21:04:14 +00001# $Id$
Benny Prijonocc1ada52008-06-15 19:43:43 +00002import random
3
4DEFAULT_ECHO = True
5DEFAULT_TRACE = True
6DEFAULT_START_SIP_PORT = 50000
7
8# Individual pjsua instance configuration class
9class InstanceParam:
10 # Name to identify this pjsua instance (e.g. "caller", "callee", etc.)
11 name = ""
12 # pjsua command line arguments, concatenated in string
13 arg = ""
14 # Specify whether pjsua output should be echoed to stdout
15 echo_enabled = DEFAULT_ECHO
16 # Enable/disable test tracing
17 trace_enabled = DEFAULT_TRACE
18 # SIP URI to send request to this instance
19 uri = ""
20 # SIP port number, zero to automatically assign
21 sip_port = 0
22 # Does this have registration? If yes then the test function will
23 # wait until the UA is registered before doing anything else
24 have_reg = False
25 # Does this have PUBLISH?
26 have_publish = False
27 def __init__( self,
28 name, # Instance name
29 arg, # Cmd-line arguments
30 uri="", # URI
31 uri_param="", # Additional URI param
32 sip_port=0, # SIP port
33 have_reg=False, # Have registration?
34 have_publish=False, # Have publish?
35 echo_enabled=DEFAULT_ECHO,
36 trace_enabled=DEFAULT_TRACE):
37 # Instance name
38 self.name = name
39 # Give random sip_port if it's not specified
40 if sip_port==0:
41 self.sip_port = random.randint(DEFAULT_START_SIP_PORT, 65534)
42 else:
43 self.sip_port = sip_port
44 # Autogenerate URI if it's empty.
45 self.uri = uri
46 if self.uri=="":
47 self.uri = "sip:pjsip@127.0.0.1:" + str(self.sip_port)
48 # Add uri_param to the URI
49 self.uri = self.uri + uri_param
50 # Add bracket to the URI
51 if self.uri[0] != "<":
52 self.uri = "<" + self.uri + ">"
53 # Add SIP local port to the argument
54 self.arg = arg + " --local-port=" + str(self.sip_port)
55 self.have_reg = have_reg
56 self.have_publish = have_publish
57 if not ("--publish" in self.arg):
58 self.arg = self.arg + " --publish"
59 self.echo_enabled = echo_enabled
60 self.trace_enabled = trace_enabled
61
62
63############################################
64# Test parameter class
65class TestParam:
66 title = ""
67 # params is list containing InstanceParams objects
68 inst_params = []
69 # list of Expect instances, to be filled at run-time by
70 # the test program
71 process = []
72 # the function for test body
73 test_func = None
Nanang Izzuddinf810f952008-06-18 21:04:14 +000074 post_func = None
75 user_data = None
Benny Prijonocc1ada52008-06-15 19:43:43 +000076 def __init__( self,
77 title, # Test title
78 inst_params, # InstanceParam's as list
Nanang Izzuddinf810f952008-06-18 21:04:14 +000079 func=None,
80 post_func=None,
81 user_data=None):
Benny Prijonocc1ada52008-06-15 19:43:43 +000082 self.title = title
83 self.inst_params = inst_params
84 self.test_func = func
Nanang Izzuddinf810f952008-06-18 21:04:14 +000085 self.post_func = post_func
86 self.user_data = user_data
Benny Prijonocc1ada52008-06-15 19:43:43 +000087
88
Benny Prijono7d578a72008-06-20 00:25:55 +000089###################################
90# TestError exception
91class TestError:
92 desc = ""
93 def __init__(self, desc):
94 self.desc = desc
95
Benny Prijonocc1ada52008-06-15 19:43:43 +000096