OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
6 #include <windows.h> | 6 #include <windows.h> |
7 #include <process.h> | 7 #include <process.h> |
8 #endif | 8 #endif |
9 | 9 |
10 #include "base/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 TEST(ThreadLocalStorageTest, Basics) { | 75 TEST(ThreadLocalStorageTest, Basics) { |
76 ThreadLocalStorage::Slot slot; | 76 ThreadLocalStorage::Slot slot; |
77 slot.Set(reinterpret_cast<void*>(123)); | 77 slot.Set(reinterpret_cast<void*>(123)); |
78 int value = reinterpret_cast<intptr_t>(slot.Get()); | 78 int value = reinterpret_cast<intptr_t>(slot.Get()); |
79 EXPECT_EQ(value, 123); | 79 EXPECT_EQ(value, 123); |
80 } | 80 } |
81 | 81 |
82 #if defined(THREAD_SANITIZER) || \ | 82 #if defined(THREAD_SANITIZER) || \ |
83 (defined(OS_WIN) && defined(ARCH_CPU_X86_64) && \ | 83 (defined(OS_WIN) && defined(ARCH_CPU_X86_64) && !defined(NDEBUG)) |
84 defined(INCREMENTAL_LINKING)) | |
85 // Do not run the test under ThreadSanitizer. Because this test iterates its | 84 // Do not run the test under ThreadSanitizer. Because this test iterates its |
86 // own TSD destructor for the maximum possible number of times, TSan can't jump | 85 // own TSD destructor for the maximum possible number of times, TSan can't jump |
87 // in after the last destructor invocation, therefore the destructor remains | 86 // in after the last destructor invocation, therefore the destructor remains |
88 // unsynchronized with the following users of the same TSD slot. This results | 87 // unsynchronized with the following users of the same TSD slot. This results |
89 // in race reports between the destructor and functions in other tests. | 88 // in race reports between the destructor and functions in other tests. |
90 // | 89 // |
91 // It is disabled on Win x64 with incremental linking pending resolution of | 90 // It is disabled on Win x64 with incremental linking (i.e. "Debug") pending |
92 // http://crbug.com/251251. | 91 // resolution of http://crbug.com/251251. |
93 #define MAYBE_TLSDestructors DISABLED_TLSDestructors | 92 #define MAYBE_TLSDestructors DISABLED_TLSDestructors |
94 #else | 93 #else |
95 #define MAYBE_TLSDestructors TLSDestructors | 94 #define MAYBE_TLSDestructors TLSDestructors |
96 #endif | 95 #endif |
97 TEST(ThreadLocalStorageTest, MAYBE_TLSDestructors) { | 96 TEST(ThreadLocalStorageTest, MAYBE_TLSDestructors) { |
98 // Create a TLS index with a destructor. Create a set of | 97 // Create a TLS index with a destructor. Create a set of |
99 // threads that set the TLS, while the destructor cleans it up. | 98 // threads that set the TLS, while the destructor cleans it up. |
100 // After the threads finish, verify that the value is cleaned up. | 99 // After the threads finish, verify that the value is cleaned up. |
101 const int kNumThreads = 5; | 100 const int kNumThreads = 5; |
102 int values[kNumThreads]; | 101 int values[kNumThreads]; |
(...skipping 17 matching lines...) Expand all Loading... |
120 delete threads[index]; | 119 delete threads[index]; |
121 delete thread_delegates[index]; | 120 delete thread_delegates[index]; |
122 | 121 |
123 // Verify that the destructor was called and that we reset. | 122 // Verify that the destructor was called and that we reset. |
124 EXPECT_EQ(values[index], kFinalTlsValue); | 123 EXPECT_EQ(values[index], kFinalTlsValue); |
125 } | 124 } |
126 tls_slot.Free(); // Stop doing callbacks to cleanup threads. | 125 tls_slot.Free(); // Stop doing callbacks to cleanup threads. |
127 } | 126 } |
128 | 127 |
129 } // namespace base | 128 } // namespace base |
OLD | NEW |