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 CFLAGS = -I. -Wall -g -O0 -I../machinarium
LFLAGS_LIB = ../machinarium/libmachinarium.a LFLAGS_LIB = ../machinarium/libmachinarium.a
LFLAGS = $(LFLAGS_LIB) -luv LFLAGS = $(LFLAGS_LIB) -luv
all: validate clean env TESTS = env create
all: validate clean $(TESTS)
env: env:
$(CC) $(CFLAGS) env.c $(LFLAGS) -o env $(CC) $(CFLAGS) env.c $(LFLAGS) -o env
create:
$(CC) $(CFLAGS) create.c $(LFLAGS) -o create
validate: validate:
@if [ ! -f $(LFLAGS_LIB) ]; then \ @if [ ! -f $(LFLAGS_LIB) ]; then \
echo ""; \ echo ""; \
@ -13,7 +16,8 @@ validate:
echo ""; \ echo ""; \
exit 1; \ exit 1; \
fi fi
.c.o: run:
$(CC) $(CFLAGS) -c $< ./env
./create
clean: clean:
$(RM) -f env $(RM) -f $(TESTS)