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