blob: 531fd1cb4e407aa2c2c0da5d9dae49694231dd7e [file] [log] [blame]
Benny Prijonocc1ada52008-06-15 19:43:43 +00001# $Id:$
2import 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
74 def __init__( self,
75 title, # Test title
76 inst_params, # InstanceParam's as list
77 func=None):
78 self.title = title
79 self.inst_params = inst_params
80 self.test_func = func
81
82
83