Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
test: fix test-gethostbyname to not use a DNS server on localhost
Because, you know, not everybody has one.
  • Loading branch information
piscisaureus committed Jun 29, 2012
1 parent 4c87666 commit 937d2c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion test/benchmark-ares.c
Expand Up @@ -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);
Expand Down
27 changes: 9 additions & 18 deletions test/test-gethostbyname.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}


Expand All @@ -91,7 +82,7 @@ TEST_IMPL(gethostbyname) {
}

printf("Start basic gethostbyname test\n");
prep_tcploopback();
setup_cares();

ares_bynamecallbacks = 0;
bynamecallbacksig = 7;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion test/test-list.h
Expand Up @@ -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)
Expand Down

0 comments on commit 937d2c9

Please sign in to comment.