Loading...
--- libmalloc/libmalloc-425.100.7/tests/nano_tests.c
+++ libmalloc/libmalloc-792.80.2/tests/nano_tests.c
@@ -88,25 +88,35 @@
T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
T_DECL(nano_active_test, "Test that Nano is activated",
- T_META_ENVVAR("MallocNanoZone=1"))
-{
-#if CONFIG_NANOZONE
- void *ptr = malloc(16);
- T_LOG("Nano ptr is %p\n", ptr);
- T_ASSERT_EQ(NANOZONE_SIGNATURE, (uint64_t)((uintptr_t)ptr) >> SHIFT_NANO_SIGNATURE,
- "Nanozone is active");
- T_ASSERT_NE(malloc_engaged_nano(), 0, "Nanozone engaged");
- free(ptr);
+ T_META_ENVVAR("MallocNanoZone=1"), T_META_ENVVAR("MallocProbGuard=0"),
+ T_META_TAG_ALL_ALLOCATORS, T_META_TAG_VM_PREFERRED)
+{
+#if CONFIG_NANOZONE
+ T_ASSERT_NE(malloc_engaged_nano(), 0, "Nano mode engaged");
+
+ if (!malloc_engaged_secure_allocator()) {
+ void *ptr = malloc(16);
+ T_LOG("Nano ptr is %p\n", ptr);
+ T_ASSERT_EQ(NANOZONE_SIGNATURE, (uint64_t)((uintptr_t)ptr) >> SHIFT_NANO_SIGNATURE,
+ "Nanozone is active");
+ free(ptr);
+ }
#else // CONFIG_NANOZONE
T_SKIP("Nano allocator not configured");
#endif // CONFIG_NANOZONE
}
T_DECL(nano_enumerator_test, "Test the Nanov2 enumerator",
- T_META_ENVVAR("MallocNanoZone=V2"))
-{
-#if CONFIG_NANOZONE
- T_ASSERT_EQ(malloc_engaged_nano(), 2, "Nanozone V2 engaged");
+ T_META_ENVVAR("MallocNanoZone=V2"), T_META_ENVVAR("MallocProbGuard=0"),
+ T_META_TAG_ALL_ALLOCATORS, T_META_TAG_VM_PREFERRED)
+{
+#if CONFIG_NANOZONE
+ if (malloc_engaged_secure_allocator()) {
+ T_ASSERT_NE(malloc_engaged_nano(), 0,
+ "Secure allocator nano mode engaged");
+ } else {
+ T_ASSERT_EQ(malloc_engaged_nano(), 2, "Nanozone V2 engaged");
+ }
// This test is problematic because the allocator is used before the test
// starts, so we can't start everything from zero.
@@ -138,7 +148,7 @@
"Incorrect blocks_in_use");
T_ASSERT_EQ(stats.size_in_use, initial_size_in_use + total_requested_size,
"Incorrect size_in_use");
- T_ASSERT_TRUE(stats.size_allocated - initial_size_allocated >= total_requested_size,
+ T_ASSERT_GE(stats.size_allocated, total_requested_size,
"Size allocated must be >= size requested");
T_ASSERT_EQ(ptr_count, initial_ptrs + ALLOCATION_COUNT,
@@ -161,7 +171,7 @@
T_ASSERT_EQ(stats.size_in_use,
initial_size_in_use + total_requested_size - size_freed,
"Incorrect size_in_use after half free");
- T_ASSERT_TRUE(stats.size_allocated >= initial_size_allocated ,
+ T_ASSERT_GE(stats.size_allocated, initial_size_allocated,
"Size allocated must be >= size requested");
T_ASSERT_EQ(ptr_count, initial_ptrs + ALLOCATION_COUNT / 2,
@@ -183,7 +193,7 @@
"Incorrect blocks_in_use after full free");
T_ASSERT_EQ(stats.size_in_use, initial_size_in_use,
"Incorrect size_in_use after full free");
- T_ASSERT_TRUE(stats.size_allocated >= initial_size_allocated ,
+ T_ASSERT_GE(stats.size_allocated, initial_size_allocated,
"Size allocated must be >= size requested");
T_ASSERT_EQ(ptr_count, initial_ptrs, "Incorrect number of pointers after free");
@@ -204,7 +214,8 @@
const char * const data = "abcdefghijklm";
T_DECL(realloc_nano_size_class_change, "realloc with size class change",
- T_META_ENVVAR("MallocNanoZone=1"))
+ T_META_ENVVAR("MallocNanoZone=1"), T_META_TAG_VM_PREFERRED,
+ T_META_TAG_MAGAZINE_ONLY)
{
#if CONFIG_NANOZONE
void *ptr = malloc(16);
@@ -228,7 +239,8 @@
}
T_DECL(realloc_nano_ptr_change, "realloc with pointer change",
- T_META_ENVVAR("MallocNanoZone=1"))
+ T_META_ENVVAR("MallocNanoZone=1"), T_META_TAG_VM_PREFERRED,
+ T_META_TAG_MAGAZINE_ONLY)
{
#if CONFIG_NANOZONE
void *ptr = malloc(32);
@@ -247,7 +259,8 @@
}
T_DECL(realloc_nano_to_other, "realloc with allocator change (nano)",
- T_META_ENVVAR("MallocNanoZone=1"))
+ T_META_ENVVAR("MallocNanoZone=1"), T_META_TAG_VM_PREFERRED,
+ T_META_TAG_MAGAZINE_ONLY)
{
#if CONFIG_NANOZONE
void *ptr = malloc(32); // From Nano
@@ -267,7 +280,8 @@
}
T_DECL(realloc_nano_to_zero_size, "realloc with target size zero",
- T_META_ENVVAR("MallocNanoZone=1"))
+ T_META_ENVVAR("MallocNanoZone=1"), T_META_TAG_VM_PREFERRED,
+ T_META_TAG_MAGAZINE_ONLY)
{
#if CONFIG_NANOZONE
void *ptr = malloc(16);
@@ -285,7 +299,8 @@
}
T_DECL(realloc_nano_shrink, "realloc to smaller size",
- T_META_ENVVAR("MallocNanoZone=1"))
+ T_META_ENVVAR("MallocNanoZone=1"), T_META_TAG_VM_PREFERRED,
+ T_META_TAG_MAGAZINE_ONLY)
{
#if CONFIG_NANOZONE
void *ptr = malloc(64);
@@ -311,7 +326,8 @@
}
T_DECL(nano_memalign_trivial, "Test that nano serves trivial memalign allocations",
- T_META_ENVVAR("MallocNanoZone=1"))
+ T_META_ENVVAR("MallocNanoZone=1"), T_META_TAG_VM_PREFERRED,
+ T_META_TAG_MAGAZINE_ONLY)
{
#if CONFIG_NANOZONE
size_t size = 16;
@@ -339,7 +355,8 @@
T_DECL(overspill_arena, "force overspill of an arena",
T_META_ENVVAR("MallocNanoZone=V2"),
- T_META_ENVVAR("MallocGuardEdges=all"))
+ T_META_ENVVAR("MallocGuardEdges=all"),
+ T_META_TAG_VM_PREFERRED, T_META_TAG_MAGAZINE_ONLY)
{
#if CONFIG_NANOZONE
void **ptrs = calloc(ALLOCS_PER_ARENA, sizeof(void *));
@@ -384,7 +401,8 @@
#if NANOV2_MULTIPLE_REGIONS
T_DECL(overspill_region, "force overspill of a region",
- T_META_ENVVAR("MallocNanoZone=V2"))
+ T_META_ENVVAR("MallocNanoZone=V2"), T_META_TAG_VM_PREFERRED,
+ T_META_TAG_MAGAZINE_ONLY)
{
void **ptrs = calloc(ALLOCS_PER_REGION, sizeof(void *));
T_QUIET; T_ASSERT_NOTNULL(ptrs, "Unable to allocate pointers");
@@ -420,7 +438,9 @@
T_DECL(overspill_nanozone, "force overspill of nano zone",
T_META_ENVVAR("MallocNanoZone=V2"),
- T_META_ENVVAR("MallocNanoMaxRegion=1"))
+ T_META_ENVVAR("MallocNanoMaxRegion=1"),
+ T_META_ENVVAR("MallocProbGuard=0"),
+ T_META_TAG_VM_PREFERRED, T_META_TAG_MAGAZINE_ONLY)
{
int index;
bool spilled_to_tiny = false;
@@ -440,17 +460,17 @@
T_QUIET; T_ASSERT_TRUE(malloc_zone_claimed_address(nano_zone, ptrs[0]),
"Initial allocation did not come from nano zone");
T_QUIET; T_ASSERT_FALSE(malloc_zone_claimed_address(helper_zone, ptrs[0]),
- "Initial allocation came from scalable zone");
+ "Initial allocation came from helper zone");
for (index = 1; index < (nano_max_allocations); index++) {
ptrs[index] = malloc(256);
if (malloc_zone_claimed_address(helper_zone, ptrs[index])) {
- T_LOG("Spilled to scalable zone");
+ T_LOG("Spilled to helper zone");
spilled_to_tiny = true;
break;
}
}
- T_EXPECT_TRUE(spilled_to_tiny, "Allocation falls through to scalable zone");
+ T_EXPECT_TRUE(spilled_to_tiny, "Allocation falls through to helper zone");
T_LOG("Freeing %d pointers", index);
for (int i = 0; i < MIN(index + 1, nano_max_allocations); i++) {
@@ -529,7 +549,8 @@
T_DECL(region_holes, "ensure correct handling of holes between regions",
T_META_ENVVAR("MallocNanoZone=V2"),
// Region reservation does not allow for holes between regions
- T_META_ENABLED(!CONFIG_NANO_RESERVE_REGIONS))
+ T_META_ENABLED(!CONFIG_NANO_RESERVE_REGIONS),
+ T_META_TAG_VM_NOT_PREFERRED, T_META_TAG_MAGAZINE_ONLY)
{
srandom(time(NULL));