summaryrefslogtreecommitdiffstats
path: root/base/thread_collision_warner_unittest.cc
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-26 19:29:07 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-26 19:29:07 +0000
commit0d02a5f10d50dee16267a781ddb40aa2df47171f (patch)
treedf0ca4439e611282ef4d2886f8b00aea87f7c8d5 /base/thread_collision_warner_unittest.cc
parent33124014399f72fe1e780e7a9b12505d3a840b6b (diff)
downloadchromium_src-0d02a5f10d50dee16267a781ddb40aa2df47171f.zip
chromium_src-0d02a5f10d50dee16267a781ddb40aa2df47171f.tar.gz
chromium_src-0d02a5f10d50dee16267a781ddb40aa2df47171f.tar.bz2
Add thread safety checks but keep them disabled for now until I fix all the current places where it triggers.
Fix thread_collision_warner for real this (third?) time. Review URL: http://codereview.chromium.org/18569 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread_collision_warner_unittest.cc')
-rw-r--r--base/thread_collision_warner_unittest.cc38
1 files changed, 32 insertions, 6 deletions
diff --git a/base/thread_collision_warner_unittest.cc b/base/thread_collision_warner_unittest.cc
index 7994d13..93a74e5 100644
--- a/base/thread_collision_warner_unittest.cc
+++ b/base/thread_collision_warner_unittest.cc
@@ -89,15 +89,21 @@ TEST(ThreadCollisionTest, ScopedBookCriticalSection) {
{ // Pin section.
DFAKE_SCOPED_LOCK(warner);
EXPECT_FALSE(local_reporter->fail_state());
- { // Pin section again (not allowed by DFAKE_SCOPED_LOCK)
+ {
+ // Pin section again (not allowed by DFAKE_SCOPED_LOCK)
DFAKE_SCOPED_LOCK(warner);
+#if !defined(NDEBUG)
EXPECT_TRUE(local_reporter->fail_state());
+#else
+ EXPECT_FALSE(local_reporter->fail_state());
+#endif
// Reset the status of warner for further tests.
local_reporter->reset();
} // Unpin section.
} // Unpin section.
- { // Pin section.
+ {
+ // Pin section.
DFAKE_SCOPED_LOCK(warner);
EXPECT_FALSE(local_reporter->fail_state());
} // Unpin section.
@@ -107,7 +113,10 @@ TEST(ThreadCollisionTest, MTBookCriticalSectionTest) {
class NonThreadSafeQueue {
public:
explicit NonThreadSafeQueue(base::AsserterBase* asserter)
- : push_pop_(asserter) { }
+#if !defined(NDEBUG)
+ : push_pop_(asserter)
+#endif
+ { }
void push(int value) {
DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_);
@@ -154,7 +163,11 @@ TEST(ThreadCollisionTest, MTBookCriticalSectionTest) {
thread_a.Join();
thread_b.Join();
+#if !defined(NDEBUG)
EXPECT_TRUE(local_reporter->fail_state());
+#else
+ EXPECT_FALSE(local_reporter->fail_state());
+#endif
}
TEST(ThreadCollisionTest, MTScopedBookCriticalSectionTest) {
@@ -163,7 +176,10 @@ TEST(ThreadCollisionTest, MTScopedBookCriticalSectionTest) {
class NonThreadSafeQueue {
public:
explicit NonThreadSafeQueue(base::AsserterBase* asserter)
- : push_pop_(asserter) { }
+#if !defined(NDEBUG)
+ : push_pop_(asserter)
+#endif
+ { }
void push(int value) {
DFAKE_SCOPED_LOCK(push_pop_);
@@ -211,7 +227,11 @@ TEST(ThreadCollisionTest, MTScopedBookCriticalSectionTest) {
thread_a.Join();
thread_b.Join();
+#if !defined(NDEBUG)
EXPECT_TRUE(local_reporter->fail_state());
+#else
+ EXPECT_FALSE(local_reporter->fail_state());
+#endif
}
TEST(ThreadCollisionTest, MTSynchedScopedBookCriticalSectionTest) {
@@ -220,7 +240,10 @@ TEST(ThreadCollisionTest, MTSynchedScopedBookCriticalSectionTest) {
class NonThreadSafeQueue {
public:
explicit NonThreadSafeQueue(base::AsserterBase* asserter)
- : push_pop_(asserter) { }
+#if !defined(NDEBUG)
+ : push_pop_(asserter)
+#endif
+ { }
void push(int value) {
DFAKE_SCOPED_LOCK(push_pop_);
@@ -288,7 +311,10 @@ TEST(ThreadCollisionTest, MTSynchedScopedRecursiveBookCriticalSectionTest) {
class NonThreadSafeQueue {
public:
explicit NonThreadSafeQueue(base::AsserterBase* asserter)
- : push_pop_(asserter) { }
+#if !defined(NDEBUG)
+ : push_pop_(asserter)
+#endif
+ { }
void push(int) {
DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_);