Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: base/tools_sanity_unittest.cc

Issue 389313002: Avoid macro redefinition in tools_sanity_unittest.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move #endif above Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | build/common.gypi » ('j') | build/common.gypi » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file contains intentional memory errors, some of which may lead to 5 // This file contains intentional memory errors, some of which may lead to
6 // crashes if the test is ran without special memory testing tools. We use these 6 // crashes if the test is ran without special memory testing tools. We use these
7 // errors to verify the sanity of the tools. 7 // errors to verify the sanity of the tools.
8 8
9 #include "base/atomicops.h" 9 #include "base/atomicops.h"
10 #include "base/debug/asan_invalid_access.h" 10 #include "base/debug/asan_invalid_access.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 #if (defined(ADDRESS_SANITIZER) && defined(OS_IOS)) || defined(SYZYASAN) 106 #if (defined(ADDRESS_SANITIZER) && defined(OS_IOS)) || defined(SYZYASAN)
107 // Because iOS doesn't support death tests, each of the following tests will 107 // Because iOS doesn't support death tests, each of the following tests will
108 // crash the whole program under Asan. On Windows Asan is based on SyzyAsan; the 108 // crash the whole program under Asan. On Windows Asan is based on SyzyAsan; the
109 // error report mechanism is different than with Asan so these tests will fail. 109 // error report mechanism is different than with Asan so these tests will fail.
110 #define MAYBE_AccessesToNewMemory DISABLED_AccessesToNewMemory 110 #define MAYBE_AccessesToNewMemory DISABLED_AccessesToNewMemory
111 #define MAYBE_AccessesToMallocMemory DISABLED_AccessesToMallocMemory 111 #define MAYBE_AccessesToMallocMemory DISABLED_AccessesToMallocMemory
112 #else 112 #else
113 #define MAYBE_AccessesToNewMemory AccessesToNewMemory 113 #define MAYBE_AccessesToNewMemory AccessesToNewMemory
114 #define MAYBE_AccessesToMallocMemory AccessesToMallocMemory 114 #define MAYBE_AccessesToMallocMemory AccessesToMallocMemory
115 #define MAYBE_ArrayDeletedWithoutBraces ArrayDeletedWithoutBraces 115 #endif // (defined(ADDRESS_SANITIZER) && defined(OS_IOS)) || defined(SYZYASAN)
116 #define MAYBE_SingleElementDeletedWithBraces SingleElementDeletedWithBraces
117 #endif
118 116
119 // The following tests pass with Clang r170392, but not r172454, which 117 // The following tests pass with Clang r170392, but not r172454, which
120 // makes AddressSanitizer detect errors in them. We disable these tests under 118 // makes AddressSanitizer detect errors in them. We disable these tests under
121 // AddressSanitizer until we fully switch to Clang r172454. After that the 119 // AddressSanitizer until we fully switch to Clang r172454. After that the
122 // tests should be put back under the (defined(OS_IOS) || defined(OS_WIN)) 120 // tests should be put back under the (defined(OS_IOS) || defined(OS_WIN))
123 // clause above. 121 // clause above.
124 // See also http://crbug.com/172614. 122 // See also http://crbug.com/172614.
125 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) 123 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN)
126 #define MAYBE_SingleElementDeletedWithBraces \ 124 #define MAYBE_SingleElementDeletedWithBraces \
127 DISABLED_SingleElementDeletedWithBraces 125 DISABLED_SingleElementDeletedWithBraces
128 #define MAYBE_ArrayDeletedWithoutBraces DISABLED_ArrayDeletedWithoutBraces 126 #define MAYBE_ArrayDeletedWithoutBraces DISABLED_ArrayDeletedWithoutBraces
129 #endif 127 #else
128 #define MAYBE_ArrayDeletedWithoutBraces ArrayDeletedWithoutBraces
129 #define MAYBE_SingleElementDeletedWithBraces SingleElementDeletedWithBraces
130 #endif // defined(ADDRESS_SANITIZER) || defined(SYZYASAN)
131
130 TEST(ToolsSanityTest, MAYBE_AccessesToNewMemory) { 132 TEST(ToolsSanityTest, MAYBE_AccessesToNewMemory) {
131 char *foo = new char[10]; 133 char *foo = new char[10];
132 MakeSomeErrors(foo, 10); 134 MakeSomeErrors(foo, 10);
133 delete [] foo; 135 delete [] foo;
134 // Use after delete. 136 // Use after delete.
135 HARMFUL_ACCESS(foo[5] = 0, "heap-use-after-free"); 137 HARMFUL_ACCESS(foo[5] = 0, "heap-use-after-free");
136 } 138 }
137 139
138 TEST(ToolsSanityTest, MAYBE_AccessesToMallocMemory) { 140 TEST(ToolsSanityTest, MAYBE_AccessesToMallocMemory) {
139 char *foo = reinterpret_cast<char*>(malloc(10)); 141 char *foo = reinterpret_cast<char*>(malloc(10));
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 321
320 TEST(ToolsSanityTest, AtomicsAreIgnored) { 322 TEST(ToolsSanityTest, AtomicsAreIgnored) {
321 base::subtle::Atomic32 shared = 0; 323 base::subtle::Atomic32 shared = 0;
322 ReleaseStoreThread thread1(&shared); 324 ReleaseStoreThread thread1(&shared);
323 AcquireLoadThread thread2(&shared); 325 AcquireLoadThread thread2(&shared);
324 RunInParallel(&thread1, &thread2); 326 RunInParallel(&thread1, &thread2);
325 EXPECT_EQ(kMagicValue, shared); 327 EXPECT_EQ(kMagicValue, shared);
326 } 328 }
327 329
328 } // namespace base 330 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | build/common.gypi » ('j') | build/common.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698