summaryrefslogtreecommitdiff
path: root/pjsip-apps/src/test-pjsua/inc_cfg.py
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-06-15 19:43:43 +0000
committerBenny Prijono <bennylp@teluu.com>2008-06-15 19:43:43 +0000
commit52147c5315e8922dd74eccc96aef9814c507a5ce (patch)
tree66899eb44c84f61d03e423f7589a6f2a3b7b0240 /pjsip-apps/src/test-pjsua/inc_cfg.py
parent5e535ba2d77e5fa029901d60ecfabadac0f35d61 (diff)
Added presence pjsua unit tests
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2025 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src/test-pjsua/inc_cfg.py')
-rw-r--r--pjsip-apps/src/test-pjsua/inc_cfg.py110
1 files changed, 83 insertions, 27 deletions
diff --git a/pjsip-apps/src/test-pjsua/inc_cfg.py b/pjsip-apps/src/test-pjsua/inc_cfg.py
index 7859cd8e..531fd1cb 100644
--- a/pjsip-apps/src/test-pjsua/inc_cfg.py
+++ b/pjsip-apps/src/test-pjsua/inc_cfg.py
@@ -1,27 +1,83 @@
-# $Id:$
-
-DEFAULT_ECHO = True
-DEFAULT_TRACE = True
-
-# Individual pjsua config class
-class Config:
- # pjsua command line arguments, concatenated in string
- arg = ""
- # Specify whether pjsua output should be echoed to stdout
- echo_enabled = DEFAULT_ECHO
- # Enable/disable test tracing
- trace_enabled = DEFAULT_TRACE
- def __init__(self, arg, echo_enabled=DEFAULT_ECHO, trace_enabled=DEFAULT_TRACE):
- self.arg = arg
- self.echo_enabled = echo_enabled
- self.trace_enabled = trace_enabled
-
-# Call config class
-class CallConfig:
- # additional parameter to be added to target URI
- uri_param = ""
- def __init__(self, title, callee_cfg, caller_cfg):
- self.title = title
- self.callee_cfg = callee_cfg
- self.caller_cfg = caller_cfg
-
+# $Id:$
+import random
+
+DEFAULT_ECHO = True
+DEFAULT_TRACE = True
+DEFAULT_START_SIP_PORT = 50000
+
+# Individual pjsua instance configuration class
+class InstanceParam:
+ # Name to identify this pjsua instance (e.g. "caller", "callee", etc.)
+ name = ""
+ # pjsua command line arguments, concatenated in string
+ arg = ""
+ # Specify whether pjsua output should be echoed to stdout
+ echo_enabled = DEFAULT_ECHO
+ # Enable/disable test tracing
+ trace_enabled = DEFAULT_TRACE
+ # SIP URI to send request to this instance
+ uri = ""
+ # SIP port number, zero to automatically assign
+ sip_port = 0
+ # Does this have registration? If yes then the test function will
+ # wait until the UA is registered before doing anything else
+ have_reg = False
+ # Does this have PUBLISH?
+ have_publish = False
+ def __init__( self,
+ name, # Instance name
+ arg, # Cmd-line arguments
+ uri="", # URI
+ uri_param="", # Additional URI param
+ sip_port=0, # SIP port
+ have_reg=False, # Have registration?
+ have_publish=False, # Have publish?
+ echo_enabled=DEFAULT_ECHO,
+ trace_enabled=DEFAULT_TRACE):
+ # Instance name
+ self.name = name
+ # Give random sip_port if it's not specified
+ if sip_port==0:
+ self.sip_port = random.randint(DEFAULT_START_SIP_PORT, 65534)
+ else:
+ self.sip_port = sip_port
+ # Autogenerate URI if it's empty.
+ self.uri = uri
+ if self.uri=="":
+ self.uri = "sip:pjsip@127.0.0.1:" + str(self.sip_port)
+ # Add uri_param to the URI
+ self.uri = self.uri + uri_param
+ # Add bracket to the URI
+ if self.uri[0] != "<":
+ self.uri = "<" + self.uri + ">"
+ # Add SIP local port to the argument
+ self.arg = arg + " --local-port=" + str(self.sip_port)
+ self.have_reg = have_reg
+ self.have_publish = have_publish
+ if not ("--publish" in self.arg):
+ self.arg = self.arg + " --publish"
+ self.echo_enabled = echo_enabled
+ self.trace_enabled = trace_enabled
+
+
+############################################
+# Test parameter class
+class TestParam:
+ title = ""
+ # params is list containing InstanceParams objects
+ inst_params = []
+ # list of Expect instances, to be filled at run-time by
+ # the test program
+ process = []
+ # the function for test body
+ test_func = None
+ def __init__( self,
+ title, # Test title
+ inst_params, # InstanceParam's as list
+ func=None):
+ self.title = title
+ self.inst_params = inst_params
+ self.test_func = func
+
+
+