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

Unified Diff: base/process/memory_unittest.cc

Issue 2676093003: mac: Hook up allocator shim during app startup. (Closed)
Patch Set: Remove unused include. Created 3 years, 10 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/process/memory_mac.mm ('k') | content/app/content_main_runner.cc » ('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 ce28225d3f5bc709a524e517e9990eb4efd8156d..ecf0b871ecb0415e9ecfc25443c29610cdb7b341 100644
--- a/base/process/memory_unittest.cc
+++ b/base/process/memory_unittest.cc
@@ -27,6 +27,8 @@
#endif
#if defined(OS_MACOSX)
#include <malloc/malloc.h>
+#include "base/allocator/allocator_interception_mac.h"
+#include "base/allocator/allocator_shim.h"
#include "base/process/memory_unittest_mac.h"
#endif
#if defined(OS_LINUX)
@@ -59,6 +61,9 @@ typedef BOOL (WINAPI* HeapQueryFn) \
// will fail.
TEST(ProcessMemoryTest, MacTerminateOnHeapCorruption) {
+#if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
+ base::allocator::InitializeAllocatorShim();
+#endif
// Assert that freeing an unallocated pointer will crash the process.
char buf[9];
asm("" : "=r" (buf)); // Prevent clang from being too smart.
@@ -79,6 +84,12 @@ TEST(ProcessMemoryTest, MacTerminateOnHeapCorruption) {
#endif // defined(OS_MACOSX)
TEST(MemoryTest, AllocatorShimWorking) {
+#if defined(OS_MACOSX)
+#if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
+ base::allocator::InitializeAllocatorShim();
+#endif
+ base::allocator::InterceptAllocationsMac();
+#endif
ASSERT_TRUE(base::allocator::IsAllocatorInitialized());
}
@@ -124,6 +135,10 @@ class OutOfMemoryTest : public testing::Test {
class OutOfMemoryDeathTest : public OutOfMemoryTest {
public:
void SetUpInDeathAssert() {
+#if defined(OS_MACOSX) && BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
+ base::allocator::InitializeAllocatorShim();
+#endif
+
// Must call EnableTerminationOnOutOfMemory() because that is called from
// chrome's main function and therefore hasn't been called yet.
// Since this call may result in another thread being created and death
« no previous file with comments | « base/process/memory_mac.mm ('k') | content/app/content_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698