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

Side by Side Diff: chrome/installer/setup/memory_unittest.cc

Issue 2907563002: allocator/Windows: delete the old non-unified allocator-shim (Closed)
Patch Set: remove comment Created 3 years, 6 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
« no previous file with comments | « chrome/installer/setup/BUILD.gn ('k') | media/base/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/allocator/features.h"
9 #include "base/process/memory.h" 10 #include "base/process/memory.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 #if defined(OS_MACOSX) 13 #if defined(OS_MACOSX)
13 #include "base/allocator/allocator_interception_mac.h" 14 #include "base/allocator/allocator_interception_mac.h"
14 #endif 15 #endif
15 16
16 #if defined(ALLOCATOR_SHIM) 17 #if BUILDFLAG(USE_ALLOCATOR_SHIM)
17 // Test that the allocator shim is in-place so that base::UncheckedMalloc works. 18 // Test that the allocator shim is in-place so that base::UncheckedMalloc works.
18 TEST(OutOfMemoryHandledTest, UncheckedMalloc) { 19 TEST(OutOfMemoryHandledTest, UncheckedMalloc) {
19 // Enable termination on OOM - just as setup.exe does at early initialization 20 // Enable termination on OOM - just as setup.exe does at early initialization
20 // - and test that UncheckedMalloc properly by-passes this in order to allow 21 // - and test that UncheckedMalloc properly by-passes this in order to allow
21 // the caller to handle OOM. 22 // the caller to handle OOM.
22 base::EnableTerminationOnOutOfMemory(); 23 base::EnableTerminationOnOutOfMemory();
23 24
24 const size_t kSafeMallocSize = 512; 25 const size_t kSafeMallocSize = 512;
25 26
26 void* value = nullptr; 27 void* value = nullptr;
27 EXPECT_TRUE(base::UncheckedMalloc(kSafeMallocSize, &value)); 28 EXPECT_TRUE(base::UncheckedMalloc(kSafeMallocSize, &value));
28 EXPECT_NE(nullptr, value); 29 EXPECT_NE(nullptr, value);
29 free(value); 30 free(value);
30 31
31 // Make test size as large as possible minus a few pages so that alignment or 32 // Make test size as large as possible minus a few pages so that alignment or
32 // other rounding doesn't make it wrap. 33 // other rounding doesn't make it wrap.
33 const size_t kUnsafeMallocSize( 34 const size_t kUnsafeMallocSize(
34 std::numeric_limits<std::size_t>::max() - 12 * 1024); 35 std::numeric_limits<std::size_t>::max() - 12 * 1024);
35 36
36 EXPECT_FALSE(base::UncheckedMalloc(kUnsafeMallocSize, &value)); 37 EXPECT_FALSE(base::UncheckedMalloc(kUnsafeMallocSize, &value));
37 EXPECT_EQ(nullptr, value); 38 EXPECT_EQ(nullptr, value);
38 39
39 #if defined(OS_MACOSX) 40 #if defined(OS_MACOSX)
40 base::allocator::UninterceptMallocZonesForTesting(); 41 base::allocator::UninterceptMallocZonesForTesting();
41 #endif 42 #endif
42 } 43 }
43 #endif // ALLOCATOR_SHIM 44 #endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
OLDNEW
« no previous file with comments | « chrome/installer/setup/BUILD.gn ('k') | media/base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698