- Timestamp:
- Jun 29, 2012 9:01:17 AM (12 years ago)
- Location:
- pjproject/trunk/tests/pjsua
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/tests/pjsua/mod_sipp.py
r4187 r4188 1 1 # $Id$ 2 3 ## Automatic test module for SIPp. 4 ## 5 ## This module will need a test driver for each SIPp scenario: 6 ## - For simple scenario, i.e: make/receive call (including auth), this 7 ## test module can auto-generate a default test driver, i.e: make call 8 ## or apply auto answer. Just name the SIPp scenario using "uas" or 9 ## "uac" prefix accordingly. 10 ## - Custom test driver can be defined in a python script file containing 11 ## a list of the PJSUA instances and another list for PJSUA expects/ 12 ## commands. The custom test driver file must use the same filename as 13 ## the SIPp XML scenario. See samples of SIPp scenario + its driver 14 ## in tests/pjsua/scripts-sipp/ folder for detail. 15 ## 16 ## Here are defined macros that can be used in the custom driver: 17 ## - $SIPP_PORT : SIPp binding port 18 ## - $SIPP_URI : SIPp SIP URI 19 ## - $PJSUA_PORT[N] : binding port of PJSUA instance #N 20 ## - $PJSUA_URI[N] : SIP URI of PJSUA instance #N 21 2 22 import ctypes 3 23 import time … … 23 43 #SIPP_PATH = '"C:\\Program Files (x86)\\Sipp_3.2\\sipp.exe"' 24 44 SIPP_PATH = 'sipp' 25 SIPP_PARAM = "-i 127.0.0.1 -p 6000 -m 1 127.0.0.1" 45 SIPP_PORT = 6000 46 SIPP_PARAM = "-m 1 -i 127.0.0.1 -p " + str(SIPP_PORT) 26 47 SIPP_TIMEOUT = 60 27 48 # On BG mode, SIPp doesn't require special terminal … … 31 52 #SIPP_BG_MODE = not G_INUNIX 32 53 33 # Will be updated based on configurationfile (a .py file whose the same name as SIPp XML file)54 # Will be updated based on the test driver file (a .py file whose the same name as SIPp XML file) 34 55 PJSUA_INST_PARAM = [] 35 56 PJSUA_EXPECTS = [] 36 57 37 # Default PJSUA param if configuration file (the corresponding .py file)is not available:58 # Default PJSUA param if test driver is not available: 38 59 # - no-tcp as SIPp is on UDP only 39 60 # - id, username, and realm: to allow PJSUA sending re-INVITE with auth after receiving 401/407 response … … 48 69 49 70 50 # Init PJSUA test instance 71 # Functions for resolving macros in the test driver 72 def resolve_pjsua_port(mo): 73 return str(PJSUA_INST_PARAM[int(mo.group(1))].sip_port) 74 75 def resolve_pjsua_uri(mo): 76 return PJSUA_INST_PARAM[int(mo.group(1))].uri[1:-1] 77 78 def resolve_driver_macros(st): 79 st = re.sub("\$SIPP_PORT", str(SIPP_PORT), st) 80 st = re.sub("\$SIPP_URI", "sip:sipp@127.0.0.1:"+str(SIPP_PORT), st) 81 st = re.sub("\$PJSUA_PORT\[(\d+)\]", resolve_pjsua_port, st) 82 st = re.sub("\$PJSUA_URI\[(\d+)\]", resolve_pjsua_uri, st) 83 return st 84 85 86 # Init test driver 51 87 if os.access(SIPP_SCEN_XML[:-4]+".py", os.R_OK): 52 # Load from configurationfile (the corresponding .py file), if any88 # Load test driver file (the corresponding .py file), if any 53 89 cfg_file = imp.load_source("cfg_file", SIPP_SCEN_XML[:-4]+".py") 54 90 for ua_idx, ua_param in enumerate(cfg_file.PJSUA): 55 PJSUA_INST_PARAM.append(InstanceParam("pjsua"+str(ua_idx+1), ua_param, sip_port=5060+ua_idx*2)) 91 ua_param = resolve_driver_macros(ua_param) 92 PJSUA_INST_PARAM.append(InstanceParam("pjsua"+str(ua_idx), ua_param)) 56 93 PJSUA_EXPECTS = cfg_file.PJSUA_EXPECTS 57 94 else: 58 # Just use the SIPp XML scenario95 # Generate default test driver 59 96 if os.path.basename(SIPP_SCEN_XML)[0:3] == "uas": 60 97 # auto make call when SIPp is as UAS 61 ua_param = PJSUA_DEF_PARAM + " sip:127.0.0.1: 6000"98 ua_param = PJSUA_DEF_PARAM + " sip:127.0.0.1:" + str(SIPP_PORT) 62 99 else: 63 100 # auto answer when SIPp is as UAC 64 101 ua_param = PJSUA_DEF_PARAM + " --auto-answer=200" 65 PJSUA_INST_PARAM.append(InstanceParam("pjsua", ua_param, sip_port=5060)) 66 102 PJSUA_INST_PARAM.append(InstanceParam("pjsua", ua_param)) 67 103 68 104 … … 72 108 sipp_proc = None 73 109 74 # run SIPp75 110 sipp_param = SIPP_PARAM + " -sf " + SIPP_SCEN_XML 76 111 if SIPP_BG_MODE: … … 78 113 if SIPP_TIMEOUT: 79 114 sipp_param = sipp_param + " -timeout "+str(SIPP_TIMEOUT)+"s -timeout_error" + " -deadcall_wait "+str(SIPP_TIMEOUT)+"s" 115 116 # add target param 117 sipp_param = sipp_param + " 127.0.0.1:" + str(PJSUA_INST_PARAM[0].sip_port) 118 119 # run SIPp 80 120 fullcmd = os.path.normpath(SIPP_PATH) + " " + sipp_param 81 121 print "Running SIPP: " + fullcmd … … 162 202 ua_idx = expect[0] 163 203 expect_st = expect[1] 164 send_cmd = expect[2]204 send_cmd = resolve_driver_macros(expect[2]) 165 205 # Handle exception in pjsua flow, to avoid zombie SIPp process 166 206 try: -
pjproject/trunk/tests/pjsua/scripts-sipp/strict-route.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 --id=sip:pjsua@localhost --username=pjsua --realm=* sip:sipp@localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 --id=sip:pjsua@localhost --username=pjsua --realm=* $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, "ACK sip:proxy@.* SIP/2\.0", ""], -
pjproject/trunk/tests/pjsua/scripts-sipp/transfer-attended.py
r4183 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio", # UA0 @ port 50606 "--null-audio", # UA1 @ port 50627 "--null-audio" # UA2 @ port 50645 PJSUA = ["--null-audio", # UA0 6 "--null-audio", # UA1 7 "--null-audio" # UA2 8 8 ] 9 9 … … 11 11 # A calls B 12 12 [0, "", "m"], 13 [0, "", " sip:localhost:5062"],13 [0, "", "$PJSUA_URI[1]"], 14 14 [0, const.STATE_CALLING, ""], 15 15 [1, const.EVENT_INCOMING_CALL, "a"], … … 25 25 # B calls C 26 26 [1, "", "m"], 27 [1, "", " sip:localhost:5064"],27 [1, "", "$PJSUA_URI[2]"], 28 28 [1, const.STATE_CALLING, ""], 29 29 [2, const.EVENT_INCOMING_CALL, "a"], -
pjproject/trunk/tests/pjsua/scripts-sipp/transfer-unattended.py
r4183 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio", # UA0 @ port 50606 "--null-audio", # UA1 @ port 50627 "--null-audio" # UA2 @ port 50645 PJSUA = ["--null-audio", # UA0 6 "--null-audio", # UA1 7 "--null-audio" # UA2 8 8 ] 9 9 … … 11 11 # A calls B 12 12 [0, "", "m"], 13 [0, "", " sip:localhost:5062"],13 [0, "", "$PJSUA_URI[1]"], 14 14 [0, const.STATE_CALLING, ""], 15 15 [1, const.EVENT_INCOMING_CALL, "a"], … … 20 20 # B transfer A to C 21 21 [1, "", "x"], 22 [1, "", " sip:localhost:5064"],22 [1, "", "$PJSUA_URI[2]"], 23 23 [0, const.STATE_CALLING, ""], 24 24 [2, const.EVENT_INCOMING_CALL, "a"], -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-answer-200-reinvite-without-sdp.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 sip:localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, const.STATE_CONFIRMED, "v"]] -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-answer-200-update-without-sdp.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 sip:localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, const.STATE_CONFIRMED, "U"]] -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-auth.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 --id=sip:a@localhost --username=a --realm=* --registrar= sip:localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 --id=sip:a@localhost --username=a --realm=* --registrar=$SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [] -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-cancel-no-final.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 sip:localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, const.STATE_EARLY, "h"]] -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-mwi-0.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost: 6000--mwi"]5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost:$SIPP_PORT --mwi"] 6 6 7 7 PJSUA_EXPECTS = [] -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-mwi.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost: 6000--mwi"]5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost:$SIPP_PORT --mwi"] 6 6 7 7 PJSUA_EXPECTS = [] -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-reinv-glare.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 sip:localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, const.STATE_CONFIRMED, "U"]] -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-subscribe-late-notify.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost :6000 --add-buddy sip:sipp@localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost --add-buddy $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, "", "s"], -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-subscribe-multipart-notify.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost :6000 --add-buddy sip:sipp@localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost --add-buddy $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, "", "s"], 8 8 [0, "Subscribe presence of:", "1"], 9 [0, "s ip:sipp@localhost:6000 .*Online", ""],9 [0, "status is Online", ""], 10 10 [0, "subscription state is TERMINATED", ""] 11 11 ] -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-subscribe-notify-terminate.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost :6000 --add-buddy sip:sipp@localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost --add-buddy $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, "", "s"], -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-subscribe-refresh-481.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost :6000 --add-buddy sip:sipp@localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost --add-buddy $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, "", "s"], 8 8 [0, "Subscribe presence of:", "1"], 9 [0, "s ip:sipp@localhost:6000 .*Online", ""],9 [0, "status is Online", ""], 10 10 [0, "subscription state is TERMINATED", ""] 11 11 ] -
pjproject/trunk/tests/pjsua/scripts-sipp/uas-subscribe-terminated-retry.py
r4177 r4188 3 3 import inc_const as const 4 4 5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost :6000 --add-buddy sip:sipp@localhost:6000"]5 PJSUA = ["--null-audio --max-calls=1 --id sip:pjsua@localhost --add-buddy $SIPP_URI"] 6 6 7 7 PJSUA_EXPECTS = [[0, "", "s"],
Note: See TracChangeset
for help on using the changeset viewer.