summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhenrike@webrtc.org <henrike@webrtc.org>2014-10-09 15:41:40 +0000
committerhenrike@webrtc.org <henrike@webrtc.org>2014-10-09 15:41:40 +0000
commitb5a0728f5b8393dc06e403dc21365450df267a93 (patch)
tree4bf1627e53d6378bc41f001ab4206f8ccad96a12
parent6e6ea5bb1bbec27c31cf414fdfdf59e1fffc6cb4 (diff)
downloadwebrtc-b5a0728f5b8393dc06e403dc21365450df267a93.tar.gz
base/thread_unittest: wrap test was setting current thread to NULL.
This broke unittests following ThreadTest.Wrap BUG=3836 R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/28689004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@7413 4adac7df-926f-26a2-2b94-8c16560cd09d
-rw-r--r--base/base_tests.gyp2
-rw-r--r--base/thread.h4
-rw-r--r--base/thread_unittest.cc7
-rw-r--r--build/tsan_suppressions_webrtc.cc7
4 files changed, 16 insertions, 4 deletions
diff --git a/base/base_tests.gyp b/base/base_tests.gyp
index 77bed2c6..457fbdcc 100644
--- a/base/base_tests.gyp
+++ b/base/base_tests.gyp
@@ -105,7 +105,7 @@
'task_unittest.cc',
'testclient_unittest.cc',
'thread_checker_unittest.cc',
- #'thread_unittest.cc',
+ 'thread_unittest.cc',
#'timeutils_unittest.cc',
'urlencode_unittest.cc',
#'versionparsing_unittest.cc',
diff --git a/base/thread.h b/base/thread.h
index 8276f4e8..b05d6a9d 100644
--- a/base/thread.h
+++ b/base/thread.h
@@ -213,7 +213,8 @@ class Thread : public MessageQueue {
// value. Must be called on this thread.
bool SetAllowBlockingCalls(bool allow);
- protected:
+ // These functions are public to avoid injecting test hooks. Don't call them
+ // outside of tests.
// This method should be called when thread is created using non standard
// method, like derived implementation of rtc::Thread and it can not be
// started by calling Start(). This will set started flag to true and
@@ -221,6 +222,7 @@ class Thread : public MessageQueue {
bool WrapCurrent();
void UnwrapCurrent();
+ protected:
// Same as WrapCurrent except that it never fails as it does not try to
// acquire the synchronization access of the thread. The caller should never
// call Stop() or Join() on this thread.
diff --git a/base/thread_unittest.cc b/base/thread_unittest.cc
index 57b6df66..41edd731 100644
--- a/base/thread_unittest.cc
+++ b/base/thread_unittest.cc
@@ -247,7 +247,9 @@ TEST(ThreadTest, DISABLED_ON_MAC(Priorities)) {
}
-TEST(ThreadTest, DISABLED_ON_MAC(Wrap)) {
+TEST(ThreadTest, Wrap) {
+ Thread* current_thread = Thread::Current();
+ current_thread->UnwrapCurrent();
CustomThread* cthread = new CustomThread();
EXPECT_TRUE(cthread->WrapCurrent());
EXPECT_TRUE(cthread->RunningForTest());
@@ -255,6 +257,7 @@ TEST(ThreadTest, DISABLED_ON_MAC(Wrap)) {
cthread->UnwrapCurrent();
EXPECT_FALSE(cthread->RunningForTest());
delete cthread;
+ current_thread->WrapCurrent();
}
TEST(ThreadTest, DISABLED_ON_MAC(Invoke)) {
@@ -377,7 +380,7 @@ class AsyncInvokeTest : public testing::Test {
Thread* expected_thread_;
};
-TEST_F(AsyncInvokeTest, DISABLED_FireAndForget) {
+TEST_F(AsyncInvokeTest, FireAndForget) {
AsyncInvoker invoker;
// Create and start the thread.
Thread thread;
diff --git a/build/tsan_suppressions_webrtc.cc b/build/tsan_suppressions_webrtc.cc
index 548045b6..c18bcfc7 100644
--- a/build/tsan_suppressions_webrtc.cc
+++ b/build/tsan_suppressions_webrtc.cc
@@ -41,6 +41,13 @@ char kTSanDefaultSuppressions[] =
"race:webrtc/modules/audio_processing/aec/aec_core.c\n"
"race:webrtc/modules/audio_processing/aec/aec_rdft.c\n"
+// rtc_unittest
+// https://code.google.com/p/webrtc/issues/detail?id=3911 for details.
+"race:ThreadTest_ThreeThreadsInvoke_Test::TestBody()::LocalFuncs::SetAndInvokeSet\n"
+"race:rtc::FireAndForgetAsyncClosure<FunctorB>::Execute\n"
+"race:rtc::MessageQueueManager::Clear\n"
+"race:rtc::Thread::Clear\n"
+
// libjingle_p2p_unittest
// https://code.google.com/p/webrtc/issues/detail?id=2079
"race:webrtc/base/testclient.cc\n"