3 #include <ccan/coroutine/coroutine.h>
4 #include <ccan/tap/tap.h>
6 #define STKSZ (COROUTINE_MIN_STKSZ + COROUTINE_STK_OVERHEAD)
10 static void trivial_fn(void *p)
12 struct coroutine_state *ret = (struct coroutine_state *)p;
19 static void test_trivial(struct coroutine_stack *stack)
21 struct coroutine_state t, master;
24 ok1(coroutine_stack_check(stack, NULL) == stack);
25 ok1(coroutine_stack_size(stack) == COROUTINE_MIN_STKSZ);
27 if (!COROUTINE_AVAILABLE) {
28 skip(1, "Coroutines not available");
32 coroutine_init(&t, trivial_fn, &master, stack);
33 coroutine_switch(&master, &t);
39 static char buf[STKSZ];
43 struct coroutine_stack *stack;
45 /* This is how many tests you plan to run */
46 plan_tests(2 * 4 + 1);
48 stack = coroutine_stack_init(buf, sizeof(buf), 0);
50 coroutine_stack_release(stack, 0);
51 ok1(!coroutine_stack_check(stack, NULL));
53 stack = coroutine_stack_alloc(STKSZ, 0);
55 coroutine_stack_release(stack, 0);
57 /* This exits depending on whether all tests passed */