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) |