Fix export of plottable metrics on iOS

Bug: None
Change-Id: I12c3cecb92e5f163f9451d6f90de3bce9b15bca1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168942
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30580}
This commit is contained in:
Artem Titov
2020-02-20 23:52:26 +01:00
committed by Commit Bot
parent 3cc6e05243
commit 694b74b826
4 changed files with 39 additions and 13 deletions

View File

@ -261,6 +261,7 @@ if (is_ios) {
deps = [
":perf_test",
"../sdk:helpers_objc",
"//third_party/abseil-cpp/absl/types:optional",
]
configs += [ ":test_support_objc_config" ]
}
@ -394,6 +395,8 @@ if (rtc_include_tests) {
"../system_wrappers:metrics",
"//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional",
]
}

View File

@ -11,6 +11,11 @@
#ifndef TEST_IOS_TEST_SUPPORT_H_
#define TEST_IOS_TEST_SUPPORT_H_
#include <string>
#include <vector>
#include "absl/types/optional.h"
namespace rtc {
namespace test {
// Launches an iOS app that serves as a host for a test suite.
@ -20,7 +25,8 @@ void RunTestsFromIOSApp();
void InitTestSuite(int (*test_suite)(void),
int argc,
char* argv[],
bool save_chartjson_result);
bool save_chartjson_result,
absl::optional<std::vector<std::string>> metrics_to_plot);
} // namespace test
} // namespace rtc

View File

@ -34,6 +34,7 @@ static int (*g_test_suite)(void) = NULL;
static int g_argc;
static char **g_argv;
static bool g_save_chartjson_result;
static absl::optional<std::vector<std::string>> g_metrics_to_plot;
@interface UIApplication (Testing)
- (void)_terminateWithStatus:(int)status;
@ -88,6 +89,9 @@ static bool g_save_chartjson_result;
[NSString stdStringForString:outputPath]);
}
}
if (g_metrics_to_plot) {
webrtc::test::PrintPlottableResults(*g_metrics_to_plot);
}
// If a test app is too fast, it will exit before Instruments has has a
// a chance to initialize and no test results will be seen.
@ -109,12 +113,16 @@ namespace test {
// Note: This is not thread safe, and must be called from the same thread as
// runTests above.
void InitTestSuite(int (*test_suite)(void), int argc, char *argv[],
bool save_chartjson_result) {
void InitTestSuite(int (*test_suite)(void),
int argc,
char *argv[],
bool save_chartjson_result,
absl::optional<std::vector<std::string>> metrics_to_plot) {
g_test_suite = test_suite;
g_argc = argc;
g_argv = argv;
g_save_chartjson_result = save_chartjson_result;
g_metrics_to_plot = std::move(metrics_to_plot);
}
void RunTestsFromIOSApp() {

View File

@ -16,6 +16,8 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include "rtc_base/checks.h"
#include "rtc_base/event_tracer.h"
#include "rtc_base/logging.h"
@ -69,6 +71,7 @@ ABSL_FLAG(
"by "
"https://github.com/catapult-project/catapult/blob/master/dashboard/docs/"
"data-format.md.");
#endif
constexpr char kPlotAllMetrics[] = "all";
ABSL_FLAG(std::vector<std::string>,
@ -78,8 +81,6 @@ ABSL_FLAG(std::vector<std::string>,
"available). Example: psnr,ssim,encode_time. To plot all available "
" metrics pass 'all' as flag value");
#endif
ABSL_FLAG(bool, logs, true, "print logs to stderr");
ABSL_FLAG(bool, verbose, false, "verbose logs to stderr");
@ -156,9 +157,22 @@ class TestMainImpl : public TestMain {
rtc::tracing::StartInternalCapture(trace_event_path.c_str());
}
absl::optional<std::vector<std::string>> metrics_to_plot =
absl::GetFlag(FLAGS_plot);
if (metrics_to_plot->empty()) {
metrics_to_plot = absl::nullopt;
} else {
if (metrics_to_plot->size() == 1 &&
(*metrics_to_plot)[0] == kPlotAllMetrics) {
metrics_to_plot->clear();
}
}
#if defined(WEBRTC_IOS)
rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv,
absl::GetFlag(FLAGS_save_chartjson_result));
absl::GetFlag(FLAGS_save_chartjson_result),
metrics_to_plot);
rtc::test::RunTestsFromIOSApp();
int exit_code = 0;
#else
@ -169,13 +183,8 @@ class TestMainImpl : public TestMain {
if (!chartjson_result_file.empty()) {
webrtc::test::WritePerfResults(chartjson_result_file);
}
std::vector<std::string> metrics_to_plot = absl::GetFlag(FLAGS_plot);
if (!metrics_to_plot.empty()) {
if (metrics_to_plot.size() == 1 &&
metrics_to_plot[0] == kPlotAllMetrics) {
metrics_to_plot.clear();
}
webrtc::test::PrintPlottableResults(metrics_to_plot);
if (metrics_to_plot) {
webrtc::test::PrintPlottableResults(*metrics_to_plot);
}
std::string result_filename =