blob: c6c00c599d87f7de5de7282b5ddeba3c7623e91a [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 Bonadei712989d2017-12-14 12:51:07 +000011#include <fstream>
12
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "rtc_base/flags.h"
14#include "rtc_base/logging.h"
15#include "system_wrappers/include/metrics_default.h"
16#include "test/field_trial.h"
17#include "test/gmock.h"
18#include "test/gtest.h"
19#include "test/testsupport/fileutils.h"
Edward Lemurab63bb52017-12-04 15:56:21 +010020#include "test/testsupport/perf_test.h"
ehmaldonado26bddb92016-11-30 06:12:01 -080021
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020022#if defined(WEBRTC_IOS)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020023#include "test/ios/test_support.h"
oprypin51d49b42017-08-22 10:55:47 -070024
25DEFINE_string(NSTreatUnknownArgumentsAsOpen, "",
26 "Intentionally ignored flag intended for iOS simulator.");
27DEFINE_string(ApplePersistenceIgnoreState, "",
28 "Intentionally ignored flag intended for iOS simulator.");
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020029#endif
30
ehmaldonado26bddb92016-11-30 06:12:01 -080031DEFINE_bool(logs, false, "print logs to stderr");
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000032
andresp@webrtc.org60015d22014-05-16 09:39:51 +000033DEFINE_string(force_fieldtrials, "",
34 "Field trials control experimental feature code which can be forced. "
35 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
36 " will assign the group Enable to field trial WebRTC-FooFeature.");
37
Mirko Bonadei712989d2017-12-14 12:51:07 +000038DEFINE_string(
39 chartjson_result_file,
40 "",
41 "Path where the perf results should be stored it the JSON format described "
42 "by "
43 "https://github.com/catapult-project/catapult/blob/master/dashboard/docs/"
44 "data-format.md.");
Edward Lemurab63bb52017-12-04 15:56:21 +010045
oprypin9b2f20c2017-08-29 05:51:57 -070046DEFINE_bool(help, false, "Print this message.");
47
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000048int main(int argc, char* argv[]) {
ehmaldonado26bddb92016-11-30 06:12:01 -080049 ::testing::InitGoogleMock(&argc, argv);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000050
Peter Boströmdef58202015-11-27 17:53:22 +010051 // Default to LS_INFO, even for release builds to provide better test logging.
52 // TODO(pbos): Consider adding a command-line override.
53 if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO)
54 rtc::LogMessage::LogToDebug(rtc::LS_INFO);
55
oprypin9b2f20c2017-08-29 05:51:57 -070056 if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false)) {
57 return 1;
58 }
59 if (FLAG_help) {
60 rtc::FlagList::Print(nullptr, false);
61 return 0;
62 }
andresp@webrtc.org60015d22014-05-16 09:39:51 +000063
64 webrtc::test::SetExecutablePath(argv[0]);
oprypin9b2f20c2017-08-29 05:51:57 -070065 std::string fieldtrials = FLAG_force_fieldtrials;
66 webrtc::test::InitFieldTrialsFromString(fieldtrials);
asapersson01d70a32016-05-20 06:29:46 -070067 webrtc::metrics::Enable();
ehmaldonado26bddb92016-11-30 06:12:01 -080068
oprypin9b2f20c2017-08-29 05:51:57 -070069 rtc::LogMessage::SetLogToStderr(FLAG_logs);
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020070#if defined(WEBRTC_IOS)
Mirko Bonadei712989d2017-12-14 12:51:07 +000071 rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv);
Kári Tristan Helgasone2baffb2017-06-09 10:31:58 +020072 rtc::test::RunTestsFromIOSApp();
Mirko Bonadei712989d2017-12-14 12:51:07 +000073#endif
ehmaldonado26bddb92016-11-30 06:12:01 -080074
Edward Lemurab63bb52017-12-04 15:56:21 +010075 int exit_code = RUN_ALL_TESTS();
76
Edward Lemurf7114282017-12-11 17:21:46 +010077 std::string chartjson_result_file = FLAG_chartjson_result_file;
78 if (chartjson_result_file != "") {
Mirko Bonadei712989d2017-12-14 12:51:07 +000079 std::string json_results = webrtc::test::GetPerfResultsJSON();
80 std::fstream json_file(chartjson_result_file, std::fstream::out);
81 json_file << json_results;
82 json_file.close();
Edward Lemurab63bb52017-12-04 15:56:21 +010083 }
84
85 return exit_code;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000086}