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

Unified Diff: base/process/memory_unittest.cc

Issue 1414453017: Allocator shims working on VS2015. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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 | « base/allocator/prep_libc.py ('k') | build/common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « base/allocator/prep_libc.py ('k') | build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698