OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/task_scheduler/scheduler_lock.h" | 5 #include "base/task_scheduler/scheduler_lock.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/task_scheduler/test_utils.h" |
13 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
14 #include "base/threading/simple_thread.h" | 15 #include "base/threading/simple_thread.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 namespace internal { | 19 namespace internal { |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Death tests misbehave on Android. | |
22 #if DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) | |
23 #define EXPECT_DCHECK_DEATH(statement, regex) EXPECT_DEATH(statement, regex) | |
24 #else | |
25 #define EXPECT_DCHECK_DEATH(statement, regex) | |
26 #endif | |
27 | |
28 // Adapted from base::Lock's BasicLockTestThread to make sure | 22 // Adapted from base::Lock's BasicLockTestThread to make sure |
29 // Acquire()/Release() don't crash. | 23 // Acquire()/Release() don't crash. |
30 class BasicLockTestThread : public SimpleThread { | 24 class BasicLockTestThread : public SimpleThread { |
31 public: | 25 public: |
32 explicit BasicLockTestThread(SchedulerLock* lock) | 26 explicit BasicLockTestThread(SchedulerLock* lock) |
33 : SimpleThread("BasicLockTestThread"), | 27 : SimpleThread("BasicLockTestThread"), |
34 lock_(lock), | 28 lock_(lock), |
35 acquired_(0) {} | 29 acquired_(0) {} |
36 | 30 |
37 int acquired() const { return acquired_; } | 31 int acquired() const { return acquired_; } |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 SchedulerLock lock4; | 284 SchedulerLock lock4; |
291 SchedulerLock lock5; | 285 SchedulerLock lock5; |
292 }; | 286 }; |
293 | 287 |
294 EXPECT_DCHECK_DEATH({ LockCycle cycle; }, ""); | 288 EXPECT_DCHECK_DEATH({ LockCycle cycle; }, ""); |
295 } | 289 } |
296 | 290 |
297 } // namespace | 291 } // namespace |
298 } // namespace internal | 292 } // namespace internal |
299 } // namespace base | 293 } // namespace base |
OLD | NEW |