Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 3 | * Copyright 2015, Google Inc. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 4 | * 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 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 34 | #include "src/core/lib/iomgr/resolve_address.h" |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 35 | #include <grpc/support/alloc.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 36 | #include <grpc/support/log.h> |
| 37 | #include <grpc/support/sync.h> |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 38 | #include <grpc/support/thd.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 39 | #include <grpc/support/time.h> |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 40 | #include "src/core/lib/iomgr/executor.h" |
murgatroid99 | 22d50e9 | 2016-10-12 09:54:49 -0700 | [diff] [blame] | 41 | #include "src/core/lib/iomgr/iomgr.h" |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 42 | #include "test/core/util/test_config.h" |
| 43 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 44 | static gpr_timespec test_deadline(void) { |
Robbie Shade | ca7effc | 2017-01-17 09:14:29 -0500 | [diff] [blame] | 45 | return grpc_timeout_seconds_to_deadline(100); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 46 | } |
| 47 | |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 48 | typedef struct args_struct { |
| 49 | gpr_event ev; |
| 50 | grpc_resolved_addresses *addrs; |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 51 | gpr_atm done_atm; |
| 52 | gpr_mu *mu; |
| 53 | grpc_pollset *pollset; |
| 54 | grpc_pollset_set *pollset_set; |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 55 | } args_struct; |
| 56 | |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 57 | static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} |
| 58 | |
| 59 | void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) { |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 60 | gpr_event_init(&args->ev); |
Yuchen Zeng | 47de64c | 2017-02-22 19:04:38 -0800 | [diff] [blame] | 61 | args->pollset = gpr_zalloc(grpc_pollset_size()); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 62 | grpc_pollset_init(args->pollset, &args->mu); |
| 63 | args->pollset_set = grpc_pollset_set_create(); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 64 | grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset); |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 65 | args->addrs = NULL; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 66 | } |
| 67 | |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 68 | void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 69 | GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline())); |
| 70 | grpc_resolved_addresses_destroy(args->addrs); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 71 | grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset); |
Craig Tiller | 9e5ac1b | 2017-02-14 22:25:50 -0800 | [diff] [blame] | 72 | grpc_pollset_set_destroy(exec_ctx, args->pollset_set); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 73 | grpc_closure do_nothing_cb; |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 74 | grpc_closure_init(&do_nothing_cb, do_nothing, NULL, |
| 75 | grpc_schedule_on_exec_ctx); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 76 | grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb); |
Yuchen Zeng | 8fe21f2 | 2016-11-21 13:34:16 -0800 | [diff] [blame] | 77 | // exec_ctx needs to be flushed before calling grpc_pollset_destroy() |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 78 | grpc_exec_ctx_flush(exec_ctx); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 79 | grpc_pollset_destroy(args->pollset); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 80 | gpr_free(args->pollset); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | static gpr_timespec n_sec_deadline(int seconds) { |
| 84 | return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), |
| 85 | gpr_time_from_seconds(seconds, GPR_TIMESPAN)); |
| 86 | } |
| 87 | |
| 88 | static void actually_poll(void *argsp) { |
| 89 | args_struct *args = argsp; |
| 90 | gpr_timespec deadline = n_sec_deadline(10); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 91 | while (true) { |
| 92 | bool done = gpr_atm_acq_load(&args->done_atm) != 0; |
| 93 | if (done) { |
| 94 | break; |
| 95 | } |
| 96 | gpr_timespec time_left = |
| 97 | gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); |
| 98 | gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done, |
| 99 | time_left.tv_sec, time_left.tv_nsec); |
| 100 | GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 101 | grpc_pollset_worker *worker = NULL; |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 102 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
| 103 | gpr_mu_lock(args->mu); |
| 104 | GRPC_LOG_IF_ERROR( |
| 105 | "pollset_work", |
| 106 | grpc_pollset_work(&exec_ctx, args->pollset, &worker, |
| 107 | gpr_now(GPR_CLOCK_REALTIME), n_sec_deadline(1))); |
| 108 | gpr_mu_unlock(args->mu); |
| 109 | grpc_exec_ctx_finish(&exec_ctx); |
| 110 | } |
| 111 | gpr_event_set(&args->ev, (void *)1); |
| 112 | } |
| 113 | |
| 114 | static void poll_pollset_until_request_done(args_struct *args) { |
| 115 | gpr_atm_rel_store(&args->done_atm, 0); |
| 116 | gpr_thd_id id; |
| 117 | gpr_thd_new(&id, actually_poll, args, NULL); |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp, |
| 121 | grpc_error *err) { |
| 122 | args_struct *args = argsp; |
| 123 | GPR_ASSERT(err == GRPC_ERROR_NONE); |
| 124 | GPR_ASSERT(args->addrs != NULL); |
David Garcia Quintas | d5520c1 | 2016-05-10 16:03:12 -0700 | [diff] [blame] | 125 | GPR_ASSERT(args->addrs->naddrs > 0); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 126 | gpr_atm_rel_store(&args->done_atm, 1); |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | static void must_fail(grpc_exec_ctx *exec_ctx, void *argsp, grpc_error *err) { |
| 130 | args_struct *args = argsp; |
| 131 | GPR_ASSERT(err != GRPC_ERROR_NONE); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 132 | gpr_atm_rel_store(&args->done_atm, 1); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 133 | } |
| 134 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 135 | static void test_localhost(void) { |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 136 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 137 | args_struct args; |
| 138 | args_init(&exec_ctx, &args); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 139 | poll_pollset_until_request_done(&args); |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 140 | grpc_resolve_address( |
| 141 | &exec_ctx, "localhost:1", NULL, args.pollset_set, |
| 142 | grpc_closure_create(must_succeed, &args, grpc_schedule_on_exec_ctx), |
| 143 | &args.addrs); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 144 | args_finish(&exec_ctx, &args); |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 145 | grpc_exec_ctx_finish(&exec_ctx); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 146 | } |
| 147 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 148 | static void test_default_port(void) { |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 149 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 150 | args_struct args; |
| 151 | args_init(&exec_ctx, &args); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 152 | poll_pollset_until_request_done(&args); |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 153 | grpc_resolve_address( |
| 154 | &exec_ctx, "localhost", "1", args.pollset_set, |
| 155 | grpc_closure_create(must_succeed, &args, grpc_schedule_on_exec_ctx), |
| 156 | &args.addrs); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 157 | args_finish(&exec_ctx, &args); |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 158 | grpc_exec_ctx_finish(&exec_ctx); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 159 | } |
| 160 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 161 | static void test_missing_default_port(void) { |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 162 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 163 | args_struct args; |
| 164 | args_init(&exec_ctx, &args); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 165 | poll_pollset_until_request_done(&args); |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 166 | grpc_resolve_address( |
| 167 | &exec_ctx, "localhost", NULL, args.pollset_set, |
| 168 | grpc_closure_create(must_fail, &args, grpc_schedule_on_exec_ctx), |
| 169 | &args.addrs); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 170 | args_finish(&exec_ctx, &args); |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 171 | grpc_exec_ctx_finish(&exec_ctx); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 172 | } |
| 173 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 174 | static void test_ipv6_with_port(void) { |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 175 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 176 | args_struct args; |
| 177 | args_init(&exec_ctx, &args); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 178 | poll_pollset_until_request_done(&args); |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 179 | grpc_resolve_address( |
| 180 | &exec_ctx, "[2001:db8::1]:1", NULL, args.pollset_set, |
| 181 | grpc_closure_create(must_succeed, &args, grpc_schedule_on_exec_ctx), |
| 182 | &args.addrs); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 183 | args_finish(&exec_ctx, &args); |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 184 | grpc_exec_ctx_finish(&exec_ctx); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 185 | } |
| 186 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 187 | static void test_ipv6_without_port(void) { |
Craig Tiller | 45724b3 | 2015-09-22 10:42:19 -0700 | [diff] [blame] | 188 | const char *const kCases[] = { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 189 | "2001:db8::1", "2001:db8::1.2.3.4", "[2001:db8::1]", |
Craig Tiller | 8ad8a41 | 2015-02-25 08:36:40 -0800 | [diff] [blame] | 190 | }; |
Nicolas "Pixel" Noble | 213ed91 | 2015-01-30 02:11:35 +0100 | [diff] [blame] | 191 | unsigned i; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 192 | for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 193 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 194 | args_struct args; |
| 195 | args_init(&exec_ctx, &args); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 196 | poll_pollset_until_request_done(&args); |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 197 | grpc_resolve_address( |
| 198 | &exec_ctx, kCases[i], "80", args.pollset_set, |
| 199 | grpc_closure_create(must_succeed, &args, grpc_schedule_on_exec_ctx), |
| 200 | &args.addrs); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 201 | args_finish(&exec_ctx, &args); |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 202 | grpc_exec_ctx_finish(&exec_ctx); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 203 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 204 | } |
| 205 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 206 | static void test_invalid_ip_addresses(void) { |
Craig Tiller | 45724b3 | 2015-09-22 10:42:19 -0700 | [diff] [blame] | 207 | const char *const kCases[] = { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 208 | "293.283.1238.3:1", "[2001:db8::11111]:1", |
Craig Tiller | 8ad8a41 | 2015-02-25 08:36:40 -0800 | [diff] [blame] | 209 | }; |
Nicolas "Pixel" Noble | 213ed91 | 2015-01-30 02:11:35 +0100 | [diff] [blame] | 210 | unsigned i; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 211 | for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 212 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 213 | args_struct args; |
| 214 | args_init(&exec_ctx, &args); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 215 | poll_pollset_until_request_done(&args); |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 216 | grpc_resolve_address( |
| 217 | &exec_ctx, kCases[i], NULL, args.pollset_set, |
| 218 | grpc_closure_create(must_fail, &args, grpc_schedule_on_exec_ctx), |
| 219 | &args.addrs); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 220 | args_finish(&exec_ctx, &args); |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 221 | grpc_exec_ctx_finish(&exec_ctx); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 222 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 223 | } |
| 224 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 225 | static void test_unparseable_hostports(void) { |
Craig Tiller | 45724b3 | 2015-09-22 10:42:19 -0700 | [diff] [blame] | 226 | const char *const kCases[] = { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 227 | "[", "[::1", "[::1]bad", "[1.2.3.4]", "[localhost]", "[localhost]:1", |
Craig Tiller | 8ad8a41 | 2015-02-25 08:36:40 -0800 | [diff] [blame] | 228 | }; |
Nicolas "Pixel" Noble | 213ed91 | 2015-01-30 02:11:35 +0100 | [diff] [blame] | 229 | unsigned i; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 230 | for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 231 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 232 | args_struct args; |
| 233 | args_init(&exec_ctx, &args); |
Yuchen Zeng | 15521de | 2016-11-17 20:39:27 -0800 | [diff] [blame] | 234 | poll_pollset_until_request_done(&args); |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 235 | grpc_resolve_address( |
| 236 | &exec_ctx, kCases[i], "1", args.pollset_set, |
| 237 | grpc_closure_create(must_fail, &args, grpc_schedule_on_exec_ctx), |
| 238 | &args.addrs); |
Yuchen Zeng | b4080a2 | 2016-11-17 22:03:56 -0800 | [diff] [blame] | 239 | args_finish(&exec_ctx, &args); |
Craig Tiller | e06a81f | 2016-04-21 22:58:58 -0700 | [diff] [blame] | 240 | grpc_exec_ctx_finish(&exec_ctx); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 241 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 242 | } |
| 243 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 244 | int main(int argc, char **argv) { |
| 245 | grpc_test_init(argc, argv); |
David Garcia Quintas | 4bc3463 | 2015-10-07 16:12:35 -0700 | [diff] [blame] | 246 | grpc_executor_init(); |
David Garcia Quintas | 661ad7f | 2015-10-13 15:51:31 -0700 | [diff] [blame] | 247 | grpc_iomgr_init(); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 248 | test_localhost(); |
| 249 | test_default_port(); |
| 250 | test_missing_default_port(); |
| 251 | test_ipv6_with_port(); |
| 252 | test_ipv6_without_port(); |
| 253 | test_invalid_ip_addresses(); |
| 254 | test_unparseable_hostports(); |
Craig Tiller | 3cf7922 | 2016-11-14 08:02:45 -0800 | [diff] [blame] | 255 | { |
| 256 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
| 257 | grpc_executor_shutdown(&exec_ctx); |
| 258 | grpc_iomgr_shutdown(&exec_ctx); |
| 259 | grpc_exec_ctx_finish(&exec_ctx); |
| 260 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 261 | return 0; |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 262 | } |