OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/test/test_timeouts.h" | 5 #include "base/test/test_timeouts.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // InitializeTimeout is called only once per value). | 39 // InitializeTimeout is called only once per value). |
40 // 2) min_value. | 40 // 2) min_value. |
41 // 3) the numerical value given by switch_name on the command line multiplied | 41 // 3) the numerical value given by switch_name on the command line multiplied |
42 // by kTimeoutMultiplier. | 42 // by kTimeoutMultiplier. |
43 void InitializeTimeout(const char* switch_name, int min_value, int* value) { | 43 void InitializeTimeout(const char* switch_name, int min_value, int* value) { |
44 DCHECK(value); | 44 DCHECK(value); |
45 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switch_name)) { | 45 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switch_name)) { |
46 std::string string_value(base::CommandLine::ForCurrentProcess()-> | 46 std::string string_value(base::CommandLine::ForCurrentProcess()-> |
47 GetSwitchValueASCII(switch_name)); | 47 GetSwitchValueASCII(switch_name)); |
48 int timeout; | 48 int timeout; |
49 base::StringToInt(string_value, &timeout); | 49 if (string_value == TestTimeouts::kNoTimeoutSwitchValue) |
| 50 timeout = kAlmostInfiniteTimeoutMs; |
| 51 else |
| 52 base::StringToInt(string_value, &timeout); |
50 *value = std::max(*value, timeout); | 53 *value = std::max(*value, timeout); |
51 } | 54 } |
52 *value *= kTimeoutMultiplier; | 55 *value *= kTimeoutMultiplier; |
53 *value = std::max(*value, min_value); | 56 *value = std::max(*value, min_value); |
54 } | 57 } |
55 | 58 |
56 // Sets value to the greatest of: | 59 // Sets value to the greatest of: |
57 // 1) value's current value multiplied by kTimeoutMultiplier. | 60 // 1) value's current value multiplied by kTimeoutMultiplier. |
58 // 2) 0 | 61 // 2) 0 |
59 // 3) the numerical value given by switch_name on the command line multiplied | 62 // 3) the numerical value given by switch_name on the command line multiplied |
60 // by kTimeoutMultiplier. | 63 // by kTimeoutMultiplier. |
61 void InitializeTimeout(const char* switch_name, int* value) { | 64 void InitializeTimeout(const char* switch_name, int* value) { |
62 InitializeTimeout(switch_name, 0, value); | 65 InitializeTimeout(switch_name, 0, value); |
63 } | 66 } |
64 | 67 |
65 } // namespace | 68 } // namespace |
66 | 69 |
67 // static | 70 // static |
| 71 constexpr const char TestTimeouts::kNoTimeoutSwitchValue[]; |
| 72 |
| 73 // static |
68 bool TestTimeouts::initialized_ = false; | 74 bool TestTimeouts::initialized_ = false; |
69 | 75 |
70 // The timeout values should increase in the order they appear in this block. | 76 // The timeout values should increase in the order they appear in this block. |
71 // static | 77 // static |
72 int TestTimeouts::tiny_timeout_ms_ = 100; | 78 int TestTimeouts::tiny_timeout_ms_ = 100; |
73 int TestTimeouts::action_timeout_ms_ = 10000; | 79 int TestTimeouts::action_timeout_ms_ = 10000; |
74 #ifndef NDEBUG | 80 #ifndef NDEBUG |
75 int TestTimeouts::action_max_timeout_ms_ = 45000; | 81 int TestTimeouts::action_max_timeout_ms_ = 45000; |
76 #else | 82 #else |
77 int TestTimeouts::action_max_timeout_ms_ = 30000; | 83 int TestTimeouts::action_max_timeout_ms_ = 30000; |
(...skipping 27 matching lines...) Expand all Loading... |
105 // Test launcher timeout is independent from anything above action timeout. | 111 // Test launcher timeout is independent from anything above action timeout. |
106 InitializeTimeout(switches::kTestLauncherTimeout, action_timeout_ms_, | 112 InitializeTimeout(switches::kTestLauncherTimeout, action_timeout_ms_, |
107 &test_launcher_timeout_ms_); | 113 &test_launcher_timeout_ms_); |
108 | 114 |
109 // The timeout values should be increasing in the right order. | 115 // The timeout values should be increasing in the right order. |
110 CHECK(tiny_timeout_ms_ <= action_timeout_ms_); | 116 CHECK(tiny_timeout_ms_ <= action_timeout_ms_); |
111 CHECK(action_timeout_ms_ <= action_max_timeout_ms_); | 117 CHECK(action_timeout_ms_ <= action_max_timeout_ms_); |
112 | 118 |
113 CHECK(action_timeout_ms_ <= test_launcher_timeout_ms_); | 119 CHECK(action_timeout_ms_ <= test_launcher_timeout_ms_); |
114 } | 120 } |
OLD | NEW |