Free resources on quality reporting test end and fix invalid reads if call failed

This commit is contained in:
Gautier Pelloux-Prayer 2014-09-22 13:47:24 +02:00
parent de9c426e2e
commit acaba57bdb

View file

@ -115,16 +115,29 @@ void on_report_send_with_rtcp_xr_both(const LinphoneCall *call, int stream_type,
on_report_send_with_rtcp_xr_remote(call,stream_type,content);
}
void create_call_for_quality_reporting_tests(
bool_t create_call_for_quality_reporting_tests(
LinphoneCoreManager* marie,
LinphoneCoreManager* pauline,
LinphoneCall** call_marie,
LinphoneCall** call_pauline) {
CU_ASSERT_TRUE(call(pauline,marie));
*call_marie = linphone_core_get_current_call(marie->lc);
*call_pauline = linphone_core_get_current_call(pauline->lc);
CU_ASSERT_PTR_NOT_NULL(*call_marie);
CU_ASSERT_PTR_NOT_NULL(*call_pauline);
LinphoneCall** call_pauline,
LinphoneCallParams * params_marie,
LinphoneCallParams * params_pauline
) {
bool_t call_succeeded = call_with_params(marie,pauline,params_marie,params_pauline);
CU_ASSERT_TRUE(call_succeeded);
if (call_succeeded) {
if (call_marie) {
*call_marie = linphone_core_get_current_call(marie->lc);
CU_ASSERT_PTR_NOT_NULL(*call_marie);
}
if (call_pauline) {
*call_pauline = linphone_core_get_current_call(pauline->lc);
CU_ASSERT_PTR_NOT_NULL(*call_pauline);
}
}
return call_succeeded;
}
static void quality_reporting_not_used_without_config() {
@ -133,21 +146,20 @@ static void quality_reporting_not_used_without_config() {
LinphoneCall* call_marie = NULL;
LinphoneCall* call_pauline = NULL;
create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline);
if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) {
// marie has stats collection enabled but pauline has not
CU_ASSERT_TRUE(linphone_proxy_config_quality_reporting_enabled(call_marie->dest_proxy));
CU_ASSERT_FALSE(linphone_proxy_config_quality_reporting_enabled(call_pauline->dest_proxy));
CU_ASSERT_TRUE(linphone_proxy_config_quality_reporting_enabled(call_marie->dest_proxy));
CU_ASSERT_FALSE(linphone_proxy_config_quality_reporting_enabled(call_pauline->dest_proxy));
CU_ASSERT_EQUAL(strcmp("sip:collector@sip.example.org",
linphone_proxy_config_get_quality_reporting_collector(call_marie->dest_proxy)), 0);
CU_ASSERT_EQUAL(strcmp("sip:collector@sip.example.org",
linphone_proxy_config_get_quality_reporting_collector(call_marie->dest_proxy)), 0);
// this field should be already filled
CU_ASSERT_PTR_NOT_NULL(call_marie->log->reporting.reports[0]->info.local_addr.ip);
// but not this one since it is updated at the end of call
CU_ASSERT_PTR_NULL(call_marie->log->reporting.reports[0]->dialog_id);
// this field should be already filled
CU_ASSERT_PTR_NOT_NULL(call_marie->log->reporting.reports[0]->info.local_addr.ip);
// but not this one since it is updated at the end of call
CU_ASSERT_PTR_NULL(call_marie->log->reporting.reports[0]->dialog_id);
}
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
@ -191,13 +203,13 @@ static void quality_reporting_not_sent_if_low_bandwidth() {
marie_params=linphone_core_create_default_call_parameters(marie->lc);
linphone_call_params_enable_low_bandwidth(marie_params,TRUE);
CU_ASSERT_TRUE(call_with_params(marie,pauline,marie_params,NULL));
linphone_core_terminate_all_calls(marie->lc);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);
if (create_call_for_quality_reporting_tests(marie, pauline, NULL, NULL, marie_params, NULL)) {
linphone_core_terminate_all_calls(marie->lc);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);
}
linphone_call_params_destroy(marie_params);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
@ -214,15 +226,15 @@ static void quality_reporting_invalid_report() {
LinphoneCall* call_marie = NULL;
LinphoneCall* call_pauline = NULL;
create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline);
linphone_reporting_set_on_report_send(call_marie, on_report_send_remove_fields);
if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) {
linphone_reporting_set_on_report_send(call_marie, on_report_send_remove_fields);
linphone_core_terminate_all_calls(marie->lc);
CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishError,1,3000));
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);
linphone_core_terminate_all_calls(marie->lc);
CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishError,1,3000));
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);
}
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
@ -233,24 +245,24 @@ static void quality_reporting_at_call_termination() {
LinphoneCall* call_marie = NULL;
LinphoneCall* call_pauline = NULL;
create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline);
linphone_reporting_set_on_report_send(call_marie, on_report_send_with_rtcp_xr_remote);
if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) {
linphone_reporting_set_on_report_send(call_marie, on_report_send_with_rtcp_xr_remote);
linphone_core_terminate_all_calls(marie->lc);
linphone_core_terminate_all_calls(marie->lc);
// now dialog id should be filled
CU_ASSERT_PTR_NOT_NULL(call_marie->log->reporting.reports[0]->dialog_id);
// now dialog id should be filled
CU_ASSERT_PTR_NOT_NULL(call_marie->log->reporting.reports[0]->dialog_id);
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallReleased,1, 10000));
CU_ASSERT_TRUE(wait_for_until(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallReleased,1, 10000));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallReleased,1, 10000));
CU_ASSERT_TRUE(wait_for_until(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallReleased,1, 10000));
CU_ASSERT_PTR_NULL(linphone_core_get_current_call(marie->lc));
CU_ASSERT_PTR_NULL(linphone_core_get_current_call(pauline->lc));
// PUBLISH submission to the collector should be ok
CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishProgress,1));
CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishOk,1));
CU_ASSERT_PTR_NULL(linphone_core_get_current_call(marie->lc));
CU_ASSERT_PTR_NULL(linphone_core_get_current_call(pauline->lc));
// PUBLISH submission to the collector should be ok
CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishProgress,1));
CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishOk,1));
}
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
@ -261,17 +273,17 @@ static void quality_reporting_interval_report() {
LinphoneCall* call_marie = NULL;
LinphoneCall* call_pauline = NULL;
create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline);
linphone_reporting_set_on_report_send(call_marie, on_report_send_mandatory);
linphone_proxy_config_set_quality_reporting_interval(call_marie->dest_proxy, 3);
if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) {
linphone_reporting_set_on_report_send(call_marie, on_report_send_mandatory);
linphone_proxy_config_set_quality_reporting_interval(call_marie->dest_proxy, 3);
CU_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(marie->lc));
CU_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc));
// PUBLISH submission to the collector should be ok
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,3,25000));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,3,25000));
CU_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(marie->lc));
CU_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc));
// PUBLISH submission to the collector should be ok
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,3,25000));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,3,25000));
}
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
@ -280,6 +292,7 @@ static void quality_reporting_session_report_if_video_stopped() {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc_rtcp_xr");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
LinphoneCall* call_pauline = NULL;
LinphoneCall* call_marie = NULL;
LinphoneCallParams* pauline_params;
LinphoneCallParams* marie_params;
@ -291,29 +304,32 @@ static void quality_reporting_session_report_if_video_stopped() {
linphone_call_params_enable_video(marie_params,TRUE);
pauline_params=linphone_core_create_default_call_parameters(pauline->lc);
linphone_call_params_enable_video(pauline_params,TRUE);
CU_ASSERT_TRUE(call_with_params(pauline,marie,pauline_params,marie_params));
call_pauline=linphone_core_get_current_call(pauline->lc);
linphone_reporting_set_on_report_send(linphone_core_get_current_call(marie->lc), on_report_send_with_rtcp_xr_local);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);
if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, marie_params, pauline_params)) {
linphone_reporting_set_on_report_send(call_marie, on_report_send_with_rtcp_xr_local);
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,NULL,0,3000));
CU_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline)));
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);
/*remove video*/
linphone_call_params_enable_video(pauline_params,FALSE);
linphone_core_update_call(pauline->lc,call_pauline,pauline_params);
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,NULL,0,3000));
CU_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline)));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,5000));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,5000));
/*remove video*/
linphone_call_params_enable_video(pauline_params,FALSE);
linphone_core_update_call(pauline->lc,call_pauline,pauline_params);
CU_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline)));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,5000));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,5000));
linphone_core_terminate_all_calls(marie->lc);
CU_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline)));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,2,5000));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,2,5000));
linphone_core_terminate_all_calls(marie->lc);
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,2,5000));
CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,2,5000));
}
linphone_call_params_destroy(marie_params);
linphone_call_params_destroy(pauline_params);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);