| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // Windows only supports these tests with the allocator shim in place. | 89 // Windows only supports these tests with the allocator shim in place. |
| 90 #if !defined(OS_ANDROID) && !defined(OS_OPENBSD) && \ | 90 #if !defined(OS_ANDROID) && !defined(OS_OPENBSD) && \ |
| 91 BUILDFLAG(ENABLE_WIN_ALLOCATOR_SHIM_TESTS) && \ | 91 BUILDFLAG(ENABLE_WIN_ALLOCATOR_SHIM_TESTS) && \ |
| 92 !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 92 !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| 93 | 93 |
| 94 namespace { | 94 namespace { |
| 95 #if defined(OS_WIN) | 95 #if defined(OS_WIN) |
| 96 // Windows raises an exception rather than using LOG(FATAL) in order to make the | 96 // Windows raises an exception rather than using LOG(FATAL) in order to make the |
| 97 // exit code unique to OOM. | 97 // exit code unique to OOM. |
| 98 const char* kOomRegex = ""; | 98 const char* kOomRegex = ""; |
| 99 const int kExitCode = base::win::kOomExceptionCode; | 99 // See definition in memory_win.cc. |
| 100 const int kExitCode = 0xe0000008; |
| 100 #else | 101 #else |
| 101 const char* kOomRegex = "Out of memory"; | 102 const char* kOomRegex = "Out of memory"; |
| 102 const int kExitCode = 1; | 103 const int kExitCode = 1; |
| 103 #endif | 104 #endif |
| 104 } // namespace | 105 } // namespace |
| 105 | 106 |
| 106 class OutOfMemoryTest : public testing::Test { | 107 class OutOfMemoryTest : public testing::Test { |
| 107 public: | 108 public: |
| 108 OutOfMemoryTest() | 109 OutOfMemoryTest() |
| 109 : value_(NULL), | 110 : value_(NULL), |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i) | 441 for (size_t i = 0; i < (kSafeCallocItems * kSafeCallocSize); ++i) |
| 441 EXPECT_EQ(0, bytes[i]); | 442 EXPECT_EQ(0, bytes[i]); |
| 442 free(value_); | 443 free(value_); |
| 443 | 444 |
| 444 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_)); | 445 EXPECT_FALSE(base::UncheckedCalloc(1, test_size_, &value_)); |
| 445 EXPECT_TRUE(value_ == NULL); | 446 EXPECT_TRUE(value_ == NULL); |
| 446 } | 447 } |
| 447 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 448 #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| 448 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && !(defined(OS_WIN) && | 449 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && !(defined(OS_WIN) && |
| 449 // !defined(ALLOCATOR_SHIM)) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 450 // !defined(ALLOCATOR_SHIM)) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
| OLD | NEW |