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

Side by Side Diff: base/process_util_unittest.cc

Issue 10908245: unchecked_malloc() for Skia on OSX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops, GetPurgeableZone() was exported for tests. Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « base/process_util_mac.mm ('k') | skia/ext/SkMemory_new_handler.cpp » ('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 (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 <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 }, ""); 1111 }, "");
1112 } 1112 }
1113 } 1113 }
1114 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) 1114 #endif // defined(OS_POSIX) && !defined(OS_ANDROID)
1115 1115
1116 #if defined(OS_MACOSX) 1116 #if defined(OS_MACOSX)
1117 1117
1118 // Purgeable zone tests (if it exists) 1118 // Purgeable zone tests (if it exists)
1119 1119
1120 TEST_F(OutOfMemoryDeathTest, MallocPurgeable) { 1120 TEST_F(OutOfMemoryDeathTest, MallocPurgeable) {
1121 malloc_zone_t* zone = base::GetPurgeableZone(); 1121 malloc_zone_t* zone = malloc_default_purgeable_zone();
1122 if (zone) 1122 if (zone)
Avi (use Gerrit) 2012/09/13 20:21:25 Do we need these if calls? The default purgeable z
Scott Hess - ex-Googler 2012/09/13 21:15:47 Tough crowd!
1123 ASSERT_DEATH({ 1123 ASSERT_DEATH({
1124 SetUpInDeathAssert(); 1124 SetUpInDeathAssert();
1125 value_ = malloc_zone_malloc(zone, test_size_); 1125 value_ = malloc_zone_malloc(zone, test_size_);
1126 }, ""); 1126 }, "");
1127 } 1127 }
1128 1128
1129 TEST_F(OutOfMemoryDeathTest, ReallocPurgeable) { 1129 TEST_F(OutOfMemoryDeathTest, ReallocPurgeable) {
1130 malloc_zone_t* zone = base::GetPurgeableZone(); 1130 malloc_zone_t* zone = malloc_default_purgeable_zone();
1131 if (zone) 1131 if (zone)
1132 ASSERT_DEATH({ 1132 ASSERT_DEATH({
1133 SetUpInDeathAssert(); 1133 SetUpInDeathAssert();
1134 value_ = malloc_zone_realloc(zone, NULL, test_size_); 1134 value_ = malloc_zone_realloc(zone, NULL, test_size_);
1135 }, ""); 1135 }, "");
1136 } 1136 }
1137 1137
1138 TEST_F(OutOfMemoryDeathTest, CallocPurgeable) { 1138 TEST_F(OutOfMemoryDeathTest, CallocPurgeable) {
1139 malloc_zone_t* zone = base::GetPurgeableZone(); 1139 malloc_zone_t* zone = malloc_default_purgeable_zone();
1140 if (zone) 1140 if (zone)
1141 ASSERT_DEATH({ 1141 ASSERT_DEATH({
1142 SetUpInDeathAssert(); 1142 SetUpInDeathAssert();
1143 value_ = malloc_zone_calloc(zone, 1024, test_size_ / 1024L); 1143 value_ = malloc_zone_calloc(zone, 1024, test_size_ / 1024L);
1144 }, ""); 1144 }, "");
1145 } 1145 }
1146 1146
1147 TEST_F(OutOfMemoryDeathTest, VallocPurgeable) { 1147 TEST_F(OutOfMemoryDeathTest, VallocPurgeable) {
1148 malloc_zone_t* zone = base::GetPurgeableZone(); 1148 malloc_zone_t* zone = malloc_default_purgeable_zone();
1149 if (zone) 1149 if (zone)
1150 ASSERT_DEATH({ 1150 ASSERT_DEATH({
1151 SetUpInDeathAssert(); 1151 SetUpInDeathAssert();
1152 value_ = malloc_zone_valloc(zone, test_size_); 1152 value_ = malloc_zone_valloc(zone, test_size_);
1153 }, ""); 1153 }, "");
1154 } 1154 }
1155 1155
1156 TEST_F(OutOfMemoryDeathTest, PosixMemalignPurgeable) { 1156 TEST_F(OutOfMemoryDeathTest, PosixMemalignPurgeable) {
1157 malloc_zone_t* zone = base::GetPurgeableZone(); 1157 malloc_zone_t* zone = malloc_default_purgeable_zone();
1158 1158
1159 typedef void* (*zone_memalign_t)(malloc_zone_t*, size_t, size_t); 1159 typedef void* (*zone_memalign_t)(malloc_zone_t*, size_t, size_t);
1160 // malloc_zone_memalign only exists on >= 10.6. Use dlsym to grab it at 1160 // malloc_zone_memalign only exists on >= 10.6. Use dlsym to grab it at
1161 // runtime because it may not be present in the SDK used for compilation. 1161 // runtime because it may not be present in the SDK used for compilation.
Scott Hess - ex-Googler 2012/09/13 21:15:47 Looks like I can fix this, too.
1162 zone_memalign_t zone_memalign = 1162 zone_memalign_t zone_memalign =
1163 reinterpret_cast<zone_memalign_t>( 1163 reinterpret_cast<zone_memalign_t>(
1164 dlsym(RTLD_DEFAULT, "malloc_zone_memalign")); 1164 dlsym(RTLD_DEFAULT, "malloc_zone_memalign"));
1165 1165
1166 if (zone && zone_memalign) { 1166 if (zone && zone_memalign) {
1167 ASSERT_DEATH({ 1167 ASSERT_DEATH({
1168 SetUpInDeathAssert(); 1168 SetUpInDeathAssert();
1169 value_ = zone_memalign(zone, 8, test_size_); 1169 value_ = zone_memalign(zone, 8, test_size_);
1170 }, ""); 1170 }, "");
1171 } 1171 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 SetUpInDeathAssert(); 1212 SetUpInDeathAssert();
1213 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} 1213 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {}
1214 }, ""); 1214 }, "");
1215 } 1215 }
1216 1216
1217 #endif // !ARCH_CPU_64_BITS 1217 #endif // !ARCH_CPU_64_BITS
1218 #endif // OS_MACOSX 1218 #endif // OS_MACOSX
1219 1219
1220 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && 1220 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) &&
1221 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER) 1221 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER)
OLDNEW
« no previous file with comments | « base/process_util_mac.mm ('k') | skia/ext/SkMemory_new_handler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698