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

Unified Diff: base/threading/thread_checker_unittest.cc

Issue 9020008: Enable ThreadChecker in non-debug builds if DCHECK_ALWAYS_ON is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR (pure merge). Created 8 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/threading/thread_checker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/thread_checker_unittest.cc
diff --git a/base/threading/thread_checker_unittest.cc b/base/threading/thread_checker_unittest.cc
index e1e571588f462dcc79d7d214559b664ed76a5e6e..a79e7ba348d9b647d5457bca21f83999f2e4ce1b 100644
--- a/base/threading/thread_checker_unittest.cc
+++ b/base/threading/thread_checker_unittest.cc
@@ -9,6 +9,10 @@
#include "base/threading/simple_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
+// Duplicated from base/threading/thread_checker.h so that we can be
+// good citizens there and undef the macro.
+#define ENABLE_THREAD_CHECKER (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
+
namespace base {
// Simple class to exercise the basics of ThreadChecker.
@@ -107,7 +111,7 @@ TEST(ThreadCheckerTest, DetachFromThread) {
call_on_thread.Join();
}
-#if GTEST_HAS_DEATH_TEST || NDEBUG
+#if GTEST_HAS_DEATH_TEST || !ENABLE_THREAD_CHECKER
void ThreadCheckerClass::MethodOnDifferentThreadImpl() {
scoped_ptr<ThreadCheckerClass> thread_checker_class(
@@ -121,7 +125,7 @@ void ThreadCheckerClass::MethodOnDifferentThreadImpl() {
call_on_thread.Join();
}
-#ifndef NDEBUG
+#if ENABLE_THREAD_CHECKER
TEST(ThreadCheckerDeathTest, MethodNotAllowedOnDifferentThreadInDebug) {
ASSERT_DEBUG_DEATH({
ThreadCheckerClass::MethodOnDifferentThreadImpl();
@@ -131,7 +135,7 @@ TEST(ThreadCheckerDeathTest, MethodNotAllowedOnDifferentThreadInDebug) {
TEST(ThreadCheckerTest, MethodAllowedOnDifferentThreadInRelease) {
ThreadCheckerClass::MethodOnDifferentThreadImpl();
}
-#endif // NDEBUG
+#endif // ENABLE_THREAD_CHECKER
void ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl() {
scoped_ptr<ThreadCheckerClass> thread_checker_class(
@@ -150,7 +154,7 @@ void ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl() {
thread_checker_class->DoStuff();
}
-#ifndef NDEBUG
+#if ENABLE_THREAD_CHECKER
TEST(ThreadCheckerDeathTest, DetachFromThreadInDebug) {
ASSERT_DEBUG_DEATH({
ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl();
@@ -160,8 +164,11 @@ TEST(ThreadCheckerDeathTest, DetachFromThreadInDebug) {
TEST(ThreadCheckerTest, DetachFromThreadInRelease) {
ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl();
}
-#endif // NDEBUG
+#endif // ENABLE_THREAD_CHECKER
+
+#endif // GTEST_HAS_DEATH_TEST || !ENABLE_THREAD_CHECKER
-#endif // GTEST_HAS_DEATH_TEST || NDEBUG
+// Just in case we ever get lumped together with other compilation units.
+#undef ENABLE_THREAD_CHECKER
} // namespace base
« no previous file with comments | « base/threading/thread_checker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698