flint: add fiber create-stop test

This commit is contained in:
Dmitry Simonenko 2016-11-24 16:25:40 +03:00
parent bf7a3803fe
commit 11fd5126e7
2 changed files with 38 additions and 4 deletions

30
tests/create.c Normal file
View File

@ -0,0 +1,30 @@
/*
* machinarium.
*
* Cooperative multitasking engine.
*/
#include <machinarium.h>
#include <assert.h>
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;
}

View File

@ -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)