Revision 7e5aeac2 deps/uv/test/test-gethostbyname.c
deps/uv/test/test-gethostbyname.c | ||
---|---|---|
27 | 27 |
#include <string.h> /* strlen */ |
28 | 28 |
|
29 | 29 |
static ares_channel channel; |
30 |
static struct ares_options options; |
|
31 |
static int optmask; |
|
32 | 30 |
|
33 | 31 |
static int ares_bynamecallbacks; |
34 | 32 |
static int bynamecallbacksig; |
... | ... | |
63 | 61 |
} |
64 | 62 |
|
65 | 63 |
|
66 |
static void prep_tcploopback() { |
|
67 |
/* for test, use echo server - TCP port TEST_PORT on loopback */ |
|
68 |
struct sockaddr_in test_server = uv_ip4_addr("127.0.0.1", 0); |
|
69 |
int rc; |
|
70 |
|
|
71 |
optmask = ARES_OPT_SERVERS | ARES_OPT_TCP_PORT | ARES_OPT_FLAGS; |
|
72 |
options.servers = &test_server.sin_addr; |
|
73 |
options.nservers = 1; |
|
74 |
options.tcp_port = htons(TEST_PORT); |
|
75 |
options.flags = ARES_FLAG_USEVC; |
|
76 |
|
|
77 |
rc = uv_ares_init_options(uv_default_loop(), &channel, &options, optmask); |
|
78 |
ASSERT(rc == ARES_SUCCESS); |
|
64 |
static void setup_cares() { |
|
65 |
int r; |
|
66 |
struct ares_options options; |
|
67 |
memset(&options, 0, sizeof options); |
|
68 |
r = uv_ares_init_options(uv_default_loop(), &channel, &options, 0); |
|
69 |
ASSERT(r == ARES_SUCCESS); |
|
79 | 70 |
} |
80 | 71 |
|
81 | 72 |
|
... | ... | |
91 | 82 |
} |
92 | 83 |
|
93 | 84 |
printf("Start basic gethostbyname test\n"); |
94 |
prep_tcploopback();
|
|
85 |
setup_cares();
|
|
95 | 86 |
|
96 | 87 |
ares_bynamecallbacks = 0; |
97 | 88 |
bynamecallbacksig = 7; |
... | ... | |
112 | 103 |
/* two sequential call on new channel */ |
113 | 104 |
|
114 | 105 |
printf("Start gethostbyname and gethostbyaddr sequential test\n"); |
115 |
prep_tcploopback();
|
|
106 |
setup_cares();
|
|
116 | 107 |
|
117 | 108 |
ares_bynamecallbacks = 0; |
118 | 109 |
bynamecallbacksig = 7; |
... | ... | |
151 | 142 |
/* two simultaneous calls on new channel */ |
152 | 143 |
|
153 | 144 |
printf("Start gethostbyname and gethostbyaddr concurrent test\n"); |
154 |
prep_tcploopback();
|
|
145 |
setup_cares();
|
|
155 | 146 |
|
156 | 147 |
ares_bynamecallbacks = 0; |
157 | 148 |
bynamecallbacksig = 7; |
Also available in: Unified diff