From 34cce12c239a468ef675a8f83c3e6bb5f49d72e8 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 18 Jun 2014 14:32:14 +0200 Subject: [PATCH] Quality reporting: quote adaptive algo data and add unit test for bad formatted reports --- coreapi/quality_reporting.c | 14 +++++++------- tester/quality_reporting_tester.c | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index dc36f7a25..e16dd8f81 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -313,12 +313,12 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report, if (report->qos_analyzer.timestamp!=NULL){ append_to_buffer(&buffer, &size, &offset, "AdaptiveAlg:"); - APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " NAME=%s", report->qos_analyzer.name); - APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " TS=%s", report->qos_analyzer.timestamp); - APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " IN_LEG=%s", report->qos_analyzer.input_leg); - APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " IN=%s", report->qos_analyzer.input); - APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " OUT_LEG=%s", report->qos_analyzer.output_leg); - APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " OUT=%s", report->qos_analyzer.output); + APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " NAME=\"%s\"", report->qos_analyzer.name); + APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " TS=\"%s\"", report->qos_analyzer.timestamp); + APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " IN_LEG=\"%s\"", report->qos_analyzer.input_leg); + APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " IN=\"%s\"", report->qos_analyzer.input); + APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " OUT_LEG=\"%s\"", report->qos_analyzer.output_leg); + APPEND_IF_NOT_NULL_STR(&buffer, &size, &offset, " OUT=\"%s\"", report->qos_analyzer.output); append_to_buffer(&buffer, &size, &offset, "\r\n"); } @@ -641,11 +641,11 @@ reporting_session_report_t * linphone_reporting_new() { metrics[i]->session_description.payload_type = -1; metrics[i]->session_description.sample_rate = -1; metrics[i]->session_description.frame_duration = -1; + metrics[i]->session_description.packet_loss_concealment = -1; metrics[i]->packet_loss.network_packet_loss_rate = -1; metrics[i]->packet_loss.jitter_buffer_discard_rate = -1; - metrics[i]->session_description.packet_loss_concealment = -1; metrics[i]->jitter_buffer.adaptive = -1; metrics[i]->jitter_buffer.abs_max = -1; diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 438f1ba46..b6b449b91 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -200,6 +200,31 @@ static void quality_reporting_not_sent_if_low_bandwidth() { linphone_core_manager_destroy(pauline); } +void on_report_send_remove_fields(const LinphoneCall *call, int stream_type, const LinphoneContent *content){ + char *body = (char*)content->data; + /*corrupt start of the report*/ + strncpy(body, "corrupted report is corrupted", strlen("corrupted report is corrupted")); +} + +static void quality_reporting_invalid_report() { + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); + 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); + + 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); +} + static void quality_reporting_at_call_termination() { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_rtcp_xr"); @@ -296,6 +321,7 @@ test_t quality_reporting_tests[] = { { "Not used if no config", quality_reporting_not_used_without_config}, { "Call term session report not sent if call did not start", quality_reporting_not_sent_if_call_not_started}, { "Call term session report not sent if low bandwidth", quality_reporting_not_sent_if_low_bandwidth}, + { "Call term session report invalid if missing mandatory fields", quality_reporting_invalid_report}, { "Call term session report sent if call ended normally", quality_reporting_at_call_termination}, { "Interval report if interval is configured", quality_reporting_interval_report}, { "Session report sent if video stopped during call", quality_reporting_session_report_if_video_stopped},