From b6e8c2e393c5f876f11a839ecdb41f7011896038 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Mon, 5 Dec 2022 09:18:27 +0100 Subject: [PATCH] Make iOS tests read --webrtc_test_metrics_output_path. Differently from the ChromePerfDashboardMetricsExporter, this new flag doesn't default to storing the output file to NSDocumentDirectory (and with a default name, for example perftest-output.pb) but instead just stores the file at the location specified by --webrtc_test_metrics_output_path. Bug: b/237982523 Change-Id: Ibb504fdbc94ca5179f4b3da5b06d8cea82140140 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286280 Reviewed-by: Jeremy Leconte Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#38807} --- test/BUILD.gn | 1 + test/ios/test_support.h | 1 + test/ios/test_support.mm | 8 ++++++++ test/test_main_lib.cc | 9 +++++---- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index 563825d7b0..7a560fb358 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -332,6 +332,7 @@ if (is_ios) { "../api/test/metrics:chrome_perf_dashboard_metrics_exporter", "../api/test/metrics:global_metrics_logger_and_exporter", "../api/test/metrics:metrics_exporter", + "../api/test/metrics:metrics_set_proto_file_exporter", "../api/test/metrics:print_result_proxy_metrics_exporter", "../api/test/metrics:stdout_metrics_exporter", "../sdk:helpers_objc", diff --git a/test/ios/test_support.h b/test/ios/test_support.h index 2699923e09..5ac731393f 100644 --- a/test/ios/test_support.h +++ b/test/ios/test_support.h @@ -27,6 +27,7 @@ void InitTestSuite(int (*test_suite)(void), char* argv[], bool save_chartjson_result, bool export_perf_results_new_api, + std::string webrtc_test_metrics_output_path, absl::optional> metrics_to_plot); // Returns true if unittests should be run by the XCTest runnner. diff --git a/test/ios/test_support.mm b/test/ios/test_support.mm index 1c79682375..8586f4673f 100644 --- a/test/ios/test_support.mm +++ b/test/ios/test_support.mm @@ -13,6 +13,7 @@ #include "api/test/metrics/chrome_perf_dashboard_metrics_exporter.h" #include "api/test/metrics/global_metrics_logger_and_exporter.h" #include "api/test/metrics/metrics_exporter.h" +#include "api/test/metrics/metrics_set_proto_file_exporter.h" #include "api/test/metrics/print_result_proxy_metrics_exporter.h" #include "api/test/metrics/stdout_metrics_exporter.h" #include "test/ios/coverage_util_ios.h" @@ -44,6 +45,7 @@ static int g_argc; static char **g_argv; static bool g_write_perf_output; static bool g_export_perf_results_new_api; +static std::string g_webrtc_test_metrics_output_path; static absl::optional g_is_xctest; static absl::optional> g_metrics_to_plot; @@ -110,6 +112,10 @@ static absl::optional> g_metrics_to_plot; [NSString stdStringForString:outputPath])); } } + if (!g_webrtc_test_metrics_output_path.empty()) { + exporters.push_back(std::make_unique( + webrtc::test::MetricsSetProtoFileExporter::Options(g_webrtc_test_metrics_output_path))); + } } else { exporters.push_back(std::make_unique()); } @@ -167,12 +173,14 @@ void InitTestSuite(int (*test_suite)(void), char *argv[], bool write_perf_output, bool export_perf_results_new_api, + std::string webrtc_test_metrics_output_path, absl::optional> metrics_to_plot) { g_test_suite = test_suite; g_argc = argc; g_argv = argv; g_write_perf_output = write_perf_output; g_export_perf_results_new_api = export_perf_results_new_api; + g_webrtc_test_metrics_output_path = webrtc_test_metrics_output_path; g_metrics_to_plot = std::move(metrics_to_plot); } diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc index 29caa54b1a..4c80315ac5 100644 --- a/test/test_main_lib.cc +++ b/test/test_main_lib.cc @@ -184,10 +184,11 @@ class TestMainImpl : public TestMain { } #if defined(WEBRTC_IOS) - rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv, - absl::GetFlag(FLAGS_write_perf_output_on_ios), - absl::GetFlag(FLAGS_export_perf_results_new_api), - metrics_to_plot); + rtc::test::InitTestSuite( + RUN_ALL_TESTS, argc, argv, + absl::GetFlag(FLAGS_write_perf_output_on_ios), + absl::GetFlag(FLAGS_export_perf_results_new_api), + absl::GetFlag(FLAGS_webrtc_test_metrics_output_path), metrics_to_plot); rtc::test::RunTestsFromIOSApp(); int exit_code = 0; #else