From 7c4f2f0e2e0860ff6993550d41e051fd1519e233 Mon Sep 17 00:00:00 2001 From: Dmitry Simonenko Date: Wed, 7 Dec 2016 18:24:02 +0300 Subject: [PATCH] machinarium: add second getaddrinfo test --- .gitignore | 1 + tests/makefile | 3 +++ tests/test_getaddrinfo_2.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/test_getaddrinfo_2.c diff --git a/.gitignore b/.gitignore index a4c7964d..b9001013 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/tests/makefile b/tests/makefile index 9e82a048..283027e2 100644 --- a/tests/makefile +++ b/tests/makefile @@ -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: diff --git a/tests/test_getaddrinfo_2.c b/tests/test_getaddrinfo_2.c new file mode 100644 index 00000000..4d6eb400 --- /dev/null +++ b/tests/test_getaddrinfo_2.c @@ -0,0 +1,32 @@ + +/* + * machinarium. + * + * Cooperative multitasking engine. +*/ + +#include +#include + +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; +}