OLD | NEW |
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 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } | 273 } |
274 #endif // PVALLOC_AVAILABLE == 1 | 274 #endif // PVALLOC_AVAILABLE == 1 |
275 | 275 |
276 TEST_F(OutOfMemoryDeathTest, Memalign) { | 276 TEST_F(OutOfMemoryDeathTest, Memalign) { |
277 ASSERT_DEATH({ | 277 ASSERT_DEATH({ |
278 SetUpInDeathAssert(); | 278 SetUpInDeathAssert(); |
279 value_ = memalign(4, test_size_); | 279 value_ = memalign(4, test_size_); |
280 }, kOomRegex); | 280 }, kOomRegex); |
281 } | 281 } |
282 | 282 |
| 283 #if defined(COMPONENT_BUILD) |
283 TEST_F(OutOfMemoryDeathTest, ViaSharedLibraries) { | 284 TEST_F(OutOfMemoryDeathTest, ViaSharedLibraries) { |
284 // This tests that the run-time symbol resolution is overriding malloc for | 285 // This tests that the run-time symbol resolution is overriding malloc for |
285 // shared libraries as well as for our code. | 286 // shared libraries as well as for our code. |
286 ASSERT_DEATH({ | 287 ASSERT_DEATH({ |
287 SetUpInDeathAssert(); | 288 SetUpInDeathAssert(); |
288 value_ = MallocWrapper(test_size_); | 289 value_ = MallocWrapper(test_size_); |
289 }, kOomRegex); | 290 }, kOomRegex); |
290 } | 291 } |
| 292 #endif |
291 #endif // OS_LINUX | 293 #endif // OS_LINUX |
292 | 294 |
293 // Android doesn't implement posix_memalign(). | 295 // Android doesn't implement posix_memalign(). |
294 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 296 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
295 TEST_F(OutOfMemoryDeathTest, Posix_memalign) { | 297 TEST_F(OutOfMemoryDeathTest, Posix_memalign) { |
296 // Grab the return value of posix_memalign to silence a compiler warning | 298 // Grab the return value of posix_memalign to silence a compiler warning |
297 // about unused return values. We don't actually care about the return | 299 // about unused return values. We don't actually care about the return |
298 // value, since we're asserting death. | 300 // value, since we're asserting death. |
299 ASSERT_DEATH({ | 301 ASSERT_DEATH({ |
300 SetUpInDeathAssert(); | 302 SetUpInDeathAssert(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 bytes = static_cast<const char*>(value_); | 436 bytes = static_cast<const char*>(value_); |
435 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i) | 437 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i) |
436 EXPECT_EQ(0, bytes[i]); | 438 EXPECT_EQ(0, bytes[i]); |
437 free(value_); | 439 free(value_); |
438 | 440 |
439 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_)); | 441 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_)); |
440 EXPECT_TRUE(value_ == NULL); | 442 EXPECT_TRUE(value_ == NULL); |
441 } | 443 } |
442 #endif // !defined(OS_OPENBSD) && BUILDFLAG(ENABLE_WIN_ALLOCATOR_SHIM_TESTS) && | 444 #endif // !defined(OS_OPENBSD) && BUILDFLAG(ENABLE_WIN_ALLOCATOR_SHIM_TESTS) && |
443 // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 445 // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
OLD | NEW |