Chromium Code Reviews| Index: base/process/memory_unittest.cc |
| diff --git a/base/process/memory_unittest.cc b/base/process/memory_unittest.cc |
| index 0be2d4400633ba75101423e4a452891ddb87d9aa..909905c692045dbdb9bff7472ecdde7f41506cf9 100644 |
| --- a/base/process/memory_unittest.cc |
| +++ b/base/process/memory_unittest.cc |
| @@ -409,6 +409,34 @@ class OutOfMemoryHandledTest : public OutOfMemoryTest { |
| } |
| }; |
| +#if defined(OS_WIN) |
| + |
| +namespace { |
| + |
| +DWORD HandleOutOfMemoryException(EXCEPTION_POINTERS* exception_ptrs, |
| + size_t expected_size) { |
| + EXPECT_EQ(base::win::kOomExceptionCode, |
| + exception_ptrs->ExceptionRecord->ExceptionCode); |
| + EXPECT_LE(1U, exception_ptrs->ExceptionRecord->NumberParameters); |
| + EXPECT_EQ(expected_size, |
| + exception_ptrs->ExceptionRecord->ExceptionInformation[0]); |
| + return EXCEPTION_EXECUTE_HANDLER; |
| +} |
| + |
| +} // namespace |
| + |
| +TEST_F(OutOfMemoryTest, TerminateBecauseOutOfMemoryReportsAllocSize) { |
| + // On Windows, TerminateBecauseOutOfMemory reports the attempted allocation |
| + // size in the exception raised. |
| + const size_t kAttemptedAllocationSize = 0xBADA55; |
|
Will Harris
2017/02/06 18:24:03
Can you test with a value that does not fit in 32b
Sigurður Ásgeirsson
2017/02/06 19:43:58
Done.
|
| + __try { |
| + base::TerminateBecauseOutOfMemory(kAttemptedAllocationSize); |
| + } __except (HandleOutOfMemoryException(GetExceptionInformation(), |
| + kAttemptedAllocationSize)) { |
| + } |
| +} |
| +#endif // OS_WIN |
| + |
| // TODO(b.kelemen): make UncheckedMalloc and UncheckedCalloc work |
| // on Windows as well. |
| TEST_F(OutOfMemoryHandledTest, UncheckedMalloc) { |