diff options
author | Yuchen Zeng <zyc@google.com> | 2017-05-30 18:26:17 -0700 |
---|---|---|
committer | Yuchen Zeng <zyc@google.com> | 2017-05-30 18:26:17 -0700 |
commit | 24e3bc5510bfee61d9f62feac95fbe32b1267b85 (patch) | |
tree | ce175c641997407f2ce165f1f984f55a6ae1a5ae /test/core/end2end/fuzzers | |
parent | 4c15fac09f1dcd686f777e7d3d5e9b526f77457b (diff) |
Fix api_fuzzer, dns_resolver_connectivity_test
Diffstat (limited to 'test/core/end2end/fuzzers')
-rw-r--r-- | test/core/end2end/fuzzers/api_fuzzer.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index b33b43dac5..32f75f6b7d 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -39,6 +39,8 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#include "src/core/ext/filters/client_channel/lb_policy_factory.h" +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/resolve_address.h" @@ -377,6 +379,7 @@ typedef struct addr_req { char *addr; grpc_closure *on_done; grpc_resolved_addresses **addrs; + grpc_lb_addresses **lb_addrs; } addr_req; static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg, @@ -384,11 +387,17 @@ static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg, addr_req *r = arg; if (error == GRPC_ERROR_NONE && 0 == strcmp(r->addr, "server")) { - grpc_resolved_addresses *addrs = gpr_malloc(sizeof(*addrs)); - addrs->naddrs = 1; - addrs->addrs = gpr_malloc(sizeof(*addrs->addrs)); - addrs->addrs[0].len = 0; - *r->addrs = addrs; + if (r->addrs != NULL) { + grpc_resolved_addresses *addrs = gpr_malloc(sizeof(*addrs)); + addrs->naddrs = 1; + addrs->addrs = gpr_malloc(sizeof(*addrs->addrs)); + addrs->addrs[0].len = 0; + *r->addrs = addrs; + } else if (r->lb_addrs != NULL) { + grpc_lb_addresses *lb_addrs = grpc_lb_addresses_create(1, NULL); + grpc_lb_addresses_set_address(lb_addrs, 0, NULL, 0, NULL, NULL, NULL); + *r->lb_addrs = lb_addrs; + } grpc_closure_sched(exec_ctx, r->on_done, GRPC_ERROR_NONE); } else { grpc_closure_sched(exec_ctx, r->on_done, @@ -409,6 +418,24 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, r->addr = gpr_strdup(addr); r->on_done = on_done; r->addrs = addresses; + r->lb_addrs = NULL; + grpc_timer_init( + exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_seconds(1, GPR_TIMESPAN)), + grpc_closure_create(finish_resolve, r, grpc_schedule_on_exec_ctx), + gpr_now(GPR_CLOCK_MONOTONIC)); +} + +void my_dns_lookup_ares(grpc_exec_ctx *exec_ctx, const char *dns_server, + const char *addr, const char *default_port, + grpc_pollset_set *interested_parties, + grpc_closure *on_done, grpc_lb_addresses **lb_addrs, + bool check_grpclb) { + addr_req *r = gpr_malloc(sizeof(*r)); + r->addr = gpr_strdup(addr); + r->on_done = on_done; + r->addrs = NULL; + r->lb_addrs = lb_addrs; grpc_timer_init( exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(1, GPR_TIMESPAN)), @@ -725,6 +752,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_init(); grpc_timer_manager_set_threading(false); grpc_resolve_address = my_resolve_address; + grpc_dns_lookup_ares = my_dns_lookup_ares; GPR_ASSERT(g_channel == NULL); GPR_ASSERT(g_server == NULL); |