X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fcoroutine%2Ftest%2Fapi-1.c;fp=ccan%2Fcoroutine%2Ftest%2Fapi-1.c;h=c59793a0542fe3be3018fe9f3d990eb7c5bb1826;hb=b4f0767d388c7f3629666400f48ede1a7b4be7f5;hp=ea59dc02fb3f9ad7df753b5cc84a8f91972af0c5;hpb=fe3995b4e626466ab211e37392f8500f1fffb5c7;p=ccan diff --git a/ccan/coroutine/test/api-1.c b/ccan/coroutine/test/api-1.c index ea59dc02..c59793a0 100644 --- a/ccan/coroutine/test/api-1.c +++ b/ccan/coroutine/test/api-1.c @@ -3,6 +3,8 @@ #include #include +#define STKSZ (COROUTINE_MIN_STKSZ + COROUTINE_STK_OVERHEAD) + static int global = 0; static void trivial_fn(void *p) @@ -18,6 +20,10 @@ static void test_trivial(struct coroutine_stack *stack) { struct coroutine_state t, master; + ok1(stack != NULL); + ok1(coroutine_stack_check(stack, NULL) == stack); + ok1(coroutine_stack_size(stack) == COROUTINE_MIN_STKSZ); + if (!COROUTINE_AVAILABLE) { skip(1, "Coroutines not available"); return; @@ -30,22 +36,22 @@ static void test_trivial(struct coroutine_stack *stack) } -static char buf[COROUTINE_MIN_STKSZ + COROUTINE_STK_OVERHEAD]; +static char buf[STKSZ]; int main(void) { struct coroutine_stack *stack; /* This is how many tests you plan to run */ - plan_tests(4); + plan_tests(2 * 4 + 1); stack = coroutine_stack_init(buf, sizeof(buf), 0); - ok1(stack != NULL); - ok1(coroutine_stack_check(stack, NULL) == stack); - ok1(coroutine_stack_size(stack) == COROUTINE_MIN_STKSZ); - test_trivial(stack); + coroutine_stack_release(stack, 0); + ok1(!coroutine_stack_check(stack, NULL)); + stack = coroutine_stack_alloc(STKSZ, 0); + test_trivial(stack); coroutine_stack_release(stack, 0); /* This exits depending on whether all tests passed */