summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-06-26 22:20:11 +0000
committerBenny Prijono <bennylp@teluu.com>2008-06-26 22:20:11 +0000
commit3295efbbcce1ce10d02824e2b1dad5d688f2ea54 (patch)
treee13219a06d57b8b169d9fd553a0f334fa038fd13
parentaac5231515ffded8354292ba0940ca02fa03ff5d (diff)
echo command in pjsua can be used to print any text, and this is used to better synchronize stdout in Python test apps
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2069 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app.c4
-rw-r--r--pjsip-apps/src/test-pjsua/run.py10
2 files changed, 9 insertions, 5 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index 1a8f50b1..264036ec 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -2492,7 +2492,7 @@ static void keystroke_help(void)
puts("| | V Adjust audio Volume | f Save config |");
puts("| S Send arbitrary REQUEST | Cp Codec priorities | f Save config |");
puts("+------------------------------+--------------------------+-------------------+");
- puts("| q QUIT sleep MS echo [0|1] n: detect NAT type |");
+ puts("| q QUIT sleep MS echo [0|1|txt] n: detect NAT type |");
puts("+=============================================================================+");
i = pjsua_call_get_count();
@@ -3544,7 +3544,7 @@ void console_app_main(const pj_str_t *uri_to_call)
break;
}
- cmd_echo = pj_strtoul(&tmp);
+ cmd_echo = *tmp.ptr != '0' || tmp.slen!=1;
}
break;
diff --git a/pjsip-apps/src/test-pjsua/run.py b/pjsip-apps/src/test-pjsua/run.py
index e525bac9..c1947efa 100644
--- a/pjsip-apps/src/test-pjsua/run.py
+++ b/pjsip-apps/src/test-pjsua/run.py
@@ -54,6 +54,7 @@ class Expect:
rh = re.compile(const.DESTROYED)
ra = re.compile(const.ASSERT, re.I)
rr = re.compile(const.STDOUT_REFRESH)
+ t0 = time.time()
def __init__(self, inst_param):
self.inst_param = inst_param
self.name = inst_param.name
@@ -98,15 +99,18 @@ class Expect:
def sync_stdout(self):
self.trace("sync_stdout")
- self.send("echo 1")
- self.expect("echo 1")
+ cmd = "echo 1" + str(random.randint(1000,9999))
+ self.send(cmd)
+ self.expect(cmd)
def wait(self):
self.trace("wait")
self.proc.wait()
def trace(self, s):
if self.trace_enabled:
- print self.name + ": " + "====== " + s + " ======"
+ now = time.time()
+ fmt = self.name + ": " + "================== " + s + " ==================" + " [at t=%(time)03d]"
+ print fmt % {'time':int(now - self.t0)}
#########################
# Error handling