summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-23 09:12:37 +0000
committertimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-23 09:12:37 +0000
commitadf7d80638194c86dbdea9bed0299fefb5c9a4b0 (patch)
tree0770ac03dc778ed035d87299f12ae576ca49c366 /base
parent2823fb246d4d39fd8f14fb8a29a2d53d2e67d55a (diff)
downloadchromium_src-adf7d80638194c86dbdea9bed0299fefb5c9a4b0.zip
chromium_src-adf7d80638194c86dbdea9bed0299fefb5c9a4b0.tar.gz
chromium_src-adf7d80638194c86dbdea9bed0299fefb5c9a4b0.tar.bz2
Add two tests for uninit reads to ToolsSanityTests
TEST=./tools/valgrind/chrome_tests.sh -t base --gtest_filter="Sanity*" on Linux and Mac Review URL: http://codereview.chromium.org/3470006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60271 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/tools_sanity_unittest.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/base/tools_sanity_unittest.cc b/base/tools_sanity_unittest.cc
index d4b27a5..2f758e2 100644
--- a/base/tools_sanity_unittest.cc
+++ b/base/tools_sanity_unittest.cc
@@ -35,6 +35,14 @@ TEST(ToolsSanityTest, MemoryLeak) {
leak[4] = 1; // Make sure the allocated memory is used.
}
+void ReadUninitializedValue(char *ptr) {
+ if (*ptr == true) {
+ (*ptr)++;
+ } else {
+ (*ptr)--;
+ }
+}
+
void ReadValueOutOfArrayBoundsLeft(char *ptr) {
LOG(INFO) << "Reading a byte out of bounds: " << ptr[-2];
}
@@ -54,6 +62,7 @@ void WriteValueOutOfArrayBoundsRight(char *ptr, size_t size) {
}
void MakeSomeErrors(char *ptr, size_t size) {
+ ReadUninitializedValue(ptr);
ReadValueOutOfArrayBoundsLeft(ptr);
ReadValueOutOfArrayBoundsRight(ptr, size);
WriteValueOutOfArrayBoundsLeft(ptr);