summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2011-10-16 10:47:32 +0200
committerAndreas Baumann <abaumann@yahoo.com>2011-10-16 10:47:32 +0200
commit4286a729b2114aa6620791d34ccc715034130042 (patch)
tree1386bafaf4f28ea084e8446a13b72fadd03ee7b1 /tests
parentf1fe3b912a6530a5692bbf2b44f7a440cb55e887 (diff)
downloadwolfbones-4286a729b2114aa6620791d34ccc715034130042.tar.gz
wolfbones-4286a729b2114aa6620791d34ccc715034130042.tar.bz2
made getaddrinfo test parametrizable and tests run without internet connection now
Diffstat (limited to 'tests')
-rw-r--r--tests/port/GNUmakefile2
-rw-r--r--tests/port/test_getaddrinfo.c11
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 );