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)