OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/eintr_wrapper.h" | 10 #include "base/eintr_wrapper.h" |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 // Grab the return value of posix_memalign to silence a compiler warning | 623 // Grab the return value of posix_memalign to silence a compiler warning |
624 // about unused return values. We don't actually care about the return | 624 // about unused return values. We don't actually care about the return |
625 // value, since we're asserting death. | 625 // value, since we're asserting death. |
626 ASSERT_DEATH(EXPECT_EQ(ENOMEM, posix_memalign(&value_, 8, test_size_)), ""); | 626 ASSERT_DEATH(EXPECT_EQ(ENOMEM, posix_memalign(&value_, 8, test_size_)), ""); |
627 } | 627 } |
628 #endif // OS_LINUX | 628 #endif // OS_LINUX |
629 | 629 |
630 #if defined(OS_MACOSX) | 630 #if defined(OS_MACOSX) |
631 | 631 |
632 // Since these allocation functions take a signed size, it's possible that | 632 // Since these allocation functions take a signed size, it's possible that |
633 // calling them just once won't be enough to exhaust memory. | 633 // calling them just once won't be enough to exhaust memory. In the 32-bit |
| 634 // environment, it's likely that these allocation attempts will fail because |
| 635 // not enough contiguous address space is availble. In the 64-bit environment, |
| 636 // it's likely that they'll fail because they would require a preposterous |
| 637 // amount of (virtual) memory. |
634 | 638 |
635 TEST_F(OutOfMemoryTest, CFAllocatorSystemDefault) { | 639 TEST_F(OutOfMemoryTest, CFAllocatorSystemDefault) { |
636 ASSERT_DEATH(while ((value_ = | 640 ASSERT_DEATH(while ((value_ = |
637 base::AllocateViaCFAllocatorSystemDefault(signed_test_size_))) {}, ""); | 641 base::AllocateViaCFAllocatorSystemDefault(signed_test_size_))) {}, ""); |
638 } | 642 } |
639 | 643 |
640 TEST_F(OutOfMemoryTest, CFAllocatorMalloc) { | 644 TEST_F(OutOfMemoryTest, CFAllocatorMalloc) { |
641 ASSERT_DEATH(while ((value_ = | 645 ASSERT_DEATH(while ((value_ = |
642 base::AllocateViaCFAllocatorMalloc(signed_test_size_))) {}, ""); | 646 base::AllocateViaCFAllocatorMalloc(signed_test_size_))) {}, ""); |
643 } | 647 } |
644 | 648 |
645 TEST_F(OutOfMemoryTest, CFAllocatorMallocZone) { | 649 TEST_F(OutOfMemoryTest, CFAllocatorMallocZone) { |
646 ASSERT_DEATH(while ((value_ = | 650 ASSERT_DEATH(while ((value_ = |
647 base::AllocateViaCFAllocatorMallocZone(signed_test_size_))) {}, ""); | 651 base::AllocateViaCFAllocatorMallocZone(signed_test_size_))) {}, ""); |
648 } | 652 } |
649 | 653 |
| 654 #if !defined(ARCH_CPU_64_BITS) |
| 655 |
| 656 // See process_util_unittest_mac.mm for an explanation of why this test isn't |
| 657 // run in the 64-bit environment. |
| 658 |
650 TEST_F(OutOfMemoryTest, PsychoticallyBigObjCObject) { | 659 TEST_F(OutOfMemoryTest, PsychoticallyBigObjCObject) { |
651 ASSERT_DEATH(while ((value_ = | 660 ASSERT_DEATH(while ((value_ = |
652 base::AllocatePsychoticallyBigObjCObject())) {}, ""); | 661 base::AllocatePsychoticallyBigObjCObject())) {}, ""); |
653 } | 662 } |
654 | 663 |
| 664 #endif // !ARCH_CPU_64_BITS |
655 #endif // OS_MACOSX | 665 #endif // OS_MACOSX |
656 | 666 |
657 #endif // !defined(OS_WIN) | 667 #endif // !defined(OS_WIN) |
OLD | NEW |