machinarium: add second getaddrinfo test

This commit is contained in:
Dmitry Simonenko 2016-12-07 18:24:02 +03:00
parent 65601592b0
commit 7c4f2f0e2e
3 changed files with 36 additions and 0 deletions

1
.gitignore vendored
View File

@ -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

View File

@ -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:

View File

@ -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;
}