summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2015-04-13 12:14:02 +0000
committerNanang Izzuddin <nanang@teluu.com>2015-04-13 12:14:02 +0000
commit1823322ac0a440303c65f21de535724f213f480d (patch)
tree6f39caba554406e2d8d29a259097b42d3c5ecfc1
parentd73d8cef462aa2e6f4476b53175bcb55b130b021 (diff)
Re #1842: Updated pjsua app to avoid stdout buffering, and also adjusted python tests accordingly.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5065 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app_config.c7
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app_legacy.c23
-rw-r--r--tests/pjsua/mod_call.py28
-rw-r--r--tests/pjsua/scripts-call/300_ice_1_1.py4
-rw-r--r--tests/pjsua/scripts-call/305_ice_comp_1_2.py4
-rw-r--r--tests/pjsua/scripts-call/305_ice_comp_2_1.py4
-rw-r--r--tests/pjsua/scripts-sendto/200_ice_success_2.py3
-rw-r--r--tests/pjsua/scripts-sendto/200_ice_success_3.py3
-rw-r--r--tests/pjsua/scripts-sendto/200_ice_success_4.py3
9 files changed, 49 insertions, 30 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app_config.c b/pjsip-apps/src/pjsua/pjsua_app_config.c
index 4256de95..740be6f2 100644
--- a/pjsip-apps/src/pjsua/pjsua_app_config.c
+++ b/pjsip-apps/src/pjsua/pjsua_app_config.c
@@ -214,6 +214,12 @@ static void usage(void)
fflush(stdout);
}
+static void log_writer_nobuf(int level, const char *buffer, int len)
+{
+ pj_log_write(level, buffer, len);
+ fflush(stdout);
+}
+
/*
* Read command arguments from config file.
*/
@@ -1251,6 +1257,7 @@ static pj_status_t parse_args(int argc, char *argv[],
#ifdef _IONBF
case OPT_STDOUT_NO_BUF:
setvbuf(stdout, NULL, _IONBF, 0);
+ cfg->log_cfg.cb = &log_writer_nobuf;
break;
#endif
diff --git a/pjsip-apps/src/pjsua/pjsua_app_legacy.c b/pjsip-apps/src/pjsua/pjsua_app_legacy.c
index ed960e30..d687aded 100644
--- a/pjsip-apps/src/pjsua/pjsua_app_legacy.c
+++ b/pjsip-apps/src/pjsua/pjsua_app_legacy.c
@@ -23,6 +23,20 @@
#define THIS_FILE "pjsua_app_legacy.c"
+
+/* An attempt to avoid stdout buffering for python tests:
+ * - call 'fflush(stdout)' after each call to 'printf()/puts()'
+ * - apply 'setbuf(stdout, 0)', but it is not guaranteed by the standard:
+ * http://stackoverflow.com/questions/1716296
+ */
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+ (defined (_MSC_VER) && _MSC_VER >= 1400)
+/* Variadic macro is introduced in C99; MSVC supports it in since 2005. */
+# define printf(...) {printf(__VA_ARGS__);fflush(stdout);}
+# define puts(s) {puts(s);fflush(stdout);}
+#endif
+
+
static pj_bool_t cmd_echo;
/*
@@ -38,9 +52,9 @@ static void print_buddy_list()
pjsua_enum_buddies(ids, &count);
- if (count == 0)
+ if (count == 0) {
puts(" -none-");
- else {
+ } else {
for (i=0; i<(int)count; ++i) {
pjsua_buddy_info info;
@@ -1088,9 +1102,9 @@ static void ui_call_transfer(pj_bool_t no_refersub)
pj_list_push_back(&msg_data.hdr_list, &refer_sub);
}
if (result.nb_result != PJSUA_APP_NO_NB) {
- if (result.nb_result == -1 || result.nb_result == 0)
+ if (result.nb_result == -1 || result.nb_result == 0) {
puts("You can't do that with transfer call!");
- else {
+ } else {
pjsua_buddy_info binfo;
pjsua_buddy_get_info(result.nb_result-1, &binfo);
pjsua_call_xfer( current_call, &binfo.uri, &msg_data);
@@ -1669,6 +1683,7 @@ static void ui_call_redirect(char menuin[])
}
}
+
/*
* Main "user interface" loop.
*/
diff --git a/tests/pjsua/mod_call.py b/tests/pjsua/mod_call.py
index 7081aed4..950a70da 100644
--- a/tests/pjsua/mod_call.py
+++ b/tests/pjsua/mod_call.py
@@ -53,19 +53,19 @@ def test_func(t):
callee.send("200")
# Wait until call is connected in both endpoints
- time.sleep(0.2)
+ ##time.sleep(0.2)
caller.expect(const.STATE_CONFIRMED)
callee.expect(const.STATE_CONFIRMED)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
- time.sleep(0.1)
+ ##time.sleep(0.1)
caller.sync_stdout()
callee.sync_stdout()
# Test that media is okay
- time.sleep(0.3)
+ ##time.sleep(0.3)
check_media(caller, callee)
check_media(callee, caller)
@@ -73,20 +73,20 @@ def test_func(t):
caller.send("H")
caller.expect("INVITE sip:")
callee.expect("INVITE sip:")
- caller.expect(const.MEDIA_HOLD)
callee.expect(const.MEDIA_HOLD)
+ caller.expect(const.MEDIA_HOLD)
# Synchronize stdout
caller.sync_stdout()
callee.sync_stdout()
# Release hold
- time.sleep(0.5)
+ ##time.sleep(0.5)
caller.send("v")
caller.expect("INVITE sip:")
callee.expect("INVITE sip:")
- 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")
+ caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
# Synchronize stdout
caller.sync_stdout()
@@ -112,12 +112,12 @@ def test_func(t):
callee.sync_stdout()
# Release hold
- time.sleep(0.1)
+ ##time.sleep(0.1)
callee.send("v")
callee.expect("INVITE sip:")
caller.expect("INVITE sip:")
- 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")
+ callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
# Synchronize stdout
caller.sync_stdout()
@@ -125,7 +125,7 @@ def test_func(t):
# Test that media is okay
# Wait for some time for ICE negotiation
- time.sleep(0.6)
+ ##time.sleep(0.6)
check_media(caller, callee)
check_media(callee, caller)
@@ -144,7 +144,7 @@ def test_func(t):
callee.sync_stdout()
# Test that media is okay
- time.sleep(0.1)
+ ##time.sleep(0.1)
check_media(caller, callee)
check_media(callee, caller)
@@ -160,7 +160,7 @@ def test_func(t):
callee.sync_stdout()
# Test that media is okay
- time.sleep(0.1)
+ ##time.sleep(0.1)
check_media(caller, callee)
check_media(callee, caller)
@@ -193,7 +193,7 @@ def test_func(t):
caller.sync_stdout()
# Test that media is still okay
- time.sleep(0.1)
+ ##time.sleep(0.1)
check_media(caller, callee)
check_media(callee, caller)
@@ -207,12 +207,12 @@ def test_func(t):
callee.sync_stdout()
# Test that media is still okay
- time.sleep(0.1)
+ ##time.sleep(0.1)
check_media(callee, caller)
check_media(caller, callee)
# Hangup call
- time.sleep(0.1)
+ ##time.sleep(0.1)
caller.send("h")
# Wait until calls are cleared in both endpoints
diff --git a/tests/pjsua/scripts-call/300_ice_1_1.py b/tests/pjsua/scripts-call/300_ice_1_1.py
index 456aa46b..0bf8cc15 100644
--- a/tests/pjsua/scripts-call/300_ice_1_1.py
+++ b/tests/pjsua/scripts-call/300_ice_1_1.py
@@ -6,7 +6,7 @@ from inc_cfg import *
test_param = TestParam(
"Callee=use ICE, caller=use ICE",
[
- InstanceParam("callee", "--null-audio --use-ice --max-calls=1", enable_buffer=True),
- InstanceParam("caller", "--null-audio --use-ice --max-calls=1", enable_buffer=True)
+ InstanceParam("callee", "--null-audio --use-ice --max-calls=1"),
+ InstanceParam("caller", "--null-audio --use-ice --max-calls=1")
]
)
diff --git a/tests/pjsua/scripts-call/305_ice_comp_1_2.py b/tests/pjsua/scripts-call/305_ice_comp_1_2.py
index 7580b204..5efeb0ce 100644
--- a/tests/pjsua/scripts-call/305_ice_comp_1_2.py
+++ b/tests/pjsua/scripts-call/305_ice_comp_1_2.py
@@ -6,7 +6,7 @@ from inc_cfg import *
test_param = TestParam(
"Callee=use ICE, caller=use ICE",
[
- InstanceParam("callee", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp", enable_buffer=True),
- InstanceParam("caller", "--null-audio --use-ice --max-calls=1", enable_buffer=True)
+ InstanceParam("callee", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp"),
+ InstanceParam("caller", "--null-audio --use-ice --max-calls=1")
]
)
diff --git a/tests/pjsua/scripts-call/305_ice_comp_2_1.py b/tests/pjsua/scripts-call/305_ice_comp_2_1.py
index a0ddaf78..304079e3 100644
--- a/tests/pjsua/scripts-call/305_ice_comp_2_1.py
+++ b/tests/pjsua/scripts-call/305_ice_comp_2_1.py
@@ -6,7 +6,7 @@ from inc_cfg import *
test_param = TestParam(
"Callee=use ICE, caller=use ICE",
[
- InstanceParam("callee", "--null-audio --use-ice --max-calls=1", enable_buffer=True),
- InstanceParam("caller", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp", enable_buffer=True)
+ InstanceParam("callee", "--null-audio --use-ice --max-calls=1"),
+ InstanceParam("caller", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp")
]
)
diff --git a/tests/pjsua/scripts-sendto/200_ice_success_2.py b/tests/pjsua/scripts-sendto/200_ice_success_2.py
index caf64b91..324fca0e 100644
--- a/tests/pjsua/scripts-sendto/200_ice_success_2.py
+++ b/tests/pjsua/scripts-sendto/200_ice_success_2.py
@@ -31,6 +31,5 @@ exclude = [
sendto_cfg = sip.SendtoCfg( "caller sends only one component",
pjsua_args=args, sdp=sdp, resp_code=200,
- resp_inc=include, resp_exc=exclude,
- enable_buffer = True)
+ resp_inc=include, resp_exc=exclude)
diff --git a/tests/pjsua/scripts-sendto/200_ice_success_3.py b/tests/pjsua/scripts-sendto/200_ice_success_3.py
index 2c741e44..307e6afe 100644
--- a/tests/pjsua/scripts-sendto/200_ice_success_3.py
+++ b/tests/pjsua/scripts-sendto/200_ice_success_3.py
@@ -30,6 +30,5 @@ exclude = [
sendto_cfg = sip.SendtoCfg( "caller sends two components without a=rtcp line",
pjsua_args=args, sdp=sdp, resp_code=200,
- resp_inc=include, resp_exc=exclude,
- enable_buffer = True)
+ resp_inc=include, resp_exc=exclude)
diff --git a/tests/pjsua/scripts-sendto/200_ice_success_4.py b/tests/pjsua/scripts-sendto/200_ice_success_4.py
index 0ec3849c..ede6a430 100644
--- a/tests/pjsua/scripts-sendto/200_ice_success_4.py
+++ b/tests/pjsua/scripts-sendto/200_ice_success_4.py
@@ -30,6 +30,5 @@ exclude = [
sendto_cfg = sip.SendtoCfg( "pjsua with --ice-no-rtcp ignores RTCP things in the SDP",
pjsua_args=args, sdp=sdp, resp_code=200,
- resp_inc=include, resp_exc=exclude,
- enable_buffer = True)
+ resp_inc=include, resp_exc=exclude)