2017-05-15 13:41:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* machinarium.
|
|
|
|
*
|
|
|
|
* Cooperative multitasking engine.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <machinarium.h>
|
|
|
|
#include <machinarium_test.h>
|
|
|
|
|
|
|
|
static void
|
2017-05-17 14:23:21 +00:00
|
|
|
fiber(void *arg)
|
2017-05-15 13:41:31 +00:00
|
|
|
{
|
2017-05-17 14:23:21 +00:00
|
|
|
machine_sleep(0);
|
|
|
|
machine_stop();
|
2017-05-15 13:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
test_sleep_yield(void)
|
|
|
|
{
|
2017-05-17 14:23:21 +00:00
|
|
|
machinarium_init();
|
|
|
|
|
|
|
|
int id;
|
|
|
|
id = machine_create(fiber, NULL);
|
|
|
|
test(id != -1);
|
2017-05-15 13:41:31 +00:00
|
|
|
|
|
|
|
int rc;
|
2017-05-17 14:23:21 +00:00
|
|
|
rc = machine_join(id);
|
2017-05-15 13:41:31 +00:00
|
|
|
test(rc != -1);
|
|
|
|
|
2017-05-17 14:23:21 +00:00
|
|
|
machinarium_free();
|
2017-05-15 13:41:31 +00:00
|
|
|
}
|