From 18617cfde8537293ab3fa537f7231b5007844cb3 Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Mon, 15 Sep 2014 11:19:35 +0000 Subject: [PATCH] Fix ThreadChecker unittests when DCHECK_ALWAYS_ON is defined This requires two fixes: 1. Use DCHECK instead of assert in ThreadChecker's unittest. 2. Activate DCHECK when DCHECK_ALWAYS_ON in enabled. Both these modifications are in line with Chromium's implementation. The ThreadChecker unittest was changed to use assert instead of DCHECK on the initial import (since WebRTC did not have a DCHECK back then). BUG=3803 TEST=local out/{Debug,Release}/rtc_unittests built with and without DCHECK_ALWAYS_ON R=andrew@webrtc.org, pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/24569004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7178 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/base/checks.h | 2 +- webrtc/base/thread_checker_unittest.cc | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/webrtc/base/checks.h b/webrtc/base/checks.h index fc3b32932..821b75be1 100644 --- a/webrtc/base/checks.h +++ b/webrtc/base/checks.h @@ -154,7 +154,7 @@ DEFINE_CHECK_OP_IMPL(GT, > ) // The DCHECK macro is equivalent to CHECK except that it only generates code in // debug builds. -#if !defined(NDEBUG) +#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) #define DCHECK(condition) CHECK(condition) #define DCHECK_EQ(v1, v2) CHECK_EQ(v1, v2) #define DCHECK_NE(v1, v2) CHECK_NE(v1, v2) diff --git a/webrtc/base/thread_checker_unittest.cc b/webrtc/base/thread_checker_unittest.cc index dcaf75b6e..87e69c035 100644 --- a/webrtc/base/thread_checker_unittest.cc +++ b/webrtc/base/thread_checker_unittest.cc @@ -10,9 +10,8 @@ // Borrowed from Chromium's src/base/threading/thread_checker_unittest.cc. -#include - #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/checks.h" #include "webrtc/base/thread.h" #include "webrtc/base/thread_checker.h" #include "webrtc/base/scoped_ptr.h" @@ -38,7 +37,7 @@ class ThreadCheckerClass : public ThreadChecker { // Verifies that it was called on the same thread as the constructor. void DoStuff() { - assert(CalledOnValidThread()); + DCHECK(CalledOnValidThread()); } void DetachFromThread() {