diff --git a/test/test_main.cc b/test/test_main.cc index 8bd2ed2244..5023ae6558 100644 --- a/test/test_main.cc +++ b/test/test_main.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "rtc_base/file.h" #include "rtc_base/flags.h" #include "rtc_base/logging.h" #include "system_wrappers/include/metrics_default.h" @@ -15,6 +16,7 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/fileutils.h" +#include "test/testsupport/perf_test.h" #if defined(WEBRTC_IOS) #include "test/ios/test_support.h" @@ -32,6 +34,14 @@ DEFINE_string(force_fieldtrials, "", "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" " will assign the group Enable to field trial WebRTC-FooFeature."); +DEFINE_string( + perf_results_json_path, + "", + "Path where the perf results should be stored it the JSON format described " + "by " + "https://github.com/catapult-project/catapult/blob/master/dashboard/docs/" + "data-format.md."); + DEFINE_bool(help, false, "Print this message."); int main(int argc, char* argv[]) { @@ -61,5 +71,16 @@ int main(int argc, char* argv[]) { rtc::test::RunTestsFromIOSApp(); #endif - return RUN_ALL_TESTS(); + int exit_code = RUN_ALL_TESTS(); + + std::string perf_results_json_path = FLAG_perf_results_json_path; + if (perf_results_json_path != "") { + std::string json_results = webrtc::test::GetPerfResultsJSON(); + rtc::File json_file = rtc::File::Open(perf_results_json_path); + json_file.Write(reinterpret_cast(json_results.c_str()), + json_results.size()); + json_file.Close(); + } + + return exit_code; }