blob: 277d420c6756f24c8d85b14230b1e5e279df24ac [file] [log] [blame]
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#include "rtc_base/flags.h"
12#include "rtc_base/logging.h"
Bjorn Tereliusedab3012018-01-31 17:23:40 +010013#include "system_wrappers/include/field_trial_default.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#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 Lemurab63bb52017-12-04 15:56:21 +010019#include "test/testsupport/perf_test.h"
ehmaldonado26bddb92016-11-30 06:12:01 -080020
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020021#if defined(WEBRTC_IOS)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020022#include "test/ios/test_support.h"
oprypin51d49b42017-08-22 10:55:47 -070023
Yves Gerey665174f2018-06-19 15:03:05 +020024DEFINE_string(NSTreatUnknownArgumentsAsOpen,
25 "",
26 "Intentionally ignored flag intended for iOS simulator.");
27DEFINE_string(ApplePersistenceIgnoreState,
28 "",
29 "Intentionally ignored flag intended for iOS simulator.");
Edward Lemure66572b2018-01-05 15:34:09 +010030DEFINE_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 Gerey665174f2018-06-19 15:03:05 +020040DEFINE_string(isolated_script_test_output,
41 "",
42 "Intentionally ignored flag intended for Chromium.");
Edward Lemur0c15a092018-02-08 20:16:41 +010043
44DEFINE_string(
45 isolated_script_test_perf_output,
Edward Lemure66572b2018-01-05 15:34:09 +010046 "",
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 Helgasone2baffb2017-06-09 10:31:58 +020052#endif
53
ehmaldonado26bddb92016-11-30 06:12:01 -080054DEFINE_bool(logs, false, "print logs to stderr");
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000055
Yves Gerey665174f2018-06-19 15:03:05 +020056DEFINE_string(
57 force_fieldtrials,
58 "",
andresp@webrtc.org60015d22014-05-16 09:39:51 +000059 "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
oprypin9b2f20c2017-08-29 05:51:57 -070063DEFINE_bool(help, false, "Print this message.");
64
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000065int main(int argc, char* argv[]) {
ehmaldonado26bddb92016-11-30 06:12:01 -080066 ::testing::InitGoogleMock(&argc, argv);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000067
Peter Boströmdef58202015-11-27 17:53:22 +010068 // 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
oprypin9b2f20c2017-08-29 05:51:57 -070073 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.org60015d22014-05-16 09:39:51 +000080
81 webrtc::test::SetExecutablePath(argv[0]);
Bjorn Tereliusedab3012018-01-31 17:23:40 +010082 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);
asapersson01d70a32016-05-20 06:29:46 -070086 webrtc::metrics::Enable();
ehmaldonado26bddb92016-11-30 06:12:01 -080087
oprypin9b2f20c2017-08-29 05:51:57 -070088 rtc::LogMessage::SetLogToStderr(FLAG_logs);
Edward Lemure66572b2018-01-05 15:34:09 +010089
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020090#if defined(WEBRTC_IOS)
Edward Lemure66572b2018-01-05 15:34:09 +010091
92 rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv,
93 FLAG_save_chartjson_result);
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020094 rtc::test::RunTestsFromIOSApp();
Edward Lemure66572b2018-01-05 15:34:09 +010095
96#else
ehmaldonado26bddb92016-11-30 06:12:01 -080097
Edward Lemurab63bb52017-12-04 15:56:21 +010098 int exit_code = RUN_ALL_TESTS();
99
Edward Lemur0c15a092018-02-08 20:16:41 +0100100 std::string chartjson_result_file = FLAG_isolated_script_test_perf_output;
Edward Lemur3460fa62018-01-08 15:52:14 +0100101 if (!chartjson_result_file.empty()) {
Edward Lemure66572b2018-01-05 15:34:09 +0100102 webrtc::test::WritePerfResults(chartjson_result_file);
Edward Lemurab63bb52017-12-04 15:56:21 +0100103 }
104
105 return exit_code;
Edward Lemure66572b2018-01-05 15:34:09 +0100106
107#endif
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000108}