summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2012-06-28 09:16:03 +0000
committerNanang Izzuddin <nanang@teluu.com>2012-06-28 09:16:03 +0000
commit4b9c3d123588928f32790788779b0fee51bbe84b (patch)
tree1c17b9f0b07e5343de7f31475fd2c098b8f10b5e /tests
parent8fa7c55111900eeaf1ce86a38dbe574cc787ef28 (diff)
Re #1523:
- runall.py: fix option parser - run.py: avoid double newlines in logging - mod_sipp.py: redirect sipp output to /dev/null & add sipp error string - misc fixes on sipp scenarios, e.g: regex to get via branch, file rename. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4183 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'tests')
-rw-r--r--tests/pjsua/mod_sipp.py37
-rw-r--r--tests/pjsua/run.py2
-rw-r--r--tests/pjsua/runall.py9
-rw-r--r--tests/pjsua/scripts-sipp/transfer-attended.py5
-rw-r--r--tests/pjsua/scripts-sipp/transfer-unattended.py4
-rw-r--r--tests/pjsua/scripts-sipp/uas-forked-100rel.xml4
-rw-r--r--tests/pjsua/scripts-sipp/uas-forked-200.xml4
-rw-r--r--tests/pjsua/scripts-sipp/uas-inv-answered-with-srtp.xml (renamed from tests/pjsua/scripts-sipp/uas-invite.xml)0
-rw-r--r--tests/pjsua/scripts-sipp/uas-prack_fork.xml5
-rw-r--r--tests/pjsua/scripts-sipp/uas-reinv-and-ack-same-branch-without-sdp.xml (renamed from tests/pjsua/scripts-sipp/uas-reinv-and-ack(same-branch)-without-sdp.xml)0
10 files changed, 51 insertions, 19 deletions
diff --git a/tests/pjsua/mod_sipp.py b/tests/pjsua/mod_sipp.py
index bda52781..82e6b75a 100644
--- a/tests/pjsua/mod_sipp.py
+++ b/tests/pjsua/mod_sipp.py
@@ -16,6 +16,9 @@ if sys.platform.lower().find("win32")!=-1 or sys.platform.lower().find("microsof
else:
G_INUNIX = True
+# /dev/null handle, for redirecting output when SIPP is not in background mode
+FDEVNULL = None
+
# SIPp executable path and param
#SIPP_PATH = '"C:\\Program Files (x86)\\Sipp_3.2\\sipp.exe"'
SIPP_PATH = 'sipp'
@@ -24,8 +27,8 @@ SIPP_TIMEOUT = 60
# On BG mode, SIPp doesn't require special terminal
# On non-BG mode, on win, it needs env var: "TERMINFO=c:\cygwin\usr\share\terminfo"
# TODO: on unix with BG mode, waitpid() always fails, need to be fixed
-#SIPP_BG_MODE = True
-SIPP_BG_MODE = not G_INUNIX
+SIPP_BG_MODE = False
+#SIPP_BG_MODE = not G_INUNIX
# Will be updated based on configuration file (a .py file whose the same name as SIPp XML file)
PJSUA_INST_PARAM = []
@@ -79,7 +82,10 @@ def start_sipp():
if SIPP_BG_MODE:
sipp_proc = subprocess.Popen(fullcmd, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=G_INUNIX, universal_newlines=False)
else:
- sipp_proc = subprocess.Popen(fullcmd, shell=G_INUNIX)
+ # redirect output to NULL
+ global FDEVNULL
+ FDEVNULL = open(os.devnull, 'w')
+ sipp_proc = subprocess.Popen(fullcmd, shell=G_INUNIX, stdout=FDEVNULL, stderr=FDEVNULL)
if not SIPP_BG_MODE:
if sipp_proc == None or sipp_proc.poll():
@@ -114,7 +120,9 @@ def start_sipp():
# Wait SIPp process to exit, returning SIPp exit code
def wait_sipp(sipp):
if not SIPP_BG_MODE:
+ global FDEVNULL
sipp.wait()
+ FDEVNULL.close()
return sipp.returncode
else:
@@ -175,11 +183,29 @@ def exec_pjsua_expects(t, sipp):
# PJSUA process may stuck.
# Ideally the poll should be done contiunously until SIPp process is
# terminated.
- ua[0].expect(inc_const.STDOUT_REFRESH, raise_on_error = False)
+ for ua_idx in range(len(ua)):
+ ua[ua_idx].expect(inc_const.STDOUT_REFRESH, raise_on_error = False)
return ua_err_st
+def sipp_err_to_str(err_code):
+ if err_code == 0:
+ return "All calls were successful"
+ elif err_code == 1:
+ return "At least one call failed"
+ elif err_code == 97:
+ return "exit on internal command. Calls may have been processed"
+ elif err_code == 99:
+ return "Normal exit without calls processed"
+ elif err_code == -1:
+ return "Fatal error (timeout)"
+ elif err_code == -2:
+ return "Fatal error binding a socket"
+ else:
+ return "Unknown error"
+
+
# Test body function
def TEST_FUNC(t):
@@ -198,7 +224,8 @@ def TEST_FUNC(t):
raise TestError(ua_err_st)
if sipp_ret_code:
- raise TestError("SIPp returned error " + str(sipp_ret_code))
+ rc = ctypes.c_byte(sipp_ret_code).value
+ raise TestError("SIPp returned error " + str(rc) + ": " + sipp_err_to_str(rc))
# Here where it all comes together
diff --git a/tests/pjsua/run.py b/tests/pjsua/run.py
index d6d558b1..7eee316a 100644
--- a/tests/pjsua/run.py
+++ b/tests/pjsua/run.py
@@ -143,7 +143,7 @@ class Expect:
raise inc.TestError(self.name + ": Premature EOF")
# Print the line if echo is ON
if self.echo:
- print self.name + ": " + line,
+ print self.name + ": " + line.rstrip()
# Trap assertion error
if self.ra.search(line) != None:
if raise_on_error:
diff --git a/tests/pjsua/runall.py b/tests/pjsua/runall.py
index 046a0cb6..1968ca92 100644
--- a/tests/pjsua/runall.py
+++ b/tests/pjsua/runall.py
@@ -93,7 +93,7 @@ while len(sys.argv):
if len(sys.argv) > 1:
resume_script=sys.argv[1]
sys.argv.pop(0)
- sys.argv.pop(1)
+ sys.argv.pop(0)
else:
sys.argv.pop(0)
sys.stderr.write("Error: argument value required")
@@ -119,15 +119,18 @@ while len(sys.argv):
if len(sys.argv) > 1:
shell_cmd = sys.argv[1]
sys.argv.pop(0)
- sys.argv.pop(1)
+ sys.argv.pop(0)
else:
sys.argv.pop(0)
sys.stderr.write("Error: argument value required")
sys.exit(1)
+ else:
+ # should be run.py options
+ break
# Generate arguments for run.py
-argv_st = " ".join(sys.argv)
+argv_st = " ".join(sys.argv) + " "
# Init vars
fails_cnt = 0
diff --git a/tests/pjsua/scripts-sipp/transfer-attended.py b/tests/pjsua/scripts-sipp/transfer-attended.py
index 2cd6ddef..7063d675 100644
--- a/tests/pjsua/scripts-sipp/transfer-attended.py
+++ b/tests/pjsua/scripts-sipp/transfer-attended.py
@@ -11,6 +11,7 @@ PJSUA_EXPECTS = [
# A calls B
[0, "", "m"],
[0, "", "sip:localhost:5062"],
+ [0, const.STATE_CALLING, ""],
[1, const.EVENT_INCOMING_CALL, "a"],
[1, "", "200"],
[0, const.STATE_CONFIRMED, ""],
@@ -24,6 +25,7 @@ PJSUA_EXPECTS = [
# B calls C
[1, "", "m"],
[1, "", "sip:localhost:5064"],
+ [1, const.STATE_CALLING, ""],
[2, const.EVENT_INCOMING_CALL, "a"],
[2, "", "200"],
[1, const.STATE_CONFIRMED, ""],
@@ -46,6 +48,5 @@ PJSUA_EXPECTS = [
[1, "call transfered successfully", ""],
[0, const.MEDIA_ACTIVE, ""],
[2, const.MEDIA_ACTIVE, ""],
- [1, "", " "],
- [1, "have 0 active call", ""],
+ [1, const.STATE_DISCONNECTED, ""]
]
diff --git a/tests/pjsua/scripts-sipp/transfer-unattended.py b/tests/pjsua/scripts-sipp/transfer-unattended.py
index da404426..0dd6e00d 100644
--- a/tests/pjsua/scripts-sipp/transfer-unattended.py
+++ b/tests/pjsua/scripts-sipp/transfer-unattended.py
@@ -11,6 +11,7 @@ PJSUA_EXPECTS = [
# A calls B
[0, "", "m"],
[0, "", "sip:localhost:5062"],
+ [0, const.STATE_CALLING, ""],
[1, const.EVENT_INCOMING_CALL, "a"],
[1, "", "200"],
[0, const.STATE_CONFIRMED, ""],
@@ -25,6 +26,5 @@ PJSUA_EXPECTS = [
[0, const.MEDIA_ACTIVE, ""],
[2, const.MEDIA_ACTIVE, ""],
[1, "call transfered successfully", ""],
- [1, "", " "],
- [1, "have 0 active call", ""],
+ [1, const.STATE_DISCONNECTED, ""]
]
diff --git a/tests/pjsua/scripts-sipp/uas-forked-100rel.xml b/tests/pjsua/scripts-sipp/uas-forked-100rel.xml
index c2f2044b..3a1ca229 100644
--- a/tests/pjsua/scripts-sipp/uas-forked-100rel.xml
+++ b/tests/pjsua/scripts-sipp/uas-forked-100rel.xml
@@ -22,9 +22,9 @@
<scenario name="Forked INVITE, one of them require PRACK">
<recv request="INVITE" crlf="true">
<action>
- <ereg regexp="branch=([0-9a-zA-Z\-]*)"
+ <ereg regexp="branch=([^;]*)"
search_in="hdr"
- header="Via"
+ header="Via"
assign_to="1,2"/>
<assign assign_to="1" variable="2"/>
<ereg regexp="CSeq: [ 0-9A-Z]+"
diff --git a/tests/pjsua/scripts-sipp/uas-forked-200.xml b/tests/pjsua/scripts-sipp/uas-forked-200.xml
index 3878ad4a..a67f8cae 100644
--- a/tests/pjsua/scripts-sipp/uas-forked-200.xml
+++ b/tests/pjsua/scripts-sipp/uas-forked-200.xml
@@ -22,9 +22,9 @@
<scenario name="Forked INVITE, one of them require PRACK">
<recv request="INVITE" crlf="true">
<action>
- <ereg regexp="branch=([0-9a-zA-Z]*)"
+ <ereg regexp="branch=([^;]*)"
search_in="hdr"
- header="Via"
+ header="Via"
assign_to="1,2"/>
<assign assign_to="1" variable="2"/>
</action>
diff --git a/tests/pjsua/scripts-sipp/uas-invite.xml b/tests/pjsua/scripts-sipp/uas-inv-answered-with-srtp.xml
index 1f928e7c..1f928e7c 100644
--- a/tests/pjsua/scripts-sipp/uas-invite.xml
+++ b/tests/pjsua/scripts-sipp/uas-inv-answered-with-srtp.xml
diff --git a/tests/pjsua/scripts-sipp/uas-prack_fork.xml b/tests/pjsua/scripts-sipp/uas-prack_fork.xml
index ae1c6054..ddae747c 100644
--- a/tests/pjsua/scripts-sipp/uas-prack_fork.xml
+++ b/tests/pjsua/scripts-sipp/uas-prack_fork.xml
@@ -22,8 +22,9 @@
<scenario name="Forked INVITE, one of them require PRACK">
<recv request="INVITE" crlf="true">
<action>
- <ereg regexp="branch=([0-9a-zA-Z]*)"
- search_in="msg"
+ <ereg regexp="branch=([^;]*)"
+ search_in="hdr"
+ header="Via"
assign_to="3"/>
<ereg regexp="CSeq: ([0-9a-zA-Z ]*)"
search_in="msg"
diff --git a/tests/pjsua/scripts-sipp/uas-reinv-and-ack(same-branch)-without-sdp.xml b/tests/pjsua/scripts-sipp/uas-reinv-and-ack-same-branch-without-sdp.xml
index cab4e535..cab4e535 100644
--- a/tests/pjsua/scripts-sipp/uas-reinv-and-ack(same-branch)-without-sdp.xml
+++ b/tests/pjsua/scripts-sipp/uas-reinv-and-ack-same-branch-without-sdp.xml