void testcase_run(TestCaseState_t *tcs) { Carrier_t *c; Block_t *blk; void *p; Allctr_t *a = START_ALC("basic_", 0, NULL); tcs->extra = (void *) a; ASSERT(tcs, a); p = ALLOC(a, 10); ASSERT(tcs, p); p = REALLOC(a, p, 15); ASSERT(tcs, p); FREE(a, p); c = FIRST_MBC(a); ASSERT(tcs, !NEXT_C(c)); blk = MBC_TO_FIRST_BLK(a, c); ASSERT(tcs, IS_LAST_BLK(blk)); ASSERT(tcs, IS_FREE_BLK(blk)); STOP_ALC((Allctr_t *) a); tcs->extra = NULL; }
void setup_sequence(TestCaseState_t *tcs, Allctr_t *a, Ulong bsz, int no, void *res[]) { Carrier_t *c; Block_t *blk; int i; testcase_printf(tcs, "Setting up a sequence of %d blocks of size %lu\n", no, bsz); c = FIRST_MBC(a); ASSERT(tcs, !NEXT_C(c)); blk = MBC2FBLK(a, c); ASSERT(tcs, IS_LAST_BLK(blk)); for (i = 0; i < no; i++) res[i] = ALLOC(a, bsz); for (i = 0; i < no; i++) ASSERT(tcs, res[i]); testcase_printf(tcs, "Checking that sequence was set up as expected\n"); for (i = 1; i < no; i++) ASSERT(tcs, NXT_BLK(UMEM2BLK(res[i-1])) == UMEM2BLK(res[i])); blk = NXT_BLK(UMEM2BLK(res[no-1])); ASSERT(tcs, IS_LAST_BLK(blk)); testcase_printf(tcs, "Sequence ok\n"); /* If we fail in setup_sequence(), it doesn't mean that something is wrong. It is just a faulty assumption in setup_sequence() about how blocks are going to be placed. Fix setup_sequence()... */ }