blob: 3623bd7be8b627661422a65ec6b30656f26467b1 [file] [log] [blame]
nnoble0c475f02014-12-05 15:37:39 -08001/*
2 *
Craig Tiller6169d5f2016-03-31 07:46:18 -07003 * Copyright 2015, Google Inc.
nnoble0c475f02014-12-05 15:37:39 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
murgatroid99c36f6ea2016-10-03 09:24:09 -070034#include "src/core/lib/iomgr/port.h"
35
36// This test won't work except with posix sockets enabled
37#ifdef GRPC_POSIX_SOCKET
38
Craig Tiller68bad432015-04-29 14:33:26 -070039#include <string.h>
David Garcia Quintas2bfd2752015-08-20 11:42:29 -070040
nnoble0c475f02014-12-05 15:37:39 -080041#include <grpc/grpc.h>
42#include <grpc/support/alloc.h>
43#include <grpc/support/host_port.h>
44#include <grpc/support/log.h>
Craig Tiller698d00c2015-07-20 12:32:58 -070045#include <grpc/support/string_util.h>
David Garcia Quintas2bfd2752015-08-20 11:42:29 -070046
Craig Tiller9533d042016-03-25 17:11:06 -070047#include "src/core/lib/iomgr/resolve_address.h"
48#include "src/core/lib/iomgr/socket_utils_posix.h"
Craig Tillere4222b42016-10-26 17:15:30 -070049#include "src/core/lib/slice/slice_string_helpers.h"
Craig Tiller9533d042016-03-25 17:11:06 -070050#include "src/core/lib/support/string.h"
nnoble0c475f02014-12-05 15:37:39 -080051#include "test/core/end2end/cq_verifier.h"
52#include "test/core/util/port.h"
53#include "test/core/util/test_config.h"
54
55/* This test exercises IPv4, IPv6, and dualstack sockets in various ways. */
56
Craig Tiller7536af02015-12-22 13:49:30 -080057static void *tag(intptr_t i) { return (void *)i; }
Craig Tillera82950e2015-09-22 12:33:20 -070058
59static gpr_timespec ms_from_now(int ms) {
Robbie Shadeca7effc2017-01-17 09:14:29 -050060 return grpc_timeout_milliseconds_to_deadline(ms);
nnoble0c475f02014-12-05 15:37:39 -080061}
62
Craig Tillera82950e2015-09-22 12:33:20 -070063static void drain_cq(grpc_completion_queue *cq) {
Craig Tiller64be9f72015-05-04 14:53:51 -070064 grpc_event ev;
Craig Tillera82950e2015-09-22 12:33:20 -070065 do {
66 ev = grpc_completion_queue_next(cq, ms_from_now(5000), NULL);
67 } while (ev.type != GRPC_QUEUE_SHUTDOWN);
nnoble0c475f02014-12-05 15:37:39 -080068}
69
Craig Tillera82950e2015-09-22 12:33:20 -070070static void do_nothing(void *ignored) {}
Craig Tiller45724b32015-09-22 10:42:19 -070071
Craig Tillera82950e2015-09-22 12:33:20 -070072void test_connect(const char *server_host, const char *client_host, int port,
73 int expect_ok) {
nnoble0c475f02014-12-05 15:37:39 -080074 char *client_hostport;
75 char *server_hostport;
76 grpc_channel *client;
77 grpc_server *server;
Craig Tillerbed32602015-05-11 15:26:02 -070078 grpc_completion_queue *cq;
nnoble0c475f02014-12-05 15:37:39 -080079 grpc_call *c;
80 grpc_call *s;
Craig Tillerbed32602015-05-11 15:26:02 -070081 cq_verifier *cqv;
nnoble0c475f02014-12-05 15:37:39 -080082 gpr_timespec deadline;
ctiller570d1f42015-01-12 16:29:52 -080083 int got_port;
Craig Tiller68bad432015-04-29 14:33:26 -070084 grpc_op ops[6];
85 grpc_op *op;
86 grpc_metadata_array initial_metadata_recv;
87 grpc_metadata_array trailing_metadata_recv;
88 grpc_metadata_array request_metadata_recv;
89 grpc_status_code status;
Nicolas "Pixel" Noble9a123df2015-07-29 23:45:08 +020090 grpc_call_error error;
Craig Tiller7c70b6c2017-01-23 07:48:42 -080091 grpc_slice details;
Craig Tiller68bad432015-04-29 14:33:26 -070092 int was_cancelled = 2;
93 grpc_call_details call_details;
Craig Tiller1b22b9d2015-07-20 13:42:22 -070094 char *peer;
David Klempner6fb122d2016-05-13 15:24:17 -070095 int picked_port = 0;
nnoble0c475f02014-12-05 15:37:39 -080096
Craig Tillera82950e2015-09-22 12:33:20 -070097 if (port == 0) {
98 port = grpc_pick_unused_port_or_die();
David Klempner6fb122d2016-05-13 15:24:17 -070099 picked_port = 1;
Craig Tillera82950e2015-09-22 12:33:20 -0700100 }
David Klempner57c00612015-02-25 13:37:12 -0800101
Craig Tillera82950e2015-09-22 12:33:20 -0700102 gpr_join_host_port(&server_hostport, server_host, port);
nnoble0c475f02014-12-05 15:37:39 -0800103
Craig Tillera82950e2015-09-22 12:33:20 -0700104 grpc_metadata_array_init(&initial_metadata_recv);
105 grpc_metadata_array_init(&trailing_metadata_recv);
106 grpc_metadata_array_init(&request_metadata_recv);
107 grpc_call_details_init(&call_details);
Craig Tiller68bad432015-04-29 14:33:26 -0700108
nnoble0c475f02014-12-05 15:37:39 -0800109 /* Create server. */
Craig Tillera82950e2015-09-22 12:33:20 -0700110 cq = grpc_completion_queue_create(NULL);
111 server = grpc_server_create(NULL, NULL);
112 grpc_server_register_completion_queue(server, cq, NULL);
113 GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port(
114 server, server_hostport)) > 0);
115 if (port == 0) {
116 port = got_port;
117 } else {
118 GPR_ASSERT(port == got_port);
119 }
120 grpc_server_start(server);
121 cqv = cq_verifier_create(cq);
nnoble0c475f02014-12-05 15:37:39 -0800122
123 /* Create client. */
Craig Tillera82950e2015-09-22 12:33:20 -0700124 if (client_host[0] == 'i') {
125 /* for ipv4:/ipv6: addresses, concatenate the port to each of the parts */
126 size_t i;
Craig Tillerd41a4a72016-10-26 16:16:06 -0700127 grpc_slice uri_slice;
128 grpc_slice_buffer uri_parts;
Craig Tillera82950e2015-09-22 12:33:20 -0700129 char **hosts_with_port;
David Garcia Quintas2bfd2752015-08-20 11:42:29 -0700130
Craig Tillera82950e2015-09-22 12:33:20 -0700131 uri_slice =
Craig Tillerd41a4a72016-10-26 16:16:06 -0700132 grpc_slice_new((char *)client_host, strlen(client_host), do_nothing);
133 grpc_slice_buffer_init(&uri_parts);
134 grpc_slice_split(uri_slice, ",", &uri_parts);
Craig Tillera82950e2015-09-22 12:33:20 -0700135 hosts_with_port = gpr_malloc(sizeof(char *) * uri_parts.count);
136 for (i = 0; i < uri_parts.count; i++) {
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800137 char *uri_part_str = grpc_slice_to_c_string(uri_parts.slices[i]);
Craig Tillera82950e2015-09-22 12:33:20 -0700138 gpr_asprintf(&hosts_with_port[i], "%s:%d", uri_part_str, port);
139 gpr_free(uri_part_str);
David Garcia Quintas2bfd2752015-08-20 11:42:29 -0700140 }
Craig Tillera82950e2015-09-22 12:33:20 -0700141 client_hostport = gpr_strjoin_sep((const char **)hosts_with_port,
142 uri_parts.count, ",", NULL);
143 for (i = 0; i < uri_parts.count; i++) {
144 gpr_free(hosts_with_port[i]);
David Garcia Quintas2bfd2752015-08-20 11:42:29 -0700145 }
Craig Tillera82950e2015-09-22 12:33:20 -0700146 gpr_free(hosts_with_port);
Craig Tiller10cd3562016-11-09 15:20:59 -0800147 grpc_slice_buffer_destroy(&uri_parts);
Craig Tillerd41a4a72016-10-26 16:16:06 -0700148 grpc_slice_unref(uri_slice);
Craig Tillera82950e2015-09-22 12:33:20 -0700149 } else {
150 gpr_join_host_port(&client_hostport, client_host, port);
151 }
152 client = grpc_insecure_channel_create(client_hostport, NULL, NULL);
nnoble0c475f02014-12-05 15:37:39 -0800153
Craig Tillera82950e2015-09-22 12:33:20 -0700154 gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)",
155 server_hostport, client_hostport, expect_ok ? "success" : "failure");
ctiller570d1f42015-01-12 16:29:52 -0800156
Craig Tillera82950e2015-09-22 12:33:20 -0700157 gpr_free(client_hostport);
158 gpr_free(server_hostport);
ctiller570d1f42015-01-12 16:29:52 -0800159
Craig Tillera82950e2015-09-22 12:33:20 -0700160 if (expect_ok) {
161 /* Normal deadline, shouldn't be reached. */
162 deadline = ms_from_now(60000);
163 } else {
164 /* Give up faster when failure is expected.
165 BUG: Setting this to 1000 reveals a memory leak (b/18608927). */
166 deadline = ms_from_now(1500);
167 }
nnoble0c475f02014-12-05 15:37:39 -0800168
169 /* Send a trivial request. */
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800170 grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr");
Craig Tillera82950e2015-09-22 12:33:20 -0700171 c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800172 grpc_slice_from_static_string("/foo"), &host,
173 deadline, NULL);
Craig Tillera82950e2015-09-22 12:33:20 -0700174 GPR_ASSERT(c);
nnoble0c475f02014-12-05 15:37:39 -0800175
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700176 memset(ops, 0, sizeof(ops));
Craig Tiller68bad432015-04-29 14:33:26 -0700177 op = ops;
178 op->op = GRPC_OP_SEND_INITIAL_METADATA;
179 op->data.send_initial_metadata.count = 0;
Mark D. Roth8bc8a832016-10-06 08:11:29 -0700180 op->flags = expect_ok ? GRPC_INITIAL_METADATA_WAIT_FOR_READY : 0;
Nicolas "Pixel" Noble49605162015-08-01 00:12:01 +0200181 op->reserved = NULL;
Craig Tiller68bad432015-04-29 14:33:26 -0700182 op++;
183 op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700184 op->flags = 0;
Nicolas "Pixel" Noble49605162015-08-01 00:12:01 +0200185 op->reserved = NULL;
Craig Tiller68bad432015-04-29 14:33:26 -0700186 op++;
187 op->op = GRPC_OP_RECV_INITIAL_METADATA;
Mark D. Roth435f9f22017-01-25 12:53:54 -0800188 op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700189 op->flags = 0;
Nicolas "Pixel" Noble49605162015-08-01 00:12:01 +0200190 op->reserved = NULL;
Craig Tiller68bad432015-04-29 14:33:26 -0700191 op++;
192 op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
193 op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
194 op->data.recv_status_on_client.status = &status;
195 op->data.recv_status_on_client.status_details = &details;
David Garcia Quintas1d5aca52015-06-14 14:42:04 -0700196 op->flags = 0;
Nicolas "Pixel" Noble49605162015-08-01 00:12:01 +0200197 op->reserved = NULL;
Craig Tiller68bad432015-04-29 14:33:26 -0700198 op++;
Craig Tillera82950e2015-09-22 12:33:20 -0700199 error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
200 GPR_ASSERT(GRPC_CALL_OK == error);
Craig Tiller68bad432015-04-29 14:33:26 -0700201
Craig Tillera82950e2015-09-22 12:33:20 -0700202 if (expect_ok) {
203 /* Check for a successful request. */
204 error = grpc_server_request_call(server, &s, &call_details,
205 &request_metadata_recv, cq, cq, tag(101));
206 GPR_ASSERT(GRPC_CALL_OK == error);
Mark D. Roth7187ab92016-08-24 13:49:22 -0700207 CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
Craig Tillera82950e2015-09-22 12:33:20 -0700208 cq_verify(cqv);
nnoble0c475f02014-12-05 15:37:39 -0800209
David Garcia Quintasa301eaa2016-05-06 16:59:03 -0700210 memset(ops, 0, sizeof(ops));
Craig Tillera82950e2015-09-22 12:33:20 -0700211 op = ops;
212 op->op = GRPC_OP_SEND_INITIAL_METADATA;
213 op->data.send_initial_metadata.count = 0;
214 op->flags = 0;
215 op++;
216 op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
217 op->data.send_status_from_server.trailing_metadata_count = 0;
218 op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800219 grpc_slice status_details = grpc_slice_from_static_string("xyz");
220 op->data.send_status_from_server.status_details = &status_details;
Craig Tillera82950e2015-09-22 12:33:20 -0700221 op->flags = 0;
222 op++;
223 op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
224 op->data.recv_close_on_server.cancelled = &was_cancelled;
225 op->flags = 0;
226 op++;
227 error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
228 GPR_ASSERT(GRPC_CALL_OK == error);
nnoble0c475f02014-12-05 15:37:39 -0800229
Mark D. Roth7187ab92016-08-24 13:49:22 -0700230 CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
231 CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
Craig Tillera82950e2015-09-22 12:33:20 -0700232 cq_verify(cqv);
Craig Tiller68bad432015-04-29 14:33:26 -0700233
Craig Tillera82950e2015-09-22 12:33:20 -0700234 peer = grpc_call_get_peer(c);
235 gpr_log(GPR_DEBUG, "got peer: '%s'", peer);
236 gpr_free(peer);
Craig Tiller1b22b9d2015-07-20 13:42:22 -0700237
Craig Tillera82950e2015-09-22 12:33:20 -0700238 GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800239 GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz"));
240 GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
241 GPR_ASSERT(0 ==
242 grpc_slice_str_cmp(call_details.host, "foo.test.google.fr"));
Craig Tillera82950e2015-09-22 12:33:20 -0700243 GPR_ASSERT(was_cancelled == 1);
Craig Tiller68bad432015-04-29 14:33:26 -0700244
Craig Tillera82950e2015-09-22 12:33:20 -0700245 grpc_call_destroy(s);
246 } else {
247 /* Check for a failed connection. */
Mark D. Roth7187ab92016-08-24 13:49:22 -0700248 CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
Craig Tillera82950e2015-09-22 12:33:20 -0700249 cq_verify(cqv);
nnoble0c475f02014-12-05 15:37:39 -0800250
Craig Tiller8c0d96f2016-03-11 14:27:52 -0800251 GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
Craig Tillera82950e2015-09-22 12:33:20 -0700252 }
nnoble0c475f02014-12-05 15:37:39 -0800253
Craig Tillera82950e2015-09-22 12:33:20 -0700254 grpc_call_destroy(c);
Craig Tiller68bad432015-04-29 14:33:26 -0700255
Craig Tillera82950e2015-09-22 12:33:20 -0700256 cq_verifier_destroy(cqv);
nnoble0c475f02014-12-05 15:37:39 -0800257
258 /* Destroy client. */
Craig Tillera82950e2015-09-22 12:33:20 -0700259 grpc_channel_destroy(client);
nnoble0c475f02014-12-05 15:37:39 -0800260
261 /* Destroy server. */
Craig Tillera82950e2015-09-22 12:33:20 -0700262 grpc_server_shutdown_and_notify(server, cq, tag(1000));
Craig Tillerf40df232016-03-25 13:38:14 -0700263 GPR_ASSERT(grpc_completion_queue_pluck(
Robbie Shadeca7effc2017-01-17 09:14:29 -0500264 cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL)
Craig Tillerf40df232016-03-25 13:38:14 -0700265 .type == GRPC_OP_COMPLETE);
Craig Tillera82950e2015-09-22 12:33:20 -0700266 grpc_server_destroy(server);
267 grpc_completion_queue_shutdown(cq);
268 drain_cq(cq);
269 grpc_completion_queue_destroy(cq);
Craig Tiller99d5c102015-05-20 16:19:09 -0700270
Craig Tillera82950e2015-09-22 12:33:20 -0700271 grpc_metadata_array_destroy(&initial_metadata_recv);
272 grpc_metadata_array_destroy(&trailing_metadata_recv);
273 grpc_metadata_array_destroy(&request_metadata_recv);
Craig Tiller0dc5e6c2015-07-10 10:07:53 -0700274
Craig Tillera82950e2015-09-22 12:33:20 -0700275 grpc_call_details_destroy(&call_details);
Craig Tiller7c70b6c2017-01-23 07:48:42 -0800276 grpc_slice_unref(details);
David Klempner6fb122d2016-05-13 15:24:17 -0700277 if (picked_port) {
278 grpc_recycle_unused_port(port);
279 }
nnoble0c475f02014-12-05 15:37:39 -0800280}
281
Craig Tillera82950e2015-09-22 12:33:20 -0700282int external_dns_works(const char *host) {
yang-gc7940ba2016-07-06 16:48:19 -0700283 grpc_resolved_addresses *res = NULL;
Craig Tillerf707d622016-05-06 14:26:12 -0700284 grpc_error *error = grpc_blocking_resolve_address(host, "80", &res);
285 GRPC_ERROR_UNREF(error);
Craig Tillera82950e2015-09-22 12:33:20 -0700286 if (res != NULL) {
287 grpc_resolved_addresses_destroy(res);
288 return 1;
289 }
Paul Marks6a70b012015-09-08 18:11:15 -0700290 return 0;
291}
292
Craig Tillera82950e2015-09-22 12:33:20 -0700293int main(int argc, char **argv) {
pmarks465554e2014-12-10 18:09:25 -0800294 int do_ipv6 = 1;
nnoble0c475f02014-12-05 15:37:39 -0800295
Craig Tillera82950e2015-09-22 12:33:20 -0700296 grpc_test_init(argc, argv);
297 grpc_init();
nnoble0c475f02014-12-05 15:37:39 -0800298
Craig Tillera82950e2015-09-22 12:33:20 -0700299 if (!grpc_ipv6_loopback_available()) {
300 gpr_log(GPR_INFO, "Can't bind to ::1. Skipping IPv6 tests.");
301 do_ipv6 = 0;
302 }
pmarks465554e2014-12-10 18:09:25 -0800303
Craig Tilleree76f4f2015-04-08 16:10:29 -0700304 /* For coverage, test with and without dualstack sockets. */
Craig Tillera82950e2015-09-22 12:33:20 -0700305 for (grpc_forbid_dualstack_sockets_for_testing = 0;
306 grpc_forbid_dualstack_sockets_for_testing <= 1;
307 grpc_forbid_dualstack_sockets_for_testing++) {
308 /* :: and 0.0.0.0 are handled identically. */
309 test_connect("::", "127.0.0.1", 0, 1);
310 test_connect("::", "::ffff:127.0.0.1", 0, 1);
311 test_connect("::", "ipv4:127.0.0.1", 0, 1);
312 test_connect("::", "ipv6:[::ffff:127.0.0.1]", 0, 1);
313 test_connect("::", "localhost", 0, 1);
314 test_connect("0.0.0.0", "127.0.0.1", 0, 1);
315 test_connect("0.0.0.0", "::ffff:127.0.0.1", 0, 1);
316 test_connect("0.0.0.0", "ipv4:127.0.0.1", 0, 1);
317 test_connect("0.0.0.0", "ipv4:127.0.0.1,127.0.0.2,127.0.0.3", 0, 1);
318 test_connect("0.0.0.0", "ipv6:[::ffff:127.0.0.1],[::ffff:127.0.0.2]", 0, 1);
319 test_connect("0.0.0.0", "localhost", 0, 1);
320 if (do_ipv6) {
321 test_connect("::", "::1", 0, 1);
322 test_connect("0.0.0.0", "::1", 0, 1);
323 test_connect("::", "ipv6:[::1]", 0, 1);
324 test_connect("0.0.0.0", "ipv6:[::1]", 0, 1);
David Klempner57c00612015-02-25 13:37:12 -0800325 }
nnoble0c475f02014-12-05 15:37:39 -0800326
Craig Tillera82950e2015-09-22 12:33:20 -0700327 /* These only work when the families agree. */
328 test_connect("127.0.0.1", "127.0.0.1", 0, 1);
329 test_connect("127.0.0.1", "ipv4:127.0.0.1", 0, 1);
330 if (do_ipv6) {
331 test_connect("::1", "::1", 0, 1);
332 test_connect("::1", "127.0.0.1", 0, 0);
333 test_connect("127.0.0.1", "::1", 0, 0);
334 test_connect("::1", "ipv6:[::1]", 0, 1);
335 test_connect("::1", "ipv4:127.0.0.1", 0, 0);
336 test_connect("127.0.0.1", "ipv6:[::1]", 0, 0);
337 }
338
339 if (!external_dns_works("loopback46.unittest.grpc.io")) {
340 gpr_log(GPR_INFO, "Skipping tests that depend on *.unittest.grpc.io.");
341 } else {
342 test_connect("loopback46.unittest.grpc.io", "loopback4.unittest.grpc.io",
343 0, 1);
344 test_connect("loopback4.unittest.grpc.io", "loopback46.unittest.grpc.io",
345 0, 1);
346 if (do_ipv6) {
347 test_connect("loopback46.unittest.grpc.io",
348 "loopback6.unittest.grpc.io", 0, 1);
349 test_connect("loopback6.unittest.grpc.io",
350 "loopback46.unittest.grpc.io", 0, 1);
351 test_connect("loopback4.unittest.grpc.io", "loopback6.unittest.grpc.io",
352 0, 0);
353 test_connect("loopback6.unittest.grpc.io", "loopback4.unittest.grpc.io",
354 0, 0);
355 }
356 }
357 }
358
359 grpc_shutdown();
nnoble0c475f02014-12-05 15:37:39 -0800360
361 return 0;
Craig Tiller190d3602015-02-18 09:23:38 -0800362}
murgatroid99c36f6ea2016-10-03 09:24:09 -0700363
364#else /* GRPC_POSIX_SOCKET */
365
murgatroid99aa9c5782016-10-10 12:16:13 -0700366int main(int argc, char **argv) { return 1; }
murgatroid99c36f6ea2016-10-03 09:24:09 -0700367
368#endif /* GRPC_POSIX_SOCKET */