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

Side by Side Diff: base/process/memory_unittest.cc

Issue 2173463002: Make base::TerminateBecauseOutOfMemory call RaiseException on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unittests Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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
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
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)
OLDNEW
« no previous file with comments | « base/process/memory.cc ('k') | base/process/memory_win.cc » ('j') | base/process/memory_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698