OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 // | 10 // |
11 // A reuseable entry point for gunit tests. | 11 // A reuseable entry point for gunit tests. |
12 | 12 |
13 #if defined(WEBRTC_WIN) | 13 #if defined(WEBRTC_WIN) |
14 #include <crtdbg.h> | 14 #include <crtdbg.h> |
15 #endif | 15 #endif |
16 | 16 |
17 #include "webrtc/base/flags.h" | 17 #include "webrtc/base/flags.h" |
18 #include "webrtc/base/fileutils.h" | 18 #include "webrtc/base/fileutils.h" |
19 #include "webrtc/base/gunit.h" | 19 #include "webrtc/base/gunit.h" |
20 #include "webrtc/base/logging.h" | 20 #include "webrtc/base/logging.h" |
21 #include "webrtc/base/ssladapter.h" | 21 #include "webrtc/base/ssladapter.h" |
| 22 #include "webrtc/test/field_trial.h" |
22 | 23 |
23 DEFINE_bool(help, false, "prints this message"); | 24 DEFINE_bool(help, false, "prints this message"); |
24 DEFINE_string(log, "", "logging options to use"); | 25 DEFINE_string(log, "", "logging options to use"); |
| 26 DEFINE_string( |
| 27 force_fieldtrials, |
| 28 "", |
| 29 "Field trials control experimental feature code which can be forced. " |
| 30 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
| 31 " will assign the group Enable to field trial WebRTC-FooFeature."); |
25 #if defined(WEBRTC_WIN) | 32 #if defined(WEBRTC_WIN) |
26 DEFINE_int(crt_break_alloc, -1, "memory allocation to break on"); | 33 DEFINE_int(crt_break_alloc, -1, "memory allocation to break on"); |
27 DEFINE_bool(default_error_handlers, false, | 34 DEFINE_bool(default_error_handlers, false, |
28 "leave the default exception/dbg handler functions in place"); | 35 "leave the default exception/dbg handler functions in place"); |
29 | 36 |
30 void TestInvalidParameterHandler(const wchar_t* expression, | 37 void TestInvalidParameterHandler(const wchar_t* expression, |
31 const wchar_t* function, | 38 const wchar_t* function, |
32 const wchar_t* file, | 39 const wchar_t* file, |
33 unsigned int line, | 40 unsigned int line, |
34 uintptr_t pReserved) { | 41 uintptr_t pReserved) { |
(...skipping 19 matching lines...) Expand all Loading... |
54 #endif // WEBRTC_WIN | 61 #endif // WEBRTC_WIN |
55 | 62 |
56 int main(int argc, char** argv) { | 63 int main(int argc, char** argv) { |
57 testing::InitGoogleTest(&argc, argv); | 64 testing::InitGoogleTest(&argc, argv); |
58 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false); | 65 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false); |
59 if (FLAG_help) { | 66 if (FLAG_help) { |
60 rtc::FlagList::Print(NULL, false); | 67 rtc::FlagList::Print(NULL, false); |
61 return 0; | 68 return 0; |
62 } | 69 } |
63 | 70 |
| 71 webrtc::test::InitFieldTrialsFromString(FLAG_force_fieldtrials); |
| 72 |
64 #if defined(WEBRTC_WIN) | 73 #if defined(WEBRTC_WIN) |
65 if (!FLAG_default_error_handlers) { | 74 if (!FLAG_default_error_handlers) { |
66 // Make sure any errors don't throw dialogs hanging the test run. | 75 // Make sure any errors don't throw dialogs hanging the test run. |
67 _set_invalid_parameter_handler(TestInvalidParameterHandler); | 76 _set_invalid_parameter_handler(TestInvalidParameterHandler); |
68 _set_purecall_handler(TestPureCallHandler); | 77 _set_purecall_handler(TestPureCallHandler); |
69 _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestCrtReportHandler); | 78 _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, TestCrtReportHandler); |
70 } | 79 } |
71 | 80 |
72 #ifdef _DEBUG // Turn on memory leak checking on Windows. | 81 #ifdef _DEBUG // Turn on memory leak checking on Windows. |
73 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF |_CRTDBG_LEAK_CHECK_DF); | 82 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF |_CRTDBG_LEAK_CHECK_DF); |
(...skipping 24 matching lines...) Expand all Loading... |
98 | 107 |
99 #if defined(WEBRTC_WIN) | 108 #if defined(WEBRTC_WIN) |
100 // Unhook crt function so that we don't ever log after statics have been | 109 // Unhook crt function so that we don't ever log after statics have been |
101 // uninitialized. | 110 // uninitialized. |
102 if (!FLAG_default_error_handlers) | 111 if (!FLAG_default_error_handlers) |
103 _CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestCrtReportHandler); | 112 _CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, TestCrtReportHandler); |
104 #endif | 113 #endif |
105 | 114 |
106 return res; | 115 return res; |
107 } | 116 } |
OLD | NEW |