Index: base/tools_sanity_unittest.cc |
diff --git a/base/tools_sanity_unittest.cc b/base/tools_sanity_unittest.cc |
index b1da3e1aa59fc79a4fe5391d208614bf634deda0..7d4c96eb5f71c6cb080fa96971233b235724cbba 100644 |
--- a/base/tools_sanity_unittest.cc |
+++ b/base/tools_sanity_unittest.cc |
@@ -7,6 +7,8 @@ |
// errors to verify the sanity of the tools. |
#include "base/atomicops.h" |
+#include "base/debug/asan_invalid_access.h" |
+#include "base/debug/profiler.h" |
#include "base/message_loop/message_loop.h" |
#include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
#include "base/threading/thread.h" |
@@ -24,9 +26,16 @@ const base::subtle::Atomic32 kMagicValue = 42; |
#if defined(OS_IOS) |
// EXPECT_DEATH is not supported on IOS. |
#define HARMFUL_ACCESS(action,error_regexp) do { action; } while (0) |
+#elif defined(SYZYASAN) |
+// We won't get a meaningful error message because we're not running under the |
+// SyzyASan logger, but we can at least make sure that the error has been |
+// generated in the SyzyASan runtime. |
+#define HARMFUL_ACCESS(action,unused) \ |
+if (debug::IsBinaryInstrumented()) { EXPECT_DEATH(action, \ |
+ "AsanRuntime::OnError"); } |
#else |
#define HARMFUL_ACCESS(action,error_regexp) EXPECT_DEATH(action,error_regexp) |
-#endif // !OS_IOS |
+#endif // !OS_IOS && !SYZYASAN |
#else |
#define HARMFUL_ACCESS(action,error_regexp) \ |
do { if (RunningOnValgrind()) { action; } } while (0) |
@@ -162,6 +171,7 @@ TEST(ToolsSanityTest, MAYBE_SingleElementDeletedWithBraces) { |
} |
#if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
+ |
TEST(ToolsSanityTest, DISABLED_AddressSanitizerNullDerefCrashTest) { |
// Intentionally crash to make sure AddressSanitizer is running. |
// This test should not be ran on bots. |
@@ -193,7 +203,31 @@ TEST(ToolsSanityTest, DISABLED_AddressSanitizerGlobalOOBCrashTest) { |
*access = 43; |
} |
-#endif |
+TEST(ToolsSanityTest, AsanHeapOverflow) { |
+ HARMFUL_ACCESS(debug::AsanHeapOverflow() ,"to the right"); |
+} |
+ |
+TEST(ToolsSanityTest, AsanHeapUnderflow) { |
+ HARMFUL_ACCESS(debug::AsanHeapUnderflow(), "to the left"); |
+} |
+ |
+TEST(ToolsSanityTest, AsanHeapUseAfterFree) { |
+ HARMFUL_ACCESS(debug::AsanHeapUseAfterFree(), "heap-use-after-free"); |
+} |
+ |
+#if defined(SYZYASAN) |
+TEST(ToolsSanityTest, AsanCorruptHeapBlock) { |
+ HARMFUL_ACCESS(debug::AsanCorruptHeapBlock(), ""); |
+} |
+ |
+TEST(ToolsSanityTest, AsanCorruptHeap) { |
+ // This test will kill the process by raising an exception, there's no |
+ // particular string to look for in the stack trace. |
+ EXPECT_DEATH(debug::AsanCorruptHeap(), ""); |
+} |
+#endif // SYZYASAN |
+ |
+#endif // ADDRESS_SANITIZER || SYZYASAN |
namespace { |