mirror of https://github.com/yandex/odyssey.git
machinarium: add second getaddrinfo test
This commit is contained in:
parent
65601592b0
commit
7c4f2f0e2e
|
@ -11,6 +11,7 @@ tests/test_sleep
|
|||
tests/test_wait
|
||||
tests/test_io_new
|
||||
tests/test_getaddrinfo
|
||||
tests/test_getaddrinfo_2
|
||||
tests/test_client_server
|
||||
tests/test_client_server_ra
|
||||
tests/test_cancel_sleep
|
||||
|
|
|
@ -10,6 +10,7 @@ TESTS = test_new \
|
|||
test_wait \
|
||||
test_io_new \
|
||||
test_getaddrinfo \
|
||||
test_getaddrinfo_2 \
|
||||
test_client_server \
|
||||
test_client_server_ra \
|
||||
test_cancel_sleep \
|
||||
|
@ -34,6 +35,8 @@ test_io_new:
|
|||
$(CC) $(CFLAGS) test_io_new.c $(LFLAGS) -o test_io_new
|
||||
test_getaddrinfo:
|
||||
$(CC) $(CFLAGS) test_getaddrinfo.c $(LFLAGS) -o test_getaddrinfo
|
||||
test_getaddrinfo_2:
|
||||
$(CC) $(CFLAGS) test_getaddrinfo_2.c $(LFLAGS) -o test_getaddrinfo_2
|
||||
test_client_server:
|
||||
$(CC) $(CFLAGS) test_client_server.c $(LFLAGS) -o test_client_server
|
||||
test_client_server_ra:
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
/*
|
||||
* machinarium.
|
||||
*
|
||||
* Cooperative multitasking engine.
|
||||
*/
|
||||
|
||||
#include <machinarium.h>
|
||||
#include <assert.h>
|
||||
|
||||
static void
|
||||
fiber(void *arg)
|
||||
{
|
||||
mm_t env = arg;
|
||||
mm_io_t io = mm_io_new(env);
|
||||
struct addrinfo *res = NULL;
|
||||
int rc = mm_getaddrinfo(io, "abracadabra", "http", NULL, &res, 0);
|
||||
assert(rc < 0);
|
||||
assert(res == NULL);
|
||||
mm_close(io);
|
||||
mm_stop(env);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
mm_t env = mm_new();
|
||||
mm_create(env, fiber, env);
|
||||
mm_start(env);
|
||||
mm_free(env);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue