Index: base/process/memory_unittest.cc |
diff --git a/base/process/memory_unittest.cc b/base/process/memory_unittest.cc |
index c4728c52371263dd6f731998761959c08407eda7..86f03b4303ac26cd6e651a65310237d9299bf552 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" |
@@ -139,6 +141,10 @@ TEST(ProcessMemoryTest, MacTerminateOnHeapCorruption) { |
#endif // defined(OS_MACOSX) |
+TEST(MemoryTest, AllocatorShimWorking) { |
Primiano Tucci (use gerrit)
2016/03/29 18:46:07
Not sure how much this will add. It's very easy to
Will Harris
2016/03/29 18:56:20
Ack. I added it after I tripped it while developin
Primiano Tucci (use gerrit)
2016/03/29 19:30:03
Acknowledged.
|
+ 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 |
@@ -219,6 +225,27 @@ TEST_F(OutOfMemoryDeathTest, Calloc) { |
}, kOomRegex); |
} |
+TEST_F(OutOfMemoryDeathTest, AlignedAlloc) { |
+ ASSERT_DEATH({ |
+ SetUpInDeathAssert(); |
+ value_ = base::AlignedAlloc(test_size_, 8); |
+ }, kOomRegex); |
+} |
+ |
+TEST_F(OutOfMemoryDeathTest, AlignedMalloc) { |
+ ASSERT_DEATH({ |
+ SetUpInDeathAssert(); |
+ value_ = _aligned_malloc(test_size_, 8); |
+ }, kOomRegex); |
+} |
+ |
+TEST_F(OutOfMemoryDeathTest, AlignedRealloc) { |
+ ASSERT_DEATH({ |
+ SetUpInDeathAssert(); |
+ value_ = _aligned_realloc(NULL, test_size_, 8); |
+ }, kOomRegex); |
+} |
+ |
// OS X has no 2Gb allocation limit. |
// See https://crbug.com/169327. |
#if !defined(OS_MACOSX) |
@@ -256,6 +283,28 @@ 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); |
+} |
+ |
+TEST_F(OutOfMemoryDeathTest, SecurityAlignedMalloc) { |
+ ASSERT_DEATH({ |
+ SetUpInDeathAssert(); |
+ value_ = _aligned_malloc(insecure_test_size_, 8); |
+ }, kOomRegex); |
+} |
+ |
+TEST_F(OutOfMemoryDeathTest, SecurityAlignedRealloc) { |
+ ASSERT_DEATH({ |
+ SetUpInDeathAssert(); |
+ value_ = _aligned_realloc(NULL, insecure_test_size_, 8); |
+ }, kOomRegex); |
+} |
+ |
#endif // !defined(OS_MACOSX) |
#if defined(OS_LINUX) |