Changeset 2025 for pjproject/trunk/pjsip-apps/src/test-pjsua
- Timestamp:
- Jun 15, 2008 7:43:43 PM (16 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/test-pjsua
- Files:
-
- 5 added
- 1 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/test-pjsua/inc_cfg.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 1 1 # $Id:$ 2 import random 2 3 3 4 DEFAULT_ECHO = True 4 5 DEFAULT_TRACE = True 6 DEFAULT_START_SIP_PORT = 50000 5 7 6 # Individual pjsua config class 7 class Config: 8 # Individual pjsua instance configuration class 9 class InstanceParam: 10 # Name to identify this pjsua instance (e.g. "caller", "callee", etc.) 11 name = "" 8 12 # pjsua command line arguments, concatenated in string 9 13 arg = "" … … 12 16 # Enable/disable test tracing 13 17 trace_enabled = DEFAULT_TRACE 14 def __init__(self, arg, echo_enabled=DEFAULT_ECHO, trace_enabled=DEFAULT_TRACE): 15 self.arg = arg 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" 16 59 self.echo_enabled = echo_enabled 17 60 self.trace_enabled = trace_enabled 18 61 19 # Call config class 20 class CallConfig: 21 # additional parameter to be added to target URI 22 uri_param = "" 23 def __init__(self, title, callee_cfg, caller_cfg): 62 63 ############################################ 64 # Test parameter class 65 class 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): 24 78 self.title = title 25 self. callee_cfg = callee_cfg26 self. caller_cfg = caller_cfg79 self.inst_params = inst_params 80 self.test_func = func 27 81 82 83 -
pjproject/trunk/pjsip-apps/src/test-pjsua/inc_const.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
-
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_call.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 3 3 import imp 4 4 import sys 5 import inc_param as param6 5 import inc_const as const 7 6 … … 9 8 cfg_file = imp.load_source("cfg_file", sys.argv[2]) 10 9 11 # Test title12 title = cfg_file.config.title13 port1 = "9060"14 15 # First pjsua16 p1 = param.Pjsua(17 "callee",18 args = cfg_file.config.callee_cfg.arg + " --local-port="+port1,19 echo = cfg_file.config.callee_cfg.echo_enabled,20 trace = cfg_file.config.callee_cfg.trace_enabled21 )22 23 # Second pjsua, make call to the first one24 p2 = param.Pjsua(25 "caller",26 args = cfg_file.config.caller_cfg.arg + " --local-port=0",27 echo = cfg_file.config.caller_cfg.echo_enabled,28 trace = cfg_file.config.caller_cfg.trace_enabled29 )30 10 31 11 # Test body function … … 36 16 # Caller making call 37 17 caller.send("m") 38 caller.send( "sip:localhost:" + port1 + cfg_file.config.uri_param)18 caller.send(t.inst_params[0].uri) 39 19 caller.expect(const.STATE_CALLING) 40 20 … … 147 127 148 128 # Here where it all comes together 149 test = param.Test(title, run=[p1, p2], func=test_func) 129 test = cfg_file.test_param 130 test.test_func = test_func 150 131 151 -
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_run.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 2 2 import imp 3 3 import sys 4 import inc_param as param5 4 6 5 … … 8 7 cfg_file = imp.load_source("cfg_file", sys.argv[2]) 9 8 10 # Test title11 title = "Basic pjsua"12 13 # Param to spawn pjsua14 p1 = param.Pjsua("pjsua", args=cfg_file.config.arg,15 echo=cfg_file.config.echo_enabled,16 trace=cfg_file.config.trace_enabled)17 18 9 # Here where it all comes together 19 test = param.Test(title, run=[p1])10 test = cfg_file.test_param -
pjproject/trunk/pjsip-apps/src/test-pjsua/run.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 6 6 import time 7 7 8 import inc_param as param9 8 import inc_const as const 10 9 11 10 # Defaults 12 G_ECHO=True13 G_TRACE=False14 11 G_EXE="..\\..\\bin\\pjsua_vc6d.exe" 15 12 … … 28 25 trace_enabled = False 29 26 name = "" 27 inst_param = None 30 28 rh = re.compile(const.DESTROYED) 31 29 ra = re.compile(const.ASSERT, re.I) 32 30 rr = re.compile(const.STDOUT_REFRESH) 33 def __init__(self, name, exe, args="", echo=G_ECHO, trace_enabled=G_TRACE): 34 self.name = name 35 self.echo = echo 36 self.trace_enabled = trace_enabled 37 fullcmd = exe + " " + args + " --stdout-refresh=5 --stdout-refresh-text=" + const.STDOUT_REFRESH 31 def __init__(self, inst_param): 32 self.inst_param = inst_param 33 self.name = inst_param.name 34 self.echo = inst_param.echo_enabled 35 self.trace_enabled = inst_param.trace_enabled 36 fullcmd = G_EXE + " " + inst_param.arg + " --stdout-refresh=5 --stdout-refresh-text=" + const.STDOUT_REFRESH 38 37 self.trace("Popen " + fullcmd) 39 38 self.proc = subprocess.Popen(fullcmd, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) … … 70 69 if r.search(line) != None: 71 70 return line 71 72 def sync_stdout(self): 73 self.trace("sync_stdout") 74 self.send("echo 1") 75 self.expect("echo 1") 76 72 77 def wait(self): 73 78 self.trace("wait") … … 83 88 time.sleep(1) 84 89 for p in t.process: 90 p.send("q") 85 91 p.send("q") 86 92 p.expect(const.DESTROYED, False) … … 108 114 sys.exit(1) 109 115 110 if len(script.test. run) == 0:116 if len(script.test.inst_params) == 0: 111 117 print "Error: test doesn't contain pjsua run descriptions" 112 118 sys.exit(1) … … 114 120 # Instantiate pjsuas 115 121 print "====== Running " + script.test.title + " ======" 116 for run in script.test.run:122 for inst_param in script.test.inst_params: 117 123 try: 118 p = Expect(run.name, G_EXE, args=run.args, echo=run.echo, trace_enabled=run.trace) 119 # Wait until initialized 124 # Create pjsua's Expect instance from the param 125 p = Expect(inst_param) 126 # Wait until registration completes 127 if inst_param.have_reg: 128 p.expect(inst_param.uri+".*registration success") 129 # Synchronize stdout 130 p.send("") 120 131 p.expect(const.PROMPT) 121 132 p.send("echo 1") … … 124 135 # add running instance 125 136 script.test.process.append(p) 126 # run initial script127 for cmd in run.cmds:128 if len(cmd) >= 3 and cmd[2]!="":129 print "====== " + cmd[2] + " ======"130 if len(cmd) >= 1 and cmd[0]!="":131 p.send(cmd[0])132 if len(cmd) >= 2 and cmd[1]!="":133 p.expect(cmd[1])134 137 135 138 except TestError, e: … … 146 149 time.sleep(2) 147 150 for p in script.test.process: 151 # Unregister if we have_reg to make sure that next tests 152 # won't wail 153 if p.inst_param.have_reg: 154 p.send("ru") 155 p.expect(p.inst_param.uri+".*unregistration success") 156 p.send("q") 148 157 p.send("q") 149 158 time.sleep(0.5) -
pjproject/trunk/pjsip-apps/src/test-pjsua/runall.py
r2017 r2025 1 # $Id :$1 # $Id$ 2 2 import os 3 3 import sys … … 13 13 "scripts-call/300_ice_1_1"] 14 14 15 # Add all tests in "scripts-run" directory.15 # Add basic tests 16 16 for f in os.listdir("scripts-run"): 17 17 tests.append("mod_run.py scripts-run/" + f) 18 18 19 # Add all tests in "scripts-call" directory.19 # Add basic call tests 20 20 for f in os.listdir("scripts-call"): 21 21 tests.append("mod_call.py scripts-call/" + f) 22 23 # Add presence tests 24 for f in os.listdir("scripts-pres"): 25 tests.append("mod_pres.py scripts-pres/" + f) 22 26 23 27 # Filter-out excluded tests -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/100_simplecall.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 1 1 # $Id:$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 5 # Simple call 6 config = inc_cfg.CallConfig( 7 title = "Basic call", 8 callee_cfg = inc_cfg.Config(arg="--null-audio"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio") 6 test_param = TestParam( 7 "Basic call", 8 [ 9 InstanceParam("callee", "--null-audio --max-calls=1"), 10 InstanceParam("caller", "--null-audio --max-calls=1") 11 ] 10 12 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/150_srtp_0_1.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 1 1 # $Id:$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 # Simple call 6 config = inc_cfg.CallConfig( 7 title = "Callee=no SRTP, caller=optional SRTP", 8 callee_cfg = inc_cfg.Config(arg="--null-audio"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=1 --srtp-secure=0") 5 test_param= TestParam( 6 "Callee=no SRTP, caller=optional SRTP", 7 [ 8 InstanceParam("callee", "--null-audio --max-calls=1"), 9 InstanceParam("caller", "--null-audio --use-srtp=1 --srtp-secure=0 --max-calls=1") 10 ] 10 11 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/150_srtp_1_0.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 1 1 # $Id:$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 # Simple call 6 config = inc_cfg.CallConfig( 7 title = "Callee=optional SRTP, caller=no SRTP", 8 callee_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=1 --srtp-secure=0"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio") 5 test_param = TestParam( 6 "Callee=optional SRTP, caller=no SRTP", 7 [ 8 InstanceParam("callee", "--null-audio --use-srtp=1 --srtp-secure=0 --max-calls=1"), 9 InstanceParam("caller", "--null-audio --max-calls=1") 10 ] 10 11 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/150_srtp_1_1.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 1 1 # $Id:$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 # Simple call 6 config = inc_cfg.CallConfig( 7 title = "Callee=optional SRTP, caller=optional SRTP", 8 callee_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=1 --srtp-secure=0"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=1 --srtp-secure=0") 5 test_param = TestParam( 6 "Callee=optional SRTP, caller=optional SRTP", 7 [ 8 InstanceParam("callee", "--null-audio --use-srtp=1 --srtp-secure=0 --max-calls=1"), 9 InstanceParam("caller", "--null-audio --use-srtp=1 --srtp-secure=0 --max-calls=1") 10 ] 10 11 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/150_srtp_1_2.py
r2012 r2025 1 1 # $Id$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 # Simple call 6 config = inc_cfg.CallConfig( 7 title = "Callee=optional SRTP, caller=mandatory SRTP", 8 callee_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=1 --srtp-secure=0"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=2 --srtp-secure=0") 5 test_param = TestParam( 6 "Callee=optional SRTP, caller=mandatory SRTP", 7 [ 8 InstanceParam("callee", "--null-audio --use-srtp=1 --srtp-secure=0 --max-calls=1"), 9 InstanceParam("caller", "--null-audio --use-srtp=2 --srtp-secure=0 --max-calls=1") 10 ] 10 11 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/150_srtp_2_1.py
r2012 r2025 1 1 # $Id$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 5 # Simple call 6 config = inc_cfg.CallConfig( 7 title = "Callee=mandatory SRTP, caller=optional SRTP", 8 callee_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=2 --srtp-secure=0"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=1 --srtp-secure=0") 6 test_param = TestParam( 7 "Callee=mandatory SRTP, caller=optional SRTP", 8 [ 9 InstanceParam("callee", "--null-audio --use-srtp=2 --srtp-secure=0 --max-calls=1"), 10 InstanceParam("caller", "--null-audio --use-srtp=1 --srtp-secure=0 --max-calls=1") 11 ] 10 12 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/150_srtp_2_2.py
r2012 r2025 1 1 # $Id$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 # Simple call 6 config = inc_cfg.CallConfig( 7 title = "Callee=mandatory SRTP, caller=mandatory SRTP", 8 callee_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=2 --srtp-secure=0"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio --use-srtp=2 --srtp-secure=0") 5 test_param = TestParam( 6 "Callee=mandatory SRTP, caller=mandatory SRTP", 7 [ 8 InstanceParam("callee", "--null-audio --use-srtp=2 --srtp-secure=0 --max-calls=1"), 9 InstanceParam("caller", "--null-audio --use-srtp=2 --srtp-secure=0 --max-calls=1") 10 ] 10 11 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/200_tcp.py
r2017 r2025 1 1 # $Id$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 5 # TCP call 6 config = inc_cfg.CallConfig( 7 title = "TCP transport", 8 callee_cfg = inc_cfg.Config(arg="--null-audio --no-udp"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio --no-udp") 6 test_param = TestParam( 7 "TCP transport", 8 [ 9 InstanceParam("callee", "--null-audio --no-udp", uri_param=";transport=tcp --max-calls=1"), 10 InstanceParam("caller", "--null-audio --no-udp --max-calls=1") 11 ] 10 12 ) 11 config.uri_param = ";transport=tcp" -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/300_ice_0_1.py
r2017 r2025 1 # $Id :$1 # $Id$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 5 # ICE mismatch 6 config = inc_cfg.CallConfig( 7 title = "Callee=no ICE, caller=use ICE", 8 callee_cfg = inc_cfg.Config(arg="--null-audio"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio --use-ice") 6 test_param = TestParam( 7 "Callee=no ICE, caller=use ICE", 8 [ 9 InstanceParam("callee", "--null-audio --max-calls=1"), 10 InstanceParam("caller", "--null-audio --use-ice --max-calls=1") 11 ] 10 12 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/300_ice_1_0.py
r2017 r2025 1 # $Id :$1 # $Id$ 2 2 # 3 import inc_cfg 4 3 from inc_cfg import * 4 5 5 # ICE mismatch 6 config = inc_cfg.CallConfig( 7 title = "Callee=use ICE, caller=no ICE", 8 callee_cfg = inc_cfg.Config(arg="--null-audio --use-ice"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio") 6 test_param = TestParam( 7 "Callee=use ICE, caller=no ICE", 8 [ 9 InstanceParam("callee", "--null-audio --use-ice --max-calls=1"), 10 InstanceParam("caller", "--null-audio --max-calls=1") 11 ] 10 12 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-call/300_ice_1_1.py
r2017 r2025 1 # $Id :$1 # $Id$ 2 2 # 3 import inc_cfg 3 from inc_cfg import * 4 4 5 5 # ICE mismatch 6 config = inc_cfg.CallConfig( 7 title = "Callee=use ICE, caller=use ICE", 8 callee_cfg = inc_cfg.Config(arg="--null-audio --use-ice"), 9 caller_cfg = inc_cfg.Config(arg="--null-audio --use-ice") 6 test_param = TestParam( 7 "Callee=use ICE, caller=use ICE", 8 [ 9 InstanceParam("callee", "--null-audio --use-ice --max-calls=1"), 10 InstanceParam("caller", "--null-audio --use-ice --max-calls=1") 11 ] 10 12 ) -
pjproject/trunk/pjsip-apps/src/test-pjsua/scripts-run/100_simple.py
- Property svn:eol-style set to native
- Property svn:keywords set to id
r2017 r2025 3 3 # Just about the simple pjsua command line parameter, which should 4 4 # never fail in any circumstances 5 import inc_cfg 5 from inc_cfg import * 6 6 7 config = inc_cfg.Config(arg = "--null-audio --local-port 0 --rtp-port 0") 7 test_param = TestParam( 8 "Basic run", 9 [ 10 InstanceParam("pjsua", "--null-audio --local-port 0 --rtp-port 0") 11 ] 12 ) 8 13
Note: See TracChangeset
for help on using the changeset viewer.