diff options
Diffstat (limited to 'pjsip-apps/src/test-pjsua')
-rw-r--r-- | pjsip-apps/src/test-pjsua/mod_call.py | 69 | ||||
-rw-r--r-- | pjsip-apps/src/test-pjsua/run.py | 7 |
2 files changed, 59 insertions, 17 deletions
diff --git a/pjsip-apps/src/test-pjsua/mod_call.py b/pjsip-apps/src/test-pjsua/mod_call.py index 7e30a837..e123b3e7 100644 --- a/pjsip-apps/src/test-pjsua/mod_call.py +++ b/pjsip-apps/src/test-pjsua/mod_call.py @@ -70,7 +70,7 @@ def test_func(t, user_data): # Hold call by caller caller.send("H") - caller.sync_stdout() + #caller.sync_stdout() caller.expect(const.MEDIA_HOLD) callee.expect(const.MEDIA_HOLD) @@ -81,9 +81,9 @@ def test_func(t, user_data): # Release hold time.sleep(2) caller.send("v") - caller.sync_stdout() - callee.expect(const.MEDIA_ACTIVE) - caller.expect(const.MEDIA_ACTIVE) + #caller.sync_stdout() + callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") + caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") # Synchronize stdout caller.sync_stdout() @@ -99,7 +99,7 @@ def test_func(t, user_data): # Hold call by callee callee.send("H") - callee.sync_stdout() + #callee.sync_stdout() caller.expect(const.MEDIA_HOLD) callee.expect(const.MEDIA_HOLD) @@ -110,9 +110,9 @@ def test_func(t, user_data): # Release hold time.sleep(2) callee.send("v") - callee.sync_stdout() - caller.expect(const.MEDIA_ACTIVE) - callee.expect(const.MEDIA_ACTIVE) + #callee.sync_stdout() + caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") + callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold") # Synchronize stdout caller.sync_stdout() @@ -128,9 +128,9 @@ def test_func(t, user_data): # UPDATE (by caller) caller.send("U") - caller.sync_stdout() - callee.expect(const.MEDIA_ACTIVE) - caller.expect(const.MEDIA_ACTIVE) + #caller.sync_stdout() + callee.expect(const.MEDIA_ACTIVE, title="waiting for media active with UPDATE") + caller.expect(const.MEDIA_ACTIVE, title="waiting for media active with UPDATE") # Synchronize stdout caller.sync_stdout() @@ -143,9 +143,9 @@ def test_func(t, user_data): # UPDATE (by callee) callee.send("U") - callee.sync_stdout() - caller.expect(const.MEDIA_ACTIVE) - callee.expect(const.MEDIA_ACTIVE) + #callee.sync_stdout() + caller.expect(const.MEDIA_ACTIVE, title="waiting for media active with UPDATE") + callee.expect(const.MEDIA_ACTIVE, title="waiting for media active with UPDATE") # Synchronize stdout caller.sync_stdout() @@ -156,6 +156,47 @@ def test_func(t, user_data): check_media(caller, callee) check_media(callee, caller) + # Synchronize stdout + caller.sync_stdout() + callee.sync_stdout() + + # Set codecs in both caller and callee so that there is + # no common codec between them. + # In caller we only enable PCMU, in callee we only enable PCMA + caller.send("Cp") + caller.send("* 0") + caller.send("Cp") + caller.send("pcmu 120") + + callee.send("Cp") + callee.send("* 0") + callee.send("Cp") + callee.send("pcma 120") + + # Test when UPDATE fails (by callee) + callee.send("U") + caller.expect("SIP/2.0 488") + callee.expect("SIP/2.0 488") + callee.sync_stdout() + caller.sync_stdout() + + # Test that media is still okay + time.sleep(2) + check_media(caller, callee) + check_media(callee, caller) + + # Test when UPDATE fails (by caller) + caller.send("U") + callee.expect("SIP/2.0 488") + caller.expect("SIP/2.0 488") + caller.sync_stdout() + callee.sync_stdout() + + # Test that media is still okay + time.sleep(2) + check_media(callee, caller) + check_media(caller, callee) + # Hangup call time.sleep(1) caller.send("h") diff --git a/pjsip-apps/src/test-pjsua/run.py b/pjsip-apps/src/test-pjsua/run.py index 95d6d45e..ad038882 100644 --- a/pjsip-apps/src/test-pjsua/run.py +++ b/pjsip-apps/src/test-pjsua/run.py @@ -61,11 +61,12 @@ class Expect: self.trace_enabled = inst_param.trace_enabled fullcmd = G_EXE + " " + inst_param.arg + " --stdout-refresh=5 --stdout-refresh-text=" + const.STDOUT_REFRESH self.trace("Popen " + fullcmd) - self.proc = subprocess.Popen(fullcmd, shell=G_INUNIX, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) + self.proc = subprocess.Popen(fullcmd, shell=G_INUNIX, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=False) def send(self, cmd): self.trace("send " + cmd) self.proc.stdin.writelines(cmd + "\n") - def expect(self, pattern, raise_on_error=True): + self.proc.stdin.flush() + def expect(self, pattern, raise_on_error=True, title=""): self.trace("expect " + pattern) r = re.compile(pattern, re.I) refresh_cnt = 0 @@ -88,7 +89,7 @@ class Expect: if refresh_cnt >= 6: self.trace("Timed-out!") if raise_on_error: - raise TestError(self.name + ": Timeout expecting pattern: " + pattern) + raise TestError(self.name + " " + title + ": Timeout expecting pattern: \"" + pattern + "\"") else: return None # timeout # Search for expected text |