[Freeswitch-svn] [commit] r11936 - freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua
FreeSWITCH SVN
mikej at freeswitch.org
Thu Feb 12 13:03:16 PST 2009
Author: mikej
Date: Thu Feb 12 15:03:16 2009
New Revision: 11936
Log:
Tue Feb 10 08:10:41 CST 2009 Pekka Pessi <first.last at nokia.com>
* check_nua: run all the test cases with and without stack thread
Ignore-this: e1966c560fb8e32d5a2d292e5e8dbdc0
Better detect race conditions.
Modified:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c Thu Feb 12 15:03:16 2009
@@ -22,11 +22,12 @@
*
*/
-/**@CFILE check_session.c
+/**@CFILE check_etsi.c
*
- * @brief NUA module tests for SIP session handling
+ * @brief ETSI test cases
*
* @author Pekka Pessi <Pekka.Pessi at nokia.com>
+ * @author Paulo Pizarro
*
* @copyright (C) 2008 Nokia Corporation.
*/
@@ -83,6 +84,18 @@
d2 = su_home_new(sizeof *d2); fail_if(!d2);
}
+static void etsi_thread_setup(void)
+{
+ s2_nua_thread = 1;
+ etsi_setup();
+}
+
+static void etsi_threadless_setup(void)
+{
+ s2_nua_thread = 0;
+ etsi_setup();
+}
+
static void etsi_teardown(void)
{
s2_teardown_started("ETSI");
@@ -239,29 +252,33 @@
invite = invite_sent_by_nua(nh, TAG_END());
- s2_respond_to(invite, d1, SIP_404_NOT_FOUND, TAG_END());
+ s2_respond_to(invite, d1, 404, "First not found", TAG_END());
fail_unless(s2_check_event(nua_r_invite, 404));
fail_unless(s2_check_callstate(nua_callstate_terminated));
fail_unless(s2_check_request(SIP_METHOD_ACK));
- s2_fast_forward(5, s2->root);;
+ s2_fast_forward(5, s2->root);
- s2_respond_to(invite, d1, SIP_404_NOT_FOUND, TAG_END());
+ s2_respond_to(invite, d1, 404, "Not found after 5 seconds", TAG_END());
fail_unless(s2_check_request(SIP_METHOD_ACK));
- s2_fast_forward(5, s2->root);;
+ s2_fast_forward(5, s2->root);
- s2_respond_to(invite, d1, SIP_404_NOT_FOUND, TAG_END());
+ s2_respond_to(invite, d1, 404, "Not found after 10 seconds", TAG_END());
fail_unless(s2_check_request(SIP_METHOD_ACK));
- s2_fast_forward(21, s2->root);;
+ s2_fast_forward(21, s2->root);
- s2_respond_to(invite, d1, SIP_404_NOT_FOUND, TAG_END());
+ s2_respond_to(invite, d1, 404, "Not found after 31 seconds", TAG_END());
fail_unless(s2_check_request(SIP_METHOD_ACK));
- s2_fast_forward(1, s2->root);;
+ s2_fast_forward(5, s2->root);
- s2_respond_to(invite, d1, SIP_404_NOT_FOUND, TAG_END());
+ /* Wake up nua thread and let it time out INVITE transaction */
+ nua_set_params(s2->nua, TAG_END());
+ s2_check_event(nua_r_set_params, 0);
+
+ s2_respond_to(invite, d1, 404, "Not found after 32 seconds", TAG_END());
s2_free_message(invite);
fail_if(s2_check_request_timeout(SIP_METHOD_ACK, 500));
@@ -294,19 +311,24 @@
fail_unless(s2_check_callstate(nua_callstate_ready));
fail_unless(s2_check_request(SIP_METHOD_ACK));
- s2_fast_forward(5, s2->root);;
+ s2_fast_forward(5, s2->root);
respond_with_sdp(invite, d1, SIP_200_OK, TAG_END());
fail_unless(s2_check_request(SIP_METHOD_ACK));
- s2_fast_forward(5, s2->root);;
+ s2_fast_forward(5, s2->root);
respond_with_sdp(invite, d1, SIP_200_OK, TAG_END());
fail_unless(s2_check_request(SIP_METHOD_ACK));
- s2_fast_forward(21, s2->root);;
+ s2_fast_forward(21, s2->root);
respond_with_sdp(invite, d1, SIP_200_OK, TAG_END());
fail_unless(s2_check_request(SIP_METHOD_ACK));
- s2_fast_forward(1, s2->root);;
+ s2_fast_forward(5, s2->root);
+
+ /* Wake up nua thread and let it time out INVITE transaction */
+ nua_set_params(s2->nua, TAG_END());
+ s2_check_event(nua_r_set_params, 0);
+
respond_with_sdp(invite, d1, SIP_200_OK, TAG_END());
s2_free_message(invite);
fail_if(s2_check_request_timeout(SIP_METHOD_ACK, 500));
@@ -317,10 +339,13 @@
}
END_TEST
-TCase *sip_cc_oe_ce_tcase(void)
+TCase *sip_cc_oe_ce_tcase(int threading)
{
TCase *tc = tcase_create("6.1 - ETSI CC OE - Call Establishment");
- tcase_add_checked_fixture(tc, etsi_setup, etsi_teardown);
+
+ void (*setup)(void) = threading ? etsi_thread_setup : etsi_threadless_setup;
+
+ tcase_add_checked_fixture(tc, setup, etsi_teardown);
{
tcase_add_test(tc, SIP_CC_OE_CE_V_019);
tcase_add_test(tc, SIP_CC_OE_CE_TI_008);
@@ -331,7 +356,7 @@
/* ====================================================================== */
-void check_etsi_cases(Suite *suite)
+void check_etsi_cases(Suite *suite, int threading)
{
- suite_add_tcase(suite, sip_cc_oe_ce_tcase());
+ suite_add_tcase(suite, sip_cc_oe_ce_tcase(threading));
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c Thu Feb 12 15:03:16 2009
@@ -48,20 +48,28 @@
int main(int argc, char *argv[])
{
int failed = 0;
+ int threading;
- Suite *suite = suite_create("Unit tests for Sofia-SIP UA Engine");
SRunner *runner;
+ Suite *suite = suite_create("Unit tests for Sofia-SIP UA Engine");
+
s2_tester = "check_nua";
+
if (getenv("CHECK_NUA_VERBOSE"))
s2_start_stop = strtoul(getenv("CHECK_NUA_VERBOSE"), NULL, 10);
s2_select_tests(getenv("CHECK_NUA_CASES"));
- check_register_cases(suite);
- check_session_cases(suite);
- check_etsi_cases(suite);
- check_simple_cases(suite);
+ check_register_cases(suite, threading = 0);
+ check_simple_cases(suite, threading = 0);
+ check_session_cases(suite, threading = 0);
+ check_etsi_cases(suite, threading = 0);
+
+ check_register_cases(suite, threading = 1);
+ check_session_cases(suite, threading = 1);
+ check_etsi_cases(suite, threading = 1);
+ check_simple_cases(suite, threading = 1);
runner = srunner_create(suite);
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.h Thu Feb 12 15:03:16 2009
@@ -2,10 +2,10 @@
#include <s2check.h>
-void check_session_cases(Suite *suite);
-void check_register_cases(Suite *suite);
-void check_etsi_cases(Suite *suite);
-void check_simple_cases(Suite *suite);
+void check_session_cases(Suite *suite, int threading);
+void check_register_cases(Suite *suite, int threading);
+void check_etsi_cases(Suite *suite, int threading);
+void check_simple_cases(Suite *suite, int threading);
#endif
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c Thu Feb 12 15:03:16 2009
@@ -57,7 +57,19 @@
nua = s2_nua_setup("register", TAG_END());
}
-static void register_pingpong_setup(void)
+static void register_thread_setup(void)
+{
+ s2_nua_thread = 1;
+ register_setup();
+}
+
+static void register_threadless_setup(void)
+{
+ s2_nua_thread = 1;
+ register_setup();
+}
+
+static void pingpong_setup(void)
{
nua = s2_nua_setup("register with pingpong",
TPTAG_PINGPONG(20000),
@@ -66,6 +78,17 @@
tport_set_params(s2->tcp.tport, TPTAG_PONG2PING(1), TAG_END());
}
+static void pingpong_thread_setup(void)
+{
+ s2_nua_thread = 1;
+ pingpong_setup();
+}
+
+static void pingpong_threadless_setup(void)
+{
+ s2_nua_thread = 0;
+ pingpong_setup();
+}
static void register_teardown(void)
{
@@ -75,6 +98,17 @@
s2_nua_teardown();
}
+static void add_register_fixtures(TCase *tc, int threading, int pingpong)
+{
+ void (*setup)(void);
+
+ if (pingpong)
+ setup = threading ? pingpong_thread_setup : pingpong_threadless_setup;
+ else
+ setup = threading ? register_thread_setup : register_threadless_setup;
+
+ tcase_add_checked_fixture(tc, setup, register_teardown);
+}
/* ---------------------------------------------------------------------- */
@@ -335,7 +369,7 @@
s2_free_message(m);
su_root_step(s2->root, 20); su_root_step(s2->root, 20);
- s2_fast_forward(120, s2->root);; /* Default keepalive interval */
+ s2_fast_forward(120, s2->root); /* Default keepalive interval */
mark_point();
m = s2_wait_for_request(SIP_METHOD_OPTIONS);
@@ -346,7 +380,7 @@
s2_free_message(m);
su_root_step(s2->root, 20); su_root_step(s2->root, 20);
- s2_fast_forward(120, s2->root);; /* Default keepalive interval */
+ s2_fast_forward(120, s2->root); /* Default keepalive interval */
mark_point();
receive_natted = "received=4.255.255.10";
@@ -400,7 +434,7 @@
receive_natted = "received=4.255.255.10";
- s2_fast_forward(3600, s2->root);;
+ s2_fast_forward(3600, s2->root);
mark_point();
m = s2_wait_for_request(SIP_METHOD_REGISTER);
@@ -637,7 +671,7 @@
if (!tport_is_udp(m->tport)) /* Drop UDP */
break;
s2_free_message(m);
- s2_fast_forward(4, s2->root);;
+ s2_fast_forward(4, s2->root);
}
tcp = tport_ref(m->tport);
@@ -695,7 +729,7 @@
su_root_step(s2->root, 5);
su_root_step(s2->root, 5);
su_root_step(s2->root, 5);
- s2_fast_forward(5, s2->root);;
+ s2_fast_forward(5, s2->root);
}
}
@@ -705,11 +739,12 @@
/* ---------------------------------------------------------------------- */
-TCase *register_tcase(void)
+TCase *register_tcase(int threading)
{
TCase *tc = tcase_create("1 - REGISTER");
- /* Each testcase is run in different process */
- tcase_add_checked_fixture(tc, register_setup, register_teardown);
+
+ add_register_fixtures(tc, threading, 0);
+
{
tcase_add_test(tc, register_1_0_1);
tcase_add_test(tc, register_1_1_1);
@@ -727,21 +762,23 @@
return tc;
}
-TCase *pingpong_tcase(void)
+TCase *pingpong_tcase(int threading)
{
- TCase *tc = tcase_create("1 - REGISTER with PingPong");
- /* Each testcase is run in different process */
- tcase_add_checked_fixture(tc, register_pingpong_setup, register_teardown);
+ TCase *tc = tcase_create("1 - REGISTER (with PingPong)");
+
+ add_register_fixtures(tc, threading, 1);
+
{
tcase_add_test(tc, register_1_3_3_1);
}
+
tcase_set_timeout(tc, 10);
return tc;
}
-void check_register_cases(Suite *suite)
+void check_register_cases(Suite *suite, int threading)
{
- suite_add_tcase(suite, register_tcase());
- suite_add_tcase(suite, pingpong_tcase());
+ suite_add_tcase(suite, register_tcase(threading));
+ suite_add_tcase(suite, pingpong_tcase(threading));
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Thu Feb 12 15:03:16 2009
@@ -82,6 +82,12 @@
s2_register_setup();
}
+static void call_thread_setup(void)
+{
+ s2_nua_thread = 1;
+ call_setup();
+}
+
static void call_teardown(void)
{
s2_teardown_started("call");
@@ -96,6 +102,15 @@
s2_nua_teardown();
}
+static void
+add_call_fixtures(TCase *tc, int threading)
+{
+ if (threading)
+ tcase_add_checked_fixture(tc, call_thread_setup, call_teardown);
+ else
+ tcase_add_checked_fixture(tc, call_setup, call_teardown);
+}
+
static void save_sdp_to_soa(struct message *message)
{
sip_payload_t *pl;
@@ -666,10 +681,10 @@
END_TEST
-TCase *invite_tcase(void)
+TCase *invite_tcase(int threading)
{
TCase *tc = tcase_create("2.1 - Basic INVITE");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+ add_call_fixtures(tc, threading);
{
tcase_add_test(tc, call_2_1_1);
tcase_add_test(tc, call_2_1_2_1);
@@ -986,10 +1001,10 @@
}
END_TEST
-TCase *cancel_tcase(void)
+TCase *cancel_tcase(int threading)
{
TCase *tc = tcase_create("2.2 - CANCEL");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+ add_call_fixtures(tc, threading);
tcase_add_test(tc, cancel_2_2_1);
tcase_add_test(tc, cancel_2_2_2);
@@ -1054,11 +1069,11 @@
SIPTAG_REQUIRE_STR("timer"),
TAG_END());
- s2_fast_forward(300, s2->root);;
+ s2_fast_forward(300, s2->root);
ack = invite_timer_round(nh, "300;refresher=uac", rr);
fail_if(ack->sip->sip_route &&
su_strmatch(ack->sip->sip_route->r_url->url_user, "record"));
- s2_fast_forward(300, s2->root);;
+ s2_fast_forward(300, s2->root);
invite_timer_round(nh, "300;refresher=uac", NULL);
bye_by_nua(nh, TAG_END());
@@ -1082,9 +1097,9 @@
SIPTAG_REQUIRE_STR("timer"),
TAG_END());
- s2_fast_forward(300, s2->root);;
+ s2_fast_forward(300, s2->root);
invite_timer_round(nh, "300", NULL);
- s2_fast_forward(300, s2->root);;
+ s2_fast_forward(300, s2->root);
invite_timer_round(nh, "300", NULL);
bye_by_nua(nh, TAG_END());
@@ -1095,10 +1110,10 @@
-TCase *session_timer_tcase(void)
+TCase *session_timer_tcase(int threading)
{
TCase *tc = tcase_create("2.3 - Session timers");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+ add_call_fixtures(tc, threading);
{
tcase_add_test(tc, call_2_3_1);
tcase_add_test(tc, call_2_3_2);
@@ -1227,10 +1242,10 @@
}
END_TEST
-TCase *invite_100rel_tcase(void)
+TCase *invite_100rel_tcase(int threading)
{
TCase *tc = tcase_create("2.4 - INVITE with 100rel");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+ add_call_fixtures(tc, threading);
{
tcase_add_test(tc, call_2_4_1);
tcase_add_test(tc, call_2_4_2);
@@ -1459,10 +1474,10 @@
}
END_TEST
-TCase *invite_precondition_tcase(void)
+TCase *invite_precondition_tcase(int threading)
{
TCase *tc = tcase_create("2.5 - Call with preconditions");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+ add_call_fixtures(tc, threading);
{
tcase_add_test(tc, call_2_5_1);
tcase_add_test(tc, call_2_5_2);
@@ -1551,7 +1566,7 @@
/* We get nua_r_invite with 100 trying (and 500 in sip->sip_status) */
fail_unless(s2_check_event(nua_r_invite, 100));
- s2_fast_forward(10, s2->root);;
+ s2_fast_forward(10, s2->root);
fail_unless(s2_check_callstate(nua_callstate_calling));
@@ -1605,7 +1620,7 @@
fail_unless(s2_check_event(nua_i_ack, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
- s2_fast_forward(10, s2->root);;
+ s2_fast_forward(10, s2->root);
nua_set_hparams(nh, NUTAG_REFRESH_WITHOUT_SDP(1), TAG_END());
fail_unless(s2_check_event(nua_r_set_params, 200));
@@ -1673,11 +1688,11 @@
}
END_TEST
-TCase *reinvite_tcase(void)
+TCase *reinvite_tcase(int threading)
{
TCase *tc = tcase_create("2.6 - re-INVITEs");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+ add_call_fixtures(tc, threading);
{
tcase_add_test(tc, call_2_6_1);
tcase_add_test(tc, call_2_6_2);
@@ -1752,7 +1767,7 @@
if (i == 3)
break;
fail_unless(s2_check_event(nua_r_invite, 100));
- s2_fast_forward(5, s2->root);;
+ s2_fast_forward(5, s2->root);
}
fail_unless(s2_check_event(nua_r_invite, 500));
@@ -1822,7 +1837,7 @@
if (i == 3)
break;
fail_unless(s2_check_event(nua_r_invite, 100));
- s2_fast_forward(5, s2->root);;
+ s2_fast_forward(5, s2->root);
}
fail_unless(s2_check_event(nua_r_invite, 500));
@@ -1869,10 +1884,10 @@
END_TEST
-TCase *invite_error_tcase(void)
+TCase *invite_error_tcase(int threading)
{
TCase *tc = tcase_create("3 - Call Errors");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+ add_call_fixtures(tc, threading);
{
tcase_add_test(tc, call_3_1_1);
tcase_add_test(tc, call_3_1_2);
@@ -2344,7 +2359,7 @@
SIPTAG_REQUIRE_STR("timer"),
TAG_END());
- s2_fast_forward(300, s2->root);;
+ s2_fast_forward(300, s2->root);
invite_timer_round(nh, "300", NULL);
nua_bye(nh, TAG_END());
@@ -2357,7 +2372,7 @@
s2_free_message(bye);
fail_unless(s2_check_event(nua_r_bye, 407));
- s2_fast_forward(300, s2->root);;
+ s2_fast_forward(300, s2->root);
nua_authenticate(nh, NUTAG_AUTH("Digest:\"s2test\":abc:abc"), TAG_END());
bye = s2_wait_for_request(SIP_METHOD_BYE);
@@ -2388,10 +2403,10 @@
SIPTAG_REQUIRE_STR("timer"),
TAG_END());
- s2_fast_forward(300, s2->root);;
+ s2_fast_forward(300, s2->root);
invite_timer_round(nh, "300", NULL);
- s2_fast_forward(140, s2->root);;
+ s2_fast_forward(140, s2->root);
nua_bye(nh, TAG_END());
@@ -2403,7 +2418,7 @@
s2_free_message(bye);
fail_unless(s2_check_event(nua_r_bye, 407));
- s2_fast_forward(160, s2->root);;
+ s2_fast_forward(160, s2->root);
nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END());
bye = s2_wait_for_request(SIP_METHOD_BYE);
@@ -2418,10 +2433,10 @@
}
END_TEST
-TCase *termination_tcase(void)
+TCase *termination_tcase(int threading)
{
TCase *tc = tcase_create("4 - Call Termination");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+ add_call_fixtures(tc, threading);
{
tcase_add_test(tc, bye_4_1_1);
tcase_add_test(tc, bye_4_1_2);
@@ -2928,11 +2943,11 @@
}
END_TEST
-TCase *destroy_tcase(void)
+static TCase *destroy_tcase(int threading)
{
TCase *tc = tcase_create("4.3 - Destroying Handle");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+ add_call_fixtures(tc, threading);
{
tcase_add_test(tc, destroy_4_3_1);
@@ -3056,7 +3071,7 @@
END_TEST
#endif
-TCase *options_tcase(void)
+TCase *options_tcase(int threading)
{
TCase *tc = tcase_create("5 - OPTIONS, etc");
@@ -3068,7 +3083,6 @@
return tc;
}
-
static void options_setup(void)
{
s2_nua_thread = 1;
@@ -3096,13 +3110,14 @@
s2_setup_logs(0);
tport_set_params(s2->master, TPTAG_LOG(0), TAG_END());
}
-
END_TEST
-TCase *empty_tcase(void)
+TCase *empty_tcase(int threading)
{
TCase *tc = tcase_create("0 - Empty");
- tcase_add_checked_fixture(tc, call_setup, call_teardown);
+
+ add_call_fixtures(tc, threading);
+
tcase_add_test(tc, empty);
return tc;
@@ -3110,19 +3125,19 @@
/* ====================================================================== */
-void check_session_cases(Suite *suite)
+void check_session_cases(Suite *suite, int threading)
{
- suite_add_tcase(suite, invite_tcase());
- suite_add_tcase(suite, cancel_tcase());
- suite_add_tcase(suite, session_timer_tcase());
- suite_add_tcase(suite, invite_100rel_tcase());
- suite_add_tcase(suite, invite_precondition_tcase());
- suite_add_tcase(suite, reinvite_tcase());
- suite_add_tcase(suite, invite_error_tcase());
- suite_add_tcase(suite, termination_tcase());
- suite_add_tcase(suite, destroy_tcase());
- suite_add_tcase(suite, options_tcase());
+ suite_add_tcase(suite, invite_tcase(threading));
+ suite_add_tcase(suite, cancel_tcase(threading));
+ suite_add_tcase(suite, session_timer_tcase(threading));
+ suite_add_tcase(suite, invite_100rel_tcase(threading));
+ suite_add_tcase(suite, invite_precondition_tcase(threading));
+ suite_add_tcase(suite, reinvite_tcase(threading));
+ suite_add_tcase(suite, invite_error_tcase(threading));
+ suite_add_tcase(suite, termination_tcase(threading));
+ suite_add_tcase(suite, destroy_tcase(threading));
+ suite_add_tcase(suite, options_tcase(threading));
if (0) /* Template */
- suite_add_tcase(suite, empty_tcase());
+ suite_add_tcase(suite, empty_tcase(threading));
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Thu Feb 12 15:03:16 2009
@@ -95,6 +95,22 @@
s2_nua_teardown();
}
+static void simple_thread_setup(void)
+{
+ s2_nua_thread = 1;
+ s2_dialog_setup();
+}
+
+static void simple_threadless_setup(void)
+{
+ s2_nua_thread = 0;
+ s2_dialog_setup();
+}
+
+static void simple_teardown(void)
+{
+ s2_dialog_teardown();
+}
static char const presence_open[] =
"<?xml version='1.0' encoding='UTF-8'?>\n"
@@ -290,7 +306,7 @@
s2_free_event(notify);
/* Wait for refresh */
- s2_fast_forward(600, s2->root);;
+ s2_fast_forward(600, s2->root);
subscribe = s2_wait_for_request(SIP_METHOD_SUBSCRIBE);
s2_respond_to(subscribe, dialog, SIP_200_OK,
SIPTAG_EXPIRES_STR("600"),
@@ -377,7 +393,7 @@
su_home_unref((void *)dialog), dialog = su_home_new(sizeof *dialog); fail_if(!dialog);
- s2_fast_forward(5, s2->root);;
+ s2_fast_forward(5, s2->root);
/* nua re-establishes the subscription */
notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END());
s2_free_event(notify);
@@ -391,10 +407,14 @@
}
END_TEST
-TCase *subscribe_tcase(void)
+TCase *subscribe_tcase(int threading)
{
TCase *tc = tcase_create("6.1 - Basic SUBSCRIBE_");
- tcase_add_checked_fixture(tc, s2_dialog_setup, s2_dialog_teardown);
+ void (*simple_setup)(void);
+
+ simple_setup = threading ? simple_thread_setup : simple_threadless_setup;
+ tcase_add_checked_fixture(tc, simple_setup, simple_teardown);
+
{
tcase_add_test(tc, subscribe_6_1_1);
tcase_add_test(tc, subscribe_6_1_2);
@@ -460,7 +480,7 @@
fail_unless(s2_check_substate(event, nua_substate_embryonic));
s2_free_event(event);
- s2_fast_forward(600, s2->root);;
+ s2_fast_forward(600, s2->root);
event = s2_wait_for_event(nua_i_notify, 408); fail_if(!event);
fail_unless(s2_check_substate(event, nua_substate_terminated));
@@ -471,10 +491,14 @@
END_TEST
-TCase *fetch_tcase(void)
+TCase *fetch_tcase(int threading)
{
TCase *tc = tcase_create("6.2 - Event fetch");
- tcase_add_checked_fixture(tc, s2_dialog_setup, s2_dialog_teardown);
+ void (*simple_setup)(void);
+
+ simple_setup = threading ? simple_thread_setup : simple_threadless_setup;
+ tcase_add_checked_fixture(tc, simple_setup, simple_teardown);
+
{
tcase_add_test(tc, fetch_6_2_1);
tcase_add_test(tc, fetch_6_2_2);
@@ -500,10 +524,14 @@
END_TEST
-static TCase *empty_tcase(void)
+static TCase *empty_tcase(int threading)
{
TCase *tc = tcase_create("0 - Empty");
- tcase_add_checked_fixture(tc, s2_dialog_setup, s2_dialog_teardown);
+ void (*simple_setup)(void);
+
+ simple_setup = threading ? simple_thread_setup : simple_threadless_setup;
+ tcase_add_checked_fixture(tc, simple_setup, simple_teardown);
+
tcase_add_test(tc, empty);
return tc;
@@ -511,12 +539,12 @@
/* ====================================================================== */
-void check_simple_cases(Suite *suite)
+void check_simple_cases(Suite *suite, int threading)
{
- suite_add_tcase(suite, subscribe_tcase());
- suite_add_tcase(suite, fetch_tcase());
+ suite_add_tcase(suite, subscribe_tcase(threading));
+ suite_add_tcase(suite, fetch_tcase(threading));
if (0) /* Template */
- suite_add_tcase(suite, empty_tcase());
+ suite_add_tcase(suite, empty_tcase(threading));
}
More information about the Freeswitch-svn
mailing list