From 7628b6597e0d585668a8ed2da182b9fd3c5901db Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Fri, 29 Jun 2012 05:44:20 +0200 Subject: [PATCH] test: fix test-gethostbyname to not use a DNS server on localhost Because, you know, not everybody has one. --- test/test-gethostbyname.c | 27 +++++++++------------------ test/test-list.h | 1 - 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/test/test-gethostbyname.c b/test/test-gethostbyname.c index e49c69c4..1df2aaac 100644 --- a/test/test-gethostbyname.c +++ b/test/test-gethostbyname.c @@ -27,8 +27,6 @@ #include /* strlen */ static ares_channel channel; -static struct ares_options options; -static int optmask; static int ares_bynamecallbacks; static int bynamecallbacksig; @@ -63,19 +61,12 @@ static void aresbyaddrcallback( void *arg, } -static void prep_tcploopback() { - /* for test, use echo server - TCP port TEST_PORT on loopback */ - struct sockaddr_in test_server = uv_ip4_addr("127.0.0.1", 0); - int rc; - - optmask = ARES_OPT_SERVERS | ARES_OPT_TCP_PORT | ARES_OPT_FLAGS; - options.servers = &test_server.sin_addr; - options.nservers = 1; - options.tcp_port = htons(TEST_PORT); - options.flags = ARES_FLAG_USEVC; - - rc = uv_ares_init_options(uv_default_loop(), &channel, &options, optmask); - ASSERT(rc == ARES_SUCCESS); +static void setup_cares() { + int r; + struct ares_options options; + memset(&options, 0, sizeof options); + r = uv_ares_init_options(uv_default_loop(), &channel, &options, 0); + ASSERT(r == ARES_SUCCESS); } @@ -91,7 +82,7 @@ TEST_IMPL(gethostbyname) { } printf("Start basic gethostbyname test\n"); - prep_tcploopback(); + setup_cares(); ares_bynamecallbacks = 0; bynamecallbacksig = 7; @@ -112,7 +103,7 @@ TEST_IMPL(gethostbyname) { /* two sequential call on new channel */ printf("Start gethostbyname and gethostbyaddr sequential test\n"); - prep_tcploopback(); + setup_cares(); ares_bynamecallbacks = 0; bynamecallbacksig = 7; @@ -151,7 +142,7 @@ TEST_IMPL(gethostbyname) { /* two simultaneous calls on new channel */ printf("Start gethostbyname and gethostbyaddr concurrent test\n"); - prep_tcploopback(); + setup_cares(); ares_bynamecallbacks = 0; bynamecallbacksig = 7; diff --git a/test/test-list.h b/test/test-list.h index cf9a02ed..c1836fbd 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -342,7 +342,6 @@ TASK_LIST_START TEST_ENTRY (getaddrinfo_concurrent) TEST_ENTRY (gethostbyname) - TEST_HELPER (gethostbyname, tcp4_echo_server) TEST_ENTRY (getsockname_tcp) TEST_ENTRY (getsockname_udp)