Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: webrtc/base/unittest_main.cc

Issue 2877023002: Move webrtc/{base => rtc_base} (Closed)
Patch Set: update presubmit.py and DEPS include rules Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/type_traits.h ('k') | webrtc/base/unixfilesystem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2007 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 //
11 // A reuseable entry point for gunit tests.
12
13 #if defined(WEBRTC_WIN)
14 #include <crtdbg.h>
15 #endif
16
17 #include "webrtc/base/flags.h"
18 #include "webrtc/base/fileutils.h"
19 #include "webrtc/base/gunit.h"
20 #include "webrtc/base/logging.h"
21 #include "webrtc/base/ssladapter.h"
22 #include "webrtc/base/sslstreamadapter.h"
23 #include "webrtc/test/field_trial.h"
24 #include "webrtc/test/testsupport/fileutils.h"
25
26 #if defined(WEBRTC_IOS)
27 #include "webrtc/test/ios/test_support.h"
28 #endif
29
30 DEFINE_bool(help, false, "prints this message");
31 DEFINE_string(log, "", "logging options to use");
32 DEFINE_string(
33 force_fieldtrials,
34 "",
35 "Field trials control experimental feature code which can be forced. "
36 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
37 " will assign the group Enable to field trial WebRTC-FooFeature.");
38 #if defined(WEBRTC_WIN)
39 DEFINE_int(crt_break_alloc, -1, "memory allocation to break on");
40 DEFINE_bool(default_error_handlers, false,
41 "leave the default exception/dbg handler functions in place");
42
43 void TestInvalidParameterHandler(const wchar_t* expression,
44 const wchar_t* function,
45 const wchar_t* file,
46 unsigned int line,
47 uintptr_t pReserved) {
48 LOG(LS_ERROR) << "InvalidParameter Handler called. Exiting.";
49 LOG(LS_ERROR) << expression << std::endl << function << std::endl << file
50 << std::endl << line;
51 exit(1);
52 }
53 void TestPureCallHandler() {
54 LOG(LS_ERROR) << "Purecall Handler called. Exiting.";
55 exit(1);
56 }
57 int TestCrtReportHandler(int report_type, char* msg, int* retval) {
58 LOG(LS_ERROR) << "CrtReport Handler called...";
59 LOG(LS_ERROR) << msg;
60 if (report_type == _CRT_ASSERT) {
61 exit(1);
62 } else {
63 *retval = 0;
64 return TRUE;
65 }
66 }
67 #endif // WEBRTC_WIN
68
69 int main(int argc, char** argv) {
70 testing::InitGoogleTest(&argc, argv);
71 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false);
72 if (FLAG_help) {
73 rtc::FlagList::Print(nullptr, false);
74 return 0;
75 }
76
77 webrtc::test::SetExecutablePath(argv[0]);
78 webrtc::test::InitFieldTrialsFromString(FLAG_force_fieldtrials);
79
80 #if defined(WEBRTC_WIN)
81 if (!FLAG_default_error_handlers) {
82 // Make sure any errors don't throw dialogs hanging the test run.
83 _set_invalid_parameter_handler(TestInvalidParameterHandler);
84 _set_purecall_handler(TestPureCallHandler);
85 _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestCrtReportHandler);
86 }
87
88 #if !defined(NDEBUG) // Turn on memory leak checking on Windows.
89 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF |_CRTDBG_LEAK_CHECK_DF);
90 if (FLAG_crt_break_alloc >= 0) {
91 _crtBreakAlloc = FLAG_crt_break_alloc;
92 }
93 #endif
94 #endif // WEBRTC_WIN
95
96 // By default, log timestamps. Allow overrides by used of a --log flag.
97 rtc::LogMessage::LogTimestamps();
98 if (*FLAG_log != '\0') {
99 rtc::LogMessage::ConfigureLogging(FLAG_log);
100 } else if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO) {
101 // Default to LS_INFO, even for release builds to provide better test
102 // logging.
103 rtc::LogMessage::LogToDebug(rtc::LS_INFO);
104 }
105
106 // Initialize SSL which are used by several tests.
107 rtc::InitializeSSL();
108 rtc::SSLStreamAdapter::enable_time_callback_for_testing();
109
110 #if defined(WEBRTC_IOS)
111 rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv);
112 rtc::test::RunTestsFromIOSApp();
113 #endif
114 const int res = RUN_ALL_TESTS();
115
116 rtc::CleanupSSL();
117
118 // clean up logging so we don't appear to leak memory.
119 rtc::LogMessage::ConfigureLogging("");
120
121 #if defined(WEBRTC_WIN)
122 // Unhook crt function so that we don't ever log after statics have been
123 // uninitialized.
124 if (!FLAG_default_error_handlers)
125 _CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestCrtReportHandler);
126 #endif
127
128 return res;
129 }
OLDNEW
« no previous file with comments | « webrtc/base/type_traits.h ('k') | webrtc/base/unixfilesystem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698