aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/client_channel
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-10-23 15:33:21 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2017-10-25 16:23:01 -0700
commit34a57d0346afe95e11104462c30dc468b0cb0b89 (patch)
tree67db15f7b8b361e0618199dc55215f3b4d626201 /test/core/client_channel
parentc563b583cb9b7fecc33971581368796d2df4759d (diff)
rename all test core files to cc and a lot of C++ style conversions
Diffstat (limited to 'test/core/client_channel')
-rw-r--r--test/core/client_channel/lb_policies_test.cc (renamed from test/core/client_channel/lb_policies_test.c)106
-rw-r--r--test/core/client_channel/parse_address_test.cc (renamed from test/core/client_channel/parse_address_test.c)0
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc (renamed from test/core/client_channel/resolvers/dns_resolver_connectivity_test.c)12
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_test.cc (renamed from test/core/client_channel/resolvers/dns_resolver_test.c)0
-rw-r--r--test/core/client_channel/resolvers/fake_resolver_test.cc (renamed from test/core/client_channel/resolvers/fake_resolver_test.c)6
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.cc (renamed from test/core/client_channel/resolvers/sockaddr_resolver_test.c)2
-rw-r--r--test/core/client_channel/uri_fuzzer_test.cc (renamed from test/core/client_channel/uri_fuzzer_test.c)2
-rw-r--r--test/core/client_channel/uri_parser_test.cc (renamed from test/core/client_channel/uri_parser_test.c)0
8 files changed, 77 insertions, 51 deletions
diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.cc
index ba37cd673f..4379af11da 100644
--- a/test/core/client_channel/lb_policies_test.c
+++ b/test/core/client_channel/lb_policies_test.cc
@@ -88,14 +88,16 @@ static test_spec *test_spec_create(size_t num_iters, size_t num_servers) {
test_spec *spec;
size_t i;
- spec = gpr_malloc(sizeof(test_spec));
+ spec = static_cast<test_spec *>(gpr_malloc(sizeof(test_spec)));
spec->num_iters = num_iters;
spec->num_servers = num_servers;
- spec->kill_at = gpr_malloc(sizeof(int *) * num_iters);
- spec->revive_at = gpr_malloc(sizeof(int *) * num_iters);
+ spec->kill_at = static_cast<int **>(gpr_malloc(sizeof(int *) * num_iters));
+ spec->revive_at = static_cast<int **>(gpr_malloc(sizeof(int *) * num_iters));
for (i = 0; i < num_iters; i++) {
- spec->kill_at[i] = gpr_malloc(sizeof(int) * num_servers);
- spec->revive_at[i] = gpr_malloc(sizeof(int) * num_servers);
+ spec->kill_at[i] =
+ static_cast<int *>(gpr_malloc(sizeof(int) * num_servers));
+ spec->revive_at[i] =
+ static_cast<int *>(gpr_malloc(sizeof(int) * num_servers));
}
test_spec_reset(spec);
@@ -172,16 +174,20 @@ static void revive_server(const servers_fixture *f, request_data *rdata,
static servers_fixture *setup_servers(const char *server_host,
request_data *rdata,
const size_t num_servers) {
- servers_fixture *f = gpr_malloc(sizeof(servers_fixture));
+ servers_fixture *f =
+ static_cast<servers_fixture *>(gpr_malloc(sizeof(servers_fixture)));
size_t i;
f->num_servers = num_servers;
- f->server_calls = gpr_malloc(sizeof(grpc_call *) * num_servers);
- f->request_metadata_recv =
- gpr_malloc(sizeof(grpc_metadata_array) * num_servers);
+ f->server_calls =
+ static_cast<grpc_call **>(gpr_malloc(sizeof(grpc_call *) * num_servers));
+ f->request_metadata_recv = static_cast<grpc_metadata_array *>(
+ gpr_malloc(sizeof(grpc_metadata_array) * num_servers));
/* Create servers. */
- f->servers = gpr_malloc(sizeof(grpc_server *) * num_servers);
- f->servers_hostports = gpr_malloc(sizeof(char *) * num_servers);
+ f->servers = static_cast<grpc_server **>(
+ gpr_malloc(sizeof(grpc_server *) * num_servers));
+ f->servers_hostports =
+ static_cast<char **>(gpr_malloc(sizeof(char *) * num_servers));
f->cq = grpc_completion_queue_create_for_next(NULL);
f->shutdown_cq = grpc_completion_queue_create_for_pluck(NULL);
for (i = 0; i < num_servers; i++) {
@@ -226,8 +232,10 @@ static void teardown_servers(servers_fixture *f) {
static request_sequences request_sequences_create(size_t n) {
request_sequences res;
res.n = n;
- res.connections = gpr_malloc(sizeof(*res.connections) * n);
- res.connectivity_states = gpr_malloc(sizeof(*res.connectivity_states) * n);
+ res.connections =
+ static_cast<int *>(gpr_malloc(sizeof(*res.connections) * n));
+ res.connectivity_states =
+ static_cast<int *>(gpr_malloc(sizeof(*res.connectivity_states) * n));
memset(res.connections, 0, sizeof(*res.connections) * n);
memset(res.connectivity_states, 0, sizeof(*res.connectivity_states) * n);
return res;
@@ -255,7 +263,7 @@ static request_sequences perform_request(servers_fixture *f,
int completed_client;
const request_sequences sequences = request_sequences_create(spec->num_iters);
- s_valid = gpr_malloc(sizeof(int) * f->num_servers);
+ s_valid = static_cast<int *>(gpr_malloc(sizeof(int) * f->num_servers));
for (iter_num = 0; iter_num < spec->num_iters; iter_num++) {
cq_verifier *cqv = cq_verifier_create(f->cq);
@@ -426,7 +434,8 @@ static grpc_call **perform_multirequest(servers_fixture *f,
grpc_op *op;
size_t i;
- calls = gpr_malloc(sizeof(grpc_call *) * concurrent_calls);
+ calls = static_cast<grpc_call **>(
+ gpr_malloc(sizeof(grpc_call *) * concurrent_calls));
for (i = 0; i < f->num_servers; i++) {
kill_server(f, i);
}
@@ -465,8 +474,8 @@ void run_spec(const test_spec *spec) {
servers_fixture *f;
grpc_channel_args args;
grpc_arg arg_array[2];
- rdata.call_details =
- gpr_malloc(sizeof(grpc_call_details) * spec->num_servers);
+ rdata.call_details = static_cast<grpc_call_details *>(
+ gpr_malloc(sizeof(grpc_call_details) * spec->num_servers));
f = setup_servers("127.0.0.1", &rdata, spec->num_servers);
/* Create client. */
@@ -475,11 +484,12 @@ void run_spec(const test_spec *spec) {
gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str);
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].key =
+ const_cast<char *>("grpc.testing.fixed_reconnect_backoff_ms");
arg_array[0].value.integer = RETRY_TIMEOUT;
arg_array[1].type = GRPC_ARG_STRING;
- arg_array[1].key = GRPC_ARG_LB_POLICY_NAME;
- arg_array[1].value.string = "round_robin";
+ arg_array[1].key = const_cast<char *>(GRPC_ARG_LB_POLICY_NAME);
+ arg_array[1].value.string = const_cast<char *>("round_robin");
args.num_args = 2;
args.args = arg_array;
@@ -513,13 +523,15 @@ static grpc_channel *create_client(const servers_fixture *f) {
gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str);
arg_array[0].type = GRPC_ARG_INTEGER;
- arg_array[0].key = "grpc.testing.fixed_reconnect_backoff_ms";
+ arg_array[0].key =
+ const_cast<char *>("grpc.testing.fixed_reconnect_backoff_ms");
arg_array[0].value.integer = RETRY_TIMEOUT;
arg_array[1].type = GRPC_ARG_STRING;
- arg_array[1].key = GRPC_ARG_LB_POLICY_NAME;
- arg_array[1].value.string = "ROUND_ROBIN";
+ arg_array[1].key = const_cast<char *>(GRPC_ARG_LB_POLICY_NAME);
+ arg_array[1].value.string = const_cast<char *>("ROUND_ROBIN");
arg_array[2].type = GRPC_ARG_INTEGER;
- arg_array[2].key = GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS;
+ arg_array[2].key =
+ const_cast<char *>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS);
arg_array[2].value.integer = 0;
args.num_args = GPR_ARRAY_SIZE(arg_array);
args.args = arg_array;
@@ -540,7 +552,8 @@ static void test_ping() {
const size_t num_servers = 1;
int i;
- rdata.call_details = gpr_malloc(sizeof(grpc_call_details) * num_servers);
+ rdata.call_details = static_cast<grpc_call_details *>(
+ gpr_malloc(sizeof(grpc_call_details) * num_servers));
f = setup_servers("127.0.0.1", &rdata, num_servers);
cqv = cq_verifier_create(f->cq);
@@ -585,8 +598,8 @@ static void test_pending_calls(size_t concurrent_calls) {
request_data rdata;
servers_fixture *f;
test_spec *spec = test_spec_create(0, 4);
- rdata.call_details =
- gpr_malloc(sizeof(grpc_call_details) * spec->num_servers);
+ rdata.call_details = static_cast<grpc_call_details *>(
+ gpr_malloc(sizeof(grpc_call_details) * spec->num_servers));
f = setup_servers("127.0.0.1", &rdata, spec->num_servers);
client = create_client(f);
@@ -626,7 +639,7 @@ static void test_get_channel_info() {
gpr_free(lb_policy_name);
// Request service config, which does not exist, so we'll get nothing back.
memset(&channel_info, 0, sizeof(channel_info));
- char *service_config_json = "dummy_string";
+ char *service_config_json = const_cast<char *>("dummy_string");
channel_info.service_config_json = &service_config_json;
grpc_channel_get_info(channel, &channel_info);
GPR_ASSERT(service_config_json == NULL);
@@ -634,8 +647,9 @@ static void test_get_channel_info() {
grpc_channel_destroy(channel);
grpc_arg arg;
arg.type = GRPC_ARG_STRING;
- arg.key = GRPC_ARG_SERVICE_CONFIG;
- arg.value.string = "{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}";
+ arg.key = const_cast<char *>(GRPC_ARG_SERVICE_CONFIG);
+ arg.value.string =
+ const_cast<char *>("{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}");
grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, NULL);
{
@@ -676,7 +690,7 @@ static void verify_vanilla_round_robin(const servers_fixture *f,
/* verify conn. seq. expectation */
/* get the first sequence of "num_servers" elements */
int *expected_connection_sequence =
- gpr_malloc(sizeof(int) * expected_seq_length);
+ static_cast<int *>(gpr_malloc(sizeof(int) * expected_seq_length));
memcpy(expected_connection_sequence, sequences->connections,
sizeof(int) * expected_seq_length);
@@ -695,7 +709,8 @@ static void verify_vanilla_round_robin(const servers_fixture *f,
/* All servers are available, therefore all client subchannels are READY, even
* when we only need one for the client channel state to be READY */
for (size_t i = 0; i < sequences->n; i++) {
- const grpc_connectivity_state actual = sequences->connectivity_states[i];
+ const grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[i]);
const grpc_connectivity_state expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -721,7 +736,8 @@ static void verify_vanishing_floor_round_robin(
/* verify conn. seq. expectation */
/* copy the first full sequence (without -1s) */
- expected_connection_sequence = gpr_malloc(sizeof(int) * expected_seq_length);
+ expected_connection_sequence =
+ static_cast<int *>(gpr_malloc(sizeof(int) * expected_seq_length));
memcpy(expected_connection_sequence, sequences->connections + 2,
expected_seq_length * sizeof(int));
@@ -750,7 +766,8 @@ static void verify_vanishing_floor_round_robin(
/* There's always at least one subchannel READY (connected), therefore the
* overall state of the client channel is READY at all times. */
for (i = 0; i < sequences->n; i++) {
- const grpc_connectivity_state actual = sequences->connectivity_states[i];
+ const grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[i]);
const grpc_connectivity_state expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -785,7 +802,8 @@ static void verify_total_carnage_round_robin(const servers_fixture *f,
* Note that all other states (IDLE, CONNECTING, TRANSIENT_FAILURE) are still
* possible, as the policy transitions while attempting to reconnect. */
for (size_t i = 0; i < sequences->n; i++) {
- const grpc_connectivity_state actual = sequences->connectivity_states[i];
+ const grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[i]);
if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) {
gpr_log(GPR_ERROR,
"CONNECTIVITY STATUS SEQUENCE FAILURE: got unexpected state "
@@ -805,7 +823,8 @@ static void verify_partial_carnage_round_robin(
/* verify conn. seq. expectation */
/* get the first sequence of "num_servers" elements */
- expected_connection_sequence = gpr_malloc(sizeof(int) * expected_seq_length);
+ expected_connection_sequence =
+ static_cast<int *>(gpr_malloc(sizeof(int) * expected_seq_length));
memcpy(expected_connection_sequence, sequences->connections,
sizeof(int) * expected_seq_length);
@@ -827,7 +846,8 @@ static void verify_partial_carnage_round_robin(
/* We can assert that the first client channel state should be READY, when all
* servers were available */
- grpc_connectivity_state actual = sequences->connectivity_states[0];
+ grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[0]);
grpc_connectivity_state expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -841,7 +861,8 @@ static void verify_partial_carnage_round_robin(
/* ... and that the last one shouldn't be READY (or SHUTDOWN): all servers are
* gone. It may be all other states (IDLE, CONNECTING, TRANSIENT_FAILURE), as
* the policy transitions while attempting to reconnect. */
- actual = sequences->connectivity_states[num_iters - 1];
+ actual = static_cast<grpc_connectivity_state>(
+ sequences->connectivity_states[num_iters - 1]);
for (i = 0; i < sequences->n; i++) {
if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) {
gpr_log(GPR_ERROR,
@@ -894,7 +915,8 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
/* We can assert that the first client channel state should be READY, when all
* servers were available; same thing for the last one. In the middle
* somewhere there must exist at least one TRANSIENT_FAILURE */
- grpc_connectivity_state actual = sequences->connectivity_states[0];
+ grpc_connectivity_state actual =
+ static_cast<grpc_connectivity_state>(sequences->connectivity_states[0]);
grpc_connectivity_state expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -905,7 +927,8 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
abort();
}
- actual = sequences->connectivity_states[num_iters - 1];
+ actual = static_cast<grpc_connectivity_state>(
+ sequences->connectivity_states[num_iters - 1]);
expected = GRPC_CHANNEL_READY;
if (actual != expected) {
gpr_log(GPR_ERROR,
@@ -931,7 +954,8 @@ static void verify_rebirth_round_robin(const servers_fixture *f,
"instead:");
for (size_t i = 0; i < num_iters; i++) {
gpr_log(GPR_ERROR, "[%d]: %s", (int)i,
- grpc_connectivity_state_name(sequences->connectivity_states[i]));
+ grpc_connectivity_state_name(static_cast<grpc_connectivity_state>(
+ sequences->connectivity_states[i])));
}
}
}
diff --git a/test/core/client_channel/parse_address_test.c b/test/core/client_channel/parse_address_test.cc
index d011176869..d011176869 100644
--- a/test/core/client_channel/parse_address_test.c
+++ b/test/core/client_channel/parse_address_test.cc
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
index 4597285063..4dfee8cf90 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
@@ -49,9 +49,11 @@ static void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
} else {
gpr_mu_unlock(&g_mu);
- *addrs = gpr_malloc(sizeof(**addrs));
+ *addrs =
+ static_cast<grpc_resolved_addresses *>(gpr_malloc(sizeof(**addrs)));
(*addrs)->naddrs = 1;
- (*addrs)->addrs = gpr_malloc(sizeof(*(*addrs)->addrs));
+ (*addrs)->addrs = static_cast<grpc_resolved_address *>(
+ gpr_malloc(sizeof(*(*addrs)->addrs)));
(*addrs)->addrs[0].len = 123;
}
GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
@@ -95,7 +97,7 @@ static grpc_resolver *create_resolver(grpc_exec_ctx *exec_ctx,
}
static void on_done(grpc_exec_ctx *exec_ctx, void *ev, grpc_error *error) {
- gpr_event_set(ev, (void *)1);
+ gpr_event_set((gpr_event *)ev, (void *)1);
}
// interleave waiting for an event with a timer check
@@ -121,7 +123,7 @@ typedef struct next_args {
static void call_resolver_next_now_lock_taken(grpc_exec_ctx *exec_ctx,
void *arg,
grpc_error *error_unused) {
- next_args *a = arg;
+ next_args *a = static_cast<next_args *>(arg);
grpc_resolver_next_locked(exec_ctx, a->resolver, a->result, a->on_complete);
gpr_free(a);
}
@@ -130,7 +132,7 @@ static void call_resolver_next_after_locking(grpc_exec_ctx *exec_ctx,
grpc_resolver *resolver,
grpc_channel_args **result,
grpc_closure *on_complete) {
- next_args *a = gpr_malloc(sizeof(*a));
+ next_args *a = static_cast<next_args *>(gpr_malloc(sizeof(*a)));
a->resolver = resolver;
a->result = result;
a->on_complete = on_complete;
diff --git a/test/core/client_channel/resolvers/dns_resolver_test.c b/test/core/client_channel/resolvers/dns_resolver_test.cc
index a14926f173..a14926f173 100644
--- a/test/core/client_channel/resolvers/dns_resolver_test.c
+++ b/test/core/client_channel/resolvers/dns_resolver_test.cc
diff --git a/test/core/client_channel/resolvers/fake_resolver_test.c b/test/core/client_channel/resolvers/fake_resolver_test.cc
index 9b0854d6d8..ed14151ae3 100644
--- a/test/core/client_channel/resolvers/fake_resolver_test.c
+++ b/test/core/client_channel/resolvers/fake_resolver_test.cc
@@ -56,7 +56,7 @@ typedef struct on_resolution_arg {
} on_resolution_arg;
void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- on_resolution_arg *res = arg;
+ on_resolution_arg *res = static_cast<on_resolution_arg *>(arg);
// We only check the addresses channel arg because that's the only one
// explicitly set by the test via
// grpc_fake_resolver_response_generator_set_response.
@@ -84,7 +84,7 @@ static void test_fake_resolver() {
// Setup expectations.
grpc_uri *uris[] = {grpc_uri_parse(&exec_ctx, "ipv4:10.2.1.1:1234", true),
grpc_uri_parse(&exec_ctx, "ipv4:127.0.0.1:4321", true)};
- char *balancer_names[] = {"name1", "name2"};
+ const char *balancer_names[] = {"name1", "name2"};
const bool is_balancer[] = {true, false};
grpc_lb_addresses *addresses = grpc_lb_addresses_create(3, NULL);
for (size_t i = 0; i < GPR_ARRAY_SIZE(uris); ++i) {
@@ -117,7 +117,7 @@ static void test_fake_resolver() {
// Setup update.
grpc_uri *uris_update[] = {
grpc_uri_parse(&exec_ctx, "ipv4:192.168.1.0:31416", true)};
- char *balancer_names_update[] = {"name3"};
+ const char *balancer_names_update[] = {"name3"};
const bool is_balancer_update[] = {false};
grpc_lb_addresses *addresses_update = grpc_lb_addresses_create(1, NULL);
for (size_t i = 0; i < GPR_ARRAY_SIZE(uris_update); ++i) {
diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.c b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
index 8b88619164..254ce59bc2 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.c
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
@@ -36,7 +36,7 @@ typedef struct on_resolution_arg {
} on_resolution_arg;
void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- on_resolution_arg *res = arg;
+ on_resolution_arg *res = static_cast<on_resolution_arg *>(arg);
grpc_channel_args_destroy(exec_ctx, res->resolver_result);
}
diff --git a/test/core/client_channel/uri_fuzzer_test.c b/test/core/client_channel/uri_fuzzer_test.cc
index e51d0031ec..8c071454bc 100644
--- a/test/core/client_channel/uri_fuzzer_test.c
+++ b/test/core/client_channel/uri_fuzzer_test.cc
@@ -29,7 +29,7 @@ bool squelch = true;
bool leak_check = true;
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- char *s = gpr_malloc(size + 1);
+ char *s = static_cast<char *>(gpr_malloc(size + 1));
memcpy(s, data, size);
s[size] = 0;
diff --git a/test/core/client_channel/uri_parser_test.c b/test/core/client_channel/uri_parser_test.cc
index f53cae196b..f53cae196b 100644
--- a/test/core/client_channel/uri_parser_test.c
+++ b/test/core/client_channel/uri_parser_test.cc