blob: 4b36271333d8595ad4c72dd96c1168e7e40dbf94 [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 Lemur8b886bb2017-12-13 13:23:17 +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
Edward Lemurab63bb52017-12-04 15:56:21 +010054
oprypin9b2f20c2017-08-29 05:51:57 -070055DEFINE_bool(help, false, "Print this message.");
56
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000057int main(int argc, char* argv[]) {
ehmaldonado26bddb92016-11-30 06:12:01 -080058 ::testing::InitGoogleMock(&argc, argv);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000059
Peter Boströmdef58202015-11-27 17:53:22 +010060 // 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
oprypin9b2f20c2017-08-29 05:51:57 -070065 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.org60015d22014-05-16 09:39:51 +000072
73 webrtc::test::SetExecutablePath(argv[0]);
oprypin9b2f20c2017-08-29 05:51:57 -070074 std::string fieldtrials = FLAG_force_fieldtrials;
75 webrtc::test::InitFieldTrialsFromString(fieldtrials);
asapersson01d70a32016-05-20 06:29:46 -070076 webrtc::metrics::Enable();
ehmaldonado26bddb92016-11-30 06:12:01 -080077
Edward Lemur8b886bb2017-12-13 13:23:17 +010078
oprypin9b2f20c2017-08-29 05:51:57 -070079 rtc::LogMessage::SetLogToStderr(FLAG_logs);
Edward Lemur8b886bb2017-12-13 13:23:17 +010080
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020081#if defined(WEBRTC_IOS)
Edward Lemur8b886bb2017-12-13 13:23:17 +010082
83 rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv,
84 FLAG_save_chartjson_result);
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020085 rtc::test::RunTestsFromIOSApp();
Edward Lemur8b886bb2017-12-13 13:23:17 +010086
87#else
ehmaldonado26bddb92016-11-30 06:12:01 -080088
Edward Lemurab63bb52017-12-04 15:56:21 +010089 int exit_code = RUN_ALL_TESTS();
90
Edward Lemurf7114282017-12-11 17:21:46 +010091 std::string chartjson_result_file = FLAG_chartjson_result_file;
92 if (chartjson_result_file != "") {
Edward Lemur8b886bb2017-12-13 13:23:17 +010093 webrtc::test::WritePerfResults(chartjson_result_file);
Edward Lemurab63bb52017-12-04 15:56:21 +010094 }
95
96 return exit_code;
Edward Lemur8b886bb2017-12-13 13:23:17 +010097
98#endif
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000099}