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 | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "rtc_base/flags.h" |
| 12 | #include "rtc_base/logging.h" |
Bjorn Terelius | edab301 | 2018-01-31 17:23:40 +0100 | [diff] [blame^] | 13 | #include "system_wrappers/include/field_trial_default.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "system_wrappers/include/metrics_default.h" |
| 15 | #include "test/field_trial.h" |
| 16 | #include "test/gmock.h" |
| 17 | #include "test/gtest.h" |
| 18 | #include "test/testsupport/fileutils.h" |
Edward Lemur | ab63bb5 | 2017-12-04 15:56:21 +0100 | [diff] [blame] | 19 | #include "test/testsupport/perf_test.h" |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 20 | |
Kári Tristan Helgason | e2baffb | 2017-06-09 10:31:58 +0200 | [diff] [blame] | 21 | #if defined(WEBRTC_IOS) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "test/ios/test_support.h" |
oprypin | 51d49b4 | 2017-08-22 10:55:47 -0700 | [diff] [blame] | 23 | |
| 24 | DEFINE_string(NSTreatUnknownArgumentsAsOpen, "", |
| 25 | "Intentionally ignored flag intended for iOS simulator."); |
| 26 | DEFINE_string(ApplePersistenceIgnoreState, "", |
| 27 | "Intentionally ignored flag intended for iOS simulator."); |
Edward Lemur | e66572b | 2018-01-05 15:34:09 +0100 | [diff] [blame] | 28 | DEFINE_bool( |
| 29 | save_chartjson_result, |
| 30 | false, |
| 31 | "Store the perf results in Documents/perf_result.json in the format " |
| 32 | "described by " |
| 33 | "https://github.com/catapult-project/catapult/blob/master/dashboard/docs/" |
| 34 | "data-format.md."); |
| 35 | |
| 36 | #else |
| 37 | |
| 38 | DEFINE_string( |
| 39 | chartjson_result_file, |
| 40 | "", |
| 41 | "Path where the perf results should be stored in the JSON format described " |
| 42 | "by " |
| 43 | "https://github.com/catapult-project/catapult/blob/master/dashboard/docs/" |
| 44 | "data-format.md."); |
| 45 | |
Kári Tristan Helgason | e2baffb | 2017-06-09 10:31:58 +0200 | [diff] [blame] | 46 | #endif |
| 47 | |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 48 | DEFINE_bool(logs, false, "print logs to stderr"); |
pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 49 | |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 50 | DEFINE_string(force_fieldtrials, "", |
| 51 | "Field trials control experimental feature code which can be forced. " |
| 52 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
| 53 | " will assign the group Enable to field trial WebRTC-FooFeature."); |
| 54 | |
oprypin | 9b2f20c | 2017-08-29 05:51:57 -0700 | [diff] [blame] | 55 | DEFINE_bool(help, false, "Print this message."); |
| 56 | |
pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 57 | int main(int argc, char* argv[]) { |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 58 | ::testing::InitGoogleMock(&argc, argv); |
pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 59 | |
Peter Boström | def5820 | 2015-11-27 17:53:22 +0100 | [diff] [blame] | 60 | // Default to LS_INFO, even for release builds to provide better test logging. |
| 61 | // TODO(pbos): Consider adding a command-line override. |
| 62 | if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO) |
| 63 | rtc::LogMessage::LogToDebug(rtc::LS_INFO); |
| 64 | |
oprypin | 9b2f20c | 2017-08-29 05:51:57 -0700 | [diff] [blame] | 65 | if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false)) { |
| 66 | return 1; |
| 67 | } |
| 68 | if (FLAG_help) { |
| 69 | rtc::FlagList::Print(nullptr, false); |
| 70 | return 0; |
| 71 | } |
andresp@webrtc.org | 60015d2 | 2014-05-16 09:39:51 +0000 | [diff] [blame] | 72 | |
| 73 | webrtc::test::SetExecutablePath(argv[0]); |
Bjorn Terelius | edab301 | 2018-01-31 17:23:40 +0100 | [diff] [blame^] | 74 | webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials); |
| 75 | // InitFieldTrialsFromString stores the char*, so the char array must outlive |
| 76 | // the application. |
| 77 | webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials); |
asapersson | 01d70a3 | 2016-05-20 06:29:46 -0700 | [diff] [blame] | 78 | webrtc::metrics::Enable(); |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 79 | |
Edward Lemur | e66572b | 2018-01-05 15:34:09 +0100 | [diff] [blame] | 80 | |
oprypin | 9b2f20c | 2017-08-29 05:51:57 -0700 | [diff] [blame] | 81 | rtc::LogMessage::SetLogToStderr(FLAG_logs); |
Edward Lemur | e66572b | 2018-01-05 15:34:09 +0100 | [diff] [blame] | 82 | |
Kári Tristan Helgason | e2baffb | 2017-06-09 10:31:58 +0200 | [diff] [blame] | 83 | #if defined(WEBRTC_IOS) |
Edward Lemur | e66572b | 2018-01-05 15:34:09 +0100 | [diff] [blame] | 84 | |
| 85 | rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv, |
| 86 | FLAG_save_chartjson_result); |
Kári Tristan Helgason | e2baffb | 2017-06-09 10:31:58 +0200 | [diff] [blame] | 87 | rtc::test::RunTestsFromIOSApp(); |
Edward Lemur | e66572b | 2018-01-05 15:34:09 +0100 | [diff] [blame] | 88 | |
| 89 | #else |
ehmaldonado | 26bddb9 | 2016-11-30 06:12:01 -0800 | [diff] [blame] | 90 | |
Edward Lemur | ab63bb5 | 2017-12-04 15:56:21 +0100 | [diff] [blame] | 91 | int exit_code = RUN_ALL_TESTS(); |
| 92 | |
Edward Lemur | e66572b | 2018-01-05 15:34:09 +0100 | [diff] [blame] | 93 | std::string chartjson_result_file = FLAG_chartjson_result_file; |
Edward Lemur | 3460fa6 | 2018-01-08 15:52:14 +0100 | [diff] [blame] | 94 | if (!chartjson_result_file.empty()) { |
Edward Lemur | e66572b | 2018-01-05 15:34:09 +0100 | [diff] [blame] | 95 | webrtc::test::WritePerfResults(chartjson_result_file); |
Edward Lemur | ab63bb5 | 2017-12-04 15:56:21 +0100 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | return exit_code; |
Edward Lemur | e66572b | 2018-01-05 15:34:09 +0100 | [diff] [blame] | 99 | |
| 100 | #endif |
pbos@webrtc.org | af8d5af | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 101 | } |