From b1ae7bf0287497e16cea83944b70cb2d866643d5 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 17 Sep 2015 11:06:35 +0200 Subject: [PATCH] tester: add before_each and after_each functions to allow init/cleanup of tests individually --- mediastreamer2 | 2 +- tester/call_tester.c | 165 +++++++++++++--------------- tester/common/bc_tester_utils.c | 85 ++++++++------ tester/common/bc_tester_utils.h | 21 ++-- tester/complex_sip_call.c | 26 ++--- tester/dtmf_tester.c | 9 +- tester/eventapi_tester.c | 10 +- tester/flexisip_tester.c | 12 +- tester/liblinphone_tester.h | 2 +- tester/log_collection_tester.c | 11 +- tester/message_tester.c | 10 +- tester/multi_call_tester.c | 9 +- tester/multicast_call_tester.c | 10 +- tester/offeranswer_tester.c | 11 +- tester/player_tester.c | 9 +- tester/presence_tester.c | 10 +- tester/proxy_config_tester.c | 9 +- tester/quality_reporting_tester.c | 10 +- tester/register_tester.c | 10 +- tester/remote_provisioning_tester.c | 10 +- tester/setup_tester.c | 10 +- tester/stun_tester.c | 9 +- tester/tester.c | 6 +- tester/tunnel_tester.c | 9 +- tester/upnp_tester.c | 9 +- tester/video_tester.c | 18 +-- 26 files changed, 202 insertions(+), 300 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index d24bc5aae..a4067c188 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit d24bc5aae19921183b19e0f7bdf8378b5f75109f +Subproject commit a4067c188fab858ce829c3868a2e1d7d316fc531 diff --git a/tester/call_tester.c b/tester/call_tester.c index fd42f0e86..ce7d9a4ac 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -1274,14 +1274,13 @@ static void call_paused_by_both() { linphone_core_pause_call(marie->lc, call_marie); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausing,1)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPaused,1)); - + wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); /*pauline must stay in paused state*/ BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallPaused, 1, int, "%i"); check_media_direction(pauline, call_pauline, lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionInvalid); check_media_direction(marie, call_marie, lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionInvalid); - - + /*now pauline wants to resume*/ linphone_core_resume_call(pauline->lc, call_pauline); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallResuming,1)); @@ -1289,7 +1288,7 @@ static void call_paused_by_both() { /*Marie must stay in paused state*/ wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallPaused, 1, int, "%i"); - + /*now marie wants to resume also*/ linphone_core_resume_call(marie->lc, call_marie); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallResuming,1)); @@ -4208,7 +4207,7 @@ static void video_call_with_re_invite_inactive_followed_by_re_invite_base(Linpho linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv); linphone_core_update_call(marie->lc,linphone_core_get_current_call(marie->lc),params); linphone_call_params_destroy(params); - + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); @@ -4357,40 +4356,40 @@ static void simple_stereo_call_opus(void){ } static void call_with_complex_late_offering(void){ - LinphoneCallParams *params; + LinphoneCallParams *params; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCall* call_pauline; LinphoneCall* call_marie; LinphoneVideoPolicy vpol = {TRUE, TRUE}; bool_t call_ok; - + linphone_core_enable_video(pauline->lc, TRUE, TRUE); linphone_core_enable_video(marie->lc, TRUE, TRUE); linphone_core_set_video_policy(pauline->lc, &vpol); linphone_core_set_video_policy(marie->lc, &vpol); linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); - + BC_ASSERT_TRUE((call_ok=call(pauline,marie))); if (!call_ok) goto end; - + call_pauline = linphone_core_get_current_call(pauline->lc); call_marie = linphone_core_get_current_call(marie->lc); - + //Invite inactive Audio/video (Marie pause Pauline) ms_message("CONTEXT: Marie sends INVITE with SDP with all streams inactive"); params=linphone_core_create_call_params(marie->lc,call_marie); linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionInactive); linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); - + linphone_core_update_call(marie->lc, call_marie ,params); linphone_call_params_destroy(params); - + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,1)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); - + //Marie sends INVITE without SDP ms_message("CONTEXT: Marie sends INVITE without SDP for setting streams in send-only mode"); linphone_core_enable_sdp_200_ack(marie->lc,TRUE); @@ -4404,7 +4403,7 @@ static void call_with_complex_late_offering(void){ BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,2)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,2)); - + linphone_core_enable_sdp_200_ack(marie->lc,FALSE); //Pauline pause Marie @@ -4413,7 +4412,7 @@ static void call_with_complex_late_offering(void){ BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPaused,1)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1)); - + //Pauline resume Marie ms_message("CONTEXT: Pauline resumes the call"); wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); @@ -4421,22 +4420,22 @@ static void call_with_complex_late_offering(void){ BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,4)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallResuming,1)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,3)); - + wait_for_until(pauline->lc, marie->lc, NULL, 0, 2000); - + //Marie invite inactive Audio/Video ms_message("CONTEXT: Marie sends INVITE with SDP with all streams inactive"); params=linphone_core_create_call_params(marie->lc,call_marie); linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionInactive); linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); - + linphone_core_update_call(marie->lc, call_marie,params); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,3)); linphone_call_params_destroy(params); - + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,4)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,5)); - + //Marie sends INVITE without SDP ms_message("CONTEXT: Marie sends INVITE without SDP in the purpose of re-enabling streams in sendrecv mode"); linphone_core_enable_sdp_200_ack(marie->lc,TRUE); @@ -4449,17 +4448,15 @@ static void call_with_complex_late_offering(void){ BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,5)); - + linphone_core_enable_sdp_200_ack(marie->lc,FALSE); - - + end_call(marie,pauline); - + end: - + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); - } static void simple_mono_call_opus(void){ @@ -4628,26 +4625,26 @@ static int rtptm_on_send(RtpTransportModifier *rtptm, mblk_t *msg) { int i = 0; unsigned char *src; int size = 0; - + if (rtp->version == 0) { // This is probably a STUN packet, so don't count it (oRTP won't) and don't encrypt it either return msgdsize(msg); } - + // Mediastream can create a mblk_t with only the RTP header and setting the b_cont pointer to the actual RTP content buffer // In this scenario, the result of rtp_get_payload will be 0, and we won't be able to do our XOR encryption on the payload // The call to msgpullup will trigger a memcpy of the header and the payload in the same buffer in the msg mblk_t msgpullup(msg, -1); // Now that the mblk_t buffer directly contains the header and the payload, we can get the size of the payload and a pointer to it's start (we don't encrypt the RTP header) size = rtp_get_payload(msg, &src); - + // Just for fun, let's do a XOR encryption for (i = 0; i < size; i++) { src[i] ^= (unsigned char) XOR_KEY[i % strlen(XOR_KEY)]; } - + data->packetSentCount += 1; - + /* /!\ DO NOT RETURN 0 or the packet will never leave /!\ */ return msgdsize(msg); } @@ -4660,23 +4657,23 @@ static int rtptm_on_receive(RtpTransportModifier *rtptm, mblk_t *msg) { int i = 0; unsigned char *src; int size = 0; - + if (rtp->version == 0) { // This is probably a STUN packet, so don't count it (oRTP won't) and don't decrypt it either return msgdsize(msg); } - + // On the receiving side, there is no need for a msgpullup, the mblk_t contains the header and the payload in the same buffer // We just ask for the size and a pointer to the payload buffer size = rtp_get_payload(msg, &src); - + // Since we did a XOR encryption on the send side, we have to do it again to decrypt the payload for (i = 0; i < size; i++) { src[i] ^= (unsigned char) XOR_KEY[i % strlen(XOR_KEY)]; } - + data->packetReceivedCount += 1; - + /* /!\ DO NOT RETURN 0 or the packet will be dropped /!\ */ return msgdsize(msg); } @@ -4690,7 +4687,7 @@ static void rtptm_destroy(RtpTransportModifier *rtptm) { // This is the callback called when the state of the call change void static call_state_changed_4(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg) { int i = 0; - + // To add a custom RTP transport modifier, we have to do it before the call is running, but after the RTP session is created. if (cstate == LinphoneCallIncomingReceived || cstate == LinphoneCallOutgoingProgress) { RtpTransport *rtpt = NULL; @@ -4700,16 +4697,16 @@ void static call_state_changed_4(LinphoneCore *lc, LinphoneCall *call, LinphoneC rtptm->t_process_on_send = rtptm_on_send; rtptm->t_process_on_receive = rtptm_on_receive; rtptm->t_destroy = rtptm_destroy; - + // Here we iterate on each meta rtp transport available for (i = 0; i < linphone_call_get_stream_count(call); i++) { MSFormatType type; - + rtpt = linphone_call_get_meta_rtp_transport(call, i); - + // If we wanted, we also could get the RTCP meta transports like this: // rtcpt = linphone_call_get_meta_rtcp_transport(call, i); - + // If you want to know which stream meta RTP transport is the current one, you can use type = linphone_call_get_stream_type(call, i); // Currently there is only MSAudio and MSVideo types, but this could change later @@ -4719,7 +4716,6 @@ void static call_state_changed_4(LinphoneCore *lc, LinphoneCall *call, LinphoneC } else if (type == MSVideo) { // Because the call of this test is audio only, we don't have to append our modifier to the meta RTP transport from the video stream } - } // We save the pointer to our RtpTransportModifier in the call user_data to be able to get to it later call->user_data = rtptm; @@ -4745,7 +4741,7 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_file_player", "wav"); // File to record the received sound double similar = 1; // The factor of similarity between the played file and the one recorded const double threshold = 0.85; // Minimum similarity value to consider the record file equal to the one sent - + // We create a new vtable to listen only to the call state changes, in order to plug our RTP Transport Modifier when the call will be established v_table = linphone_core_v_table_new(); v_table->call_state_changed = call_state_changed_4; @@ -4753,11 +4749,11 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { v_table = linphone_core_v_table_new(); v_table->call_state_changed = call_state_changed_4; linphone_core_add_listener(marie->lc,v_table); - + if (recordTest) { // When we do the record test, we need a file player to play the content of a sound file /*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/ unlink(recordpath); - + linphone_core_use_files(pauline->lc,TRUE); linphone_core_set_play_file(pauline->lc,NULL); linphone_core_set_record_file(pauline->lc,NULL); @@ -4772,16 +4768,16 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { BC_ASSERT_TRUE((call_ok=call(pauline,marie))); if (!call_ok) goto end; - + // Ref the call to keep the pointer valid even after the call is release call_pauline = linphone_call_ref(linphone_core_get_current_call(pauline->lc)); call_marie = linphone_call_ref(linphone_core_get_current_call(marie->lc)); - + // This is for the pause/resume test, we don't do it in the call record test to be able to check the recorded call matches the file played if (pauseResumeTest) { // This only wait for 3 seconds in order to generate traffic for the test wait_for_until(pauline->lc, marie->lc, NULL, 5, 3000); - + linphone_core_pause_call(pauline->lc,call_pauline); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallPausing, 1)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallPausedByRemote, 1)); @@ -4794,7 +4790,7 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); - + /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/ wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000); @@ -4817,10 +4813,10 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { wait_for_until(pauline->lc, marie->lc, NULL, 0, 1000); end_call(pauline, marie); - + // Now we compute a similarity factor between the original file and the one we recorded on the callee side BC_ASSERT_EQUAL(ms_audio_diff(hellopath, recordpath, &similar, &audio_cmp_params, NULL, NULL), 0, int, "%d"); - + BC_ASSERT_GREATER(similar, threshold, double, "%g"); BC_ASSERT_LOWER(similar, 1.0, double, "%g"); if (similar >= threshold && similar <= 1.0) { @@ -4830,17 +4826,17 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { } else { // This only wait for 3 seconds in order to generate traffic for the test wait_for_until(pauline->lc, marie->lc, NULL, 5, 3000); - + // We termine the call and check the stats to see if the call is correctly ended on both sides end_call(pauline, marie); } - + // Now we can go fetch our custom structure and check the number of packets sent/received is the same on both sides rtptm_marie = (RtpTransportModifier *)call_marie->user_data; rtptm_pauline = (RtpTransportModifier *)call_pauline->user_data; data_marie = (RtpTransportModifierData *)rtptm_marie->data; data_pauline = (RtpTransportModifierData *)rtptm_pauline->data; - + BC_ASSERT_PTR_NOT_NULL(data_marie); BC_ASSERT_PTR_NOT_NULL(data_pauline); ms_message("Marie sent %i RTP packets and received %i (through our modifier)", (int)data_marie->packetSentCount, (int)data_marie->packetReceivedCount); @@ -4849,7 +4845,7 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { BC_ASSERT_TRUE(data_marie->packetSentCount - data_pauline->packetReceivedCount < 50); BC_ASSERT_TRUE(data_marie->packetReceivedCount == data_pauline->packetSentCount); // At this point, we know each packet that has been processed in the send callback of our RTP modifier also go through the recv callback of the remote. - + // Now we want to ensure that all sent RTP packets actually go through our RTP transport modifier and thus no packet leave without being processed (by any operation we might want to do on it) { const LinphoneCallStats *marie_stats = linphone_call_get_audio_stats(call_marie); @@ -4874,7 +4870,7 @@ end: ms_free(data_marie); } ms_free(rtptm_marie); - + // Unref the previously ref calls if (call_marie) { linphone_call_unref(call_marie); @@ -4882,11 +4878,11 @@ end: if (call_pauline) { linphone_call_unref(call_pauline); } - + // The test is finished, the linphone core are no longer needed, we can safely free them linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); - + ms_free(recordpath); ms_free(hellopath); } @@ -4907,34 +4903,34 @@ static void _call_with_network_switch(bool_t use_ice){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); bool_t call_ok; - + if (use_ice){ linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); } - + BC_ASSERT_TRUE((call_ok=call(pauline,marie))); if (!call_ok) goto end; - + wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000); if (use_ice) BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection)); - + /*marie looses the network and reconnects*/ linphone_core_set_network_reachable(marie->lc, FALSE); wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000); - + /*marie will reconnect and register*/ linphone_core_set_network_reachable(marie->lc, TRUE); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneRegistrationOk, 2)); - + /*pauline shall receive a reINVITE to update the session*/ BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, 1)); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2)); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); - + liblinphone_tester_check_rtcp(pauline, marie); if (use_ice) BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection)); - + /*pauline shall be able to end the call without problem now*/ end_call(pauline, marie); end: @@ -4959,18 +4955,18 @@ static void call_logs_migrate() { char *logs_db = create_filepath(bc_tester_get_writable_dir_prefix(), "call_logs", "db"); int i = 0; int incoming_count = 0, outgoing_count = 0, missed_count = 0, aborted_count = 0, decline_count = 0, video_enabled_count = 0; - + call_logs_read_from_config_file(laure->lc); BC_ASSERT_TRUE(ms_list_size(laure->lc->call_logs) == 10); - + linphone_core_set_call_logs_database_path(laure->lc, logs_db); BC_ASSERT_TRUE(linphone_core_get_call_history_size(laure->lc) == 10); - + for (; i < ms_list_size(laure->lc->call_logs); i++) { LinphoneCallLog *log = ms_list_nth_data(laure->lc->call_logs, i); LinphoneCallStatus state = linphone_call_log_get_status(log); LinphoneCallDir direction = linphone_call_log_get_dir(log); - + if (state == LinphoneCallAborted) { aborted_count += 1; } else if (state == LinphoneCallMissed) { @@ -4978,13 +4974,13 @@ static void call_logs_migrate() { } else if (state == LinphoneCallDeclined) { decline_count += 1; } - + if (direction == LinphoneCallOutgoing) { outgoing_count += 1; } else { incoming_count += 1; } - + if (linphone_call_log_video_enabled(log)) { video_enabled_count += 1; } @@ -4995,11 +4991,11 @@ static void call_logs_migrate() { BC_ASSERT_TRUE(aborted_count == 3); BC_ASSERT_TRUE(decline_count == 2); BC_ASSERT_TRUE(video_enabled_count == 3); - + laure->lc->call_logs = ms_list_free_with_data(laure->lc->call_logs, (void (*)(void*))linphone_call_log_unref); call_logs_read_from_config_file(laure->lc); BC_ASSERT_TRUE(ms_list_size(laure->lc->call_logs) == 0); - + remove(logs_db); ms_free(logs_db); linphone_core_manager_destroy(laure); @@ -5014,27 +5010,27 @@ static void call_logs_sqlite_storage() { linphone_core_set_call_logs_database_path(marie->lc, logs_db); BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 0); - + BC_ASSERT_TRUE(call(marie, pauline)); wait_for_until(marie->lc, pauline->lc, NULL, 5, 1000); end_call(marie, pauline); BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 1); - + logs = linphone_core_get_call_history_for_address(marie->lc, linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc))); BC_ASSERT_TRUE(ms_list_size(logs) == 1); ms_list_free_with_data(logs, (void (*)(void*))linphone_call_log_unref); - + laure = linphone_address_new("\"Laure\" "); logs = linphone_core_get_call_history_for_address(marie->lc, laure); BC_ASSERT_TRUE(ms_list_size(logs) == 0); ms_free(laure); - + logs = linphone_core_get_call_history_for_address(marie->lc, linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc))); BC_ASSERT_TRUE(ms_list_size(logs) == 1); linphone_core_delete_call_log(marie->lc, (LinphoneCallLog *)ms_list_nth_data(logs, 0)); ms_list_free_with_data(logs, (void (*)(void*))linphone_call_log_unref); BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 0); - + BC_ASSERT_TRUE(call(marie, pauline)); wait_for_until(marie->lc, pauline->lc, NULL, 5, 1000); end_call(marie, pauline); @@ -5042,7 +5038,7 @@ static void call_logs_sqlite_storage() { wait_for_until(marie->lc, pauline->lc, NULL, 5, 1000); end_call(marie, pauline); BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 2); - + linphone_core_delete_call_history(marie->lc); BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 0); @@ -5198,10 +5194,5 @@ test_t call_tests[] = { #endif }; -test_suite_t call_test_suite = { - "Single Call", - liblinphone_tester_setup, - NULL, - sizeof(call_tests) / sizeof(call_tests[0]), - call_tests -}; +test_suite_t call_test_suite = {"Single Call", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(call_tests) / sizeof(call_tests[0]), call_tests}; diff --git a/tester/common/bc_tester_utils.c b/tester/common/bc_tester_utils.c index 27eee709e..4f9fe9b2d 100644 --- a/tester/common/bc_tester_utils.c +++ b/tester/common/bc_tester_utils.c @@ -49,7 +49,6 @@ along with this program. If not, see . #include #endif - static char *bc_tester_resource_dir_prefix = NULL; static char *bc_tester_writable_dir_prefix = NULL; @@ -82,7 +81,7 @@ void bc_tester_printf(int level, const char *fmt, ...) { int bc_tester_run_suite(test_suite_t *suite) { int i; - CU_pSuite pSuite = CU_add_suite(suite->name, suite->init_func, suite->cleanup_func); + CU_pSuite pSuite = CU_add_suite(suite->name, suite->before_all, suite->after_all); for (i = 0; i < suite->nb_tests; i++) { if (NULL == CU_add_test(pSuite, suite->tests[i].name, suite->tests[i].func)) { @@ -102,7 +101,7 @@ int bc_tester_suite_index(const char *suite_name) { int i; for (i = 0; i < nb_test_suites; i++) { - if ((strcmp(suite_name, test_suite[i]->name) == 0) && (strlen(suite_name) == strlen(test_suite[i]->name))) { + if (strcmp(suite_name, test_suite[i]->name) == 0) { return i; } } @@ -165,25 +164,35 @@ static void suite_start_message_handler(const CU_pSuite pSuite) { suite_start_time = time(NULL); } static void suite_complete_message_handler(const CU_pSuite pSuite, const CU_pFailureRecord pFailure) { - bc_tester_printf(bc_printf_verbosity_info,"Suite [%s] ended in %lu sec\n", pSuite->pName, time(NULL) - suite_start_time); + bc_tester_printf(bc_printf_verbosity_info, "Suite [%s] ended in %lu sec\n", pSuite->pName, + time(NULL) - suite_start_time); } static time_t test_start_time = 0; static void test_start_message_handler(const CU_pTest pTest, const CU_pSuite pSuite) { + int suite_index = bc_tester_suite_index(pSuite->pName); bc_tester_printf(bc_printf_verbosity_info,"Suite [%s] Test [%s] started", pSuite->pName,pTest->pName); test_start_time = time(NULL); + if (test_suite[suite_index]->before_each) { + test_suite[suite_index]->before_each(); + } } /*derivated from cunit*/ -static void test_complete_message_handler(const CU_pTest pTest, - const CU_pSuite pSuite, - const CU_pFailureRecord pFailureList) { +static void test_complete_message_handler(const CU_pTest pTest, const CU_pSuite pSuite, + const CU_pFailureRecord pFailureList) { int i; + int suite_index = bc_tester_suite_index(pSuite->pName); char result[2048]={0}; char buffer[2048]={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)); + + if (test_suite[suite_index]->after_each) { + test_suite[suite_index]->after_each(); + } + + 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)); if (pFailure) { for (i = 1 ; (NULL != pFailure) ; pFailure = pFailure->pNext, i++) { snprintf(buffer, sizeof(buffer), "\n %d. %s:%u - %s", i, @@ -197,15 +206,20 @@ static void test_complete_message_handler(const CU_pTest pTest, #ifdef __linux /* use mallinfo() to monitor allocated space. It is linux specific but other methods don't work: * setrlimit() RLIMIT_DATA doesn't count memory allocated via mmap() (which is used internally by malloc) - * setrlimit() RLIMIT_AS works but also counts virtual memory allocated by thread stacks, which is very big and hardly controllable. + * setrlimit() RLIMIT_AS works but also counts virtual memory allocated by thread stacks, which is very big and + * hardly controllable. * setrlimit() RLIMIT_RSS does nothing interesting on linux. - * getrusage() of RSS is unreliable: memory blocks can be leaked without being read or written, which would not appear in RSS. + * getrusage() of RSS is unreliable: memory blocks can be leaked without being read or written, which would not + * appear in RSS. * mallinfo() itself is the less worse solution. Allocated bytes are returned as 'int' so limited to 2GB */ - if (max_vm_kb){ + if (max_vm_kb) { struct mallinfo minfo = mallinfo(); - if (minfo.uordblks > max_vm_kb * 1024){ - bc_tester_printf(bc_printf_verbosity_error, "The program exceeded the maximum ammount of memory allocatable (%i bytes), aborting now.\n", minfo.uordblks); + if (minfo.uordblks > max_vm_kb * 1024) { + bc_tester_printf( + bc_printf_verbosity_error, + "The program exceeded the maximum amount of memory allocatable (%i bytes), aborting now.\n", + minfo.uordblks); abort(); } } @@ -281,30 +295,31 @@ int bc_tester_run_tests(const char *suite_name, const char *test_name) { } } #ifdef __linux - bc_tester_printf(bc_printf_verbosity_info, "Still %i kilobytes allocated when all tests are finished.", mallinfo().uordblks/1024); + bc_tester_printf(bc_printf_verbosity_info, "Still %i kilobytes allocated when all tests are finished.", + mallinfo().uordblks / 1024); #endif - + return CU_get_number_of_tests_failed()!=0; } void bc_tester_helper(const char *name, const char* additionnal_helper) { - bc_tester_printf(bc_printf_verbosity_info,"%s --help\n" - "\t\t\t--list-suites\n" - "\t\t\t--list-tests \n" - "\t\t\t--suite \n" - "\t\t\t--test \n" + bc_tester_printf(bc_printf_verbosity_info, + "%s --help\n" + "\t\t\t--list-suites\n" + "\t\t\t--list-tests \n" + "\t\t\t--suite \n" + "\t\t\t--test \n" #ifdef HAVE_CU_CURSES - "\t\t\t--curses\n" + "\t\t\t--curses\n" #endif - "\t\t\t--xml\n" - "\t\t\t--xml-file \n" - "\t\t\t--max-alloc (maximum ammount of memory obtained via malloc allocator)\n" - "And additionally:\n" - "%s" - , name - , additionnal_helper); + "\t\t\t--xml\n" + "\t\t\t--xml-file \n" + "\t\t\t--max-alloc (maximum ammount of memory obtained via malloc allocator)\n" + "And additionally:\n" + "%s", + name, additionnal_helper); } void bc_tester_init(void (*ftester_printf)(int level, const char *fmt, va_list args), int iverbosity_info, int iverbosity_error) { @@ -329,19 +344,19 @@ void bc_tester_init(void (*ftester_printf)(int level, const char *fmt, va_list a bc_printf_verbosity_info = iverbosity_info; } -void bc_tester_set_max_vm(long max_vm_kb){ +void bc_tester_set_max_vm(long max_vm_kb) { #ifdef __linux max_vm_kb = max_vm_kb; bc_tester_printf(bc_printf_verbosity_info, "Maximum virtual memory space set to %li kilo bytes", max_vm_kb); #else - bc_tester_printf(bc_printf_verbosity_error,"Maximum virtual memory space setting is only implemented on Linux."); + bc_tester_printf(bc_printf_verbosity_error, "Maximum virtual memory space setting is only implemented on Linux."); #endif } int bc_tester_parse_args(int argc, char **argv, int argid) { int i = argid; - + if (strcmp(argv[i],"--help")==0){ return -1; } else if (strcmp(argv[i],"--test")==0){ @@ -364,7 +379,7 @@ int bc_tester_parse_args(int argc, char **argv, int argid) xml_enabled = 1; } else if (strcmp(argv[i], "--xml") == 0){ xml_enabled = 1; - } else if (strcmp(argv[i], "--max-alloc") == 0){ + } else if (strcmp(argv[i], "--max-alloc") == 0) { CHECK_ARG("--max-alloc", ++i, argc); max_vm_kb = atol(argv[i]); } else { @@ -383,10 +398,10 @@ int bc_tester_parse_args(int argc, char **argv, int argid) int bc_tester_start(void) { int ret; - + if (max_vm_kb) bc_tester_set_max_vm(max_vm_kb); - + if( xml_enabled ){ size_t size = strlen(xml_file) + strlen(".tmp") + 1; char * xml_tmp_file = malloc(sizeof(char) * size); diff --git a/tester/common/bc_tester_utils.h b/tester/common/bc_tester_utils.h index b3c1deaae..ad786f32a 100644 --- a/tester/common/bc_tester_utils.h +++ b/tester/common/bc_tester_utils.h @@ -35,9 +35,11 @@ extern int bc_printf_verbosity_info; extern int bc_printf_verbosity_error; typedef void (*test_function_t)(void); -typedef int (*init_function_t)(void); -typedef int (*cleanup_function_t)(void); -typedef int (*test_suite_function_t)(const char *name); +/** Function used in all suites - it is invoked before all and each tests and also after each and all tests + * @return 0 means success, otherwise it's an error +**/ +typedef int (*pre_post_function_t)(void); +// typedef int (*test_suite_function_t)(const char *name); typedef struct { const char *name; @@ -45,11 +47,14 @@ typedef struct { } test_t; typedef struct { - const char *name; - init_function_t init_func; - cleanup_function_t cleanup_func; - int nb_tests; - test_t *tests; + const char *name; /*suite name*/ + pre_post_function_t + before_all; /*function invoked before running the suite. If not returning 0, suite is not launched. */ + pre_post_function_t after_all; /*function invoked at the end of the suite, even if some tests failed. */ + test_function_t before_each; /*function invoked before each test within this suite. */ + test_function_t after_each; /*function invoked after each test within this suite, even if it failed. */ + int nb_tests; /* number of tests */ + test_t *tests; /* tests within this suite */ } test_suite_t; #ifdef __cplusplus diff --git a/tester/complex_sip_call.c b/tester/complex_sip_call.c index 40bfe7999..c66e24e61 100644 --- a/tester/complex_sip_call.c +++ b/tester/complex_sip_call.c @@ -27,14 +27,14 @@ static FILE *sip_start(const char *senario, const char* dest_username, LinphoneA char *dest; char *command; FILE *file; - + if (linphone_address_get_port(dest_addres)>0) dest = ms_strdup_printf("%s:%i",linphone_address_get_domain(dest_addres),linphone_address_get_port(dest_addres)); 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 -m 1 -d 1000 ",senario,dest_username,dest); - + ms_message("Starting sipp commad [%s]",command); file = popen(command, "r"); ms_free(command); @@ -55,7 +55,7 @@ static void sip_update_within_icoming_reinvite_with_no_sdp(void) { char *identity_char; char *scen; FILE * sipp_out; - + /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2( "empty_rc", FALSE); mgr->identity= linphone_core_get_primary_contact_parsed(mgr->lc); @@ -72,15 +72,16 @@ static void sip_update_within_icoming_reinvite_with_no_sdp(void) { ,&addrinfo); linphone_address_destroy(dest); dest=linphone_address_new(NULL); - + wait_for(mgr->lc, mgr->lc, (int*)&addrinfo, 1); - err=getnameinfo((struct sockaddr *)addrinfo->ai_addr,addrinfo->ai_addrlen,ipstring,INET6_ADDRSTRLEN,NULL,0,NI_NUMERICHOST); + err=getnameinfo((struct sockaddr + *)addrinfo->ai_addr,addrinfo->ai_addrlen,ipstring,INET6_ADDRSTRLEN,NULL,0,NI_NUMERICHOST); linphone_address_set_domain(dest, ipstring); if (port > 0) linphone_address_set_port(dest, port); */ scen = bc_tester_res("sipp/sip_update_within_icoming_reinvite_with_no_sdp.xml"); - + sipp_out = sip_start(scen , linphone_address_get_username(mgr->identity) , mgr->identity); @@ -93,18 +94,11 @@ static void sip_update_within_icoming_reinvite_with_no_sdp(void) { pclose(sipp_out); } linphone_core_manager_destroy(mgr); - } static test_t tests[] = { { "SIP UPDATE within incoming reinvite witjout sdp", sip_update_within_icoming_reinvite_with_no_sdp}, }; -test_suite_t complex_sip_call_test_suite = { - "Complex SIP Call", - liblinphone_tester_setup, - NULL, - sizeof(tests) / sizeof(tests[0]), - tests -}; - +test_suite_t complex_sip_call_test_suite = {"Complex SIP Call", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(tests) / sizeof(tests[0]), tests}; diff --git a/tester/dtmf_tester.c b/tester/dtmf_tester.c index 38d6c3579..d427d63a0 100644 --- a/tester/dtmf_tester.c +++ b/tester/dtmf_tester.c @@ -171,10 +171,5 @@ test_t dtmf_tests[] = { { "Send DTMF using RFC2833 using Opus",send_dtmf_rfc2833_opus}, }; -test_suite_t dtmf_test_suite = { - "DTMF", - liblinphone_tester_setup, - NULL, - sizeof(dtmf_tests) / sizeof(dtmf_tests[0]), - dtmf_tests -}; +test_suite_t dtmf_test_suite = {"DTMF", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(dtmf_tests) / sizeof(dtmf_tests[0]), dtmf_tests}; diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index b196652db..df88b245c 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -367,11 +367,5 @@ test_t event_tests[] = { { "Publish without automatic refresh",publish_no_auto_test } }; -test_suite_t event_test_suite = { - "Event", - liblinphone_tester_setup, - NULL, - sizeof(event_tests) / sizeof(event_tests[0]), - event_tests -}; - +test_suite_t event_test_suite = {"Event", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(event_tests) / sizeof(event_tests[0]), event_tests}; diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 758bab93e..cc2bc4d19 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -926,13 +926,5 @@ test_t flexisip_tests[] = { { "DoS module trigger by sending a lot of chat messages", dos_module_trigger } }; - -test_suite_t flexisip_test_suite = { - "Flexisip", - liblinphone_tester_setup, - NULL, - sizeof(flexisip_tests) / sizeof(flexisip_tests[0]), - flexisip_tests -}; - - +test_suite_t flexisip_test_suite = {"Flexisip", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(flexisip_tests) / sizeof(flexisip_tests[0]), flexisip_tests}; diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index ffb3aacfb..0d3dd5efb 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -335,7 +335,7 @@ int linphone_core_manager_get_mean_audio_up_bw(const LinphoneCoreManager *mgr); void video_call_base_2(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled); -int liblinphone_tester_setup(); +void liblinphone_tester_before_each(); void liblinphone_tester_init(void(*ftester_printf)(int level, const char *fmt, va_list args)); void liblinphone_tester_uninit(void); diff --git a/tester/log_collection_tester.c b/tester/log_collection_tester.c index 4beabef73..d5b44d696 100644 --- a/tester/log_collection_tester.c +++ b/tester/log_collection_tester.c @@ -324,11 +324,6 @@ test_t log_collection_tests[] = { { "Upload collected traces", upload_collected_traces} }; -test_suite_t log_collection_test_suite = { - "LogCollection", - liblinphone_tester_setup, - NULL, - sizeof(log_collection_tests) / sizeof(log_collection_tests[0]), - log_collection_tests -}; - +test_suite_t log_collection_test_suite = {"LogCollection", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(log_collection_tests) / sizeof(log_collection_tests[0]), + log_collection_tests}; diff --git a/tester/message_tester.c b/tester/message_tester.c index c94bfae40..e3f570255 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1658,11 +1658,5 @@ test_t message_tests[] = { ,{"file transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom} }; -test_suite_t message_test_suite = { - "Message", - liblinphone_tester_setup, - NULL, - sizeof(message_tests) / sizeof(message_tests[0]), - message_tests -}; - +test_suite_t message_test_suite = {"Message", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(message_tests) / sizeof(message_tests[0]), message_tests}; diff --git a/tester/multi_call_tester.c b/tester/multi_call_tester.c index 45f7bfcbc..a752ea6ef 100644 --- a/tester/multi_call_tester.c +++ b/tester/multi_call_tester.c @@ -553,10 +553,5 @@ test_t multi_call_tests[] = { { "Incoming call accepted when outgoing call in outgoing ringing early media",incoming_call_accepted_when_outgoing_call_in_outgoing_ringing_early_media}, }; -test_suite_t multi_call_test_suite = { - "Multi call", - liblinphone_tester_setup, - NULL, - sizeof(multi_call_tests) / sizeof(multi_call_tests[0]), - multi_call_tests -}; +test_suite_t multi_call_test_suite = {"Multi call", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(multi_call_tests) / sizeof(multi_call_tests[0]), multi_call_tests}; diff --git a/tester/multicast_call_tester.c b/tester/multicast_call_tester.c index 437867329..549c6b2ed 100644 --- a/tester/multicast_call_tester.c +++ b/tester/multicast_call_tester.c @@ -269,10 +269,6 @@ test_t multicast_call_tests[] = { #endif }; -test_suite_t multicast_call_test_suite = { - "Multicast Call", - liblinphone_tester_setup, - NULL, - sizeof(multicast_call_tests) / sizeof(multicast_call_tests[0]), - multicast_call_tests -}; +test_suite_t multicast_call_test_suite = {"Multicast Call", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(multicast_call_tests) / sizeof(multicast_call_tests[0]), + multicast_call_tests}; diff --git a/tester/offeranswer_tester.c b/tester/offeranswer_tester.c index b433bda5c..cdffe306d 100644 --- a/tester/offeranswer_tester.c +++ b/tester/offeranswer_tester.c @@ -350,7 +350,7 @@ static void compatible_avpf_features(void) { BC_ASSERT_TRUE((call_ok=call(marie, pauline))); if (!call_ok) goto end; - + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1)); check_avpf_features(marie->lc, lpt->avpf.features); @@ -417,10 +417,5 @@ static test_t offeranswer_tests[] = { #endif }; -test_suite_t offeranswer_test_suite = { - "Offer-answer", - liblinphone_tester_setup, - NULL, - sizeof(offeranswer_tests) / sizeof(offeranswer_tests[0]), - offeranswer_tests -}; +test_suite_t offeranswer_test_suite = {"Offer-answer", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(offeranswer_tests) / sizeof(offeranswer_tests[0]), offeranswer_tests}; diff --git a/tester/player_tester.c b/tester/player_tester.c index 332bcffbc..e8458e9d7 100644 --- a/tester/player_tester.c +++ b/tester/player_tester.c @@ -82,10 +82,5 @@ test_t player_tests[] = { { "Local MKV file" , playing_test } }; -test_suite_t player_test_suite = { - "Player", - liblinphone_tester_setup, - NULL, - sizeof(player_tests) / sizeof(test_t), - player_tests -}; +test_suite_t player_test_suite = {"Player", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(player_tests) / sizeof(test_t), player_tests}; diff --git a/tester/presence_tester.c b/tester/presence_tester.c index a685aba7a..f72acb736 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -482,11 +482,5 @@ test_t presence_tests[] = { #endif }; -test_suite_t presence_test_suite = { - "Presence", - liblinphone_tester_setup, - NULL, - sizeof(presence_tests) / sizeof(presence_tests[0]), - presence_tests -}; - +test_suite_t presence_test_suite = {"Presence", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(presence_tests) / sizeof(presence_tests[0]), presence_tests}; diff --git a/tester/proxy_config_tester.c b/tester/proxy_config_tester.c index 8dbedea37..baf874be1 100644 --- a/tester/proxy_config_tester.c +++ b/tester/proxy_config_tester.c @@ -108,10 +108,5 @@ test_t proxy_config_tests[] = { { "SIP URI normalization", sip_uri_normalization }, }; -test_suite_t proxy_config_test_suite = { - "Proxy config", - liblinphone_tester_setup, - NULL, - sizeof(proxy_config_tests) / sizeof(proxy_config_tests[0]), - proxy_config_tests -}; +test_suite_t proxy_config_test_suite = {"Proxy config", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(proxy_config_tests) / sizeof(proxy_config_tests[0]), proxy_config_tests}; diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index debfb2608..57b63a3f9 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -383,10 +383,6 @@ test_t quality_reporting_tests[] = { { "Sent using custom route", quality_reporting_sent_using_custom_route}, }; -test_suite_t quality_reporting_test_suite = { - "QualityReporting", - liblinphone_tester_setup, - NULL, - sizeof(quality_reporting_tests) / sizeof(quality_reporting_tests[0]), - quality_reporting_tests -}; +test_suite_t quality_reporting_test_suite = {"QualityReporting", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(quality_reporting_tests) / sizeof(quality_reporting_tests[0]), + quality_reporting_tests}; diff --git a/tester/register_tester.c b/tester/register_tester.c index ab159ea2a..cce4045ad 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -894,11 +894,5 @@ test_t register_tests[] = { { "Simple redirect", redirect} }; -test_suite_t register_test_suite = { - "Register", - liblinphone_tester_setup, - NULL, - sizeof(register_tests) / sizeof(register_tests[0]), - register_tests -}; - +test_suite_t register_test_suite = {"Register", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(register_tests) / sizeof(register_tests[0]), register_tests}; diff --git a/tester/remote_provisioning_tester.c b/tester/remote_provisioning_tester.c index ac6e5602f..02e4e8452 100644 --- a/tester/remote_provisioning_tester.c +++ b/tester/remote_provisioning_tester.c @@ -134,10 +134,6 @@ test_t remote_provisioning_tests[] = { { "Remote provisioning invalid URI", remote_provisioning_invalid_uri } }; -test_suite_t remote_provisioning_test_suite = { - "RemoteProvisioning", - NULL, - NULL, - sizeof(remote_provisioning_tests) / sizeof(remote_provisioning_tests[0]), - remote_provisioning_tests -}; +test_suite_t remote_provisioning_test_suite = {"RemoteProvisioning", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(remote_provisioning_tests) / sizeof(remote_provisioning_tests[0]), + remote_provisioning_tests}; diff --git a/tester/setup_tester.c b/tester/setup_tester.c index c24aa27b8..ffb8b550f 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -306,11 +306,5 @@ test_t setup_tests[] = { { "Codec usability", codec_usability_test } }; -test_suite_t setup_test_suite = { - "Setup", - liblinphone_tester_setup, - NULL, - sizeof(setup_tests) / sizeof(setup_tests[0]), - setup_tests -}; - +test_suite_t setup_test_suite = {"Setup", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(setup_tests) / sizeof(setup_tests[0]), setup_tests}; diff --git a/tester/stun_tester.c b/tester/stun_tester.c index 89762cab3..ef14f5670 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -110,10 +110,5 @@ test_t stun_tests[] = { { "STUN encode buffer protection", linphone_stun_test_encode }, }; -test_suite_t stun_test_suite = { - "Stun", - liblinphone_tester_setup, - NULL, - sizeof(stun_tests) / sizeof(stun_tests[0]), - stun_tests -}; +test_suite_t stun_test_suite = {"Stun", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(stun_tests) / sizeof(stun_tests[0]), stun_tests}; diff --git a/tester/tester.c b/tester/tester.c index 4d77534cc..85ce01d20 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -479,12 +479,10 @@ int linphone_core_manager_get_mean_audio_up_bw(const LinphoneCoreManager *mgr) { , sizeof(mgr->stat.audio_upload_bandwidth)/sizeof(int)); } -int liblinphone_tester_setup() { +void liblinphone_tester_before_each() { if (manager_count != 0) { // crash in some linphone core have not been destroyed because if we continue // it will crash in CUnit AND we should NEVER keep a manager alive - ms_fatal("%d linphone core manager still alive!", manager_count); - return 1; + ms_fatal("%d linphone core managers are still alive!", manager_count); } - return 0; } diff --git a/tester/tunnel_tester.c b/tester/tunnel_tester.c index 76ce2a826..7dd32631c 100644 --- a/tester/tunnel_tester.c +++ b/tester/tunnel_tester.c @@ -262,10 +262,5 @@ test_t tunnel_tests[] = { #endif }; -test_suite_t tunnel_test_suite = { - "Tunnel", - liblinphone_tester_setup, - NULL, - sizeof(tunnel_tests) / sizeof(tunnel_tests[0]), - tunnel_tests -}; +test_suite_t tunnel_test_suite = {"Tunnel", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(tunnel_tests) / sizeof(tunnel_tests[0]), tunnel_tests}; diff --git a/tester/upnp_tester.c b/tester/upnp_tester.c index fc487b75e..e17e1e287 100644 --- a/tester/upnp_tester.c +++ b/tester/upnp_tester.c @@ -59,10 +59,5 @@ test_t upnp_tests[] = { { "Check ip address", upnp_check_ipaddress }, }; -test_suite_t upnp_test_suite = { - "Upnp", - liblinphone_tester_setup, - NULL, - sizeof(upnp_tests) / sizeof(upnp_tests[0]), - upnp_tests -}; +test_suite_t upnp_test_suite = {"Upnp", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(upnp_tests) / sizeof(upnp_tests[0]), upnp_tests}; diff --git a/tester/video_tester.c b/tester/video_tester.c index abffb59ab..918529fdc 100644 --- a/tester/video_tester.c +++ b/tester/video_tester.c @@ -430,13 +430,13 @@ static void forked_outgoing_early_media_video_call_with_inactive_audio_test(void linphone_core_invite_address_with_params(pauline->lc, marie1->identity, pauline_params); linphone_call_params_destroy(pauline_params); - + BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingReceived, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingReceived, 1, 3000)); - + marie1_call = linphone_core_get_current_call(marie1->lc); marie2_call = linphone_core_get_current_call(marie2->lc); - + if (marie1_call){ linphone_call_set_next_video_frame_decoded_callback(marie1_call, linphone_call_iframe_decoded_cb, marie1->lc); } @@ -449,7 +449,6 @@ static void forked_outgoing_early_media_video_call_with_inactive_audio_test(void BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia, 1, 3000)); pauline_call = linphone_core_get_current_call(pauline->lc); - BC_ASSERT_PTR_NOT_NULL(pauline_call); BC_ASSERT_PTR_NOT_NULL(marie1_call); @@ -457,7 +456,7 @@ static void forked_outgoing_early_media_video_call_with_inactive_audio_test(void if (pauline_call && marie1_call && marie2_call) { linphone_call_set_next_video_frame_decoded_callback(pauline_call, linphone_call_iframe_decoded_cb, pauline->lc); - + /* wait a bit that streams are established */ wait_for_list(lcs, &dummy, 1, 3000); BC_ASSERT_EQUAL(linphone_call_get_audio_stats(pauline_call)->download_bandwidth, 0, float, "%f"); @@ -553,12 +552,7 @@ test_t video_tests[] = { }; -test_suite_t video_test_suite = { - "Video", - liblinphone_tester_setup, - NULL, - sizeof(video_tests) / sizeof(video_tests[0]), - video_tests -}; +test_suite_t video_test_suite = {"Video", NULL, NULL, liblinphone_tester_before_each, NULL, + sizeof(video_tests) / sizeof(video_tests[0]), video_tests}; #endif /* VIDEO_ENABLED */