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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 a.Stop(); | 126 a.Stop(); |
127 EXPECT_FALSE(a.message_loop()); | 127 EXPECT_FALSE(a.message_loop()); |
128 EXPECT_FALSE(a.IsRunning()); | 128 EXPECT_FALSE(a.IsRunning()); |
129 } | 129 } |
130 | 130 |
131 TEST_F(ThreadTest, StartWithOptions_StackSize) { | 131 TEST_F(ThreadTest, StartWithOptions_StackSize) { |
132 Thread a("StartWithStackSize"); | 132 Thread a("StartWithStackSize"); |
133 // Ensure that the thread can work with only 12 kb and still process a | 133 // Ensure that the thread can work with only 12 kb and still process a |
134 // message. | 134 // message. |
135 Thread::Options options; | 135 Thread::Options options; |
| 136 #if defined(ADDRESS_SANITIZER) && defined(OS_MACOSX) |
| 137 // ASan bloats the stack variables and overflows the 12 kb stack on OSX. |
| 138 options.stack_size = 24*1024; |
| 139 #else |
136 options.stack_size = 12*1024; | 140 options.stack_size = 12*1024; |
| 141 #endif |
137 EXPECT_TRUE(a.StartWithOptions(options)); | 142 EXPECT_TRUE(a.StartWithOptions(options)); |
138 EXPECT_TRUE(a.message_loop()); | 143 EXPECT_TRUE(a.message_loop()); |
139 EXPECT_TRUE(a.IsRunning()); | 144 EXPECT_TRUE(a.IsRunning()); |
140 | 145 |
141 bool was_invoked = false; | 146 bool was_invoked = false; |
142 a.message_loop()->PostTask(FROM_HERE, base::Bind(&ToggleValue, &was_invoked)); | 147 a.message_loop()->PostTask(FROM_HERE, base::Bind(&ToggleValue, &was_invoked)); |
143 | 148 |
144 // wait for the task to run (we could use a kernel event here | 149 // wait for the task to run (we could use a kernel event here |
145 // instead to avoid busy waiting, but this is sufficient for | 150 // instead to avoid busy waiting, but this is sufficient for |
146 // testing purposes). | 151 // testing purposes). |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 227 |
223 // Upon leaving this scope, the thread is deleted. | 228 // Upon leaving this scope, the thread is deleted. |
224 } | 229 } |
225 | 230 |
226 // Check the order of events during shutdown. | 231 // Check the order of events during shutdown. |
227 ASSERT_EQ(static_cast<size_t>(THREAD_NUM_EVENTS), captured_events.size()); | 232 ASSERT_EQ(static_cast<size_t>(THREAD_NUM_EVENTS), captured_events.size()); |
228 EXPECT_EQ(THREAD_EVENT_INIT, captured_events[0]); | 233 EXPECT_EQ(THREAD_EVENT_INIT, captured_events[0]); |
229 EXPECT_EQ(THREAD_EVENT_CLEANUP, captured_events[1]); | 234 EXPECT_EQ(THREAD_EVENT_CLEANUP, captured_events[1]); |
230 EXPECT_EQ(THREAD_EVENT_MESSAGE_LOOP_DESTROYED, captured_events[2]); | 235 EXPECT_EQ(THREAD_EVENT_MESSAGE_LOOP_DESTROYED, captured_events[2]); |
231 } | 236 } |
OLD | NEW |