pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 712989d | 2017-12-14 12:51:07 +0000 | [diff] [blame] | 11 | #include <fstream> |
| 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "rtc_base/flags.h" |
| 14 | #include "rtc_base/logging.h" |
| 15 | #include "system_wrappers/include/metrics_default.h" |
| 16 | #include "test/field_trial.h" |
| 17 | #include "test/gmock.h" |
| 18 | #include "test/gtest.h" |
| 19 | #include "test/testsupport/fileutils.h" |
Edward Lemur | ab63bb5 | 2017-12-04 15:56:21 +0100 | [diff] [blame] | 20 | #include "test/testsupport/perf_test.h" |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 21 | |
Kári Tristan Helgason | e2baffb | 2017-06-09 10:31:58 +0200 | [diff] [blame] | 22 | #if defined(WEBRTC_IOS) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "test/ios/test_support.h" |
oprypin | 51d49b4 | 2017-08-22 10:55:47 -0700 | [diff] [blame] | 24 | |
| 25 | DEFINE_string(NSTreatUnknownArgumentsAsOpen, "", |
| 26 | "Intentionally ignored flag intended for iOS simulator."); |
| 27 | DEFINE_string(ApplePersistenceIgnoreState, "", |
| 28 | "Intentionally ignored flag intended for iOS simulator."); |
Kári Tristan Helgason | e2baffb | 2017-06-09 10:31:58 +0200 | [diff] [blame] | 29 | #endif |
| 30 | |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 31 | DEFINE_bool(logs, false, "print logs to stderr"); |
pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 32 | |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 33 | DEFINE_string(force_fieldtrials, "", |
| 34 | "Field trials control experimental feature code which can be forced. " |
| 35 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
| 36 | " will assign the group Enable to field trial WebRTC-FooFeature."); |
| 37 | |
Mirko Bonadei | 712989d | 2017-12-14 12:51:07 +0000 | [diff] [blame] | 38 | DEFINE_string( |
| 39 | chartjson_result_file, |
| 40 | "", |
| 41 | "Path where the perf results should be stored it the JSON format described " |
| 42 | "by " |
| 43 | "https://github.com/catapult-project/catapult/blob/master/dashboard/docs/" |
| 44 | "data-format.md."); |
Edward Lemur | ab63bb5 | 2017-12-04 15:56:21 +0100 | [diff] [blame] | 45 | |
oprypin | 9b2f20c | 2017-08-29 05:51:57 -0700 | [diff] [blame] | 46 | DEFINE_bool(help, false, "Print this message."); |
| 47 | |
pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 48 | int main(int argc, char* argv[]) { |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 49 | ::testing::InitGoogleMock(&argc, argv); |
pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 50 | |
Peter Boström | def5820 | 2015-11-27 17:53:22 +0100 | [diff] [blame] | 51 | // Default to LS_INFO, even for release builds to provide better test logging. |
| 52 | // TODO(pbos): Consider adding a command-line override. |
| 53 | if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO) |
| 54 | rtc::LogMessage::LogToDebug(rtc::LS_INFO); |
| 55 | |
oprypin | 9b2f20c | 2017-08-29 05:51:57 -0700 | [diff] [blame] | 56 | if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false)) { |
| 57 | return 1; |
| 58 | } |
| 59 | if (FLAG_help) { |
| 60 | rtc::FlagList::Print(nullptr, false); |
| 61 | return 0; |
| 62 | } |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 63 | |
| 64 | webrtc::test::SetExecutablePath(argv[0]); |
oprypin | 9b2f20c | 2017-08-29 05:51:57 -0700 | [diff] [blame] | 65 | std::string fieldtrials = FLAG_force_fieldtrials; |
| 66 | webrtc::test::InitFieldTrialsFromString(fieldtrials); |
asapersson | 01d70a3 | 2016-05-20 06:29:46 -0700 | [diff] [blame] | 67 | webrtc::metrics::Enable(); |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 68 | |
oprypin | 9b2f20c | 2017-08-29 05:51:57 -0700 | [diff] [blame] | 69 | rtc::LogMessage::SetLogToStderr(FLAG_logs); |
Kári Tristan Helgason | e2baffb | 2017-06-09 10:31:58 +0200 | [diff] [blame] | 70 | #if defined(WEBRTC_IOS) |
Mirko Bonadei | 712989d | 2017-12-14 12:51:07 +0000 | [diff] [blame] | 71 | rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv); |
Kári Tristan Helgason | e2baffb | 2017-06-09 10:31:58 +0200 | [diff] [blame] | 72 | rtc::test::RunTestsFromIOSApp(); |
Mirko Bonadei | 712989d | 2017-12-14 12:51:07 +0000 | [diff] [blame] | 73 | #endif |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 74 | |
Edward Lemur | ab63bb5 | 2017-12-04 15:56:21 +0100 | [diff] [blame] | 75 | int exit_code = RUN_ALL_TESTS(); |
| 76 | |
Edward Lemur | f711428 | 2017-12-11 17:21:46 +0100 | [diff] [blame] | 77 | std::string chartjson_result_file = FLAG_chartjson_result_file; |
| 78 | if (chartjson_result_file != "") { |
Mirko Bonadei | 712989d | 2017-12-14 12:51:07 +0000 | [diff] [blame] | 79 | std::string json_results = webrtc::test::GetPerfResultsJSON(); |
| 80 | std::fstream json_file(chartjson_result_file, std::fstream::out); |
| 81 | json_file << json_results; |
| 82 | json_file.close(); |
Edward Lemur | ab63bb5 | 2017-12-04 15:56:21 +0100 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | return exit_code; |
pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 86 | } |