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..59cf2006ffdf8d05f81d61c9cee05c7ea1a8badb 100644 |
| --- a/base/process/memory_unittest.cc |
| +++ b/base/process/memory_unittest.cc |
| @@ -99,6 +99,16 @@ const int kExitCode = base::win::kOomExceptionCode; |
| const char* kOomRegex = "Out of memory"; |
| const int kExitCode = 1; |
| #endif |
| + |
| +// See corresponding function in content/renderer/render_frame_impl.cc |
| +NOINLINE void ExhaustMemory() { |
| + volatile void* ptr = nullptr; |
| + do { |
| + ptr = malloc(0x10000000); |
| + base::debug::Alias(&ptr); |
| + } while (ptr); |
| +} |
| + |
| } // namespace |
| class OutOfMemoryTest : public testing::Test { |
| @@ -133,6 +143,13 @@ class OutOfMemoryDeathTest : public OutOfMemoryTest { |
| } |
| }; |
| +TEST_F(OutOfMemoryDeathTest, Exhaust) { |
| + ASSERT_EXIT({ |
| + SetUpInDeathAssert(); |
| + ExhaustMemory(); |
| + }, testing::ExitedWithCode(kExitCode), kOomRegex); |
| +} |
|
Nico
2017/01/26 17:56:53
do we really need this test? it duplicates the fun
Will Harris
2017/01/26 18:12:44
I'm not sure I totally understand what you mean by
|
| + |
| TEST_F(OutOfMemoryDeathTest, New) { |
| ASSERT_EXIT({ |
| SetUpInDeathAssert(); |