diff options
author | Craig Tiller <ctiller@google.com> | 2016-05-06 14:26:12 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-05-06 14:26:12 -0700 |
commit | f707d62db625e3929680d165f2fbc67f9c8d3f9c (patch) | |
tree | 0741e3319b8a90ffe177752e8743db416de4f066 /test/core/end2end | |
parent | ddad97899654c1eb3805ec165e842f8f465702a1 (diff) |
Convert tests to new error scheme
Diffstat (limited to 'test/core/end2end')
-rw-r--r-- | test/core/end2end/dualstack_socket_test.c | 4 | ||||
-rw-r--r-- | test/core/end2end/fuzzers/api_fuzzer.c | 6 | ||||
-rw-r--r-- | test/core/end2end/goaway_server_test.c | 27 | ||||
-rw-r--r-- | test/core/end2end/tests/filter_causes_close.c | 5 |
4 files changed, 23 insertions, 19 deletions
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 81f76ea79c..9be72824fa 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -266,7 +266,9 @@ void test_connect(const char *server_host, const char *client_host, int port, } int external_dns_works(const char *host) { - grpc_resolved_addresses *res = grpc_blocking_resolve_address(host, "80"); + grpc_resolved_addresses *res; + grpc_error *error = grpc_blocking_resolve_address(host, "80", &res); + GRPC_ERROR_UNREF(error); if (res != NULL) { grpc_resolved_addresses_destroy(res); return 1; diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 858ebd9683..3eba4a4e2e 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -50,7 +50,7 @@ //////////////////////////////////////////////////////////////////////////////// // logging -static const bool squelch = true; +static const bool squelch = !true; static void dont_log(gpr_log_func_args *args) {} @@ -202,7 +202,7 @@ static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg, *r->addrs = addrs; grpc_exec_ctx_push(exec_ctx, r->on_done, GRPC_ERROR_NONE, NULL); } else { - grpc_error_ref(error); + GRPC_ERROR_REF(error); grpc_exec_ctx_push( exec_ctx, r->on_done, GRPC_ERROR_CREATE_REFERENCING("Resolution failed", &error, 1), NULL); @@ -248,7 +248,7 @@ static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { future_connect *fc = arg; if (error != GRPC_ERROR_NONE) { *fc->ep = NULL; - grpc_exec_ctx_push(exec_ctx, fc->closure, grpc_error_ref(error), NULL); + grpc_exec_ctx_push(exec_ctx, fc->closure, GRPC_ERROR_REF(error), NULL); } else if (g_server != NULL) { grpc_endpoint *client; grpc_endpoint *server; diff --git a/test/core/end2end/goaway_server_test.c b/test/core/end2end/goaway_server_test.c index 5f8c2641e7..1da120c9b4 100644 --- a/test/core/end2end/goaway_server_test.c +++ b/test/core/end2end/goaway_server_test.c @@ -46,8 +46,9 @@ static void *tag(intptr_t i) { return (void *)i; } static gpr_mu g_mu; static int g_resolve_port = -1; -static grpc_resolved_addresses *(*iomgr_resolve_address)( - const char *name, const char *default_port); +static grpc_error *(*iomgr_resolve_address)(const char *name, + const char *default_port, + grpc_resolved_addresses **addrs); static void set_resolve_port(int port) { gpr_mu_lock(&g_mu); @@ -55,28 +56,28 @@ static void set_resolve_port(int port) { gpr_mu_unlock(&g_mu); } -static grpc_resolved_addresses *my_resolve_address(const char *name, - const char *addr) { +static grpc_error *my_resolve_address(const char *name, const char *addr, + grpc_resolved_addresses **addrs) { if (0 != strcmp(name, "test")) { - return iomgr_resolve_address(name, addr); + return iomgr_resolve_address(name, addr, addrs); } gpr_mu_lock(&g_mu); if (g_resolve_port < 0) { gpr_mu_unlock(&g_mu); - return NULL; + return GRPC_ERROR_CREATE("Forced Failure"); } else { - grpc_resolved_addresses *addrs = gpr_malloc(sizeof(*addrs)); - addrs->naddrs = 1; - addrs->addrs = gpr_malloc(sizeof(*addrs->addrs)); - memset(addrs->addrs, 0, sizeof(*addrs->addrs)); - struct sockaddr_in *sa = (struct sockaddr_in *)addrs->addrs[0].addr; + *addrs = gpr_malloc(sizeof(*addrs)); + (*addrs)->naddrs = 1; + (*addrs)->addrs = gpr_malloc(sizeof(*(*addrs)->addrs)); + memset((*addrs)->addrs, 0, sizeof(*(*addrs)->addrs)); + struct sockaddr_in *sa = (struct sockaddr_in *)(*addrs)->addrs[0].addr; sa->sin_family = AF_INET; sa->sin_addr.s_addr = htonl(0x7f000001); sa->sin_port = htons((uint16_t)g_resolve_port); - addrs->addrs[0].len = sizeof(*sa); + (*addrs)->addrs[0].len = sizeof(*sa); gpr_mu_unlock(&g_mu); - return addrs; + return GRPC_ERROR_NONE; } } diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index 99049aa6bd..405e75294d 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -202,10 +202,11 @@ typedef struct { grpc_closure *recv_im_ready; } call_data; typedef struct { uint8_t unused; } channel_data; -static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg, bool success) { +static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { grpc_call_element *elem = arg; call_data *calld = elem->call_data; - if (success) { + if (error == GRPC_ERROR_NONE) { // close the stream with an error. gpr_slice message = gpr_slice_from_copied_string("Random failure that's not preventable."); |