summaryrefslogtreecommitdiff
path: root/test/pkmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/pkmem.c')
-rw-r--r--test/pkmem.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/pkmem.c b/test/pkmem.c
index ad95899..36bf0eb 100644
--- a/test/pkmem.c
+++ b/test/pkmem.c
@@ -113,5 +113,72 @@ int main(int argc, char *argv[])
teardown();
}
+ // expand buckets
+ {
+ // spinup_w_instr();
+ spinup();
+
+ /*
+ * [00-47] (48) ptr1
+ * [48-XX] ( 1) HEAD
+ */
+ void *ptr1 = pk_new_bkt(48, 1, mt.bkt1);
+ (void)ptr1;
+
+ if ((void*)&mt.bkt1->data[0] != ptr1) exit(1);
+ if (mt.bkt1->alloc_count != 1) exit(1);
+ if (mt.bkt1->head != 48) exit(1);
+ if (mt.bkt1->debug_head_l != 1) exit(1);
+ if (mt.bkt1->debug_head_r != 1) exit(1);
+ if (mt.bkt1->block_head_l != 0) exit(1);
+ if (mt.bkt1->block_head_r != 0) exit(1);
+
+ /*
+ * [00-47] (48) ptr1
+ * [ 48] ( 1) ptr2
+ * [49-XX] ( 1) HEAD
+ */
+ void *ptr2 = pk_new_bkt(1, 1, mt.bkt1);
+
+ if ((void*)(&mt.bkt1->data[0]+48) != ptr2) exit(1);
+ if (mt.bkt1->alloc_count != 2) exit(1);
+ if (mt.bkt1->head != 49) exit(1);
+ if (mt.bkt1->debug_head_l != 2) exit(1);
+ if (mt.bkt1->debug_head_r != 2) exit(1);
+ if (mt.bkt1->block_head_l != 0) exit(1);
+ if (mt.bkt1->block_head_r != 0) exit(1);
+
+ /*
+ * [00-47] (48) ptr1
+ * [48-XX] ( 1) HEAD
+ */
+ pk_delete_bkt(ptr2, 1, mt.bkt1);
+
+ if (mt.bkt1->alloc_count != 1) exit(1);
+ if (mt.bkt1->head != 48) exit(1);
+ if (mt.bkt1->debug_head_l != 1) exit(1);
+ if (mt.bkt1->debug_head_r != 2) exit(1);
+ if (mt.bkt1->block_head_l != 0) exit(1);
+ if (mt.bkt1->block_head_r != 0) exit(1);
+
+ /*
+ * [00-47] (48) ptr1
+ * [ 48] ( 1) ptr2
+ * [49-XX] ( 1) HEAD
+ */
+ ptr2 = pk_new_bkt(1, 1, mt.bkt1);
+
+ if ((void*)(&mt.bkt1->data[0]+48) != ptr2) exit(1);
+ if (mt.bkt1->alloc_count != 2) exit(1);
+ if (mt.bkt1->head != 49) exit(1);
+ if (mt.bkt1->debug_head_l != 2) exit(1);
+ if (mt.bkt1->debug_head_r != 2) exit(1);
+ if (mt.bkt1->block_head_l != 0) exit(1);
+ if (mt.bkt1->block_head_r != 0) exit(1);
+
+ PK_LOGV_INF("%s: %s\n", __FILE__, "handles free last + new");
+ teardown();
+ }
+
return 0;
}