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

Unified Diff: Source/wtf/PartitionAllocTest.cpp

Issue 18242004: Use the partition allocator and run the test in debug too. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Run test in debug. Created 7 years, 6 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 | « Source/wtf/PartitionAlloc.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PartitionAllocTest.cpp
diff --git a/Source/wtf/PartitionAllocTest.cpp b/Source/wtf/PartitionAllocTest.cpp
index 4a4fbc86cb6823406c38b32c3db5a2b34d5fe82f..8e44c9b930bf94107475b60c04dca50182830f4e 100644
--- a/Source/wtf/PartitionAllocTest.cpp
+++ b/Source/wtf/PartitionAllocTest.cpp
@@ -46,7 +46,7 @@
#endif
#endif // OS(UNIX)
-#if defined(NDEBUG) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
+#if !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
namespace {
@@ -67,7 +67,9 @@ static void TestSetup()
static void TestShutdown()
{
- partitionAllocShutdown(&root);
+ // We expect no leaks in the general case. We have a test for leak
+ // detection.
+ EXPECT_TRUE(partitionAllocShutdown(&root));
}
static WTF::PartitionPageHeader* GetFullPage(size_t size)
@@ -133,6 +135,14 @@ TEST(WTF_PartitionAlloc, Basic)
TestShutdown();
}
+// Check that we can detect a memory leak.
+TEST(WTF_PartitionAlloc, SimpleLeak)
+{
+ TestSetup();
+ void* leakedPtr = partitionAlloc(&root, kTestAllocSize);
+ EXPECT_FALSE(partitionAllocShutdown(&root));
+}
+
// Test multiple allocations, and freelist handling.
TEST(WTF_PartitionAlloc, MultiAlloc)
{
@@ -382,4 +392,4 @@ TEST(WTF_PartitionAlloc, MappingCollision)
} // namespace
-#endif // defined(NDEBUG) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
+#endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
« no previous file with comments | « Source/wtf/PartitionAlloc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698