mirror of https://github.com/yandex/odyssey.git
flint: add fiber sleep tests
This commit is contained in:
parent
a1b53f1d33
commit
654a9e1e08
|
@ -7,4 +7,5 @@ example/cancel
|
|||
example/cancel_connect
|
||||
tests/env
|
||||
tests/create
|
||||
tests/sleep
|
||||
tests/wait
|
||||
|
|
|
@ -4,12 +4,14 @@ CFLAGS = -I. -Wall -g -O0 -I../machinarium
|
|||
LFLAGS_LIB = ../machinarium/libmachinarium.a
|
||||
LFLAGS_LIB_UV = ~/temp/libuv/.libs/libuv.a -pthread
|
||||
LFLAGS = $(LFLAGS_LIB) $(LFLAGS_LIB_UV)
|
||||
TESTS = env create wait
|
||||
TESTS = env create sleep wait
|
||||
all: validate clean $(TESTS)
|
||||
env:
|
||||
$(CC) $(CFLAGS) env.c $(LFLAGS) -o env
|
||||
create:
|
||||
$(CC) $(CFLAGS) create.c $(LFLAGS) -o create
|
||||
sleep:
|
||||
$(CC) $(CFLAGS) sleep.c $(LFLAGS) -o sleep
|
||||
wait:
|
||||
$(CC) $(CFLAGS) wait.c $(LFLAGS) -o wait
|
||||
validate:
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
/*
|
||||
* machinarium.
|
||||
*
|
||||
* Cooperative multitasking engine.
|
||||
*/
|
||||
|
||||
#include <machinarium.h>
|
||||
#include <assert.h>
|
||||
|
||||
static void
|
||||
test_child(void *arg)
|
||||
{
|
||||
mm_t env = arg;
|
||||
printf("child started\n");
|
||||
printf("sleep 10 ms\n");
|
||||
mm_sleep(env, 10);
|
||||
printf("sleep wakeup\n");
|
||||
printf("child ended\n");
|
||||
mm_stop(env);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
mm_t env = mm_new();
|
||||
mm_create(env, test_child, env);
|
||||
mm_start(env);
|
||||
mm_free(env);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue