diff options
-rw-r--r-- | tests/port/GNUmakefile | 2 | ||||
-rw-r--r-- | tests/port/test_getaddrinfo.c | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/tests/port/GNUmakefile b/tests/port/GNUmakefile index 64e3fe6..84401a9 100644 --- a/tests/port/GNUmakefile +++ b/tests/port/GNUmakefile @@ -54,6 +54,6 @@ local_test: @echo "Testing itoa.." @./test_itoa > /dev/null @echo "Testing getaddrinfo.." - @./test_getaddrinfo > /dev/null + @./test_getaddrinfo `hostname` 80 > /dev/null @echo "Testing gai_strerror_r.." @./test_gai_strerror_r > /dev/null diff --git a/tests/port/test_getaddrinfo.c b/tests/port/test_getaddrinfo.c index 5b76c28..24fc19b 100644 --- a/tests/port/test_getaddrinfo.c +++ b/tests/port/test_getaddrinfo.c @@ -23,12 +23,16 @@ #include <stdio.h> /* for fprintf */ #include <string.h> /* for memset */ -int main( void ) { +int main( int argc, char **argv ) { struct addrinfo hints; struct addrinfo *result; struct addrinfo *res; int error; - char port_or_service[10]; + + if( argc != 3 ) { + fputs( "usage: test_getaddrinfo <host> <port>\n", stderr ); + exit( EXIT_FAILURE ); + } #ifdef _WIN32 WSADATA wsa_data; @@ -43,8 +47,7 @@ int main( void ) { hints.ai_protocol = IPPROTO_TCP; /* resolve the domain name into a list of addresses */ - itoa( 80, port_or_service, 10 ); - error = getaddrinfo( "www.yahoo.com", port_or_service, &hints, &result ); + error = getaddrinfo( argv[1], argv[2], &hints, &result ); if( error != 0 ) { fprintf( stderr, "getaddrinfo failed: %s (%d)\n", gai_strerror( error ), error ); |