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

Unified Diff: base/tools_sanity_unittest.cc

Issue 139723002: Update base/tools_sanity_unittest.cc to cover MSan. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tools_sanity_unittest.cc
diff --git a/base/tools_sanity_unittest.cc b/base/tools_sanity_unittest.cc
index 4804a35a3b9ef95cec9db0327982fd394b6da30a..c763a32a53159b0aa1a5a22cf5942a3c0d83eef6 100644
--- a/base/tools_sanity_unittest.cc
+++ b/base/tools_sanity_unittest.cc
@@ -32,17 +32,26 @@ const base::subtle::Atomic32 kMagicValue = 42;
do { if (RunningOnValgrind()) { action; } } while (0)
#endif
-void ReadUninitializedValue(char *ptr) {
+void DoReadUninitializedValue(char *ptr) {
// Comparison with 64 is to prevent clang from optimizing away the
// jump -- valgrind only catches jumps and conditional moves, but clang uses
// the borrow flag if the condition is just `*ptr == '\0'`.
if (*ptr == 64) {
- (*ptr)++;
+ VLOG(1) << "Uninit condition is true";
Nico 2014/01/15 17:46:18 why this change?
} else {
- (*ptr)--;
+ VLOG(1) << "Uninit condition is false";
}
}
+void ReadUninitializedValue(char *ptr) {
+#if defined(MEMORY_SANITIZER)
+ EXPECT_DEATH(DoReadUninitializedValue(ptr),
+ "use-of-uninitialized-value");
+#else
+ DoReadUninitializedValue(ptr);
+#endif
+}
+
void ReadValueOutOfArrayBoundsLeft(char *ptr) {
char c = ptr[-2];
VLOG(1) << "Reading a byte out of bounds: " << c;
« 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