| 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) || (defined(OS_IOS) && !defined(NDEBUG)) | 140 #if defined(ADDRESS_SANITIZER) |
| 141 // ASan bloats the stack variables and overflows the 12 kb stack. Debug iOS | 141 // ASan bloats the stack variables and overflows the 12 kb stack. |
| 142 // builds also grow the stack too much. | |
| 143 options.stack_size = 24*1024; | 142 options.stack_size = 24*1024; |
| 144 #else | 143 #else |
| 145 options.stack_size = 12*1024; | 144 options.stack_size = 12*1024; |
| 146 #endif | 145 #endif |
| 147 EXPECT_TRUE(a.StartWithOptions(options)); | 146 EXPECT_TRUE(a.StartWithOptions(options)); |
| 148 EXPECT_TRUE(a.message_loop()); | 147 EXPECT_TRUE(a.message_loop()); |
| 149 EXPECT_TRUE(a.IsRunning()); | 148 EXPECT_TRUE(a.IsRunning()); |
| 150 | 149 |
| 151 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 150 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 152 base::WaitableEvent::InitialState::NOT_SIGNALED); | 151 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 473 |
| 475 a.Stop(); | 474 a.Stop(); |
| 476 EXPECT_FALSE(a.message_loop()); | 475 EXPECT_FALSE(a.message_loop()); |
| 477 EXPECT_FALSE(a.IsRunning()); | 476 EXPECT_FALSE(a.IsRunning()); |
| 478 | 477 |
| 479 // Confirm that running any remaining tasks posted from Stop() goes smoothly | 478 // Confirm that running any remaining tasks posted from Stop() goes smoothly |
| 480 // (e.g. https://codereview.chromium.org/2135413003/#ps300001 crashed if | 479 // (e.g. https://codereview.chromium.org/2135413003/#ps300001 crashed if |
| 481 // StopSoon() posted Thread::ThreadQuitHelper() while |run_loop_| was null). | 480 // StopSoon() posted Thread::ThreadQuitHelper() while |run_loop_| was null). |
| 482 base::RunLoop().RunUntilIdle(); | 481 base::RunLoop().RunUntilIdle(); |
| 483 } | 482 } |
| OLD | NEW |