Loading...
--- libmalloc/libmalloc-657.80.3/tests/pgm_zone_api.c
+++ libmalloc/libmalloc-521.120.7/tests/pgm_zone_api.c
@@ -57,33 +57,21 @@
{
T_ATEND(teardown);
- wrapped_zone.version = 16;
+ wrapped_zone.version = 13;
wrapped_zone.calloc = malloc_default_zone()->calloc;
zone = (pgm_zone_t *)pgm_create_zone(&wrapped_zone);
wrapped_zone.calloc = NULL;
- wrapped_zone.version = 0;
-}
-
-T_DECL(optional_apis, "Restrict zone API to what is supported by wrapped zone", T_META_TAG_VM_PREFERRED)
+}
+
+T_DECL(optional_apis, "Restrict zone API to what is supported by wrapped zone")
{
setup();
malloc_zone_t *z = &zone->malloc_zone;
-
- // Always supported
- T_EXPECT_NOTNULL(z->batch_malloc, NULL);
- T_EXPECT_NOTNULL(z->batch_free, NULL);
- T_EXPECT_NOTNULL(z->pressure_relief, NULL);
-
- // Never supported
- T_EXPECT_NULL(z->try_free_default, NULL);
-
- // Supported if wrapped zone has it
- T_EXPECT_NULL(z->memalign, NULL);
- T_EXPECT_NULL(z->malloc_type_memalign, NULL);
- T_EXPECT_NULL(z->free_definite_size, NULL);
- T_EXPECT_NULL(z->claimed_address, NULL);
- T_EXPECT_NULL(z->malloc_type_malloc_with_options, NULL);
+ T_EXPECT_NOTNULL(z->batch_malloc, "batch_malloc() is always supported");
+ T_EXPECT_NOTNULL(z->batch_free, "batch_free() is always supported");
+ T_EXPECT_NULL(z->memalign, "memalign() is optional");
+ T_EXPECT_NULL(z->free_definite_size, "free_definite_size() is optional");
}
static size_t wrapped_zone_malloc_expected_size = size;
@@ -96,8 +84,7 @@
}
T_DECL(delegate_unsampled, "delegation of unsampled allocations",
- T_META_ENVVAR("MallocProbGuardAllocations=1"),
- T_META_TAG_VM_PREFERRED)
+ T_META_ENVVAR("MallocProbGuardAllocations=1"))
{
setup();
wrapped_zone.malloc = wrapped_zone_malloc;
@@ -128,7 +115,7 @@
wrapped_zone_free_call_count++;
}
-T_DECL(delegate_unguarded, "delegation of unguarded deallocations", T_META_TAG_VM_PREFERRED)
+T_DECL(delegate_unguarded, "delegation of unguarded deallocations")
{
setup();
wrapped_zone.free = wrapped_zone_free;
@@ -146,7 +133,7 @@
T_EXPECT_EQ(wrapped_zone_free_call_count, 1, "delegate unguarded");
}
-T_DECL(size, "size is rounded up to multiple of 16", T_META_TAG_VM_PREFERRED)
+T_DECL(size, "size is rounded up to multiple of 16")
{
setup();
size_t requested_sizes[] = {0, 1, 16, 17, 32, 33, 48, 49};
@@ -166,7 +153,7 @@
return ((uintptr_t)ptr % alignment) == 0;
}
-T_DECL(alignment, "alignments", T_META_TAG_VM_PREFERRED)
+T_DECL(alignment, "alignments")
{
wrapped_zone.memalign = malloc_default_zone()->memalign;
setup();
@@ -187,12 +174,14 @@
return ++wrapped_zone_memalign_ret_value;
}
-T_DECL(memalign_invalid_alignment, "memalign delegates for alignment greater than page size", T_META_TAG_VM_PREFERRED)
+T_DECL(memalign_invalid_alignment, "memalign delegates for invalid alignment")
{
wrapped_zone.memalign = wrapped_zone_memalign;
setup();
T_EXPECT_EQ(CALL(memalign, 2 * PAGE_SIZE, size), (void *)1, "alignment > page size");
+ T_EXPECT_EQ(CALL(memalign, 32+16, size), (void *)2, "alignment not a power of 2");
+ T_EXPECT_EQ(CALL(memalign, sizeof(void *) / 2, size), (void *)3, "alignment < sizeof(void *)");
}
static void *
@@ -201,7 +190,7 @@
return (void *)7;
}
-T_DECL(calloc_overflow, "calloc delegates on overflow", T_META_TAG_VM_PREFERRED)
+T_DECL(calloc_overflow, "calloc delegates on overflow")
{
setup();
wrapped_zone.calloc = wrapped_zone_calloc;
@@ -226,8 +215,7 @@
T_DECL(calloc_zeroed_memory, "calloc provides zeroed memory",
T_META_ENVVAR("MallocProbGuardSlots=2"),
T_META_ENVVAR("MallocProbGuardMetadata=2"),
- T_META_ENVVAR("MallocProbGuardAllocations=1"),
- T_META_TAG_VM_PREFERRED)
+ T_META_ENVVAR("MallocProbGuardAllocations=1"))
{
setup();
@@ -246,7 +234,7 @@
T_EXPECT_TRUE(is_zeroed_page(ptr3), "zeroed page");
}
-T_DECL(realloc_null_pointer, "realloc forwards to malloc for null pointers", T_META_TAG_VM_PREFERRED)
+T_DECL(realloc_null_pointer, "realloc forwards to malloc for null pointers")
{
setup();
wrapped_zone.malloc = wrapped_zone_malloc;
@@ -262,8 +250,7 @@
return (void *)9;
}
-T_DECL(realloc_unguarded_and_unsampled, "realloc only delegates for old-unguarded and new-unsampled combination",
- T_META_TAG_VM_PREFERRED)
+T_DECL(realloc_unguarded_and_unsampled, "realloc only delegates for old-unguarded and new-unsampled combination")
{
setup();
wrapped_zone.realloc = wrapped_zone_realloc;
@@ -273,8 +260,7 @@
}
T_DECL(batch_malloc, "batch_malloc implementation",
- T_META_ENVVAR("MallocProbGuardAllocations=2"),
- T_META_TAG_VM_PREFERRED)
+ T_META_ENVVAR("MallocProbGuardAllocations=2"))
{
setup();
wrapped_zone.malloc = wrapped_zone_malloc;
@@ -291,7 +277,7 @@
T_EXPECT_EQ(results[2], (void *)1, "Wrapped zone allocation");
}
-T_DECL(batch_free, "batch_free implementation", T_META_TAG_VM_PREFERRED)
+T_DECL(batch_free, "batch_free implementation")
{
setup();
wrapped_zone.free = wrapped_zone_free;
@@ -323,7 +309,7 @@
T_QUIET; T_EXPECT_EQ(count, 1, NULL);
}
-T_DECL(introspection_enumerator, "In-process block enumeration", T_META_TAG_VM_PREFERRED)
+T_DECL(introspection_enumerator, "In-process block enumeration")
{
setup();
expected_ranges[0] = (vm_range_t){(vm_address_t)CALL(malloc, 7), 16};