Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: base/task_scheduler/scheduler_lock_unittest.cc

Issue 2213933003: Change EXPECT/ASSERT_DCHECK_DEATH macro to not expose the |regex| parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b2b0_simplethreadJoinable
Patch Set: Disabling a death test which crashed instead of DCHECKing : http://crbug.com/634552 Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 lock.Release(); 124 lock.Release();
125 predecessor.Release(); 125 predecessor.Release();
126 } 126 }
127 127
128 TEST(TaskSchedulerLock, AcquirePredecessorWrongOrder) { 128 TEST(TaskSchedulerLock, AcquirePredecessorWrongOrder) {
129 SchedulerLock predecessor; 129 SchedulerLock predecessor;
130 SchedulerLock lock(&predecessor); 130 SchedulerLock lock(&predecessor);
131 EXPECT_DCHECK_DEATH({ 131 EXPECT_DCHECK_DEATH({
132 lock.Acquire(); 132 lock.Acquire();
133 predecessor.Acquire(); 133 predecessor.Acquire();
134 }, ""); 134 });
135 } 135 }
136 136
137 TEST(TaskSchedulerLock, AcquireNonPredecessor) { 137 TEST(TaskSchedulerLock, AcquireNonPredecessor) {
138 SchedulerLock lock1; 138 SchedulerLock lock1;
139 SchedulerLock lock2; 139 SchedulerLock lock2;
140 EXPECT_DCHECK_DEATH({ 140 EXPECT_DCHECK_DEATH({
141 lock1.Acquire(); 141 lock1.Acquire();
142 lock2.Acquire(); 142 lock2.Acquire();
143 }, ""); 143 });
144 } 144 }
145 145
146 TEST(TaskSchedulerLock, AcquireMultipleLocksInOrder) { 146 TEST(TaskSchedulerLock, AcquireMultipleLocksInOrder) {
147 SchedulerLock lock1; 147 SchedulerLock lock1;
148 SchedulerLock lock2(&lock1); 148 SchedulerLock lock2(&lock1);
149 SchedulerLock lock3(&lock2); 149 SchedulerLock lock3(&lock2);
150 lock1.Acquire(); 150 lock1.Acquire();
151 lock2.Acquire(); 151 lock2.Acquire();
152 lock3.Acquire(); 152 lock3.Acquire();
153 lock3.Release(); 153 lock3.Release();
(...skipping 11 matching lines...) Expand all
165 lock2.Release(); 165 lock2.Release();
166 } 166 }
167 167
168 TEST(TaskSchedulerLock, AcquireMultipleLocksNoTransitivity) { 168 TEST(TaskSchedulerLock, AcquireMultipleLocksNoTransitivity) {
169 SchedulerLock lock1; 169 SchedulerLock lock1;
170 SchedulerLock lock2(&lock1); 170 SchedulerLock lock2(&lock1);
171 SchedulerLock lock3(&lock2); 171 SchedulerLock lock3(&lock2);
172 EXPECT_DCHECK_DEATH({ 172 EXPECT_DCHECK_DEATH({
173 lock1.Acquire(); 173 lock1.Acquire();
174 lock3.Acquire(); 174 lock3.Acquire();
175 }, ""); 175 });
176 } 176 }
177 177
178 TEST(TaskSchedulerLock, AcquireLocksDifferentThreadsSafely) { 178 TEST(TaskSchedulerLock, AcquireLocksDifferentThreadsSafely) {
179 SchedulerLock lock1; 179 SchedulerLock lock1;
180 SchedulerLock lock2; 180 SchedulerLock lock2;
181 BasicLockAcquireAndWaitThread thread(&lock1); 181 BasicLockAcquireAndWaitThread thread(&lock1);
182 thread.Start(); 182 thread.Start();
183 183
184 lock2.Acquire(); 184 lock2.Acquire();
185 thread.WaitForLockAcquisition(); 185 thread.WaitForLockAcquisition();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 predecessor.Release(); 251 predecessor.Release();
252 } 252 }
253 253
254 TEST(TaskSchedulerLock, SelfReferentialLock) { 254 TEST(TaskSchedulerLock, SelfReferentialLock) {
255 struct SelfReferentialLock { 255 struct SelfReferentialLock {
256 SelfReferentialLock() : lock(&lock) {} 256 SelfReferentialLock() : lock(&lock) {}
257 257
258 SchedulerLock lock; 258 SchedulerLock lock;
259 }; 259 };
260 260
261 EXPECT_DCHECK_DEATH({ SelfReferentialLock lock; }, ""); 261 EXPECT_DCHECK_DEATH({ SelfReferentialLock lock; });
262 } 262 }
263 263
264 TEST(TaskSchedulerLock, PredecessorCycle) { 264 TEST(TaskSchedulerLock, PredecessorCycle) {
265 struct LockCycle { 265 struct LockCycle {
266 LockCycle() : lock1(&lock2), lock2(&lock1) {} 266 LockCycle() : lock1(&lock2), lock2(&lock1) {}
267 267
268 SchedulerLock lock1; 268 SchedulerLock lock1;
269 SchedulerLock lock2; 269 SchedulerLock lock2;
270 }; 270 };
271 271
272 EXPECT_DCHECK_DEATH({ LockCycle cycle; }, ""); 272 EXPECT_DCHECK_DEATH({ LockCycle cycle; });
273 } 273 }
274 274
275 TEST(TaskSchedulerLock, PredecessorLongerCycle) { 275 TEST(TaskSchedulerLock, PredecessorLongerCycle) {
276 struct LockCycle { 276 struct LockCycle {
277 LockCycle() 277 LockCycle()
278 : lock1(&lock5), 278 : lock1(&lock5),
279 lock2(&lock1), 279 lock2(&lock1),
280 lock3(&lock2), 280 lock3(&lock2),
281 lock4(&lock3), 281 lock4(&lock3),
282 lock5(&lock4) {} 282 lock5(&lock4) {}
283 283
284 SchedulerLock lock1; 284 SchedulerLock lock1;
285 SchedulerLock lock2; 285 SchedulerLock lock2;
286 SchedulerLock lock3; 286 SchedulerLock lock3;
287 SchedulerLock lock4; 287 SchedulerLock lock4;
288 SchedulerLock lock5; 288 SchedulerLock lock5;
289 }; 289 };
290 290
291 EXPECT_DCHECK_DEATH({ LockCycle cycle; }, ""); 291 EXPECT_DCHECK_DEATH({ LockCycle cycle; });
292 } 292 }
293 293
294 } // namespace 294 } // namespace
295 } // namespace internal 295 } // namespace internal
296 } // namespace base 296 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/priority_queue_unittest.cc ('k') | base/task_scheduler/scheduler_worker_pool_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698