Loading...
--- libmalloc/libmalloc-521.120.7/tests/pgm_zone_api.c
+++ libmalloc/libmalloc-792.80.2/tests/pgm_zone_api.c
@@ -7,7 +7,10 @@
 
 #include <darwintest.h>
 
-T_GLOBAL_META(T_META_RUN_CONCURRENTLY(TRUE), T_META_NAMESPACE("pgm"));
+// TODO: support these tests with xzone malloc - currently their direct
+// manipulation of the wrapped zone may prevent this (not tested)
+T_GLOBAL_META(T_META_RUN_CONCURRENTLY(TRUE), T_META_NAMESPACE("pgm"),
+		T_META_TAG_MAGAZINE_ONLY);
 
 #define PGM_MOCK_SHOULD_SAMPLE_COUNTER
 static uint32_t should_sample_counter_call_count;
@@ -57,21 +60,33 @@
 {
 	T_ATEND(teardown);
 
-	wrapped_zone.version = 13;
+	wrapped_zone.version = 16;
 	wrapped_zone.calloc = malloc_default_zone()->calloc;
 	zone = (pgm_zone_t *)pgm_create_zone(&wrapped_zone);
 	wrapped_zone.calloc = NULL;
-}
-
-T_DECL(optional_apis, "Restrict zone API to what is supported by wrapped zone")
+	wrapped_zone.version = 0;
+}
+
+T_DECL(optional_apis, "Restrict zone API to what is supported by wrapped zone", T_META_TAG_VM_PREFERRED)
 {
 	setup();
 
 	malloc_zone_t *z = &zone->malloc_zone;
-	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");
+
+	// 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);
 }
 
 static size_t wrapped_zone_malloc_expected_size = size;
@@ -84,7 +99,8 @@
 }
 
 T_DECL(delegate_unsampled, "delegation of unsampled allocations",
-		T_META_ENVVAR("MallocProbGuardAllocations=1"))
+		T_META_ENVVAR("MallocProbGuardAllocations=1"),
+		T_META_TAG_VM_PREFERRED)
 {
 	setup();
 	wrapped_zone.malloc = wrapped_zone_malloc;
@@ -115,7 +131,7 @@
 	wrapped_zone_free_call_count++;
 }
 
-T_DECL(delegate_unguarded, "delegation of unguarded deallocations")
+T_DECL(delegate_unguarded, "delegation of unguarded deallocations", T_META_TAG_VM_PREFERRED)
 {
 	setup();
 	wrapped_zone.free = wrapped_zone_free;
@@ -133,7 +149,7 @@
 	T_EXPECT_EQ(wrapped_zone_free_call_count, 1, "delegate unguarded");
 }
 
-T_DECL(size, "size is rounded up to multiple of 16")
+T_DECL(size, "size is rounded up to multiple of 16", T_META_TAG_VM_PREFERRED)
 {
 	setup();
 	size_t requested_sizes[] = {0, 1, 16, 17, 32, 33, 48, 49};
@@ -153,7 +169,7 @@
 	return ((uintptr_t)ptr % alignment) == 0;
 }
 
-T_DECL(alignment, "alignments")
+T_DECL(alignment, "alignments", T_META_TAG_VM_PREFERRED)
 {
 	wrapped_zone.memalign = malloc_default_zone()->memalign;
 	setup();
@@ -174,14 +190,12 @@
 	return ++wrapped_zone_memalign_ret_value;
 }
 
-T_DECL(memalign_invalid_alignment, "memalign delegates for invalid alignment")
+T_DECL(memalign_invalid_alignment, "memalign delegates for alignment greater than page size", T_META_TAG_VM_PREFERRED)
 {
 	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 *
@@ -190,7 +204,7 @@
 	return (void *)7;
 }
 
-T_DECL(calloc_overflow, "calloc delegates on overflow")
+T_DECL(calloc_overflow, "calloc delegates on overflow", T_META_TAG_VM_PREFERRED)
 {
 	setup();
 	wrapped_zone.calloc = wrapped_zone_calloc;
@@ -215,7 +229,8 @@
 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_ENVVAR("MallocProbGuardAllocations=1"),
+		T_META_TAG_VM_PREFERRED)
 {
 	setup();
 
@@ -234,7 +249,7 @@
 	T_EXPECT_TRUE(is_zeroed_page(ptr3), "zeroed page");
 }
 
-T_DECL(realloc_null_pointer, "realloc forwards to malloc for null pointers")
+T_DECL(realloc_null_pointer, "realloc forwards to malloc for null pointers", T_META_TAG_VM_PREFERRED)
 {
 	setup();
 	wrapped_zone.malloc = wrapped_zone_malloc;
@@ -250,7 +265,8 @@
 	return (void *)9;
 }
 
-T_DECL(realloc_unguarded_and_unsampled, "realloc only delegates for old-unguarded and new-unsampled combination")
+T_DECL(realloc_unguarded_and_unsampled, "realloc only delegates for old-unguarded and new-unsampled combination",
+		T_META_TAG_VM_PREFERRED)
 {
 	setup();
 	wrapped_zone.realloc = wrapped_zone_realloc;
@@ -260,7 +276,8 @@
 }
 
 T_DECL(batch_malloc, "batch_malloc implementation",
-		T_META_ENVVAR("MallocProbGuardAllocations=2"))
+		T_META_ENVVAR("MallocProbGuardAllocations=2"),
+		T_META_TAG_VM_PREFERRED)
 {
 	setup();
 	wrapped_zone.malloc = wrapped_zone_malloc;
@@ -277,7 +294,7 @@
 	T_EXPECT_EQ(results[2], (void *)1, "Wrapped zone allocation");
 }
 
-T_DECL(batch_free, "batch_free implementation")
+T_DECL(batch_free, "batch_free implementation", T_META_TAG_VM_PREFERRED)
 {
 	setup();
 	wrapped_zone.free = wrapped_zone_free;
@@ -309,7 +326,7 @@
 	T_QUIET; T_EXPECT_EQ(count, 1, NULL);
 }
 
-T_DECL(introspection_enumerator, "In-process block enumeration")
+T_DECL(introspection_enumerator, "In-process block enumeration", T_META_TAG_VM_PREFERRED)
 {
 	setup();
 	expected_ranges[0] = (vm_range_t){(vm_address_t)CALL(malloc,  7), 16};