From 11fd5126e7cf6012e5ee19367058e7fd5f3b4c6b Mon Sep 17 00:00:00 2001 From: Dmitry Simonenko Date: Thu, 24 Nov 2016 16:25:40 +0300 Subject: [PATCH] flint: add fiber create-stop test --- tests/create.c | 30 ++++++++++++++++++++++++++++++ tests/makefile | 12 ++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 tests/create.c diff --git a/tests/create.c b/tests/create.c new file mode 100644 index 00000000..3ffd06dc --- /dev/null +++ b/tests/create.c @@ -0,0 +1,30 @@ + +/* + * machinarium. + * + * Cooperative multitasking engine. +*/ + +#include +#include + +int fiber_call = 0; + +static void +fiber(void *arg) +{ + mm_t env = arg; + fiber_call++; + mm_stop(env); +} + +int +main(int argc, char *argv[]) +{ + mm_t env = mm_new(); + mm_create(env, fiber, env); + mm_start(env); + assert(fiber_call == 1); + mm_free(env); + return 0; +} diff --git a/tests/makefile b/tests/makefile index 444a4c74..f076a397 100644 --- a/tests/makefile +++ b/tests/makefile @@ -3,9 +3,12 @@ RM = rm CFLAGS = -I. -Wall -g -O0 -I../machinarium LFLAGS_LIB = ../machinarium/libmachinarium.a LFLAGS = $(LFLAGS_LIB) -luv -all: validate clean env +TESTS = env create +all: validate clean $(TESTS) env: $(CC) $(CFLAGS) env.c $(LFLAGS) -o env +create: + $(CC) $(CFLAGS) create.c $(LFLAGS) -o create validate: @if [ ! -f $(LFLAGS_LIB) ]; then \ echo ""; \ @@ -13,7 +16,8 @@ validate: echo ""; \ exit 1; \ fi -.c.o: - $(CC) $(CFLAGS) -c $< +run: + ./env + ./create clean: - $(RM) -f env + $(RM) -f $(TESTS)