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

Side by Side Diff: base/synchronization/atomic_flag_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
« no previous file with comments | « base/numerics/safe_numerics_unittest.cc ('k') | base/task_scheduler/priority_queue_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/synchronization/atomic_flag.h" 5 #include "base/synchronization/atomic_flag.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "base/test/gtest_util.h" 11 #include "base/test/gtest_util.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace base { 17 namespace base {
18 18
19 namespace { 19 namespace {
20 20
21 void ExpectSetFlagDeath(AtomicFlag* flag) { 21 void ExpectSetFlagDeath(AtomicFlag* flag) {
22 ASSERT_TRUE(flag); 22 ASSERT_TRUE(flag);
23 EXPECT_DCHECK_DEATH(flag->Set(), ""); 23 EXPECT_DCHECK_DEATH(flag->Set());
24 } 24 }
25 25
26 // Busy waits (to explicitly avoid using synchronization constructs that would 26 // Busy waits (to explicitly avoid using synchronization constructs that would
27 // defeat the purpose of testing atomics) until |tested_flag| is set and then 27 // defeat the purpose of testing atomics) until |tested_flag| is set and then
28 // verifies that non-atomic |*expected_after_flag| is true and sets |*done_flag| 28 // verifies that non-atomic |*expected_after_flag| is true and sets |*done_flag|
29 // before returning if it's non-null. 29 // before returning if it's non-null.
30 void BusyWaitUntilFlagIsSet(AtomicFlag* tested_flag, bool* expected_after_flag, 30 void BusyWaitUntilFlagIsSet(AtomicFlag* tested_flag, bool* expected_after_flag,
31 AtomicFlag* done_flag) { 31 AtomicFlag* done_flag) {
32 while (!tested_flag->IsSet()) 32 while (!tested_flag->IsSet())
33 PlatformThread::YieldCurrentThread(); 33 PlatformThread::YieldCurrentThread();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 Thread t("AtomicFlagTest.SetOnDifferentThreadDeathTest"); 122 Thread t("AtomicFlagTest.SetOnDifferentThreadDeathTest");
123 ASSERT_TRUE(t.Start()); 123 ASSERT_TRUE(t.Start());
124 EXPECT_TRUE(t.WaitUntilThreadStarted()); 124 EXPECT_TRUE(t.WaitUntilThreadStarted());
125 125
126 AtomicFlag flag; 126 AtomicFlag flag;
127 flag.Set(); 127 flag.Set();
128 t.task_runner()->PostTask(FROM_HERE, Bind(&ExpectSetFlagDeath, &flag)); 128 t.task_runner()->PostTask(FROM_HERE, Bind(&ExpectSetFlagDeath, &flag));
129 } 129 }
130 130
131 } // namespace base 131 } // namespace base
OLDNEW
« no previous file with comments | « base/numerics/safe_numerics_unittest.cc ('k') | base/task_scheduler/priority_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698