}
// Check that the most basic of allocate / free pairs work.
-TEST(WTF_PartitionAlloc, Basic)
+TEST(PartitionAllocTest, Basic)
{
TestSetup();
WTF::PartitionBucket* bucket = &allocator.root()->buckets()[kTestBucketIndex];
}
// Check that we can detect a memory leak.
-TEST(WTF_PartitionAlloc, SimpleLeak)
+TEST(PartitionAllocTest, SimpleLeak)
{
TestSetup();
void* leakedPtr = partitionAlloc(allocator.root(), kTestAllocSize);
}
// Test multiple allocations, and freelist handling.
-TEST(WTF_PartitionAlloc, MultiAlloc)
+TEST(PartitionAllocTest, MultiAlloc)
{
TestSetup();
}
// Test a bucket with multiple pages.
-TEST(WTF_PartitionAlloc, MultiPages)
+TEST(PartitionAllocTest, MultiPages)
{
TestSetup();
WTF::PartitionBucket* bucket = &allocator.root()->buckets()[kTestBucketIndex];
}
// Test some finer aspects of internal page transitions.
-TEST(WTF_PartitionAlloc, PageTransitions)
+TEST(PartitionAllocTest, PageTransitions)
{
TestSetup();
WTF::PartitionBucket* bucket = &allocator.root()->buckets()[kTestBucketIndex];
// Test some corner cases relating to page transitions in the internal
// free page list metadata bucket.
-TEST(WTF_PartitionAlloc, FreePageListPageTransitions)
+TEST(PartitionAllocTest, FreePageListPageTransitions)
{
TestSetup();
WTF::PartitionBucket* bucket = &allocator.root()->buckets()[kTestBucketIndex];
// Test a large series of allocations that cross more than one underlying
// 64KB super page allocation.
-TEST(WTF_PartitionAlloc, MultiPageAllocs)
+TEST(PartitionAllocTest, MultiPageAllocs)
{
TestSetup();
// This is guaranteed to cross a super page boundary because the first
// Test the generic allocation functions that can handle arbitrary sizes and
// reallocing etc.
-TEST(WTF_PartitionAlloc, GenericAlloc)
+TEST(PartitionAllocTest, GenericAlloc)
{
TestSetup();
// Test the generic allocation functions can handle some specific sizes of
// interest.
-TEST(WTF_PartitionAlloc, GenericAllocSizes)
+TEST(PartitionAllocTest, GenericAllocSizes)
{
TestSetup();
}
// Test that we can fetch the real allocated size after an allocation.
-TEST(WTF_PartitionAlloc, GenericAllocGetSize)
+TEST(PartitionAllocTest, GenericAllocGetSize)
{
TestSetup();
}
// Test the realloc() contract.
-TEST(WTF_PartitionAlloc, Realloc)
+TEST(PartitionAllocTest, Realloc)
{
TestSetup();
partitionFreeGeneric(genericAllocator.root(), ptr);
- // Test that shrinking a direct mapped allocation happens in-place (even
- // though the new size is smaller than kGenericMaxBucketed).
+ // Test that shrinking a direct mapped allocation happens in-place.
size = WTF::kGenericMaxBucketed + 16 * WTF::kSystemPageSize;
ptr = partitionAllocGeneric(genericAllocator.root(), size);
size_t actualSize = partitionAllocGetSize(ptr);
- ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, WTF::kGenericMaxBucketed - 16 * WTF::kSystemPageSize);
+ ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, WTF::kGenericMaxBucketed + 8 * WTF::kSystemPageSize);
EXPECT_EQ(ptr, ptr2);
- EXPECT_EQ(actualSize - 32 * WTF::kSystemPageSize, partitionAllocGetSize(ptr2));
+ EXPECT_EQ(actualSize - 8 * WTF::kSystemPageSize, partitionAllocGetSize(ptr2));
// Test that a previously in-place shrunk direct mapped allocation can be
// expanded up again within its original size.
EXPECT_EQ(ptr2, ptr);
EXPECT_EQ(actualSize - WTF::kSystemPageSize, partitionAllocGetSize(ptr));
- partitionFreeGeneric(genericAllocator.root(), ptr);
+ // Test that a direct mapped allocation is performed not in-place when the
+ // new size is small enough.
+ ptr2 = partitionReallocGeneric(genericAllocator.root(), ptr, WTF::kSystemPageSize);
+ EXPECT_NE(ptr, ptr2);
+
+ partitionFreeGeneric(genericAllocator.root(), ptr2);
TestShutdown();
}
// Tests the handing out of freelists for partial pages.
-TEST(WTF_PartitionAlloc, PartialPageFreelists)
+TEST(PartitionAllocTest, PartialPageFreelists)
{
TestSetup();
}
// Test some of the fragmentation-resistant properties of the allocator.
-TEST(WTF_PartitionAlloc, PageRefilling)
+TEST(PartitionAllocTest, PageRefilling)
{
TestSetup();
WTF::PartitionBucket* bucket = &allocator.root()->buckets()[kTestBucketIndex];
}
// Basic tests to ensure that allocations work for partial page buckets.
-TEST(WTF_PartitionAlloc, PartialPages)
+TEST(PartitionAllocTest, PartialPages)
{
TestSetup();
}
// Test correct handling if our mapping collides with another.
-TEST(WTF_PartitionAlloc, MappingCollision)
+TEST(PartitionAllocTest, MappingCollision)
{
TestSetup();
// The -2 is because the first and last partition pages in a super page are
}
// Tests that pages in the free page cache do get freed as appropriate.
-TEST(WTF_PartitionAlloc, FreeCache)
+TEST(PartitionAllocTest, FreeCache)
{
TestSetup();
}
// Tests for a bug we had with losing references to free pages.
-TEST(WTF_PartitionAlloc, LostFreePagesBug)
+TEST(PartitionAllocTest, LostFreePagesBug)
{
TestSetup();
// Make sure that malloc(-1) dies.
// In the past, we had an integer overflow that would alias malloc(-1) to
// malloc(0), which is not good.
-TEST(WTF_PartitionAllocDeathTest, LargeAllocs)
+TEST(PartitionAllocDeathTest, LargeAllocs)
{
TestSetup();
// Largest alloc.
}
// Check that our immediate double-free detection works.
-TEST(WTF_PartitionAllocDeathTest, ImmediateDoubleFree)
+TEST(PartitionAllocDeathTest, ImmediateDoubleFree)
{
TestSetup();
}
// Check that our refcount-based double-free detection works.
-TEST(WTF_PartitionAllocDeathTest, RefcountDoubleFree)
+TEST(PartitionAllocDeathTest, RefcountDoubleFree)
{
TestSetup();
}
// Check that guard pages are present where expected.
-TEST(WTF_PartitionAllocDeathTest, GuardPages)
+TEST(PartitionAllocDeathTest, GuardPages)
{
TestSetup();
// It doesn't seem worth the overhead of a whole new file for these tests, so
// we'll put them here since partitionAllocGeneric will depend heavily on these
// functions working correctly.
-TEST(WTF_PartitionAlloc, CLZWorks)
+TEST(PartitionAllocTest, CLZWorks)
{
EXPECT_EQ(32u, WTF::countLeadingZeros32(0));
EXPECT_EQ(31u, WTF::countLeadingZeros32(1));