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

Unified Diff: base/memory/discardable_memory_unittest.cc

Issue 655003003: base: Add discardable memory test that check behavior when creating enough instances that could use… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_memory_unittest.cc
diff --git a/base/memory/discardable_memory_unittest.cc b/base/memory/discardable_memory_unittest.cc
index a111cfcc07916a7237fdd7d0b67d55aef1c4f688..c9d19c29c03d28cf3a95bbfa04d9d75fb62bc7ea 100644
--- a/base/memory/discardable_memory_unittest.cc
+++ b/base/memory/discardable_memory_unittest.cc
@@ -103,6 +103,22 @@ TEST_P(DiscardableMemoryTest, UnlockedMemoryAccessCrashesInDebugMode) {
}
#endif
+// Test behavior when creating enough instances that could use up a 32-bit
+// address space.
+TEST_P(DiscardableMemoryTest, AddressSpace) {
+ const size_t kLargeSize = 4 * 1024 * 1024; // 4MB.
+ const size_t kNumberOfInstances = 1024 + 1; // >4GiB total.
Avi (use Gerrit) 2014/10/15 21:11:27 Why "4MB" on the line above, and "4GiB" here? Eith
reveman 2014/10/16 20:50:34 Done.
+
+ scoped_ptr<DiscardableMemory> instances[kNumberOfInstances];
+ for (auto& memory : instances) {
+ memory = CreateLockedMemory(kLargeSize);
+ ASSERT_TRUE(memory);
+ void* addr = memory->Memory();
+ ASSERT_NE(static_cast<void*>(NULL), addr);
Avi (use Gerrit) 2014/10/15 21:11:27 nullptr, plus you shouldn't need a cast with it.
reveman 2014/10/16 20:50:34 Done.
+ memory->Unlock();
+ }
+}
+
std::vector<DiscardableMemoryType> GetSupportedDiscardableMemoryTypes() {
std::vector<DiscardableMemoryType> supported_types;
DiscardableMemory::GetSupportedTypes(&supported_types);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698