Loading...
--- libmalloc/libmalloc-646.0.13/tests/pgm_allocator.c
+++ libmalloc/libmalloc-792.80.2/tests/pgm_allocator.c
@@ -12,7 +12,8 @@
#include <darwintest.h>
-T_GLOBAL_META(T_META_RUN_CONCURRENTLY(TRUE), T_META_NAMESPACE("pgm"));
+T_GLOBAL_META(T_META_RUN_CONCURRENTLY(TRUE), T_META_NAMESPACE("pgm"),
+ T_META_TAG_VM_PREFERRED, T_META_TAG_NO_ALLOCATOR_OVERRIDE);
// Use weird page size to expose implicit assumptions and help prevent issues
// caused by different page sizes on macOS and iOS.
@@ -25,7 +26,7 @@
#pragma mark -
#pragma mark Allocator Functions
-T_DECL(lookup_size, "lookup_size", T_META_TAG_VM_PREFERRED)
+T_DECL(lookup_size, "lookup_size")
{
zone.begin = 640000; zone.end = 650240; // lookup_slot
slots[0] = (slot_t){
@@ -42,14 +43,15 @@
T_EXPECT_EQ(lookup_size(&zone, 641031), 0ul, "freed block address");
}
-T_DECL(allocate, "allocate", T_META_TAG_VM_PREFERRED)
+T_DECL(allocate, "allocate")
{
T_EXPECT_NULL(allocate(&zone, 5, 16), "zone full");
zone.max_allocations = 2; // is_full
zone.num_slots = 2; zone.rr_slot_index = 1; // choose_available_slot
zone.max_metadata = 4; zone.num_metadata = 2; // choose_metadata
- expected_upper_bound = 2; rand_ret_value = false; // choose_offset_on_page
+ zone.left_align_pct = 10; // choose_offset_on_page
+ expected_upper_bound = 100; rand_ret_value = 10; // choose_offset_on_page
expected_trace_buffers[0] = metadata[2].trace_buffer; // capture_trace
expected_trace_sizes[0] = 216; collect_trace_ret_value = 88;
zone.begin = 640000; // page_addr
@@ -73,7 +75,7 @@
T_EXPECT_EQ(zone.max_size_in_use, 55ul, "max_size_in_use is high water mark");
}
-T_DECL(deallocate, "deallocate", T_META_TAG_VM_PREFERRED)
+T_DECL(deallocate, "deallocate")
{
zone.begin = 640000; zone.end = 650240; // lookup_slot
slots[0] = (slot_t){
@@ -104,13 +106,14 @@
// TODO(yln): test for reallocate with bad ptr
-T_DECL(reallocate_guarded_to_sampled, "reallocate: guarded -> sampled", T_META_TAG_VM_PREFERRED)
+T_DECL(reallocate_guarded_to_sampled, "reallocate: guarded -> sampled")
{
zone.begin = 640000; zone.end = 650240; // is_guarded
slots[0] = (slot_t){ .state = ss_allocated, .metadata = 1, .size = 5 }; // lookup_size
zone.max_allocations = 2; // is_full
zone.num_slots = 2; // allocate
- expected_upper_bound = 2; rand_ret_value = true; // allocate -> choose_offset_on_page
+ zone.left_align_pct = 10; // allocate -> choose_offset_on_page
+ expected_upper_bound = 100; rand_ret_value = 9; // allocate -> choose_offset_on_page
zone.max_metadata = 1; // allocate -> choose_metadata
expected_trace_buffers[0] = metadata[0].trace_buffer; // allocate -> capture_trace
expected_trace_sizes[0] = 216;
@@ -124,12 +127,13 @@
T_EXPECT_EQ((unsigned int)(slots[1].state), ss_allocated, "destination slot");
}
-T_DECL(reallocate_unguarded_to_sampled, "reallocate: unguarded -> sampled", T_META_TAG_VM_PREFERRED)
+T_DECL(reallocate_unguarded_to_sampled, "reallocate: unguarded -> sampled")
{
expected_size_ptr = 1337; size_ret_value = 5; // wrapped_size
zone.max_allocations = 2; // is_full
zone.num_slots = 2; // allocate
- expected_upper_bound = 2; rand_ret_value = true; // allocate -> choose_offset_on_page
+ zone.left_align_pct = 10; // allocate -> choose_offset_on_page
+ expected_upper_bound = 100; rand_ret_value = 9; // allocate -> choose_offset_on_page
zone.max_metadata = 1; // allocate -> choose_metadata
expected_trace_buffers[0] = metadata[0].trace_buffer; // allocate -> capture_trace
expected_trace_sizes[0] = 216;
@@ -141,7 +145,7 @@
T_EXPECT_EQ((unsigned int)(slots[0].state), ss_allocated, "destination slot");
}
-T_DECL(reallocate_guarded_to_unsampled, "reallocate: guarded -> unsampled", T_META_TAG_VM_PREFERRED)
+T_DECL(reallocate_guarded_to_unsampled, "reallocate: guarded -> unsampled")
{
zone.begin = 640000; zone.end = 650240; // is_guarded
slots[0] = (slot_t){ .state = ss_allocated, .metadata = 1, .size = 5 }; // lookup_size
@@ -156,7 +160,7 @@
T_EXPECT_EQ((unsigned int)(slots[0].state), ss_freed, "source slot");
}
-T_DECL(reallocate_guarded_to_unsampled_zone_full, "reallocate: guarded -> unsampled (zone full)", T_META_TAG_VM_PREFERRED)
+T_DECL(reallocate_guarded_to_unsampled_zone_full, "reallocate: guarded -> unsampled (zone full)")
{
zone.begin = 640000; zone.end = 650240; // is_guarded
slots[0] = (slot_t){ .state = ss_allocated, .metadata = 1, .size = 5 }; // lookup_size