diff options
Diffstat (limited to 'test/core/channel')
-rw-r--r-- | test/core/channel/BUILD | 12 | ||||
-rw-r--r-- | test/core/channel/channel_args_test.cc (renamed from test/core/channel/channel_args_test.c) | 6 | ||||
-rw-r--r-- | test/core/channel/channel_stack_builder_test.cc (renamed from test/core/channel/channel_stack_builder_test.c) | 5 | ||||
-rw-r--r-- | test/core/channel/channel_stack_test.cc (renamed from test/core/channel/channel_stack_test.c) | 29 | ||||
-rw-r--r-- | test/core/channel/minimal_stack_is_minimal_test.cc (renamed from test/core/channel/minimal_stack_is_minimal_test.c) | 20 |
5 files changed, 41 insertions, 31 deletions
diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index 5ac77c449b..92f5907aac 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -20,8 +20,8 @@ licenses(["notice"]) # Apache v2 grpc_cc_test( name = "channel_args_test", - srcs = ["channel_args_test.c"], - language = "C", + srcs = ["channel_args_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -32,8 +32,8 @@ grpc_cc_test( grpc_cc_test( name = "channel_stack_test", - srcs = ["channel_stack_test.c"], - language = "C", + srcs = ["channel_stack_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -44,8 +44,8 @@ grpc_cc_test( grpc_cc_test( name = "channel_stack_builder_test", - srcs = ["channel_stack_builder_test.c"], - language = "C", + srcs = ["channel_stack_builder_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", diff --git a/test/core/channel/channel_args_test.c b/test/core/channel/channel_args_test.cc index 85baa990cd..4b4bd3e718 100644 --- a/test/core/channel/channel_args_test.c +++ b/test/core/channel/channel_args_test.cc @@ -33,13 +33,13 @@ static void test_create(void) { grpc_arg to_add[2]; grpc_channel_args* ch_args; - arg_int.key = "int_arg"; + arg_int.key = const_cast<char*>("int_arg"); arg_int.type = GRPC_ARG_INTEGER; arg_int.value.integer = 123; - arg_string.key = "str key"; + arg_string.key = const_cast<char*>("str key"); arg_string.type = GRPC_ARG_STRING; - arg_string.value.string = "str value"; + arg_string.value.string = const_cast<char*>("str value"); to_add[0] = arg_int; to_add[1] = arg_string; diff --git a/test/core/channel/channel_stack_builder_test.c b/test/core/channel/channel_stack_builder_test.cc index 2a5920c673..1571f6ec09 100644 --- a/test/core/channel/channel_stack_builder_test.c +++ b/test/core/channel/channel_stack_builder_test.cc @@ -63,7 +63,7 @@ bool g_replacement_fn_called = false; bool g_original_fn_called = false; void set_arg_once_fn(grpc_channel_stack* channel_stack, grpc_channel_element* elem, void* arg) { - bool* called = arg; + bool* called = static_cast<bool*>(arg); // Make sure this function is only called once per arg. GPR_ASSERT(*called == false); *called = true; @@ -109,7 +109,8 @@ const grpc_channel_filter original_filter = { static bool add_replacement_filter(grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) { - const grpc_channel_filter* filter = arg; + const grpc_channel_filter* filter = + static_cast<const grpc_channel_filter*>(arg); // Get rid of any other version of the filter, as determined by having the // same name. GPR_ASSERT(grpc_channel_stack_builder_remove_filter(builder, filter->name)); diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.cc index aff3fb24b7..1b661ac2f4 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.cc @@ -69,12 +69,13 @@ static void channel_func(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, static void free_channel(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - grpc_channel_stack_destroy(exec_ctx, arg); + grpc_channel_stack_destroy(exec_ctx, static_cast<grpc_channel_stack*>(arg)); gpr_free(arg); } static void free_call(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - grpc_call_stack_destroy(exec_ctx, arg, NULL, NULL); + grpc_call_stack_destroy(exec_ctx, static_cast<grpc_call_stack*>(arg), NULL, + NULL); gpr_free(arg); } @@ -104,13 +105,14 @@ static void test_create_channel_stack(void) { grpc_slice path = grpc_slice_from_static_string("/service/method"); arg.type = GRPC_ARG_INTEGER; - arg.key = "test_key"; + arg.key = const_cast<char*>("test_key"); arg.value.integer = 42; chan_args.num_args = 1; chan_args.args = &arg; - channel_stack = gpr_malloc(grpc_channel_stack_size(&filters, 1)); + channel_stack = static_cast<grpc_channel_stack*>( + gpr_malloc(grpc_channel_stack_size(&filters, 1))); grpc_channel_stack_init(&exec_ctx, 1, free_channel, channel_stack, &filters, 1, &chan_args, NULL, "test", channel_stack); GPR_ASSERT(channel_stack->count == 1); @@ -118,15 +120,18 @@ static void test_create_channel_stack(void) { channel_data = (int*)channel_elem->channel_data; GPR_ASSERT(*channel_data == 0); - call_stack = gpr_malloc(channel_stack->call_stack_size); + call_stack = + static_cast<grpc_call_stack*>(gpr_malloc(channel_stack->call_stack_size)); 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 = GRPC_MILLIS_INF_FUTURE, - .arena = NULL}; + call_stack, /* call_stack */ + nullptr, /* server_transport_data */ + nullptr, /* context */ + path, /* path */ + gpr_now(GPR_CLOCK_MONOTONIC), /* start_time */ + GRPC_MILLIS_INF_FUTURE, /* deadline */ + nullptr, /* arena */ + nullptr /* call_combiner */ + }; grpc_error* error = grpc_call_stack_init(&exec_ctx, channel_stack, 1, free_call, call_stack, &args); GPR_ASSERT(error == GRPC_ERROR_NONE); diff --git a/test/core/channel/minimal_stack_is_minimal_test.c b/test/core/channel/minimal_stack_is_minimal_test.cc index a43305aa37..c54ff2e01b 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.c +++ b/test/core/channel/minimal_stack_is_minimal_test.cc @@ -61,11 +61,11 @@ int main(int argc, char** argv) { int errors = 0; // tests with a minimal stack - grpc_arg minimal_stack_arg = {.type = GRPC_ARG_INTEGER, - .key = GRPC_ARG_MINIMAL_STACK, - .value.integer = 1}; - grpc_channel_args minimal_stack_args = {.num_args = 1, - .args = &minimal_stack_arg}; + grpc_arg minimal_stack_arg; + minimal_stack_arg.type = GRPC_ARG_INTEGER; + minimal_stack_arg.key = const_cast<char*>(GRPC_ARG_MINIMAL_STACK); + minimal_stack_arg.value.integer = 1; + grpc_channel_args minimal_stack_args = {1, &minimal_stack_arg}; errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL, "connected", NULL); errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, @@ -114,8 +114,10 @@ static int check_stack(const char* file, int line, const char* transport_name, unsigned channel_stack_type, ...) { // create dummy channel stack grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); - grpc_transport_vtable fake_transport_vtable = {.name = transport_name}; - grpc_transport fake_transport = {.vtable = &fake_transport_vtable}; + grpc_transport_vtable fake_transport_vtable; + memset(&fake_transport_vtable, 0, sizeof(grpc_transport_vtable)); + fake_transport_vtable.name = transport_name; + grpc_transport fake_transport = {&fake_transport_vtable}; grpc_channel_stack_builder_set_target(builder, "foo.test.google.fr"); grpc_channel_args* channel_args = grpc_channel_args_copy(init_args); if (transport_name != NULL) { @@ -195,7 +197,9 @@ static int check_stack(const char* file, int line, const char* transport_name, gpr_log( file, line, GPR_LOG_SEVERITY_ERROR, "FAILED transport=%s; stack_type=%s; channel_args=%s:", transport_name, - grpc_channel_stack_type_string(channel_stack_type), args_str); + grpc_channel_stack_type_string( + static_cast<grpc_channel_stack_type>(channel_stack_type)), + args_str); gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "EXPECTED: %s", expect); gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "GOT: %s", got); result = 1; |