Index: base/process/memory_unittest.cc |
diff --git a/base/process/memory_unittest.cc b/base/process/memory_unittest.cc |
index 9e5de0c95452ed5c29f21003ea51b46a99536363..7eab062b2f7d041bc4123f490af7fa3dfed43d1a 100644 |
--- a/base/process/memory_unittest.cc |
+++ b/base/process/memory_unittest.cc |
@@ -10,8 +10,10 @@ |
#include <limits> |
+#include "base/allocator/allocator_check.h" |
#include "base/compiler_specific.h" |
#include "base/debug/alias.h" |
+#include "base/memory/aligned_memory.h" |
#include "base/strings/stringprintf.h" |
#include "build/build_config.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -96,6 +98,10 @@ TEST(ProcessMemoryTest, MacTerminateOnHeapCorruption) { |
#endif // defined(OS_MACOSX) |
+TEST(MemoryTest, AllocatorShimWorking) { |
+ ASSERT_TRUE(base::allocator::IsAllocatorInitialized()); |
+} |
+ |
// Android doesn't implement set_new_handler, so we can't use the |
// OutOfMemoryTest cases. OpenBSD does not support these tests either. |
// Don't test these on ASan/TSan/MSan configurations: only test the real |
@@ -176,6 +182,23 @@ TEST_F(OutOfMemoryDeathTest, Calloc) { |
}, kOomRegex); |
} |
+TEST_F(OutOfMemoryDeathTest, AlignedAlloc) { |
+ ASSERT_DEATH({ |
+ SetUpInDeathAssert(); |
+ value_ = base::AlignedAlloc(test_size_, 8); |
+ }, kOomRegex); |
+} |
+ |
+// POSIX does not define an aligned realloc function. |
+#if defined(OS_WIN) |
+TEST_F(OutOfMemoryDeathTest, AlignedRealloc) { |
+ ASSERT_DEATH({ |
+ SetUpInDeathAssert(); |
+ value_ = _aligned_realloc(NULL, test_size_, 8); |
+ }, kOomRegex); |
+} |
+#endif // defined(OS_WIN) |
+ |
// OS X has no 2Gb allocation limit. |
// See https://crbug.com/169327. |
#if !defined(OS_MACOSX) |
@@ -213,6 +236,23 @@ TEST_F(OutOfMemoryDeathTest, SecurityCalloc) { |
value_ = calloc(1024, insecure_test_size_ / 1024L); |
}, kOomRegex); |
} |
+ |
+TEST_F(OutOfMemoryDeathTest, SecurityAlignedAlloc) { |
+ ASSERT_DEATH({ |
+ SetUpInDeathAssert(); |
+ value_ = base::AlignedAlloc(insecure_test_size_, 8); |
+ }, kOomRegex); |
+} |
+ |
+// POSIX does not define an aligned realloc function. |
+#if defined(OS_WIN) |
+TEST_F(OutOfMemoryDeathTest, SecurityAlignedRealloc) { |
+ ASSERT_DEATH({ |
+ SetUpInDeathAssert(); |
+ value_ = _aligned_realloc(NULL, insecure_test_size_, 8); |
+ }, kOomRegex); |
+} |
+#endif // defined(OS_WIN) |
#endif // !defined(OS_MACOSX) |
#if defined(OS_LINUX) |