From 4286a729b2114aa6620791d34ccc715034130042 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 16 Oct 2011 10:47:32 +0200 Subject: made getaddrinfo test parametrizable and tests run without internet connection now --- tests/port/GNUmakefile | 2 +- tests/port/test_getaddrinfo.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tests') 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 /* for fprintf */ #include /* 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 \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 ); -- cgit v1.2.3-54-g00ecf