aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Makarand Dharmapurikar <makarandd@google.com>2017-03-27 09:18:21 -0700
committerGravatar Makarand Dharmapurikar <makarandd@google.com>2017-03-27 09:18:21 -0700
commita0649dde0ec92624d56f943d3b0fae09bcb65e5b (patch)
tree8b0885a3e6d7584b79b5a31725932f4c606768a1 /test/core
parent3c7e460de68625c926b8e4581ed573e543a16a67 (diff)
parentc4478a103b68100b86f506061cedcb0ce70016ba (diff)
Merge branch 'master' of https://github.com/grpc/grpc into grpcz_client
Diffstat (limited to 'test/core')
-rw-r--r--test/core/bad_client/bad_client.c10
-rw-r--r--test/core/channel/channel_stack_test.c16
-rw-r--r--test/core/client_channel/BUILD7
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.c16
-rw-r--r--test/core/client_channel/set_initial_connect_string_test.c268
-rw-r--r--test/core/end2end/bad_server_response_test.c2
-rw-r--r--test/core/end2end/connection_refused_test.c2
-rw-r--r--test/core/end2end/end2end_tests.h7
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.c2
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.c12
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-6723650944237568bin0 -> 669 bytes
-rw-r--r--test/core/end2end/goaway_server_test.c30
-rw-r--r--test/core/end2end/tests/filter_call_init_fails.c8
-rw-r--r--test/core/end2end/tests/filter_causes_close.c4
-rw-r--r--test/core/end2end/tests/filter_latency.c4
-rw-r--r--test/core/end2end/tests/network_status_change.c4
-rw-r--r--test/core/end2end/tests/resource_quota_server.c4
-rw-r--r--test/core/http/httpcli_test.c4
-rw-r--r--test/core/http/httpscli_test.c4
-rw-r--r--test/core/iomgr/endpoint_tests.c14
-rw-r--r--test/core/iomgr/error_test.c123
-rw-r--r--test/core/iomgr/ev_epoll_linux_test.c2
-rw-r--r--test/core/iomgr/fd_posix_test.c2
-rw-r--r--test/core/iomgr/pollset_set_test.c3
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c5
-rw-r--r--test/core/iomgr/tcp_client_uv_test.c5
-rw-r--r--test/core/iomgr/tcp_server_posix_test.c5
-rw-r--r--test/core/iomgr/tcp_server_uv_test.c3
-rw-r--r--test/core/iomgr/udp_server_test.c89
-rw-r--r--test/core/memory_usage/client.c5
-rw-r--r--test/core/security/secure_endpoint_test.c10
-rw-r--r--test/core/security/ssl_server_fuzzer.c5
-rw-r--r--test/core/support/cpu_test.c7
-rw-r--r--test/core/surface/concurrent_connectivity_test.c3
-rw-r--r--test/core/transport/chttp2/hpack_parser_corpus/clusterfuzz-testcase-5298216461402112bin0 -> 172032 bytes
-rw-r--r--test/core/util/mock_endpoint.c5
-rw-r--r--test/core/util/passthru_endpoint.c15
-rw-r--r--test/core/util/reconnect_server.c3
38 files changed, 293 insertions, 415 deletions
diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c
index fdedfe284e..4870dc1a53 100644
--- a/test/core/bad_client/bad_client.c
+++ b/test/core/bad_client/bad_client.c
@@ -163,8 +163,9 @@ void grpc_run_bad_client_test(
gpr_event_wait(&a.done_write, grpc_timeout_seconds_to_deadline(5)));
if (flags & GRPC_BAD_CLIENT_DISCONNECT) {
- grpc_endpoint_shutdown(&exec_ctx, sfd.client,
- GRPC_ERROR_CREATE("Forced Disconnect"));
+ grpc_endpoint_shutdown(
+ &exec_ctx, sfd.client,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect"));
grpc_endpoint_destroy(&exec_ctx, sfd.client);
grpc_exec_ctx_finish(&exec_ctx);
sfd.client = NULL;
@@ -190,8 +191,9 @@ void grpc_run_bad_client_test(
grpc_slice_buffer_destroy_internal(&exec_ctx, &args.incoming);
}
// Shutdown.
- grpc_endpoint_shutdown(&exec_ctx, sfd.client,
- GRPC_ERROR_CREATE("Test Shutdown"));
+ grpc_endpoint_shutdown(
+ &exec_ctx, sfd.client,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
grpc_endpoint_destroy(&exec_ctx, sfd.client);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c
index 76bb57346c..af551c4928 100644
--- a/test/core/channel/channel_stack_test.c
+++ b/test/core/channel/channel_stack_test.c
@@ -68,7 +68,7 @@ static void channel_destroy_func(grpc_exec_ctx *exec_ctx,
static void call_destroy_func(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info,
- void *ignored) {
+ grpc_closure *ignored) {
++*(int *)(elem->channel_data);
}
@@ -139,10 +139,16 @@ static void test_create_channel_stack(void) {
GPR_ASSERT(*channel_data == 0);
call_stack = gpr_malloc(channel_stack->call_stack_size);
- grpc_error *error =
- grpc_call_stack_init(&exec_ctx, channel_stack, 1, free_call, call_stack,
- NULL, NULL, path, gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_inf_future(GPR_CLOCK_MONOTONIC), call_stack);
+ const grpc_call_element_args args = {
+ .call_stack = call_stack,
+ .server_transport_data = NULL,
+ .context = NULL,
+ .path = path,
+ .start_time = gpr_now(GPR_CLOCK_MONOTONIC),
+ .deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC),
+ .arena = NULL};
+ grpc_error *error = grpc_call_stack_init(&exec_ctx, channel_stack, 1,
+ free_call, call_stack, &args);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(call_stack->count == 1);
call_elem = grpc_call_stack_element(call_stack, 0);
diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD
index a29e9aca4e..55a74c6d01 100644
--- a/test/core/client_channel/BUILD
+++ b/test/core/client_channel/BUILD
@@ -45,10 +45,3 @@ cc_test(
deps = ["//:grpc", "//test/core/util:grpc_test_util", "//:gpr", "//test/core/util:gpr_test_util", "//test/core/end2end:cq_verifier"],
copts = ['-std=c99']
)
-
-cc_test(
- name = "set_initial_connect_string_test",
- srcs = ["set_initial_connect_string_test.c"],
- deps = ["//:grpc", "//test/core/util:grpc_test_util", "//:gpr", "//test/core/util:gpr_test_util"],
- copts = ['-std=c99']
-)
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
index 187757d5b3..8449afcbbe 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
@@ -48,22 +48,26 @@ static gpr_mu g_mu;
static bool g_fail_resolution = true;
static grpc_combiner *g_combiner;
-static grpc_error *my_resolve_address(const char *name, const char *addr,
- grpc_resolved_addresses **addrs) {
+static void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
+ const char *default_port,
+ grpc_pollset_set *interested_parties,
+ grpc_closure *on_done,
+ grpc_resolved_addresses **addrs) {
gpr_mu_lock(&g_mu);
- GPR_ASSERT(0 == strcmp("test", name));
+ GPR_ASSERT(0 == strcmp("test", addr));
+ grpc_error *error = GRPC_ERROR_NONE;
if (g_fail_resolution) {
g_fail_resolution = false;
gpr_mu_unlock(&g_mu);
- return GRPC_ERROR_CREATE("Forced Failure");
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
} else {
gpr_mu_unlock(&g_mu);
*addrs = gpr_malloc(sizeof(**addrs));
(*addrs)->naddrs = 1;
(*addrs)->addrs = gpr_malloc(sizeof(*(*addrs)->addrs));
(*addrs)->addrs[0].len = 123;
- return GRPC_ERROR_NONE;
}
+ grpc_closure_sched(exec_ctx, on_done, error);
}
static grpc_resolver *create_resolver(grpc_exec_ctx *exec_ctx,
@@ -135,7 +139,7 @@ int main(int argc, char **argv) {
grpc_init();
gpr_mu_init(&g_mu);
g_combiner = grpc_combiner_create(NULL);
- grpc_blocking_resolve_address = my_resolve_address;
+ grpc_resolve_address = my_resolve_address;
grpc_channel_args *result = (grpc_channel_args *)1;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
diff --git a/test/core/client_channel/set_initial_connect_string_test.c b/test/core/client_channel/set_initial_connect_string_test.c
deleted file mode 100644
index a0a33667cc..0000000000
--- a/test/core/client_channel/set_initial_connect_string_test.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- *
- * Copyright 2015, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-/* With the addition of a libuv endpoint, sockaddr.h now includes uv.h when
- using that endpoint. Because of various transitive includes in uv.h,
- including windows.h on Windows, uv.h must be included before other system
- headers. Therefore, sockaddr.h must always be included first */
-#include "src/core/lib/iomgr/sockaddr.h"
-
-#include <string.h>
-
-#include <grpc/grpc.h>
-#include <grpc/slice.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/host_port.h>
-#include <grpc/support/log.h>
-#include <grpc/support/thd.h>
-
-#include "src/core/ext/client_channel/initial_connect_string.h"
-#include "src/core/lib/iomgr/sockaddr.h"
-#include "src/core/lib/security/credentials/fake/fake_credentials.h"
-#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
-#include "test/core/util/port.h"
-#include "test/core/util/test_config.h"
-#include "test/core/util/test_tcp_server.h"
-
-struct rpc_state {
- char *target;
- grpc_channel_credentials *creds;
- grpc_completion_queue *cq;
- grpc_channel *channel;
- grpc_call *call;
- grpc_op op;
- grpc_slice_buffer incoming_buffer;
- grpc_slice_buffer temp_incoming_buffer;
- grpc_endpoint *tcp;
- gpr_atm done_atm;
-};
-
-static const char *magic_connect_string = "magic initial string";
-static int server_port;
-static struct rpc_state state;
-static grpc_closure on_read;
-
-static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_slice_buffer_move_into(&state.temp_incoming_buffer,
- &state.incoming_buffer);
- gpr_log(GPR_DEBUG, "got %" PRIuPTR " bytes, magic is %" PRIuPTR " bytes",
- state.incoming_buffer.length, strlen(magic_connect_string));
- if (state.incoming_buffer.length > strlen(magic_connect_string)) {
- gpr_atm_rel_store(&state.done_atm, 1);
- grpc_endpoint_shutdown(
- exec_ctx, state.tcp,
- GRPC_ERROR_CREATE("Incoming buffer longer than magic_connect_string"));
- grpc_endpoint_destroy(exec_ctx, state.tcp);
- } else {
- grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer,
- &on_read);
- }
-}
-
-static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
- grpc_pollset *accepting_pollset,
- grpc_tcp_server_acceptor *acceptor) {
- gpr_free(acceptor);
- test_tcp_server *server = arg;
- grpc_closure_init(&on_read, handle_read, NULL, grpc_schedule_on_exec_ctx);
- grpc_slice_buffer_init(&state.incoming_buffer);
- grpc_slice_buffer_init(&state.temp_incoming_buffer);
- state.tcp = tcp;
- grpc_endpoint_add_to_pollset(exec_ctx, tcp, server->pollset);
- grpc_endpoint_read(exec_ctx, tcp, &state.temp_incoming_buffer, &on_read);
-}
-
-static void set_magic_initial_string(grpc_resolved_address **addr,
- grpc_slice *connect_string) {
- GPR_ASSERT(addr);
- GPR_ASSERT((*addr)->len);
- *connect_string = grpc_slice_from_copied_string(magic_connect_string);
-}
-
-static void reset_addr_and_set_magic_string(grpc_resolved_address **addr,
- grpc_slice *connect_string) {
- struct sockaddr_in target;
- *connect_string = grpc_slice_from_copied_string(magic_connect_string);
- gpr_free(*addr);
- target.sin_family = AF_INET;
- target.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- target.sin_port = htons((uint16_t)server_port);
- *addr = (grpc_resolved_address *)gpr_malloc(sizeof(grpc_resolved_address));
- (*addr)->len = sizeof(target);
- memcpy((*addr)->addr, &target, sizeof(target));
-}
-
-static gpr_timespec n_sec_deadline(int seconds) {
- return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(seconds, GPR_TIMESPAN));
-}
-
-static void start_rpc(int use_creds, int target_port) {
- state.cq = grpc_completion_queue_create(NULL);
- if (use_creds) {
- state.creds = grpc_fake_transport_security_credentials_create();
- } else {
- state.creds = NULL;
- }
- gpr_join_host_port(&state.target, "127.0.0.1", target_port);
- if (use_creds) {
- state.channel =
- grpc_secure_channel_create(state.creds, state.target, NULL, NULL);
- } else {
- state.channel = grpc_insecure_channel_create(state.target, NULL, NULL);
- }
- grpc_slice host = grpc_slice_from_static_string("localhost");
- state.call = grpc_channel_create_call(
- state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq,
- grpc_slice_from_static_string("/Service/Method"), &host,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
- memset(&state.op, 0, sizeof(state.op));
- state.op.op = GRPC_OP_SEND_INITIAL_METADATA;
- state.op.data.send_initial_metadata.count = 0;
- state.op.flags = 0;
- state.op.reserved = NULL;
- GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(state.call, &state.op,
- (size_t)(1), NULL, NULL));
- grpc_completion_queue_next(state.cq, n_sec_deadline(5), NULL);
-}
-
-static void cleanup_rpc(void) {
- grpc_event ev;
- grpc_slice_buffer_destroy(&state.incoming_buffer);
- grpc_slice_buffer_destroy(&state.temp_incoming_buffer);
- grpc_channel_credentials_release(state.creds);
- grpc_call_destroy(state.call);
- grpc_completion_queue_shutdown(state.cq);
- do {
- ev = grpc_completion_queue_next(state.cq, n_sec_deadline(1), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
- grpc_completion_queue_destroy(state.cq);
- grpc_channel_destroy(state.channel);
- gpr_free(state.target);
-}
-
-typedef struct {
- test_tcp_server *server;
- gpr_event *signal_when_done;
-} poll_args;
-
-static void actually_poll_server(void *arg) {
- poll_args *pa = arg;
- gpr_timespec deadline = n_sec_deadline(10);
- while (true) {
- bool done = gpr_atm_acq_load(&state.done_atm) != 0;
- gpr_timespec time_left =
- gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME));
- gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09" PRId32, done,
- time_left.tv_sec, time_left.tv_nsec);
- if (done || gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) < 0) {
- break;
- }
- test_tcp_server_poll(pa->server, 1);
- }
- gpr_event_set(pa->signal_when_done, (void *)1);
- gpr_free(pa);
-}
-
-static void poll_server_until_read_done(test_tcp_server *server,
- gpr_event *signal_when_done) {
- gpr_atm_rel_store(&state.done_atm, 0);
- gpr_thd_id id;
- poll_args *pa = gpr_malloc(sizeof(*pa));
- pa->server = server;
- pa->signal_when_done = signal_when_done;
- gpr_thd_new(&id, actually_poll_server, pa, NULL);
-}
-
-static void match_initial_magic_string(grpc_slice_buffer *buffer) {
- size_t i, j, cmp_length;
- size_t magic_length = strlen(magic_connect_string);
- GPR_ASSERT(buffer->length >= magic_length);
- for (i = 0, j = 0; i < state.incoming_buffer.count && j < magic_length; i++) {
- char *dump = grpc_slice_to_c_string(state.incoming_buffer.slices[i]);
- cmp_length = GPR_MIN(strlen(dump), magic_length - j);
- GPR_ASSERT(strncmp(dump, magic_connect_string + j, cmp_length) == 0);
- j += cmp_length;
- gpr_free(dump);
- }
-}
-
-static void test_initial_string(test_tcp_server *server, int secure) {
- gpr_event ev;
- gpr_event_init(&ev);
- grpc_test_set_initial_connect_string_function(set_magic_initial_string);
- poll_server_until_read_done(server, &ev);
- start_rpc(secure, server_port);
- gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME));
- match_initial_magic_string(&state.incoming_buffer);
- cleanup_rpc();
-}
-
-static void test_initial_string_with_redirect(test_tcp_server *server,
- int secure) {
- gpr_event ev;
- gpr_event_init(&ev);
- int another_port = grpc_pick_unused_port_or_die();
- grpc_test_set_initial_connect_string_function(
- reset_addr_and_set_magic_string);
- poll_server_until_read_done(server, &ev);
- start_rpc(secure, another_port);
- gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME));
- match_initial_magic_string(&state.incoming_buffer);
- cleanup_rpc();
-}
-
-static void run_test(void (*test)(test_tcp_server *server, int secure),
- int secure) {
- test_tcp_server test_server;
- server_port = grpc_pick_unused_port_or_die();
- test_tcp_server_init(&test_server, on_connect, &test_server);
- test_tcp_server_start(&test_server, server_port);
- test(&test_server, secure);
- test_tcp_server_destroy(&test_server);
-}
-
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
- grpc_init();
-
- run_test(test_initial_string, 0);
- run_test(test_initial_string, 1);
- run_test(test_initial_string_with_redirect, 0);
- run_test(test_initial_string_with_redirect, 1);
-
- grpc_shutdown();
- return 0;
-}
diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c
index 39a98e84ca..c37a292af9 100644
--- a/test/core/end2end/bad_server_response_test.c
+++ b/test/core/end2end/bad_server_response_test.c
@@ -303,7 +303,7 @@ static void run_test(const char *response_payload,
/* clean up */
grpc_endpoint_shutdown(&exec_ctx, state.tcp,
- GRPC_ERROR_CREATE("Test Shutdown"));
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
grpc_endpoint_destroy(&exec_ctx, state.tcp);
cleanup_rpc(&exec_ctx);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c
index 16a3005539..6ded12ad48 100644
--- a/test/core/end2end/connection_refused_test.c
+++ b/test/core/end2end/connection_refused_test.c
@@ -53,7 +53,6 @@ static void *tag(intptr_t i) { return (void *)i; }
static void run_test(bool wait_for_ready, bool use_service_config) {
grpc_channel *chan;
grpc_call *call;
- gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2);
grpc_completion_queue *cq;
cq_verifier *cqv;
grpc_op ops[6];
@@ -98,6 +97,7 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
gpr_log(GPR_INFO, "server: %s", addr);
chan = grpc_insecure_channel_create(addr, args, NULL);
grpc_slice host = grpc_slice_from_static_string("nonexistant");
+ gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2);
call = grpc_channel_create_call(
chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/service/method"), &host, deadline, NULL);
diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h
index cb0afd9cd9..cdb26a67e9 100644
--- a/test/core/end2end/end2end_tests.h
+++ b/test/core/end2end/end2end_tests.h
@@ -39,12 +39,15 @@
typedef struct grpc_end2end_test_fixture grpc_end2end_test_fixture;
typedef struct grpc_end2end_test_config grpc_end2end_test_config;
+/* Test feature flags. */
#define FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION 1
#define FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION 2
#define FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS 4
#define FEATURE_MASK_SUPPORTS_REQUEST_PROXYING 8
#define FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL 16
#define FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER 32
+#define FEATURE_MASK_DOES_NOT_SUPPORT_RESOURCE_QUOTA_SERVER 64
+#define FEATURE_MASK_DOES_NOT_SUPPORT_NETWORK_STATUS_CHANGE 128
#define FAIL_AUTH_CHECK_SERVER_ARG_NAME "fail_auth_check"
@@ -56,8 +59,12 @@ struct grpc_end2end_test_fixture {
};
struct grpc_end2end_test_config {
+ /* A descriptive name for this test fixture. */
const char *name;
+
+ /* Which features are supported by this fixture. See feature flags above. */
uint32_t feature_mask;
+
grpc_end2end_test_fixture (*create_fixture)(grpc_channel_args *client_args,
grpc_channel_args *server_args);
void (*init_client)(grpc_end2end_test_fixture *f,
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.c b/test/core/end2end/fixtures/http_proxy_fixture.c
index bcd1c9914b..451ed268d3 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.c
+++ b/test/core/end2end/fixtures/http_proxy_fixture.c
@@ -342,7 +342,7 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
char* msg;
gpr_asprintf(&msg, "HTTP proxy got request method %s",
conn->http_request.method);
- error = GRPC_ERROR_CREATE(msg);
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
proxy_connection_failed(exec_ctx, conn, true /* is_client */,
"HTTP proxy read request", error);
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c
index 0de8b9459a..a0acf5bf60 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.c
+++ b/test/core/end2end/fuzzers/api_fuzzer.c
@@ -390,9 +390,9 @@ static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg,
*r->addrs = addrs;
grpc_closure_sched(exec_ctx, r->on_done, GRPC_ERROR_NONE);
} else {
- grpc_closure_sched(
- exec_ctx, r->on_done,
- GRPC_ERROR_CREATE_REFERENCING("Resolution failed", &error, 1));
+ grpc_closure_sched(exec_ctx, r->on_done,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Resolution failed", &error, 1));
}
gpr_free(r->addr);
@@ -461,8 +461,8 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
grpc_endpoint **ep, gpr_timespec deadline) {
if (gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) < 0) {
*ep = NULL;
- grpc_closure_sched(exec_ctx, closure,
- GRPC_ERROR_CREATE("Connect deadline exceeded"));
+ grpc_closure_sched(exec_ctx, closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Connect deadline exceeded"));
return;
}
@@ -719,10 +719,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_test_only_set_slice_hash_seed(0);
if (squelch) gpr_set_log_function(dont_log);
input_stream inp = {data, data + size};
- grpc_resolve_address = my_resolve_address;
grpc_tcp_client_connect_impl = my_tcp_client_connect;
gpr_now_impl = now_impl;
grpc_init();
+ grpc_resolve_address = my_resolve_address;
GPR_ASSERT(g_channel == NULL);
GPR_ASSERT(g_server == NULL);
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-6723650944237568 b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-6723650944237568
new file mode 100644
index 0000000000..e140fdc705
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-6723650944237568
Binary files differ
diff --git a/test/core/end2end/goaway_server_test.c b/test/core/end2end/goaway_server_test.c
index a9634bfbae..22d93b321a 100644
--- a/test/core/end2end/goaway_server_test.c
+++ b/test/core/end2end/goaway_server_test.c
@@ -52,9 +52,11 @@ static void *tag(intptr_t i) { return (void *)i; }
static gpr_mu g_mu;
static int g_resolve_port = -1;
-static grpc_error *(*iomgr_resolve_address)(const char *name,
- const char *default_port,
- grpc_resolved_addresses **addrs);
+static void (*iomgr_resolve_address)(grpc_exec_ctx *exec_ctx, const char *addr,
+ const char *default_port,
+ grpc_pollset_set *interested_parties,
+ grpc_closure *on_done,
+ grpc_resolved_addresses **addresses);
static void set_resolve_port(int port) {
gpr_mu_lock(&g_mu);
@@ -62,16 +64,22 @@ static void set_resolve_port(int port) {
gpr_mu_unlock(&g_mu);
}
-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, addrs);
+static void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
+ const char *default_port,
+ grpc_pollset_set *interested_parties,
+ grpc_closure *on_done,
+ grpc_resolved_addresses **addrs) {
+ if (0 != strcmp(addr, "test")) {
+ iomgr_resolve_address(exec_ctx, addr, default_port, interested_parties,
+ on_done, addrs);
+ return;
}
+ grpc_error *error = GRPC_ERROR_NONE;
gpr_mu_lock(&g_mu);
if (g_resolve_port < 0) {
gpr_mu_unlock(&g_mu);
- return GRPC_ERROR_CREATE("Forced Failure");
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
} else {
*addrs = gpr_malloc(sizeof(**addrs));
(*addrs)->naddrs = 1;
@@ -83,8 +91,8 @@ static grpc_error *my_resolve_address(const char *name, const char *addr,
sa->sin_port = htons((uint16_t)g_resolve_port);
(*addrs)->addrs[0].len = sizeof(*sa);
gpr_mu_unlock(&g_mu);
- return GRPC_ERROR_NONE;
}
+ grpc_closure_sched(exec_ctx, on_done, error);
}
int main(int argc, char **argv) {
@@ -96,9 +104,9 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
gpr_mu_init(&g_mu);
- iomgr_resolve_address = grpc_blocking_resolve_address;
- grpc_blocking_resolve_address = my_resolve_address;
grpc_init();
+ iomgr_resolve_address = grpc_resolve_address;
+ grpc_resolve_address = my_resolve_address;
int was_cancelled1;
int was_cancelled2;
diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c
index d2d6e82d57..ebfe3b03dc 100644
--- a/test/core/end2end/tests/filter_call_init_fails.c
+++ b/test/core/end2end/tests/filter_call_init_fails.c
@@ -206,14 +206,14 @@ static void test_request(grpc_end2end_test_config config) {
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem,
const grpc_call_element_args *args) {
- return grpc_error_set_int(GRPC_ERROR_CREATE("access denied"),
- GRPC_ERROR_INT_GRPC_STATUS,
- GRPC_STATUS_PERMISSION_DENIED);
+ return grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("access denied"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_PERMISSION_DENIED);
}
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info,
- void *and_free_memory) {}
+ grpc_closure *ignored) {}
static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c
index 25e606556d..e6b02eaeee 100644
--- a/test/core/end2end/tests/filter_causes_close.c
+++ b/test/core/end2end/tests/filter_causes_close.c
@@ -210,7 +210,7 @@ static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg,
call_data *calld = elem->call_data;
grpc_closure_sched(
exec_ctx, calld->recv_im_ready,
- grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING(
+ grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failure that's not preventable.", &error, 1),
GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_PERMISSION_DENIED));
@@ -236,7 +236,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info,
- void *and_free_memory) {}
+ grpc_closure *ignored) {}
static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
diff --git a/test/core/end2end/tests/filter_latency.c b/test/core/end2end/tests/filter_latency.c
index d05e9e79a1..2428c92a42 100644
--- a/test/core/end2end/tests/filter_latency.c
+++ b/test/core/end2end/tests/filter_latency.c
@@ -267,7 +267,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem,
const grpc_call_final_info *final_info,
- void *and_free_memory) {
+ grpc_closure *ignored) {
gpr_mu_lock(&g_mu);
g_client_latency = final_info->stats.latency;
gpr_mu_unlock(&g_mu);
@@ -276,7 +276,7 @@ static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx,
static void server_destroy_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem,
const grpc_call_final_info *final_info,
- void *and_free_memory) {
+ grpc_closure *ignored) {
gpr_mu_lock(&g_mu);
g_server_latency = final_info->stats.latency;
gpr_mu_unlock(&g_mu);
diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c
index 7540ce93a1..d7a4106459 100644
--- a/test/core/end2end/tests/network_status_change.c
+++ b/test/core/end2end/tests/network_status_change.c
@@ -240,6 +240,10 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
}
void network_status_change(grpc_end2end_test_config config) {
+ if (config.feature_mask &
+ FEATURE_MASK_DOES_NOT_SUPPORT_NETWORK_STATUS_CHANGE) {
+ return;
+ }
test_invoke_network_status_change(config);
}
diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c
index 4f9ed7a3a1..db26b4480e 100644
--- a/test/core/end2end/tests/resource_quota_server.c
+++ b/test/core/end2end/tests/resource_quota_server.c
@@ -113,6 +113,10 @@ static grpc_slice generate_random_slice() {
}
void resource_quota_server(grpc_end2end_test_config config) {
+ if (config.feature_mask &
+ FEATURE_MASK_DOES_NOT_SUPPORT_RESOURCE_QUOTA_SERVER) {
+ return;
+ }
grpc_resource_quota *resource_quota =
grpc_resource_quota_create("test_server");
grpc_resource_quota_resize(resource_quota, 5 * 1024 * 1024);
diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c
index f690dbaffb..d3b45c4505 100644
--- a/test/core/http/httpcli_test.c
+++ b/test/core/http/httpcli_test.c
@@ -102,7 +102,7 @@ static void test_get(int port) {
"pollset_work",
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(20))));
+ n_seconds_time(1))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@@ -144,7 +144,7 @@ static void test_post(int port) {
"pollset_work",
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(20))));
+ n_seconds_time(1))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c
index 549411037e..acc94091f4 100644
--- a/test/core/http/httpscli_test.c
+++ b/test/core/http/httpscli_test.c
@@ -103,7 +103,7 @@ static void test_get(int port) {
"pollset_work",
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(20))));
+ n_seconds_time(1))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@@ -146,7 +146,7 @@ static void test_post(int port) {
"pollset_work",
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&worker, gpr_now(GPR_CLOCK_MONOTONIC),
- n_seconds_time(20))));
+ n_seconds_time(1))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c
index 94067a8ca4..e274796e23 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.c
@@ -233,11 +233,13 @@ static void read_and_write_test(grpc_endpoint_test_config config,
if (shutdown) {
gpr_log(GPR_DEBUG, "shutdown read");
- grpc_endpoint_shutdown(&exec_ctx, state.read_ep,
- GRPC_ERROR_CREATE("Test Shutdown"));
+ grpc_endpoint_shutdown(
+ &exec_ctx, state.read_ep,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
gpr_log(GPR_DEBUG, "shutdown write");
- grpc_endpoint_shutdown(&exec_ctx, state.write_ep,
- GRPC_ERROR_CREATE("Test Shutdown"));
+ grpc_endpoint_shutdown(
+ &exec_ctx, state.write_ep,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
}
grpc_exec_ctx_flush(&exec_ctx);
@@ -299,7 +301,7 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) {
grpc_schedule_on_exec_ctx));
wait_for_fail_count(&exec_ctx, &fail_count, 0);
grpc_endpoint_shutdown(&exec_ctx, f.client_ep,
- GRPC_ERROR_CREATE("Test Shutdown"));
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
wait_for_fail_count(&exec_ctx, &fail_count, 1);
grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer,
grpc_closure_create(inc_on_failure, &fail_count,
@@ -311,7 +313,7 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) {
grpc_schedule_on_exec_ctx));
wait_for_fail_count(&exec_ctx, &fail_count, 3);
grpc_endpoint_shutdown(&exec_ctx, f.client_ep,
- GRPC_ERROR_CREATE("Test Shutdown"));
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
wait_for_fail_count(&exec_ctx, &fail_count, 3);
grpc_slice_buffer_destroy_internal(&exec_ctx, &slice_buffer);
diff --git a/test/core/iomgr/error_test.c b/test/core/iomgr/error_test.c
index 2a6b1b17fd..5c60a4ddb8 100644
--- a/test/core/iomgr/error_test.c
+++ b/test/core/iomgr/error_test.c
@@ -44,7 +44,7 @@
#include "test/core/util/test_config.h"
static void test_set_get_int() {
- grpc_error* error = GRPC_ERROR_CREATE("Test");
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test");
GPR_ASSERT(error);
intptr_t i = 0;
GPR_ASSERT(grpc_error_get_int(error, GRPC_ERROR_INT_FILE_LINE, &i));
@@ -66,26 +66,27 @@ static void test_set_get_int() {
}
static void test_set_get_str() {
- grpc_error* error = GRPC_ERROR_CREATE("Test");
+ grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test");
- GPR_ASSERT(!grpc_error_get_str(error, GRPC_ERROR_STR_SYSCALL));
- GPR_ASSERT(!grpc_error_get_str(error, GRPC_ERROR_STR_TSI_ERROR));
+ grpc_slice str;
+ GPR_ASSERT(!grpc_error_get_str(error, GRPC_ERROR_STR_SYSCALL, &str));
+ GPR_ASSERT(!grpc_error_get_str(error, GRPC_ERROR_STR_TSI_ERROR, &str));
- const char* c = grpc_error_get_str(error, GRPC_ERROR_STR_FILE);
- GPR_ASSERT(c);
- GPR_ASSERT(strstr(c, "error_test.c")); // __FILE__ expands differently on
- // Windows. All should at least
- // contain error_test.c
+ GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_FILE, &str));
+ GPR_ASSERT(strstr((char*)GRPC_SLICE_START_PTR(str),
+ "error_test.c")); // __FILE__ expands differently on
+ // Windows. All should at least
+ // contain error_test.c
- c = grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION);
- GPR_ASSERT(c);
- GPR_ASSERT(!strcmp(c, "Test"));
+ GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &str));
+ GPR_ASSERT(!strncmp((char*)GRPC_SLICE_START_PTR(str), "Test",
+ GRPC_SLICE_LENGTH(str)));
- error =
- grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "longer message");
- c = grpc_error_get_str(error, GRPC_ERROR_STR_GRPC_MESSAGE);
- GPR_ASSERT(c);
- GPR_ASSERT(!strcmp(c, "longer message"));
+ error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
+ grpc_slice_from_static_string("longer message"));
+ GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, &str));
+ GPR_ASSERT(!strncmp((char*)GRPC_SLICE_START_PTR(str), "longer message",
+ GRPC_SLICE_LENGTH(str)));
GRPC_ERROR_UNREF(error);
}
@@ -93,26 +94,28 @@ static void test_set_get_str() {
static void test_copy_and_unref() {
// error1 has one ref
grpc_error* error1 = grpc_error_set_str(
- GRPC_ERROR_CREATE("Test"), GRPC_ERROR_STR_GRPC_MESSAGE, "message");
- const char* c = grpc_error_get_str(error1, GRPC_ERROR_STR_GRPC_MESSAGE);
- GPR_ASSERT(c);
- GPR_ASSERT(!strcmp(c, "message"));
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test"), GRPC_ERROR_STR_GRPC_MESSAGE,
+ grpc_slice_from_static_string("message"));
+ grpc_slice str;
+ GPR_ASSERT(grpc_error_get_str(error1, GRPC_ERROR_STR_GRPC_MESSAGE, &str));
+ GPR_ASSERT(!strncmp((char*)GRPC_SLICE_START_PTR(str), "message",
+ GRPC_SLICE_LENGTH(str)));
// error 1 has two refs
GRPC_ERROR_REF(error1);
// this gives error3 a ref to the new error, and decrements error1 to one ref
- grpc_error* error3 =
- grpc_error_set_str(error1, GRPC_ERROR_STR_SYSCALL, "syscall");
+ grpc_error* error3 = grpc_error_set_str(
+ error1, GRPC_ERROR_STR_SYSCALL, grpc_slice_from_static_string("syscall"));
GPR_ASSERT(error3 != error1); // should not be the same because of extra ref
- c = grpc_error_get_str(error3, GRPC_ERROR_STR_GRPC_MESSAGE);
- GPR_ASSERT(c);
- GPR_ASSERT(!strcmp(c, "message"));
+ GPR_ASSERT(grpc_error_get_str(error3, GRPC_ERROR_STR_GRPC_MESSAGE, &str));
+ GPR_ASSERT(!strncmp((char*)GRPC_SLICE_START_PTR(str), "message",
+ GRPC_SLICE_LENGTH(str)));
// error 1 should not have a syscall but 3 should
- GPR_ASSERT(!grpc_error_get_str(error1, GRPC_ERROR_STR_SYSCALL));
- c = grpc_error_get_str(error3, GRPC_ERROR_STR_SYSCALL);
- GPR_ASSERT(c);
- GPR_ASSERT(!strcmp(c, "syscall"));
+ GPR_ASSERT(!grpc_error_get_str(error1, GRPC_ERROR_STR_SYSCALL, &str));
+ GPR_ASSERT(grpc_error_get_str(error3, GRPC_ERROR_STR_SYSCALL, &str));
+ GPR_ASSERT(!strncmp((char*)GRPC_SLICE_START_PTR(str), "syscall",
+ GRPC_SLICE_LENGTH(str)));
GRPC_ERROR_UNREF(error1);
GRPC_ERROR_UNREF(error3);
@@ -120,8 +123,10 @@ static void test_copy_and_unref() {
static void test_create_referencing() {
grpc_error* child = grpc_error_set_str(
- GRPC_ERROR_CREATE("Child"), GRPC_ERROR_STR_GRPC_MESSAGE, "message");
- grpc_error* parent = GRPC_ERROR_CREATE_REFERENCING("Parent", &child, 1);
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child"),
+ GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_from_static_string("message"));
+ grpc_error* parent =
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Parent", &child, 1);
GPR_ASSERT(parent);
GRPC_ERROR_UNREF(child);
@@ -130,14 +135,18 @@ static void test_create_referencing() {
static void test_create_referencing_many() {
grpc_error* children[3];
- children[0] = grpc_error_set_str(GRPC_ERROR_CREATE("Child1"),
- GRPC_ERROR_STR_GRPC_MESSAGE, "message");
- children[1] = grpc_error_set_int(GRPC_ERROR_CREATE("Child2"),
- GRPC_ERROR_INT_HTTP2_ERROR, 5);
- children[2] = grpc_error_set_str(GRPC_ERROR_CREATE("Child3"),
- GRPC_ERROR_STR_GRPC_MESSAGE, "message 3");
-
- grpc_error* parent = GRPC_ERROR_CREATE_REFERENCING("Parent", children, 3);
+ children[0] = grpc_error_set_str(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child1"),
+ GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_from_static_string("message"));
+ children[1] =
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child2"),
+ GRPC_ERROR_INT_HTTP2_ERROR, 5);
+ children[2] = grpc_error_set_str(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Child3"),
+ GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_from_static_string("message 3"));
+
+ grpc_error* parent =
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Parent", children, 3);
GPR_ASSERT(parent);
for (size_t i = 0; i < 3; ++i) {
@@ -148,10 +157,11 @@ static void test_create_referencing_many() {
static void print_error_string() {
grpc_error* error =
- grpc_error_set_int(GRPC_ERROR_CREATE("Error"), GRPC_ERROR_INT_GRPC_STATUS,
- GRPC_STATUS_UNIMPLEMENTED);
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED);
error = grpc_error_set_int(error, GRPC_ERROR_INT_SIZE, 666);
- error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "message");
+ error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
+ grpc_slice_from_static_string("message"));
// gpr_log(GPR_DEBUG, "%s", grpc_error_string(error));
GRPC_ERROR_UNREF(error);
}
@@ -159,15 +169,18 @@ static void print_error_string() {
static void print_error_string_reference() {
grpc_error* children[2];
children[0] = grpc_error_set_str(
- grpc_error_set_int(GRPC_ERROR_CREATE("1"), GRPC_ERROR_INT_GRPC_STATUS,
- GRPC_STATUS_UNIMPLEMENTED),
- GRPC_ERROR_STR_GRPC_MESSAGE, "message for child 1");
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("1"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED),
+ GRPC_ERROR_STR_GRPC_MESSAGE,
+ grpc_slice_from_static_string("message for child 1"));
children[1] = grpc_error_set_str(
- grpc_error_set_int(GRPC_ERROR_CREATE("2sd"), GRPC_ERROR_INT_GRPC_STATUS,
- GRPC_STATUS_INTERNAL),
- GRPC_ERROR_STR_GRPC_MESSAGE, "message for child 2");
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("2sd"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL),
+ GRPC_ERROR_STR_GRPC_MESSAGE,
+ grpc_slice_from_static_string("message for child 2"));
- grpc_error* parent = GRPC_ERROR_CREATE_REFERENCING("Parent", children, 2);
+ grpc_error* parent =
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Parent", children, 2);
gpr_log(GPR_DEBUG, "%s", grpc_error_string(parent));
@@ -186,15 +199,17 @@ static void test_os_error() {
GPR_ASSERT(grpc_error_get_int(error, GRPC_ERROR_INT_ERRNO, &i));
GPR_ASSERT(i == fake_errno);
- const char* c = grpc_error_get_str(error, GRPC_ERROR_STR_SYSCALL);
- GPR_ASSERT(c);
- GPR_ASSERT(!strcmp(c, syscall));
+ grpc_slice str;
+ GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_SYSCALL, &str));
+ GPR_ASSERT(!strncmp((char*)GRPC_SLICE_START_PTR(str), syscall,
+ GRPC_SLICE_LENGTH(str)));
GRPC_ERROR_UNREF(error);
}
static void test_special() {
grpc_error* error = GRPC_ERROR_NONE;
- error = grpc_error_add_child(error, GRPC_ERROR_CREATE("test child"));
+ error = grpc_error_add_child(
+ error, GRPC_ERROR_CREATE_FROM_STATIC_STRING("test child"));
intptr_t i;
GPR_ASSERT(grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, &i));
GPR_ASSERT(i == GRPC_STATUS_OK);
diff --git a/test/core/iomgr/ev_epoll_linux_test.c b/test/core/iomgr/ev_epoll_linux_test.c
index 4ec959995b..d69f9a9d15 100644
--- a/test/core/iomgr/ev_epoll_linux_test.c
+++ b/test/core/iomgr/ev_epoll_linux_test.c
@@ -90,7 +90,7 @@ static void test_fd_cleanup(grpc_exec_ctx *exec_ctx, test_fd *tfds,
for (i = 0; i < num_fds; i++) {
grpc_fd_shutdown(exec_ctx, tfds[i].fd,
- GRPC_ERROR_CREATE("test_fd_cleanup"));
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_fd_cleanup"));
grpc_exec_ctx_flush(exec_ctx);
grpc_fd_orphan(exec_ctx, tfds[i].fd, NULL, &release_fd, "test_fd_cleanup");
diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c
index c1a0ef54d3..81d2692a08 100644
--- a/test/core/iomgr/fd_posix_test.c
+++ b/test/core/iomgr/fd_posix_test.c
@@ -133,7 +133,7 @@ static void session_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */
gpr_free(se);
/* Start to shutdown listen fd. */
grpc_fd_shutdown(exec_ctx, sv->em_fd,
- GRPC_ERROR_CREATE("session_shutdown_cb"));
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("session_shutdown_cb"));
}
/* Called when data become readable in a session. */
diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c
index f27e9db8c9..3a9d459579 100644
--- a/test/core/iomgr/pollset_set_test.c
+++ b/test/core/iomgr/pollset_set_test.c
@@ -143,7 +143,8 @@ static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds,
int release_fd;
for (int i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(exec_ctx, tfds[i].fd, GRPC_ERROR_CREATE("fd cleanup"));
+ grpc_fd_shutdown(exec_ctx, tfds[i].fd,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("fd cleanup"));
grpc_exec_ctx_flush(exec_ctx);
/* grpc_fd_orphan frees the memory allocated for grpc_fd. Normally it also
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index b324b5a65e..2fae6774e8 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -77,8 +77,9 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
GPR_ASSERT(g_connecting != NULL);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_endpoint_shutdown(exec_ctx, g_connecting,
- GRPC_ERROR_CREATE("must_succeed called"));
+ grpc_endpoint_shutdown(
+ exec_ctx, g_connecting,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called"));
grpc_endpoint_destroy(exec_ctx, g_connecting);
g_connecting = NULL;
finish_connection();
diff --git a/test/core/iomgr/tcp_client_uv_test.c b/test/core/iomgr/tcp_client_uv_test.c
index 064119f11b..92fc393422 100644
--- a/test/core/iomgr/tcp_client_uv_test.c
+++ b/test/core/iomgr/tcp_client_uv_test.c
@@ -73,8 +73,9 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
GPR_ASSERT(g_connecting != NULL);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_endpoint_shutdown(exec_ctx, g_connecting,
- GRPC_ERROR_CREATE("must_succeed called"));
+ grpc_endpoint_shutdown(
+ exec_ctx, g_connecting,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called"));
grpc_endpoint_destroy(exec_ctx, g_connecting);
g_connecting = NULL;
finish_connection();
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c
index 6e514324a5..112743b95b 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.c
@@ -163,7 +163,8 @@ static void test_addr_init_str(test_addr *addr) {
static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
grpc_pollset *pollset,
grpc_tcp_server_acceptor *acceptor) {
- grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE("Connected"));
+ grpc_endpoint_shutdown(exec_ctx, tcp,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
grpc_endpoint_destroy(exec_ctx, tcp);
on_connect_result temp_result;
@@ -285,7 +286,7 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote,
if (g_nconnects != nconnects_before + 1) {
gpr_mu_unlock(g_mu);
close(clifd);
- return GRPC_ERROR_CREATE("Didn't connect");
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Didn't connect");
}
close(clifd);
*result = g_result;
diff --git a/test/core/iomgr/tcp_server_uv_test.c b/test/core/iomgr/tcp_server_uv_test.c
index 0fc74599ea..1e039585c1 100644
--- a/test/core/iomgr/tcp_server_uv_test.c
+++ b/test/core/iomgr/tcp_server_uv_test.c
@@ -115,7 +115,8 @@ static void server_weak_ref_set(server_weak_ref *weak_ref,
static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
grpc_pollset *pollset,
grpc_tcp_server_acceptor *acceptor) {
- grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE("Connected"));
+ grpc_endpoint_shutdown(exec_ctx, tcp,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
grpc_endpoint_destroy(exec_ctx, tcp);
on_connect_result temp_result;
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index 396ec959cd..12d8406323 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -48,9 +48,12 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr.h"
+#include "src/core/lib/iomgr/socket_factory_posix.h"
#include "test/core/util/test_config.h"
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x)
@@ -94,16 +97,59 @@ static void on_fd_orphaned(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
g_number_of_orphan_calls++;
}
+struct test_socket_factory {
+ grpc_socket_factory base;
+ int number_of_socket_calls;
+ int number_of_bind_calls;
+};
+typedef struct test_socket_factory test_socket_factory;
+
+static int test_socket_factory_socket(grpc_socket_factory *factory, int domain,
+ int type, int protocol) {
+ test_socket_factory *f = (test_socket_factory *)factory;
+ f->number_of_socket_calls++;
+ return socket(domain, type, protocol);
+}
+
+static int test_socket_factory_bind(grpc_socket_factory *factory, int sockfd,
+ const grpc_resolved_address *addr) {
+ test_socket_factory *f = (test_socket_factory *)factory;
+ f->number_of_bind_calls++;
+ return bind(sockfd, (struct sockaddr *)addr->addr, (socklen_t)addr->len);
+}
+
+static int test_socket_factory_compare(grpc_socket_factory *a,
+ grpc_socket_factory *b) {
+ return GPR_ICMP(a, b);
+}
+
+static void test_socket_factory_destroy(grpc_socket_factory *factory) {
+ test_socket_factory *f = (test_socket_factory *)factory;
+ gpr_free(f);
+}
+
+static const grpc_socket_factory_vtable test_socket_factory_vtable = {
+ test_socket_factory_socket, test_socket_factory_bind,
+ test_socket_factory_compare, test_socket_factory_destroy};
+
+static test_socket_factory *test_socket_factory_create(void) {
+ test_socket_factory *factory = gpr_malloc(sizeof(test_socket_factory));
+ grpc_socket_factory_init(&factory->base, &test_socket_factory_vtable);
+ factory->number_of_socket_calls = 0;
+ factory->number_of_bind_calls = 0;
+ return factory;
+}
+
static void test_no_op(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
grpc_udp_server_destroy(&exec_ctx, s, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_no_op_with_start(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
LOG_TEST("test_no_op_with_start");
grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL);
grpc_udp_server_destroy(&exec_ctx, s, NULL);
@@ -115,7 +161,7 @@ static void test_no_op_with_port(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_resolved_address resolved_addr;
struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -131,12 +177,44 @@ static void test_no_op_with_port(void) {
GPR_ASSERT(g_number_of_orphan_calls == 1);
}
+static void test_no_op_with_port_and_socket_factory(void) {
+ g_number_of_orphan_calls = 0;
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_resolved_address resolved_addr;
+ struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
+
+ test_socket_factory *socket_factory = test_socket_factory_create();
+ grpc_arg socket_factory_arg =
+ grpc_socket_factory_to_arg(&socket_factory->base);
+ grpc_channel_args *channel_args =
+ grpc_channel_args_copy_and_add(NULL, &socket_factory_arg, 1);
+ grpc_udp_server *s = grpc_udp_server_create(channel_args);
+ grpc_channel_args_destroy(&exec_ctx, channel_args);
+
+ LOG_TEST("test_no_op_with_port_and_socket_factory");
+
+ memset(&resolved_addr, 0, sizeof(resolved_addr));
+ resolved_addr.len = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
+ on_fd_orphaned));
+ GPR_ASSERT(socket_factory->number_of_socket_calls == 1);
+ GPR_ASSERT(socket_factory->number_of_bind_calls == 1);
+
+ grpc_udp_server_destroy(&exec_ctx, s, NULL);
+ grpc_exec_ctx_finish(&exec_ctx);
+ grpc_socket_factory_unref(&socket_factory->base);
+
+ /* The server had a single FD, which should have been orphaned. */
+ GPR_ASSERT(g_number_of_orphan_calls == 1);
+}
+
static void test_no_op_with_port_and_start(void) {
g_number_of_orphan_calls = 0;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_resolved_address resolved_addr;
struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
LOG_TEST("test_no_op_with_port_and_start");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -160,7 +238,7 @@ static void test_receive(int number_of_clients) {
grpc_resolved_address resolved_addr;
struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr;
int clifd, svrfd;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
int i;
int number_of_reads_before;
gpr_timespec deadline;
@@ -243,6 +321,7 @@ int main(int argc, char **argv) {
test_no_op();
test_no_op_with_start();
test_no_op_with_port();
+ test_no_op_with_port_and_socket_factory();
test_no_op_with_port_and_start();
test_receive(1);
test_receive(10);
diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.c
index 107abbc1b3..51ea51bc12 100644
--- a/test/core/memory_usage/client.c
+++ b/test/core/memory_usage/client.c
@@ -237,6 +237,11 @@ int main(int argc, char **argv) {
0, grpc_slice_from_static_string("Reflector/GetAfterSvrCreation"));
// warmup period
+ for (int i = 0; i < warmup_iterations; i++) {
+ send_snapshot_request(
+ 0, grpc_slice_from_static_string("Reflector/SimpleSnapshot"));
+ }
+
for (call_idx = 0; call_idx < warmup_iterations; ++call_idx) {
init_ping_pong_request(call_idx + 1);
}
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c
index d2b76bae39..b3775e91a7 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.c
@@ -166,10 +166,12 @@ static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
GPR_ASSERT(incoming.count == 1);
GPR_ASSERT(grpc_slice_eq(s, incoming.slices[0]));
- grpc_endpoint_shutdown(&exec_ctx, f.client_ep,
- GRPC_ERROR_CREATE("test_leftover end"));
- grpc_endpoint_shutdown(&exec_ctx, f.server_ep,
- GRPC_ERROR_CREATE("test_leftover end"));
+ grpc_endpoint_shutdown(
+ &exec_ctx, f.client_ep,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
+ grpc_endpoint_shutdown(
+ &exec_ctx, f.server_ep,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
grpc_endpoint_destroy(&exec_ctx, f.client_ep);
grpc_endpoint_destroy(&exec_ctx, f.server_ep);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/security/ssl_server_fuzzer.c b/test/core/security/ssl_server_fuzzer.c
index 7a3612c419..cbbaf9f298 100644
--- a/test/core/security/ssl_server_fuzzer.c
+++ b/test/core/security/ssl_server_fuzzer.c
@@ -115,8 +115,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// server will wait for more data. Explicitly fail the server by shutting down
// the endpoint.
if (!state.done_callback_called) {
- grpc_endpoint_shutdown(&exec_ctx, mock_endpoint,
- GRPC_ERROR_CREATE("Explicit close"));
+ grpc_endpoint_shutdown(
+ &exec_ctx, mock_endpoint,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Explicit close"));
grpc_exec_ctx_flush(&exec_ctx);
}
diff --git a/test/core/support/cpu_test.c b/test/core/support/cpu_test.c
index ca0fe0ccb5..7b9bf6c5e1 100644
--- a/test/core/support/cpu_test.c
+++ b/test/core/support/cpu_test.c
@@ -81,9 +81,12 @@ static void worker_thread(void *arg) {
uint32_t cpu;
unsigned r = 12345678;
unsigned i, j;
- for (i = 0; i < 1000 / grpc_test_slowdown_factor(); i++) {
+ /* Avoid repetitive division calculations */
+ int64_t max_i = 1000 / grpc_test_slowdown_factor();
+ int64_t max_j = 1000000 / grpc_test_slowdown_factor();
+ for (i = 0; i < max_i; i++) {
/* run for a bit - just calculate something random. */
- for (j = 0; j < 1000000 / grpc_test_slowdown_factor(); j++) {
+ for (j = 0; j < max_j; j++) {
r = (r * 17) & ((r - i) | (r * i));
}
cpu = gpr_cpu_current_cpu();
diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c
index ff927385d4..2f7c3dfb85 100644
--- a/test/core/surface/concurrent_connectivity_test.c
+++ b/test/core/surface/concurrent_connectivity_test.c
@@ -109,7 +109,8 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *vargs, grpc_endpoint *tcp,
grpc_tcp_server_acceptor *acceptor) {
gpr_free(acceptor);
struct server_thread_args *args = (struct server_thread_args *)vargs;
- grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE("Connected"));
+ grpc_endpoint_shutdown(exec_ctx, tcp,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
grpc_endpoint_destroy(exec_ctx, tcp);
GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, NULL));
}
diff --git a/test/core/transport/chttp2/hpack_parser_corpus/clusterfuzz-testcase-5298216461402112 b/test/core/transport/chttp2/hpack_parser_corpus/clusterfuzz-testcase-5298216461402112
new file mode 100644
index 0000000000..04d48d6d76
--- /dev/null
+++ b/test/core/transport/chttp2/hpack_parser_corpus/clusterfuzz-testcase-5298216461402112
Binary files differ
diff --git a/test/core/util/mock_endpoint.c b/test/core/util/mock_endpoint.c
index b8fed7e14b..c747297984 100644
--- a/test/core/util/mock_endpoint.c
+++ b/test/core/util/mock_endpoint.c
@@ -89,8 +89,9 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep;
gpr_mu_lock(&m->mu);
if (m->on_read) {
- grpc_closure_sched(exec_ctx, m->on_read, GRPC_ERROR_CREATE_REFERENCING(
- "Endpoint Shutdown", &why, 1));
+ grpc_closure_sched(exec_ctx, m->on_read,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Endpoint Shutdown", &why, 1));
m->on_read = NULL;
}
gpr_mu_unlock(&m->mu);
diff --git a/test/core/util/passthru_endpoint.c b/test/core/util/passthru_endpoint.c
index 5f27f9ae73..121567fc0d 100644
--- a/test/core/util/passthru_endpoint.c
+++ b/test/core/util/passthru_endpoint.c
@@ -75,7 +75,8 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
half *m = (half *)ep;
gpr_mu_lock(&m->parent->mu);
if (m->parent->shutdown) {
- grpc_closure_sched(exec_ctx, cb, GRPC_ERROR_CREATE("Already shutdown"));
+ grpc_closure_sched(
+ exec_ctx, cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown"));
} else if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
grpc_closure_sched(exec_ctx, cb, GRPC_ERROR_NONE);
@@ -98,7 +99,7 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
grpc_error *error = GRPC_ERROR_NONE;
m->parent->stats->num_writes++;
if (m->parent->shutdown) {
- error = GRPC_ERROR_CREATE("Endpoint already shutdown");
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown");
} else if (m->on_read != NULL) {
for (size_t i = 0; i < slices->count; i++) {
grpc_slice_buffer_add(m->on_read_out, grpc_slice_ref(slices->slices[i]));
@@ -126,14 +127,16 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
gpr_mu_lock(&m->parent->mu);
m->parent->shutdown = true;
if (m->on_read) {
- grpc_closure_sched(exec_ctx, m->on_read,
- GRPC_ERROR_CREATE_REFERENCING("Shutdown", &why, 1));
+ grpc_closure_sched(
+ exec_ctx, m->on_read,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1));
m->on_read = NULL;
}
m = other_half(m);
if (m->on_read) {
- grpc_closure_sched(exec_ctx, m->on_read,
- GRPC_ERROR_CREATE_REFERENCING("Shutdown", &why, 1));
+ grpc_closure_sched(
+ exec_ctx, m->on_read,
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1));
m->on_read = NULL;
}
gpr_mu_unlock(&m->parent->mu);
diff --git a/test/core/util/reconnect_server.c b/test/core/util/reconnect_server.c
index 7fbd0ca6aa..90af1c107b 100644
--- a/test/core/util/reconnect_server.c
+++ b/test/core/util/reconnect_server.c
@@ -80,7 +80,8 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
timestamp_list *new_tail;
peer = grpc_endpoint_get_peer(tcp);
- grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE("Connected"));
+ grpc_endpoint_shutdown(exec_ctx, tcp,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
grpc_endpoint_destroy(exec_ctx, tcp);
if (peer) {
last_colon = strrchr(peer, ':');