odyssey/tests/test_condition1.c

49 lines
645 B
C
Raw Normal View History

2017-05-15 13:55:10 +00:00
/*
* machinarium.
*
* Cooperative multitasking engine.
*/
#include <machinarium.h>
#include <machinarium_test.h>
static void
test_condition_coroutine(void *arg)
2017-05-15 13:55:10 +00:00
{
int rc = machine_condition(1);
2017-05-15 13:55:10 +00:00
test(rc == -1);
}
static void
test_waiter(void *arg)
{
int64_t a;
a = machine_coroutine_create(test_condition_coroutine, NULL);
2017-05-15 13:55:10 +00:00
test(a != -1);
machine_sleep(100);
2017-05-15 13:55:10 +00:00
int rc;
rc = machine_signal(a);
2017-05-15 13:55:10 +00:00
test(rc == -1);
machine_stop();
2017-05-15 13:55:10 +00:00
}
void
test_condition1(void)
{
machinarium_init();
int id;
id = machine_create("test", test_waiter, NULL);
test(id != -1);
2017-05-15 13:55:10 +00:00
int rc;
2017-05-18 10:20:40 +00:00
rc = machine_wait(id);
2017-05-15 13:55:10 +00:00
test(rc != -1);
machinarium_free();
2017-05-15 13:55:10 +00:00
}