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

Side by Side Diff: base/tools_sanity_unittest.cc

Issue 55983002: Make gtest always use simple internal regex engine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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
« no previous file with comments | « base/process/memory_unittest.cc ('k') | testing/gtest.gyp » ('j') | 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/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 ptr[-1] = kMagicValue; 58 ptr[-1] = kMagicValue;
59 } 59 }
60 60
61 // This is harmless if you run it under Valgrind thanks to redzones. 61 // This is harmless if you run it under Valgrind thanks to redzones.
62 void WriteValueOutOfArrayBoundsRight(char *ptr, size_t size) { 62 void WriteValueOutOfArrayBoundsRight(char *ptr, size_t size) {
63 ptr[size] = kMagicValue; 63 ptr[size] = kMagicValue;
64 } 64 }
65 65
66 void MakeSomeErrors(char *ptr, size_t size) { 66 void MakeSomeErrors(char *ptr, size_t size) {
67 ReadUninitializedValue(ptr); 67 ReadUninitializedValue(ptr);
68
68 HARMFUL_ACCESS(ReadValueOutOfArrayBoundsLeft(ptr), 69 HARMFUL_ACCESS(ReadValueOutOfArrayBoundsLeft(ptr),
69 "heap-buffer-overflow.*2 bytes to the left"); 70 "2 bytes to the left");
70 HARMFUL_ACCESS(ReadValueOutOfArrayBoundsRight(ptr, size), 71 HARMFUL_ACCESS(ReadValueOutOfArrayBoundsRight(ptr, size),
71 "heap-buffer-overflow.*1 bytes to the right"); 72 "1 bytes to the right");
72 HARMFUL_ACCESS(WriteValueOutOfArrayBoundsLeft(ptr), 73 HARMFUL_ACCESS(WriteValueOutOfArrayBoundsLeft(ptr),
73 "heap-buffer-overflow.*1 bytes to the left"); 74 "1 bytes to the left");
74 HARMFUL_ACCESS(WriteValueOutOfArrayBoundsRight(ptr, size), 75 HARMFUL_ACCESS(WriteValueOutOfArrayBoundsRight(ptr, size),
75 "heap-buffer-overflow.*0 bytes to the right"); 76 "0 bytes to the right");
76 } 77 }
77 78
78 } // namespace 79 } // namespace
79 80
80 // A memory leak detector should report an error in this test. 81 // A memory leak detector should report an error in this test.
81 TEST(ToolsSanityTest, MemoryLeak) { 82 TEST(ToolsSanityTest, MemoryLeak) {
82 // Without the |volatile|, clang optimizes away the next two lines. 83 // Without the |volatile|, clang optimizes away the next two lines.
83 int* volatile leak = new int[256]; // Leak some memory intentionally. 84 int* volatile leak = new int[256]; // Leak some memory intentionally.
84 leak[4] = 1; // Make sure the allocated memory is used. 85 leak[4] = 1; // Make sure the allocated memory is used.
85 } 86 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 265
265 TEST(ToolsSanityTest, AtomicsAreIgnored) { 266 TEST(ToolsSanityTest, AtomicsAreIgnored) {
266 base::subtle::Atomic32 shared = 0; 267 base::subtle::Atomic32 shared = 0;
267 ReleaseStoreThread thread1(&shared); 268 ReleaseStoreThread thread1(&shared);
268 AcquireLoadThread thread2(&shared); 269 AcquireLoadThread thread2(&shared);
269 RunInParallel(&thread1, &thread2); 270 RunInParallel(&thread1, &thread2);
270 EXPECT_EQ(kMagicValue, shared); 271 EXPECT_EQ(kMagicValue, shared);
271 } 272 }
272 273
273 } // namespace base 274 } // namespace base
OLDNEW
« no previous file with comments | « base/process/memory_unittest.cc ('k') | testing/gtest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698