From 879e017e1efde7f294b48ec4fd353bf3fbeed2fd Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 23 Sep 2015 12:15:22 +0200 Subject: [PATCH] tester: update bc_tester_utils and fix some tests - disable stderr for sipp because corrupting output is not great at all --- coreapi/chat.c | 4 +- mediastreamer2 | 2 +- tester/call_tester.c | 1 - tester/common/bc_tester_utils.c | 34 ++++++-- tester/complex_sip_call_tester.c | 3 +- tester/flexisip_tester.c | 46 +++++----- tester/message_tester.c | 137 +++++++++++++++--------------- tester/quality_reporting_tester.c | 2 - tester/tester.c | 3 +- 9 files changed, 124 insertions(+), 108 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index 0b11c6db5..a16a8132f 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -329,13 +329,13 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage char *content_type; const char *identity = NULL; msg->time = time(NULL); - if (lp_config_get_int(cr->lc->config, "sip", "chat_use_call_dialogs", 0)) { + if (lp_config_get_int(cr->lc->config, "sip", "chat_use_call_dialogs", 0) != 0) { if ((call = linphone_core_get_call_by_remote_address(cr->lc, cr->peer)) != NULL) { if (call->state == LinphoneCallConnected || call->state == LinphoneCallStreamsRunning || call->state == LinphoneCallPaused || call->state == LinphoneCallPausing || call->state == LinphoneCallPausedByRemote) { ms_message("send SIP msg through the existing call."); - op = call->op; + op = sal_op_ref(call->op); identity = linphone_core_find_best_identity(cr->lc, linphone_call_get_remote_address(call)); } } diff --git a/mediastreamer2 b/mediastreamer2 index 0780ed678..3cb6bc0d7 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 0780ed6788e5224617b62a34b190a1a7197cd50f +Subproject commit 3cb6bc0d706fe4b8471a1a5a0cc5c99053efea09 diff --git a/tester/call_tester.c b/tester/call_tester.c index def43133f..e9d776476 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -606,7 +606,6 @@ static void multiple_answers_call_with_media_relay(void) { 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) ); - end_call(marie1, pauline); end_call(marie2, pauline); linphone_core_manager_destroy(pauline); diff --git a/tester/common/bc_tester_utils.c b/tester/common/bc_tester_utils.c index 92920f0b9..aa3f533d6 100644 --- a/tester/common/bc_tester_utils.c +++ b/tester/common/bc_tester_utils.c @@ -181,24 +181,34 @@ static void test_start_message_handler(const CU_pTest pTest, const CU_pSuite pSu /*derivated from cunit*/ static void test_complete_message_handler(const CU_pTest pTest, const CU_pSuite pSuite, const CU_pFailureRecord pFailureList) { + //should be done properly using dynamically growing buffer + #define BUFFER_SIZE 2048 int i; + int space_left = BUFFER_SIZE - 1; int suite_index = bc_tester_suite_index(pSuite->pName); - char result[2048]={0}; - char buffer[2048]={0}; + char result[BUFFER_SIZE]={0}; + char buffer[BUFFER_SIZE]={0}; CU_pFailureRecord pFailure = pFailureList; snprintf(result, sizeof(result), "Suite [%s] Test [%s] %s in %lu secs", pSuite->pName, pTest->pName, pFailure ? "failed" : "passed", (unsigned long)(time(NULL) - test_start_time)); + space_left -= strlen(result); if (pFailure) { - for (i = 1 ; (NULL != pFailure) ; pFailure = pFailure->pNext, i++) { - snprintf(buffer, sizeof(buffer), "\n %d. %s:%u - %s", i, + for (i = 1; (NULL != pFailure) && space_left > 0; pFailure = pFailure->pNext, i++) { + snprintf(buffer, BUFFER_SIZE, "\n %d. %s:%u - %s", i, (NULL != pFailure->strFileName) ? pFailure->strFileName : "", pFailure->uiLineNumber, (NULL != pFailure->strCondition) ? pFailure->strCondition : ""); - strncat(result, buffer, strlen(buffer)); + strncat(result, buffer, space_left); + space_left -= strlen(buffer); } } - bc_tester_printf(bc_printf_verbosity_info,"%s", result); + + if (space_left <= 0) { + bc_tester_printf(bc_printf_verbosity_error,"%s (truncated!)", result); + } else { + bc_tester_printf(bc_printf_verbosity_info,"%s", result); + } if (test_suite[suite_index]->after_each) { test_suite[suite_index]->after_each(); } @@ -369,8 +379,16 @@ static void detect_res_prefix(const char* prog) { prefix = strdup("."); } else if (file_exists("..")) { prefix = strdup(".."); - } else if (progpath && file_exists(progpath)) { - prefix = strdup(progpath); + } else if (progpath) { + //for autotools, binary is in .libs/ subdirectory + char * progpath2 = malloc(sizeof(char)*(strlen(progpath)+strlen("/../")+1)); + sprintf(progpath2, "%s/../", progpath); + if (file_exists(progpath)) { + prefix = strdup(progpath); + } else if (file_exists(progpath2)) { + prefix = strdup(progpath2); + } + free(progpath2); } if (prefix != NULL) { diff --git a/tester/complex_sip_call_tester.c b/tester/complex_sip_call_tester.c index e610314d4..21b63b679 100644 --- a/tester/complex_sip_call_tester.c +++ b/tester/complex_sip_call_tester.c @@ -58,7 +58,8 @@ static FILE *sip_start(const char *senario, const char* dest_username, LinphoneA else dest = ms_strdup_printf("%s",linphone_address_get_domain(dest_addres)); - command = ms_strdup_printf("sipp -sf %s -s %s %s -trace_err -trace_msg -rtp_echo -m 1 -d 1000",senario,dest_username,dest); + //until errors logs are handled correctly and stop breaks output, they will be DISABLED + command = ms_strdup_printf("sipp -sf %s -s %s %s -trace_err -trace_msg -rtp_echo -m 1 -d 1000 2>/dev/null",senario,dest_username,dest); ms_message("Starting sipp commad [%s]",command); file = popen(command, "r"); diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 50b90abff..be4f60b29 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -222,38 +222,38 @@ static void call_forking_with_urgent_reply(void){ LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); MSList* lcs=ms_list_append(NULL,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); lcs=ms_list_append(lcs,marie2->lc); lcs=ms_list_append(lcs,marie3->lc); - linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); - linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); - linphone_core_set_user_agent(marie3->lc,"Natted Linphone",NULL); - linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); + if (linphone_core_media_encryption_supported(pauline->lc,LinphoneMediaEncryptionSRTP)) { + linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(marie3->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); - BC_ASSERT_TRUE(linphone_core_media_encryption_supported(pauline->lc,LinphoneMediaEncryptionSRTP)); - linphone_core_set_media_encryption(pauline->lc,LinphoneMediaEncryptionSRTP); - linphone_core_set_network_reachable(marie2->lc,FALSE); - linphone_core_set_network_reachable(marie3->lc,FALSE); - linphone_core_invite_address(pauline->lc,marie->identity); - /*pauline should hear ringback, after 5 seconds, when it will retry without SRTP*/ - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,9000)); - /*Marie should be ringing*/ - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,1000)); + linphone_core_set_media_encryption(pauline->lc,LinphoneMediaEncryptionSRTP); + linphone_core_set_network_reachable(marie2->lc,FALSE); + linphone_core_set_network_reachable(marie3->lc,FALSE); - /*marie accepts the call on its first device*/ - linphone_core_accept_call(marie->lc,linphone_core_get_current_call(marie->lc)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + linphone_core_invite_address(pauline->lc,marie->identity); + /*pauline should hear ringback, after 5 seconds, when it will retry without SRTP*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,9000)); + /*Marie should be ringing*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,1000)); - linphone_core_terminate_call(pauline->lc,linphone_core_get_current_call(pauline->lc)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); + /*marie accepts the call on its first device*/ + linphone_core_accept_call(marie->lc,linphone_core_get_current_call(marie->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + linphone_core_terminate_call(pauline->lc,linphone_core_get_current_call(pauline->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); + } linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); diff --git a/tester/message_tester.c b/tester/message_tester.c index 8493d9b65..2f0b64688 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -225,74 +225,6 @@ static void text_message_within_dialog(void) { linphone_core_manager_destroy(pauline); } -static void rtt_text_message(void) { - LinphoneChatRoom *pauline_chat_room, *marie_chat_room; - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - - LinphoneCallParams *marie_params = linphone_core_create_default_call_parameters(marie->lc); - LinphoneCall *pauline_call, *marie_call; - linphone_call_params_enable_realtime_text(marie_params,TRUE); - - BC_ASSERT_TRUE(call_with_caller_params(marie,pauline,marie_params)); - pauline_call=linphone_core_get_current_call(pauline->lc); - marie_call=linphone_core_get_current_call(marie->lc); - BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(pauline_call))); - - pauline_chat_room = linphone_call_get_chat_room(pauline_call); - BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); - if (pauline_chat_room) { - LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); - - linphone_chat_message_put_char(rtt_message,'B'); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,1)); - marie_chat_room = linphone_call_get_chat_room(marie_call); - BC_ASSERT_PTR_NOT_NULL(marie_chat_room); - BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'B',int,"%c"); - - linphone_chat_message_put_char(rtt_message,'L'); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,2)); - BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'L',int,"%c"); - - linphone_chat_message_put_char(rtt_message,'A'); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,3)); - BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'A',int,"%c"); - - linphone_chat_message_put_char(rtt_message,' '); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,4)); - BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),' ',int,"%c"); - - linphone_chat_message_put_char(rtt_message,'B'); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,5)); - BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'B',int,"%c"); - - linphone_chat_message_put_char(rtt_message,'L'); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,6)); - BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'L',int,"%c"); - - linphone_chat_message_put_char(rtt_message,'A'); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,7)); - BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'A',int,"%c"); - - /*Commit the message, triggers a NEW LINE in T.140 */ - linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); - - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); - { - LinphoneChatMessage * msg = marie->stat.last_received_chat_message; - BC_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity)); - BC_ASSERT_PTR_NOT_NULL(msg); - if (msg) { - BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(msg),"BLA BLA"); - } - } - } - - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - - static LinphoneAuthInfo* text_message_with_credential_from_auth_cb_auth_info; static void text_message_with_credential_from_auth_cb_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) { ms_message("text_message_with_credential_from_auth_cb:Auth info requested for user id [%s] at realm [%s]\n" @@ -1669,6 +1601,73 @@ static void file_transfer_io_error_after_destroying_chatroom() { file_transfer_io_error("https://www.linphone.org:444/lft.php", TRUE); } +static void rtt_text_message(void) { + LinphoneChatRoom *pauline_chat_room, *marie_chat_room; + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); + + LinphoneCallParams *marie_params = linphone_core_create_default_call_parameters(marie->lc); + LinphoneCall *pauline_call, *marie_call; + linphone_call_params_enable_realtime_text(marie_params,TRUE); + + BC_ASSERT_TRUE(call_with_caller_params(marie,pauline,marie_params)); + pauline_call=linphone_core_get_current_call(pauline->lc); + marie_call=linphone_core_get_current_call(marie->lc); + BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(pauline_call))); + + pauline_chat_room = linphone_call_get_chat_room(pauline_call); + BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); + if (pauline_chat_room) { + LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); + + linphone_chat_message_put_char(rtt_message,'B'); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,1)); + marie_chat_room = linphone_call_get_chat_room(marie_call); + BC_ASSERT_PTR_NOT_NULL(marie_chat_room); + BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'B',int,"%c"); + + linphone_chat_message_put_char(rtt_message,'L'); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,2)); + BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'L',int,"%c"); + + linphone_chat_message_put_char(rtt_message,'A'); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,3)); + BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'A',int,"%c"); + + linphone_chat_message_put_char(rtt_message,' '); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,4)); + BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),' ',int,"%c"); + + linphone_chat_message_put_char(rtt_message,'B'); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,5)); + BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'B',int,"%c"); + + linphone_chat_message_put_char(rtt_message,'L'); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,6)); + BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'L',int,"%c"); + + linphone_chat_message_put_char(rtt_message,'A'); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,7)); + BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),'A',int,"%c"); + + /*Commit the message, triggers a NEW LINE in T.140 */ + linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); + + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); + { + LinphoneChatMessage * msg = marie->stat.last_received_chat_message; + BC_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity)); + BC_ASSERT_PTR_NOT_NULL(msg); + if (msg) { + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(msg),"BLA BLA"); + } + } + } + end_call(marie, pauline); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + test_t message_tests[] = { {"Text message", text_message}, {"Text message within call dialog", text_message_within_dialog}, @@ -1706,7 +1705,7 @@ test_t message_tests[] = { {"Transfer not sent if host not found", file_transfer_not_sent_if_host_not_found}, {"Transfer not sent if url moved permanently", file_transfer_not_sent_if_url_moved_permanently}, {"Transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom}, - { "Real Time Text base", rtt_text_message}, + {"Real Time Text base", rtt_text_message}, }; test_suite_t message_test_suite = { diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index f7d9c08e6..abe9f9090 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -211,7 +211,6 @@ static void quality_reporting_not_sent_if_low_bandwidth() { BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); } linphone_call_params_destroy(marie_params); - end_call(marie, pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -336,7 +335,6 @@ static void quality_reporting_session_report_if_video_stopped() { linphone_call_params_destroy(marie_params); linphone_call_params_destroy(pauline_params); - end_call(marie, pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } diff --git a/tester/tester.c b/tester/tester.c index c9a5bc6fb..d6bbcbfeb 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -371,7 +371,7 @@ void linphone_core_manager_destroy(LinphoneCoreManager* mgr) { if (mgr->lc){ const char *record_file=linphone_core_get_record_file(mgr->lc); int unterminated_calls; - + if (!liblinphone_tester_keep_record_files && record_file){ if ((CU_get_number_of_failures()-mgr->number_of_cunit_error_at_creation)>0) { ms_message ("Test has failed, keeping recorded file [%s]",record_file); @@ -504,6 +504,7 @@ void liblinphone_tester_after_each() { BC_ASSERT_EQUAL(leaked_objects, 0, int, "%d"); if (leaked_objects > 0) { belle_sip_object_dump_active_objects(); + belle_sip_object_flush_active_objects(); ms_error("%d object%s leaked in latest test, please fix that!", leaked_objects, leaked_objects>1?"s were":"was"); } }