OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/threading/thread.h" | 5 #include "base/threading/thread.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 event->Signal(); | 130 event->Signal(); |
131 } | 131 } |
132 | 132 |
133 } // namespace | 133 } // namespace |
134 | 134 |
135 TEST_F(ThreadTest, StartWithOptions_StackSize) { | 135 TEST_F(ThreadTest, StartWithOptions_StackSize) { |
136 Thread a("StartWithStackSize"); | 136 Thread a("StartWithStackSize"); |
137 // Ensure that the thread can work with only 12 kb and still process a | 137 // Ensure that the thread can work with only 12 kb and still process a |
138 // message. | 138 // message. |
139 Thread::Options options; | 139 Thread::Options options; |
140 #if defined(ADDRESS_SANITIZER) | 140 #if defined(ADDRESS_SANITIZER) || !defined(NDEBUG) |
141 // ASan bloats the stack variables and overflows the 12 kb stack. | 141 // ASan bloats the stack variables and overflows the 12 kb stack. Some debug |
| 142 // builds also grow the stack too much. |
142 options.stack_size = 24*1024; | 143 options.stack_size = 24*1024; |
143 #else | 144 #else |
144 options.stack_size = 12*1024; | 145 options.stack_size = 12*1024; |
145 #endif | 146 #endif |
146 EXPECT_TRUE(a.StartWithOptions(options)); | 147 EXPECT_TRUE(a.StartWithOptions(options)); |
147 EXPECT_TRUE(a.message_loop()); | 148 EXPECT_TRUE(a.message_loop()); |
148 EXPECT_TRUE(a.IsRunning()); | 149 EXPECT_TRUE(a.IsRunning()); |
149 | 150 |
150 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 151 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
151 base::WaitableEvent::InitialState::NOT_SIGNALED); | 152 base::WaitableEvent::InitialState::NOT_SIGNALED); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 474 |
474 a.Stop(); | 475 a.Stop(); |
475 EXPECT_FALSE(a.message_loop()); | 476 EXPECT_FALSE(a.message_loop()); |
476 EXPECT_FALSE(a.IsRunning()); | 477 EXPECT_FALSE(a.IsRunning()); |
477 | 478 |
478 // Confirm that running any remaining tasks posted from Stop() goes smoothly | 479 // Confirm that running any remaining tasks posted from Stop() goes smoothly |
479 // (e.g. https://codereview.chromium.org/2135413003/#ps300001 crashed if | 480 // (e.g. https://codereview.chromium.org/2135413003/#ps300001 crashed if |
480 // StopSoon() posted Thread::ThreadQuitHelper() while |run_loop_| was null). | 481 // StopSoon() posted Thread::ThreadQuitHelper() while |run_loop_| was null). |
481 base::RunLoop().RunUntilIdle(); | 482 base::RunLoop().RunUntilIdle(); |
482 } | 483 } |
OLD | NEW |