Permalink
Browse files

test: fix test-gethostbyname to not use a DNS server on localhost

Because, you know, not everybody has one.
  • Loading branch information...
1 parent 4c87666 commit 937d2c93ea2c826ae579ae93b7c2745c4b950cc6 @piscisaureus piscisaureus committed Apr 29, 2012
Showing with 10 additions and 20 deletions.
  1. +1 −1 test/benchmark-ares.c
  2. +9 −18 test/test-gethostbyname.c
  3. +0 −1 test/test-list.h
View
@@ -64,7 +64,7 @@ static void prep_tcploopback()
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_2);
+ options.tcp_port = TEST_PORT_2;
options.flags = ARES_FLAG_USEVC;
rc = uv_ares_init_options(loop, &channel, &options, optmask);
View
@@ -27,8 +27,6 @@
#include <string.h> /* 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;
View
@@ -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)

0 comments on commit 937d2c9

Please sign in to comment.