blob: 962c677d9b087cbab88f978bcf4f0d988d579245 [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
24DEFINE_string(NSTreatUnknownArgumentsAsOpen, "",
25 "Intentionally ignored flag intended for iOS simulator.");
26DEFINE_string(ApplePersistenceIgnoreState, "",
27 "Intentionally ignored flag intended for iOS simulator.");
Edward Lemure66572b2018-01-05 15:34:09 +010028DEFINE_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
38DEFINE_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 Helgasone2baffb2017-06-09 10:31:58 +020046#endif
47
ehmaldonado26bddb92016-11-30 06:12:01 -080048DEFINE_bool(logs, false, "print logs to stderr");
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000049
andresp@webrtc.org60015d22014-05-16 09:39:51 +000050DEFINE_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
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]);
Bjorn Tereliusedab3012018-01-31 17:23:40 +010074 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);
asapersson01d70a32016-05-20 06:29:46 -070078 webrtc::metrics::Enable();
ehmaldonado26bddb92016-11-30 06:12:01 -080079
Edward Lemure66572b2018-01-05 15:34:09 +010080
oprypin9b2f20c2017-08-29 05:51:57 -070081 rtc::LogMessage::SetLogToStderr(FLAG_logs);
Edward Lemure66572b2018-01-05 15:34:09 +010082
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020083#if defined(WEBRTC_IOS)
Edward Lemure66572b2018-01-05 15:34:09 +010084
85 rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv,
86 FLAG_save_chartjson_result);
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020087 rtc::test::RunTestsFromIOSApp();
Edward Lemure66572b2018-01-05 15:34:09 +010088
89#else
ehmaldonado26bddb92016-11-30 06:12:01 -080090
Edward Lemurab63bb52017-12-04 15:56:21 +010091 int exit_code = RUN_ALL_TESTS();
92
Edward Lemure66572b2018-01-05 15:34:09 +010093 std::string chartjson_result_file = FLAG_chartjson_result_file;
Edward Lemur3460fa62018-01-08 15:52:14 +010094 if (!chartjson_result_file.empty()) {
Edward Lemure66572b2018-01-05 15:34:09 +010095 webrtc::test::WritePerfResults(chartjson_result_file);
Edward Lemurab63bb52017-12-04 15:56:21 +010096 }
97
98 return exit_code;
Edward Lemure66572b2018-01-05 15:34:09 +010099
100#endif
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000101}