From cb59e7ee957b389578a3f973484ae3198f6cfed1 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Mon, 1 Apr 2019 23:03:21 -0500 Subject: [PATCH] test calls to getcontext without makecontext --- test_libucontext.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test_libucontext.c b/test_libucontext.c index e5eac83..a4a9b4c 100644 --- a/test_libucontext.c +++ b/test_libucontext.c @@ -48,6 +48,7 @@ static void f2 (void) { int main (int argc, const char *argv[]) { char st1[8192]; char st2[8192]; + volatile int done = 0; /* poison each coroutine's stack memory for debugging purposes */ @@ -70,5 +71,16 @@ int main (int argc, const char *argv[]) { swapcontext(&ctx[0], &ctx[2]); + + + /* test ability to use getcontext/setcontext without makecontext */ + getcontext(&ctx[1]); + printf("done = %d\n", done); + if (done++ == 0) setcontext(&ctx[1]); + if (done != 2) { + fprintf(stderr, "wrong value for done. got %d, expected 2\n", done); + abort(); + } + return 0; }