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