Ensure --webrtc_test_metrics_output_path is a file name on iOS.

Bug: b/237982523
Change-Id: I5671e311fe14d7bcdd389626b6e11245d19d62c4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286425
Reviewed-by: Jeremy Leconte <jleconte@google.com>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38819}
This commit is contained in:
Mirko Bonadei 2022-12-05 21:05:58 +01:00 committed by WebRTC LUCI CQ
parent 583fd2ba99
commit 79c21b1bf5
2 changed files with 14 additions and 7 deletions

View File

@ -97,14 +97,14 @@ static absl::optional<std::vector<std::string>> g_metrics_to_plot;
int exitStatus = g_test_suite();
NSArray<NSString *> *outputDirectories =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
std::vector<std::unique_ptr<webrtc::test::MetricsExporter>> exporters;
if (g_export_perf_results_new_api) {
exporters.push_back(std::make_unique<webrtc::test::StdoutMetricsExporter>());
if (g_write_perf_output) {
// Stores data into a proto file under the app's document directory.
NSString *fileName = @"perftest-output.pb";
NSArray<NSString *> *outputDirectories =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
if ([outputDirectories count] != 0) {
NSString *outputPath = [outputDirectories[0] stringByAppendingPathComponent:fileName];
@ -113,8 +113,16 @@ static absl::optional<std::vector<std::string>> g_metrics_to_plot;
}
}
if (!g_webrtc_test_metrics_output_path.empty()) {
exporters.push_back(std::make_unique<webrtc::test::MetricsSetProtoFileExporter>(
webrtc::test::MetricsSetProtoFileExporter::Options(g_webrtc_test_metrics_output_path)));
RTC_CHECK_NE(g_webrtc_test_metrics_output_path.find('/'), std::string::npos)
<< "On iOS, --webrtc_test_metrics_output_path must only be a file name.";
if ([outputDirectories count] != 0) {
NSString *fileName = [NSString stringWithCString:g_webrtc_test_metrics_output_path.c_str()
encoding:[NSString defaultCStringEncoding]];
NSString *outputPath = [outputDirectories[0] stringByAppendingPathComponent:fileName];
exporters.push_back(std::make_unique<webrtc::test::MetricsSetProtoFileExporter>(
webrtc::test::MetricsSetProtoFileExporter::Options(
[NSString stdStringForString:outputPath])));
}
}
} else {
exporters.push_back(std::make_unique<webrtc::test::PrintResultProxyMetricsExporter>());
@ -124,8 +132,6 @@ static absl::optional<std::vector<std::string>> g_metrics_to_plot;
if (g_write_perf_output) {
// Stores data into a proto file under the app's document directory.
NSString *fileName = @"perftest-output.pb";
NSArray<NSString *> *outputDirectories =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
if ([outputDirectories count] != 0) {
NSString *outputPath = [outputDirectories[0] stringByAppendingPathComponent:fileName];

View File

@ -42,7 +42,8 @@ ABSL_FLAG(std::string,
"",
"Path where the test perf metrics should be stored using "
"api/test/metrics/metric.proto proto format. File will contain "
"MetricsSet as a root proto");
"MetricsSet as a root proto. On iOS, this MUST be a file name "
"and the file will be stored under NSDocumentDirectory.");
ABSL_FLAG(bool,
export_perf_results_new_api,