Commit cd0783c2 authored by Simon Morlat's avatar Simon Morlat
Browse files

ensure that stun server is resolved before starting a test, and assert that it is resolved or not.

parent 6077331d
......@@ -675,17 +675,17 @@ static void multiple_answers_call_with_media_relay(void) {
BC_ASSERT_PTR_NOT_NULL_FATAL(call2);
BC_ASSERT_EQUAL( linphone_core_accept_call(marie1->lc, call1), 0, int, "%d");
ms_sleep(1); /*sleep to make sure that the 200OK of marie1 reaches the server first*/
BC_ASSERT_EQUAL( linphone_core_accept_call(marie2->lc, call2), 0, int, "%d");
BC_ASSERT_TRUE( wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) );
BC_ASSERT_TRUE( wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) );
BC_ASSERT_TRUE( wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallEnd, 1, 2000) );
/*the server will send a bye to marie2, as is 200Ok arrived second*/
BC_ASSERT_TRUE( wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallEnd, 1, 4000) );
end_call(marie1, pauline);
linphone_core_manager_destroy(pauline);
linphone_core_manager_destroy(marie1);
linphone_core_manager_destroy(marie2);
ms_list_free_with_data(lcs, (void (*)(void*))linphone_core_manager_destroy);
}
static void call_with_specified_codec_bitrate(void) {
......@@ -1142,9 +1142,6 @@ static void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManag
}
static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay) {
// Force STUN server resolution to prevent DNS resolution issues on some machines
linphone_core_get_stun_server_addrinfo(pauline->lc);
linphone_core_get_stun_server_addrinfo(marie->lc);
linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL);
linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL);
......@@ -2503,10 +2500,6 @@ static void _call_with_ice_video(LinphoneVideoPolicy caller_policy, LinphoneVide
bool_t call_ok;
unsigned int nb_media_starts = 1;
/*force resolution of stun server before starting the test*/
linphone_core_get_stun_server_addrinfo(pauline->lc);
linphone_core_get_stun_server_addrinfo(marie->lc);
linphone_core_set_video_policy(pauline->lc, &caller_policy);
linphone_core_set_video_policy(marie->lc, &callee_policy);
linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce);
......@@ -2597,10 +2590,6 @@ static void call_with_ice_video_and_rtt(void) {
LinphoneCallParams *params = NULL;
LinphoneCall *marie_call = NULL;
/*force resolution of stun server before starting the test*/
linphone_core_get_stun_server_addrinfo(pauline->lc);
linphone_core_get_stun_server_addrinfo(marie->lc);
linphone_core_set_video_policy(pauline->lc, &policy);
linphone_core_set_video_policy(marie->lc, &policy);
linphone_core_enable_video_capture(marie->lc, TRUE);
......
......@@ -365,34 +365,9 @@ static void simple_encrypted_conference_with_ice(LinphoneMediaEncryption mode) {
if (linphone_core_media_encryption_supported(marie->lc,mode)) {
linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
linphone_core_set_stun_server(marie->lc,"stun.linphone.org");
linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
linphone_core_set_stun_server(pauline->lc,"stun.linphone.org");
linphone_core_set_firewall_policy(laure->lc,LinphonePolicyUseIce);
linphone_core_set_stun_server(laure->lc,"stun.linphone.org");
/*work around a to avoid stun resolution to be initiate in call_received callback leading a mainloop reentrency*/
/*
belle_sip_main_loop_iterate() at belle_sip_loop.c:369
belle_sip_main_loop_run [inlined]() at belle_sip_loop.c:478
belle_sip_main_loop_sleep() at belle_sip_loop.c:490
sal_iterate() at sal_impl.c:745
linphone_core_get_stun_server_addrinfo() at misc.c:585
linphone_core_gather_ice_candidates() at misc.c:610
linphone_call_prepare_ice() at linphonecall.c:1 906
linphone_call_new_incoming() at linphonecall.c:1 101
call_received() at callbacks.c:347
...
linphone_core_iterate() at linphonecore.c:2 620
...
linphone_core_set_stun_server() initiates an asynchronous resolution, but it needs a few iteration before it is completed.
By calling private function linphone_core_get_stun_server_addrinfo() we make sure to wait that the resolution is done before the
test calls actually start.
*/
linphone_core_get_stun_server_addrinfo(marie->lc);
linphone_core_get_stun_server_addrinfo(pauline->lc);
linphone_core_get_stun_server_addrinfo(laure->lc);
/**/
linphone_core_set_media_encryption(marie->lc,mode);
......
......@@ -221,6 +221,18 @@ bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) {
else return TRUE;
}
bool_t wait_for_stun_resolution(LinphoneCoreManager *m) {
MSTimeSpec start;
int timeout_ms = 10000;
liblinphone_tester_clock_start(&start);
while (m->lc->net_conf.stun_addrinfo == NULL && !liblinphone_tester_clock_elapsed(&start,timeout_ms)) {
linphone_core_iterate(m->lc);
ms_usleep(20000);
}
return m->lc->net_conf.stun_addrinfo != NULL;
}
static void set_codec_enable(LinphoneCore* lc,const char* type,int rate,bool_t enable) {
MSList* codecs=ms_list_copy(linphone_core_get_audio_codecs(lc));
MSList* codecs_it;
......@@ -353,6 +365,11 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies
mgr->identity = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy));
linphone_address_clean(mgr->identity);
}
if (linphone_core_get_stun_server(mgr->lc) != NULL){
/*before we go, ensure that the stun server is resolved, otherwise all ice related test will fail*/
BC_ASSERT_TRUE(wait_for_stun_resolution(mgr));
}
}
LinphoneCoreManager* linphone_core_manager_new( const char* rc_file) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment