OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/atomicops.h" | 5 #include "base/atomicops.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 7 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 delete foo; | 92 delete foo; |
93 } | 93 } |
94 | 94 |
95 TEST(ToolsSanityTest, SingleElementDeletedWithBraces) { | 95 TEST(ToolsSanityTest, SingleElementDeletedWithBraces) { |
96 // This test may corrupt memory if not run under Valgrind. | 96 // This test may corrupt memory if not run under Valgrind. |
97 if (!RunningOnValgrind()) | 97 if (!RunningOnValgrind()) |
98 return; | 98 return; |
99 | 99 |
100 // Without the |volatile|, clang optimizes away the next two lines. | 100 // Without the |volatile|, clang optimizes away the next two lines. |
101 int* volatile foo = new int; | 101 int* volatile foo = new int; |
| 102 (void) foo; |
102 delete [] foo; | 103 delete [] foo; |
103 } | 104 } |
104 | 105 |
105 | 106 |
106 namespace { | 107 namespace { |
107 | 108 |
108 // We use caps here just to ensure that the method name doesn't interfere with | 109 // We use caps here just to ensure that the method name doesn't interfere with |
109 // the wildcarded suppressions. | 110 // the wildcarded suppressions. |
110 class TOOLS_SANITY_TEST_CONCURRENT_THREAD : public PlatformThread::Delegate { | 111 class TOOLS_SANITY_TEST_CONCURRENT_THREAD : public PlatformThread::Delegate { |
111 public: | 112 public: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 182 |
182 TEST(ToolsSanityTest, AtomicsAreIgnored) { | 183 TEST(ToolsSanityTest, AtomicsAreIgnored) { |
183 base::subtle::Atomic32 shared = 0; | 184 base::subtle::Atomic32 shared = 0; |
184 ReleaseStoreThread thread1(&shared); | 185 ReleaseStoreThread thread1(&shared); |
185 AcquireLoadThread thread2(&shared); | 186 AcquireLoadThread thread2(&shared); |
186 RunInParallel(&thread1, &thread2); | 187 RunInParallel(&thread1, &thread2); |
187 EXPECT_EQ(kMagicValue, shared); | 188 EXPECT_EQ(kMagicValue, shared); |
188 } | 189 } |
189 | 190 |
190 } // namespace base | 191 } // namespace base |
OLD | NEW |