diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-11-06 14:39:17 -0800 |
---|---|---|
committer | Yash Tibrewal <yashkt@google.com> | 2017-11-06 14:43:31 -0800 |
commit | 40422d5fa621624868280094efb2f01c2cd1352b (patch) | |
tree | cbb2baa955e11c03fa004e9e0f4f3037ba3d6150 /test/core/channel | |
parent | aae4ca01a315a69fcf182d09aea1efdfcda13d48 (diff) | |
parent | e759d2ad7abdb0702970eeccc5f033ff4b2a4c7f (diff) |
Merge master
Diffstat (limited to 'test/core/channel')
-rw-r--r-- | test/core/channel/channel_args_test.cc | 14 | ||||
-rw-r--r-- | test/core/channel/channel_stack_builder_test.cc | 62 | ||||
-rw-r--r-- | test/core/channel/channel_stack_test.cc | 82 | ||||
-rw-r--r-- | test/core/channel/minimal_stack_is_minimal_test.cc | 44 |
4 files changed, 101 insertions, 101 deletions
diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc index 08dd1f47e3..4b4bd3e718 100644 --- a/test/core/channel/channel_args_test.cc +++ b/test/core/channel/channel_args_test.cc @@ -31,15 +31,15 @@ static void test_create(void) { grpc_arg arg_int; grpc_arg arg_string; grpc_arg to_add[2]; - grpc_channel_args *ch_args; + grpc_channel_args* ch_args; - arg_int.key = const_cast<char *>("int_arg"); + arg_int.key = const_cast<char*>("int_arg"); arg_int.type = GRPC_ARG_INTEGER; arg_int.value.integer = 123; - arg_string.key = const_cast<char *>("str key"); + arg_string.key = const_cast<char*>("str key"); arg_string.type = GRPC_ARG_STRING; - arg_string.value.string = const_cast<char *>("str value"); + arg_string.value.string = const_cast<char*>("str value"); to_add[0] = arg_int; to_add[1] = arg_string; @@ -61,7 +61,7 @@ static void test_create(void) { static void test_set_compression_algorithm(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_channel_args *ch_args; + grpc_channel_args* ch_args; ch_args = grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_GZIP); @@ -127,7 +127,7 @@ static void test_compression_algorithm_states(void) { } static void test_set_socket_mutator(void) { - grpc_channel_args *ch_args; + grpc_channel_args* ch_args; grpc_socket_mutator mutator; grpc_socket_mutator_init(&mutator, NULL); @@ -143,7 +143,7 @@ static void test_set_socket_mutator(void) { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_create(); diff --git a/test/core/channel/channel_stack_builder_test.cc b/test/core/channel/channel_stack_builder_test.cc index f9129605e9..1571f6ec09 100644 --- a/test/core/channel/channel_stack_builder_test.cc +++ b/test/core/channel/channel_stack_builder_test.cc @@ -29,30 +29,30 @@ #include "src/core/lib/surface/channel_init.h" #include "test/core/util/test_config.h" -static grpc_error *channel_init_func(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { +static grpc_error* channel_init_func(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, + grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } -static grpc_error *call_init_func(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { +static grpc_error* call_init_func(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_element_args* args) { return GRPC_ERROR_NONE; } -static void channel_destroy_func(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) {} +static void channel_destroy_func(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem) {} -static void call_destroy_func(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) {} +static void call_destroy_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) {} -static void call_func(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_transport_stream_op_batch *op) {} +static void call_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + grpc_transport_stream_op_batch* op) {} -static void channel_func(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, - grpc_transport_op *op) { +static void channel_func(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, + grpc_transport_op* op) { if (op->disconnect_with_error != GRPC_ERROR_NONE) { GRPC_ERROR_UNREF(op->disconnect_with_error); } @@ -61,16 +61,16 @@ static void channel_func(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, 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 = static_cast<bool *>(arg); +void set_arg_once_fn(grpc_channel_stack* channel_stack, + grpc_channel_element* elem, void* arg) { + bool* called = static_cast<bool*>(arg); // Make sure this function is only called once per arg. GPR_ASSERT(*called == false); *called = true; } static void test_channel_stack_builder_filter_replace(void) { - grpc_channel *channel = + grpc_channel* channel = grpc_insecure_channel_create("target name isn't used", NULL, NULL); GPR_ASSERT(channel != NULL); // Make sure the high priority filter has been created. @@ -106,11 +106,11 @@ const grpc_channel_filter original_filter = { grpc_channel_next_get_info, "filter_name"}; -static bool add_replacement_filter(grpc_exec_ctx *exec_ctx, - grpc_channel_stack_builder *builder, - void *arg) { - const grpc_channel_filter *filter = - static_cast<const grpc_channel_filter *>(arg); +static bool add_replacement_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, + void* 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)); @@ -118,26 +118,26 @@ static bool add_replacement_filter(grpc_exec_ctx *exec_ctx, builder, filter, set_arg_once_fn, &g_replacement_fn_called); } -static bool add_original_filter(grpc_exec_ctx *exec_ctx, - grpc_channel_stack_builder *builder, - void *arg) { +static bool add_original_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, + void* arg) { return grpc_channel_stack_builder_prepend_filter( - builder, (const grpc_channel_filter *)arg, set_arg_once_fn, + builder, (const grpc_channel_filter*)arg, set_arg_once_fn, &g_original_fn_called); } static void init_plugin(void) { grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, add_original_filter, - (void *)&original_filter); + (void*)&original_filter); grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, add_replacement_filter, - (void *)&replacement_filter); + (void*)&replacement_filter); } static void destroy_plugin(void) {} -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_register_plugin(init_plugin, destroy_plugin); grpc_init(); diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc index 88007375b2..1b661ac2f4 100644 --- a/test/core/channel/channel_stack_test.cc +++ b/test/core/channel/channel_stack_test.cc @@ -27,54 +27,54 @@ #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" -static grpc_error *channel_init_func(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { +static grpc_error* channel_init_func(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, + grpc_channel_element_args* args) { GPR_ASSERT(args->channel_args->num_args == 1); GPR_ASSERT(args->channel_args->args[0].type == GRPC_ARG_INTEGER); GPR_ASSERT(0 == strcmp(args->channel_args->args[0].key, "test_key")); GPR_ASSERT(args->channel_args->args[0].value.integer == 42); GPR_ASSERT(args->is_first); GPR_ASSERT(args->is_last); - *(int *)(elem->channel_data) = 0; + *(int*)(elem->channel_data) = 0; return GRPC_ERROR_NONE; } -static grpc_error *call_init_func(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { - ++*(int *)(elem->channel_data); - *(int *)(elem->call_data) = 0; +static grpc_error* call_init_func(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_element_args* args) { + ++*(int*)(elem->channel_data); + *(int*)(elem->call_data) = 0; return GRPC_ERROR_NONE; } -static void channel_destroy_func(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) {} +static void channel_destroy_func(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem) {} -static void call_destroy_func(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) { - ++*(int *)(elem->channel_data); +static void call_destroy_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { + ++*(int*)(elem->channel_data); } -static void call_func(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_transport_stream_op_batch *op) { - ++*(int *)(elem->call_data); +static void call_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + grpc_transport_stream_op_batch* op) { + ++*(int*)(elem->call_data); } -static void channel_func(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, - grpc_transport_op *op) { - ++*(int *)(elem->channel_data); +static void channel_func(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, + grpc_transport_op* op) { + ++*(int*)(elem->channel_data); } -static void free_channel(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - grpc_channel_stack_destroy(exec_ctx, static_cast<grpc_channel_stack *>(arg)); +static void free_channel(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + 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, static_cast<grpc_call_stack *>(arg), NULL, +static void free_call(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + grpc_call_stack_destroy(exec_ctx, static_cast<grpc_call_stack*>(arg), NULL, NULL); gpr_free(arg); } @@ -92,36 +92,36 @@ static void test_create_channel_stack(void) { channel_destroy_func, grpc_channel_next_get_info, "some_test_filter"}; - const grpc_channel_filter *filters = &filter; - grpc_channel_stack *channel_stack; - grpc_call_stack *call_stack; - grpc_channel_element *channel_elem; - grpc_call_element *call_elem; + const grpc_channel_filter* filters = &filter; + grpc_channel_stack* channel_stack; + grpc_call_stack* call_stack; + grpc_channel_element* channel_elem; + grpc_call_element* call_elem; grpc_arg arg; grpc_channel_args chan_args; - int *channel_data; - int *call_data; + int* channel_data; + int* call_data; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_slice path = grpc_slice_from_static_string("/service/method"); arg.type = GRPC_ARG_INTEGER; - arg.key = const_cast<char *>("test_key"); + arg.key = const_cast<char*>("test_key"); arg.value.integer = 42; chan_args.num_args = 1; chan_args.args = &arg; - channel_stack = static_cast<grpc_channel_stack *>( + 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); channel_elem = grpc_channel_stack_element(channel_stack, 0); - channel_data = (int *)channel_elem->channel_data; + channel_data = (int*)channel_elem->channel_data; GPR_ASSERT(*channel_data == 0); - call_stack = static_cast<grpc_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 */ nullptr, /* server_transport_data */ @@ -132,14 +132,14 @@ static void test_create_channel_stack(void) { nullptr, /* arena */ nullptr /* call_combiner */ }; - grpc_error *error = grpc_call_stack_init(&exec_ctx, channel_stack, 1, + 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); GPR_ASSERT(call_elem->filter == channel_elem->filter); GPR_ASSERT(call_elem->channel_data == channel_elem->channel_data); - call_data = (int *)call_elem->call_data; + call_data = (int*)call_elem->call_data; GPR_ASSERT(*call_data == 0); GPR_ASSERT(*channel_data == 1); @@ -153,7 +153,7 @@ static void test_create_channel_stack(void) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_create_channel_stack(); diff --git a/test/core/channel/minimal_stack_is_minimal_test.cc b/test/core/channel/minimal_stack_is_minimal_test.cc index 5884893be3..c54ff2e01b 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.cc +++ b/test/core/channel/minimal_stack_is_minimal_test.cc @@ -42,8 +42,8 @@ #include "test/core/util/test_config.h" // use CHECK_STACK instead -static int check_stack(const char *file, int line, const char *transport_name, - grpc_channel_args *init_args, +static int check_stack(const char* file, int line, const char* transport_name, + grpc_channel_args* init_args, unsigned channel_stack_type, ...); // arguments: const char *transport_name - the name of the transport type to @@ -55,7 +55,7 @@ static int check_stack(const char *file, int line, const char *transport_name, // filters to instantiate, terminated with NULL #define CHECK_STACK(...) check_stack(__FILE__, __LINE__, __VA_ARGS__) -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); int errors = 0; @@ -63,7 +63,7 @@ int main(int argc, char **argv) { // tests with a minimal stack 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.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, @@ -109,17 +109,17 @@ int main(int argc, char **argv) { * End of tests definitions, start of test infrastructure */ -static int check_stack(const char *file, int line, const char *transport_name, - grpc_channel_args *init_args, +static int check_stack(const char* file, int line, const char* transport_name, + grpc_channel_args* init_args, unsigned channel_stack_type, ...) { // create dummy channel stack - grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create(); + grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); 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); + grpc_channel_args* channel_args = grpc_channel_args_copy(init_args); if (transport_name != NULL) { grpc_channel_stack_builder_set_transport(builder, &fake_transport); } @@ -138,26 +138,26 @@ static int check_stack(const char *file, int line, const char *transport_name, va_list args; va_start(args, channel_stack_type); for (;;) { - char *a = va_arg(args, char *); + char* a = va_arg(args, char*); if (a == NULL) break; if (v.count != 0) gpr_strvec_add(&v, gpr_strdup(", ")); gpr_strvec_add(&v, gpr_strdup(a)); } va_end(args); - char *expect = gpr_strvec_flatten(&v, NULL); + char* expect = gpr_strvec_flatten(&v, NULL); gpr_strvec_destroy(&v); // build up our "got" list gpr_strvec_init(&v); - grpc_channel_stack_builder_iterator *it = + grpc_channel_stack_builder_iterator* it = grpc_channel_stack_builder_create_iterator_at_first(builder); while (grpc_channel_stack_builder_move_next(it)) { - const char *name = grpc_channel_stack_builder_iterator_filter_name(it); + const char* name = grpc_channel_stack_builder_iterator_filter_name(it); if (name == NULL) continue; if (v.count != 0) gpr_strvec_add(&v, gpr_strdup(", ")); gpr_strvec_add(&v, gpr_strdup(name)); } - char *got = gpr_strvec_flatten(&v, NULL); + char* got = gpr_strvec_flatten(&v, NULL); gpr_strvec_destroy(&v); grpc_channel_stack_builder_iterator_destroy(it); @@ -172,7 +172,7 @@ static int check_stack(const char *file, int line, const char *transport_name, gpr_strvec_add(&v, gpr_strdup("=")); switch (channel_args->args[i].type) { case GRPC_ARG_INTEGER: { - char *tmp; + char* tmp; gpr_asprintf(&tmp, "%d", channel_args->args[i].value.integer); gpr_strvec_add(&v, tmp); break; @@ -181,7 +181,7 @@ static int check_stack(const char *file, int line, const char *transport_name, gpr_strvec_add(&v, gpr_strdup(channel_args->args[i].value.string)); break; case GRPC_ARG_POINTER: { - char *tmp; + char* tmp; gpr_asprintf(&tmp, "%p", channel_args->args[i].value.pointer.p); gpr_strvec_add(&v, tmp); break; @@ -189,17 +189,17 @@ static int check_stack(const char *file, int line, const char *transport_name, } } gpr_strvec_add(&v, gpr_strdup("}")); - char *args_str = gpr_strvec_flatten(&v, NULL); + char* args_str = gpr_strvec_flatten(&v, NULL); gpr_strvec_destroy(&v); gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "**************************************************"); - gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, - "FAILED transport=%s; stack_type=%s; channel_args=%s:", - transport_name, - grpc_channel_stack_type_string( - static_cast<grpc_channel_stack_type>(channel_stack_type)), - args_str); + gpr_log( + file, line, GPR_LOG_SEVERITY_ERROR, + "FAILED transport=%s; stack_type=%s; channel_args=%s:", transport_name, + 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; |