odyssey/tests/test_channel_rw0.c

48 lines
744 B
C
Raw Normal View History

2017-05-19 12:27:50 +00:00
/*
* machinarium.
*
* Cooperative multitasking engine.
*/
#include <machinarium.h>
#include <machinarium_test.h>
static void
test_coroutine(void *arg)
2017-05-19 12:27:50 +00:00
{
machine_channel_t *channel;
2017-05-19 12:27:50 +00:00
channel = machine_channel_create();
test(channel != NULL);
2017-05-19 12:27:50 +00:00
machine_msg_t *msg;
msg = machine_msg_create(123, 0);
2017-05-19 12:27:50 +00:00
test(msg != NULL);
machine_channel_write(channel, msg);
machine_msg_t *msg_in;
2017-05-19 12:27:50 +00:00
msg_in = machine_channel_read(channel, 0);
test(msg_in != NULL);
test(msg_in == msg);
machine_msg_free(msg);
machine_channel_free(channel);
}
void
test_channel_rw0(void)
{
machinarium_init();
int id;
id = machine_create("test", test_coroutine, NULL);
2017-05-19 12:27:50 +00:00
test(id != -1);
int rc;
rc = machine_wait(id);
test(rc != -1);
machinarium_free();
}