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) && \ |
| 84 defined(INCREMENTAL_LINKING)) |
83 // Do not run the test under ThreadSanitizer. Because this test iterates its | 85 // Do not run the test under ThreadSanitizer. Because this test iterates its |
84 // own TSD destructor for the maximum possible number of times, TSan can't jump | 86 // own TSD destructor for the maximum possible number of times, TSan can't jump |
85 // in after the last destructor invocation, therefore the destructor remains | 87 // in after the last destructor invocation, therefore the destructor remains |
86 // unsynchronized with the following users of the same TSD slot. This results | 88 // unsynchronized with the following users of the same TSD slot. This results |
87 // in race reports between the destructor and functions in other tests. | 89 // in race reports between the destructor and functions in other tests. |
| 90 // |
| 91 // It is disabled on Win x64 with incremental linking pending resolution of |
| 92 // http://crbug.com/251251. |
88 #define MAYBE_TLSDestructors DISABLED_TLSDestructors | 93 #define MAYBE_TLSDestructors DISABLED_TLSDestructors |
89 #else | 94 #else |
90 #define MAYBE_TLSDestructors TLSDestructors | 95 #define MAYBE_TLSDestructors TLSDestructors |
91 #endif | 96 #endif |
92 TEST(ThreadLocalStorageTest, MAYBE_TLSDestructors) { | 97 TEST(ThreadLocalStorageTest, MAYBE_TLSDestructors) { |
93 // Create a TLS index with a destructor. Create a set of | 98 // Create a TLS index with a destructor. Create a set of |
94 // threads that set the TLS, while the destructor cleans it up. | 99 // threads that set the TLS, while the destructor cleans it up. |
95 // After the threads finish, verify that the value is cleaned up. | 100 // After the threads finish, verify that the value is cleaned up. |
96 const int kNumThreads = 5; | 101 const int kNumThreads = 5; |
97 int values[kNumThreads]; | 102 int values[kNumThreads]; |
(...skipping 17 matching lines...) Expand all Loading... |
115 delete threads[index]; | 120 delete threads[index]; |
116 delete thread_delegates[index]; | 121 delete thread_delegates[index]; |
117 | 122 |
118 // Verify that the destructor was called and that we reset. | 123 // Verify that the destructor was called and that we reset. |
119 EXPECT_EQ(values[index], kFinalTlsValue); | 124 EXPECT_EQ(values[index], kFinalTlsValue); |
120 } | 125 } |
121 tls_slot.Free(); // Stop doing callbacks to cleanup threads. | 126 tls_slot.Free(); // Stop doing callbacks to cleanup threads. |
122 } | 127 } |
123 | 128 |
124 } // namespace base | 129 } // namespace base |
OLD | NEW |