Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Unified Diff: base/process/memory_unittest.cc

Issue 2648423006: Fix ExhaustMemory on clang. (Closed)
Patch Set: all arch Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698