2018-04-04 14:35:50 +00:00
|
|
|
|
|
|
|
#include <machinarium.h>
|
|
|
|
#include <odyssey_test.h>
|
|
|
|
|
2020-12-28 11:22:53 +00:00
|
|
|
static void test_sleep_cancel0_child(void *arg)
|
2018-04-04 14:35:50 +00:00
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
machine_sleep(6000000);
|
|
|
|
test(machine_cancelled())
|
|
|
|
}
|
|
|
|
|
2020-12-28 11:22:53 +00:00
|
|
|
static void test_sleep_cancel0_parent(void *arg)
|
2018-04-04 14:35:50 +00:00
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
int64_t id;
|
|
|
|
id = machine_coroutine_create(test_sleep_cancel0_child, NULL);
|
|
|
|
test(id != -1);
|
|
|
|
|
2020-07-26 07:58:15 +00:00
|
|
|
mm_yield;
|
2018-04-04 14:35:50 +00:00
|
|
|
|
|
|
|
int rc;
|
|
|
|
rc = machine_cancel(id);
|
|
|
|
test(rc == 0);
|
|
|
|
|
|
|
|
rc = machine_join(id);
|
|
|
|
test(rc == 0);
|
|
|
|
|
2020-03-20 07:50:05 +00:00
|
|
|
machine_stop_current();
|
2018-04-04 14:35:50 +00:00
|
|
|
}
|
|
|
|
|
2020-12-28 11:22:53 +00:00
|
|
|
void machinarium_test_sleep_cancel0(void)
|
2018-04-04 14:35:50 +00:00
|
|
|
{
|
|
|
|
machinarium_init();
|
|
|
|
|
|
|
|
int id;
|
|
|
|
id = machine_create("test", test_sleep_cancel0_parent, NULL);
|
|
|
|
test(id != -1);
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
rc = machine_wait(id);
|
|
|
|
test(rc != -1);
|
|
|
|
|
|
|
|
machinarium_free();
|
|
|
|
}
|