blob: 60e75bc2e30556b9badadde5f5c6000113c8bee9 [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"
13#include "system_wrappers/include/metrics_default.h"
14#include "test/field_trial.h"
15#include "test/gmock.h"
16#include "test/gtest.h"
17#include "test/testsupport/fileutils.h"
Edward Lemurab63bb52017-12-04 15:56:21 +010018#include "test/testsupport/perf_test.h"
ehmaldonado26bddb92016-11-30 06:12:01 -080019
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020020#if defined(WEBRTC_IOS)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "test/ios/test_support.h"
oprypin51d49b42017-08-22 10:55:47 -070022
23DEFINE_string(NSTreatUnknownArgumentsAsOpen, "",
24 "Intentionally ignored flag intended for iOS simulator.");
25DEFINE_string(ApplePersistenceIgnoreState, "",
26 "Intentionally ignored flag intended for iOS simulator.");
Edward Lemure66572b2018-01-05 15:34:09 +010027DEFINE_bool(
28 save_chartjson_result,
29 false,
30 "Store the perf results in Documents/perf_result.json in the format "
31 "described by "
32 "https://github.com/catapult-project/catapult/blob/master/dashboard/docs/"
33 "data-format.md.");
34
35#else
36
37DEFINE_string(
38 chartjson_result_file,
39 "",
40 "Path where the perf results should be stored in the JSON format described "
41 "by "
42 "https://github.com/catapult-project/catapult/blob/master/dashboard/docs/"
43 "data-format.md.");
44
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020045#endif
46
ehmaldonado26bddb92016-11-30 06:12:01 -080047DEFINE_bool(logs, false, "print logs to stderr");
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000048
andresp@webrtc.org60015d22014-05-16 09:39:51 +000049DEFINE_string(force_fieldtrials, "",
50 "Field trials control experimental feature code which can be forced. "
51 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
52 " will assign the group Enable to field trial WebRTC-FooFeature.");
53
oprypin9b2f20c2017-08-29 05:51:57 -070054DEFINE_bool(help, false, "Print this message.");
55
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000056int main(int argc, char* argv[]) {
ehmaldonado26bddb92016-11-30 06:12:01 -080057 ::testing::InitGoogleMock(&argc, argv);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000058
Peter Boströmdef58202015-11-27 17:53:22 +010059 // Default to LS_INFO, even for release builds to provide better test logging.
60 // TODO(pbos): Consider adding a command-line override.
61 if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO)
62 rtc::LogMessage::LogToDebug(rtc::LS_INFO);
63
oprypin9b2f20c2017-08-29 05:51:57 -070064 if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false)) {
65 return 1;
66 }
67 if (FLAG_help) {
68 rtc::FlagList::Print(nullptr, false);
69 return 0;
70 }
andresp@webrtc.org60015d22014-05-16 09:39:51 +000071
72 webrtc::test::SetExecutablePath(argv[0]);
oprypin9b2f20c2017-08-29 05:51:57 -070073 std::string fieldtrials = FLAG_force_fieldtrials;
74 webrtc::test::InitFieldTrialsFromString(fieldtrials);
asapersson01d70a32016-05-20 06:29:46 -070075 webrtc::metrics::Enable();
ehmaldonado26bddb92016-11-30 06:12:01 -080076
Edward Lemure66572b2018-01-05 15:34:09 +010077
oprypin9b2f20c2017-08-29 05:51:57 -070078 rtc::LogMessage::SetLogToStderr(FLAG_logs);
Edward Lemure66572b2018-01-05 15:34:09 +010079
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020080#if defined(WEBRTC_IOS)
Edward Lemure66572b2018-01-05 15:34:09 +010081
82 rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv,
83 FLAG_save_chartjson_result);
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020084 rtc::test::RunTestsFromIOSApp();
Edward Lemure66572b2018-01-05 15:34:09 +010085
86#else
ehmaldonado26bddb92016-11-30 06:12:01 -080087
Edward Lemurab63bb52017-12-04 15:56:21 +010088 int exit_code = RUN_ALL_TESTS();
89
Edward Lemure66572b2018-01-05 15:34:09 +010090 std::string chartjson_result_file = FLAG_chartjson_result_file;
91 if (chartjson_result_file != "") {
92 webrtc::test::WritePerfResults(chartjson_result_file);
Edward Lemurab63bb52017-12-04 15:56:21 +010093 }
94
95 return exit_code;
Edward Lemure66572b2018-01-05 15:34:09 +010096
97#endif
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000098}