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

Side by Side Diff: base/process/memory_unittest.cc

Issue 2143693003: Start refactoring Windows allocator shim in prep for hooking in generic allocator shim on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 5 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 unified diff | Download patch
« base/allocator/winheap_stubs_win.cc ('K') | « base/base.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include "base/process/memory.h" 7 #include "base/process/memory.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
11 #include <limits> 11 #include <limits>
12 12
13 #include "base/allocator/allocator_check.h" 13 #include "base/allocator/allocator_check.h"
14 #include "base/allocator/features.h"
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/debug/alias.h" 16 #include "base/debug/alias.h"
16 #include "base/memory/aligned_memory.h" 17 #include "base/memory/aligned_memory.h"
17 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 #include <windows.h> 23 #include <windows.h>
23 #endif 24 #endif
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 TEST(MemoryTest, AllocatorShimWorking) { 82 TEST(MemoryTest, AllocatorShimWorking) {
82 ASSERT_TRUE(base::allocator::IsAllocatorInitialized()); 83 ASSERT_TRUE(base::allocator::IsAllocatorInitialized());
83 } 84 }
84 85
85 // Android doesn't implement set_new_handler, so we can't use the 86 // Android doesn't implement set_new_handler, so we can't use the
86 // OutOfMemoryTest cases. OpenBSD does not support these tests either. 87 // OutOfMemoryTest cases. OpenBSD does not support these tests either.
87 // Don't test these on ASan/TSan/MSan configurations: only test the real 88 // Don't test these on ASan/TSan/MSan configurations: only test the real
88 // allocator. 89 // allocator.
89 // Windows only supports these tests with the allocator shim in place. 90 // Windows only supports these tests with the allocator shim in place.
90 #if !defined(OS_ANDROID) && !defined(OS_OPENBSD) && \ 91 #if !defined(OS_ANDROID) && !defined(OS_OPENBSD) && \
91 !(defined(OS_WIN) && !defined(ALLOCATOR_SHIM)) && \ 92 BUILDFLAG(ENABLE_WIN_ALLOCATOR_SHIM_TESTS) && \
92 !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 93 !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
93 94
94 namespace { 95 namespace {
95 const char *kOomRegex = "Out of memory"; 96 const char *kOomRegex = "Out of memory";
96 } // namespace 97 } // namespace
97 98
98 class OutOfMemoryTest : public testing::Test { 99 class OutOfMemoryTest : public testing::Test {
99 public: 100 public:
100 OutOfMemoryTest() 101 OutOfMemoryTest()
101 : value_(NULL), 102 : value_(NULL),
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i) 447 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i)
447 EXPECT_EQ(0, bytes[i]); 448 EXPECT_EQ(0, bytes[i]);
448 free(value_); 449 free(value_);
449 450
450 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_)); 451 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_));
451 EXPECT_TRUE(value_ == NULL); 452 EXPECT_TRUE(value_ == NULL);
452 } 453 }
453 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 454 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
454 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && !(defined(OS_WIN) && 455 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && !(defined(OS_WIN) &&
455 // !defined(ALLOCATOR_SHIM)) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 456 // !defined(ALLOCATOR_SHIM)) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
OLDNEW
« base/allocator/winheap_stubs_win.cc ('K') | « base/base.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698