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

Side by Side Diff: base/tools_sanity_unittest.cc

Issue 10383208: Tweak Memcheck sanity tests to avoid duplicate reports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | no next file » | no next file with comments »
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/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 10 matching lines...) Expand all
21 // Helper for memory accesses that can potentially corrupt memory or cause a 21 // Helper for memory accesses that can potentially corrupt memory or cause a
22 // crash during a native run. 22 // crash during a native run.
23 #ifdef ADDRESS_SANITIZER 23 #ifdef ADDRESS_SANITIZER
24 #define HARMFUL_ACCESS(action,error_regexp) EXPECT_DEATH(action,error_regexp) 24 #define HARMFUL_ACCESS(action,error_regexp) EXPECT_DEATH(action,error_regexp)
25 #else 25 #else
26 #define HARMFUL_ACCESS(action,error_regexp) \ 26 #define HARMFUL_ACCESS(action,error_regexp) \
27 do { if (RunningOnValgrind()) { action; } } while (0) 27 do { if (RunningOnValgrind()) { action; } } while (0)
28 #endif 28 #endif
29 29
30 void ReadUninitializedValue(char *ptr) { 30 void ReadUninitializedValue(char *ptr) {
31 // The || in the conditional is to prevent clang from optimizing away the 31 // Comparison with 64 is to prevent clang from optimizing away the
32 // jump -- valgrind only catches jumps and conditional moves, but clang uses 32 // jump -- valgrind only catches jumps and conditional moves, but clang uses
33 // the borrow flag if the condition is just `*ptr == '\0'`. 33 // the borrow flag if the condition is just `*ptr == '\0'`.
34 if (*ptr == '\0' || *ptr == 64) { 34 if (*ptr == 64) {
35 (*ptr)++; 35 (*ptr)++;
36 } else { 36 } else {
37 (*ptr)--; 37 (*ptr)--;
38 } 38 }
39 } 39 }
40 40
41 void ReadValueOutOfArrayBoundsLeft(char *ptr) { 41 void ReadValueOutOfArrayBoundsLeft(char *ptr) {
42 char c = ptr[-2]; 42 char c = ptr[-2];
43 VLOG(1) << "Reading a byte out of bounds: " << c; 43 VLOG(1) << "Reading a byte out of bounds: " << c;
44 } 44 }
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 TEST(ToolsSanityTest, AtomicsAreIgnored) { 235 TEST(ToolsSanityTest, AtomicsAreIgnored) {
236 base::subtle::Atomic32 shared = 0; 236 base::subtle::Atomic32 shared = 0;
237 ReleaseStoreThread thread1(&shared); 237 ReleaseStoreThread thread1(&shared);
238 AcquireLoadThread thread2(&shared); 238 AcquireLoadThread thread2(&shared);
239 RunInParallel(&thread1, &thread2); 239 RunInParallel(&thread1, &thread2);
240 EXPECT_EQ(kMagicValue, shared); 240 EXPECT_EQ(kMagicValue, shared);
241 } 241 }
242 242
243 } // namespace base 243 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698