diff options
author | 2017-11-08 09:42:32 -0800 | |
---|---|---|
committer | 2017-11-08 09:42:32 -0800 | |
commit | 660d4aa2d281dbfbc6c3a3e3349b3e4b6a444285 (patch) | |
tree | 592cecc1d6670bb12b9af81c19cd3cb98cc0eeef /test/core/surface | |
parent | 48d26966646e910f7dd63d428ef831178ca9315e (diff) | |
parent | d9da7387b8057f3bd99a417a5ee905377bce9296 (diff) |
Merge github.com:grpc/grpc into tfix2
Diffstat (limited to 'test/core/surface')
-rw-r--r-- | test/core/surface/BUILD | 48 | ||||
-rw-r--r-- | test/core/surface/alarm_test.cc (renamed from test/core/surface/alarm_test.c) | 24 | ||||
-rw-r--r-- | test/core/surface/byte_buffer_reader_test.cc (renamed from test/core/surface/byte_buffer_reader_test.c) | 26 | ||||
-rw-r--r-- | test/core/surface/channel_create_test.cc (renamed from test/core/surface/channel_create_test.c) | 6 | ||||
-rw-r--r-- | test/core/surface/completion_queue_test.cc (renamed from test/core/surface/completion_queue_test.c) | 44 | ||||
-rw-r--r-- | test/core/surface/completion_queue_threading_test.cc (renamed from test/core/surface/completion_queue_threading_test.c) | 71 | ||||
-rw-r--r-- | test/core/surface/concurrent_connectivity_test.cc (renamed from test/core/surface/concurrent_connectivity_test.c) | 66 | ||||
-rw-r--r-- | test/core/surface/init_test.cc (renamed from test/core/surface/init_test.c) | 2 | ||||
-rw-r--r-- | test/core/surface/invalid_channel_args_test.cc (renamed from test/core/surface/invalid_channel_args_test.c) | 38 | ||||
-rw-r--r-- | test/core/surface/lame_client_test.cc (renamed from test/core/surface/lame_client_test.c) | 30 | ||||
-rw-r--r-- | test/core/surface/num_external_connectivity_watchers_test.cc (renamed from test/core/surface/num_external_connectivity_watchers_test.c) | 57 | ||||
-rw-r--r-- | test/core/surface/public_headers_must_be_c89.c | 289 | ||||
-rw-r--r-- | test/core/surface/secure_channel_create_test.cc (renamed from test/core/surface/secure_channel_create_test.c) | 18 | ||||
-rw-r--r-- | test/core/surface/sequential_connectivity_test.cc (renamed from test/core/surface/sequential_connectivity_test.c) | 59 | ||||
-rw-r--r-- | test/core/surface/server_chttp2_test.cc (renamed from test/core/surface/server_chttp2_test.c) | 14 | ||||
-rw-r--r-- | test/core/surface/server_test.cc (renamed from test/core/surface/server_test.c) | 49 |
16 files changed, 569 insertions, 272 deletions
diff --git a/test/core/surface/BUILD b/test/core/surface/BUILD index 17db7737f7..6cec7feabc 100644 --- a/test/core/surface/BUILD +++ b/test/core/surface/BUILD @@ -20,8 +20,8 @@ grpc_package(name = "test/core/surface") grpc_cc_test( name = "alarm_test", - srcs = ["alarm_test.c"], - language = "C", + srcs = ["alarm_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -32,8 +32,8 @@ grpc_cc_test( grpc_cc_test( name = "grpc_byte_buffer_reader_test", - srcs = ["byte_buffer_reader_test.c"], - language = "C", + srcs = ["byte_buffer_reader_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -44,8 +44,8 @@ grpc_cc_test( grpc_cc_test( name = "channel_create_test", - srcs = ["channel_create_test.c"], - language = "C", + srcs = ["channel_create_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -56,8 +56,8 @@ grpc_cc_test( grpc_cc_test( name = "grpc_completion_queue_test", - srcs = ["completion_queue_test.c"], - language = "C", + srcs = ["completion_queue_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -68,8 +68,8 @@ grpc_cc_test( grpc_cc_test( name = "concurrent_connectivity_test", - srcs = ["concurrent_connectivity_test.c"], - language = "C", + srcs = ["concurrent_connectivity_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -80,8 +80,8 @@ grpc_cc_test( grpc_cc_test( name = "init_test", - srcs = ["init_test.c"], - language = "C", + srcs = ["init_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -92,8 +92,8 @@ grpc_cc_test( grpc_cc_test( name = "grpc_invalid_channel_args_test", - srcs = ["invalid_channel_args_test.c"], - language = "C", + srcs = ["invalid_channel_args_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -104,8 +104,8 @@ grpc_cc_test( grpc_cc_test( name = "lame_client_test", - srcs = ["lame_client_test.c"], - language = "C", + srcs = ["lame_client_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -129,8 +129,8 @@ grpc_cc_test( grpc_cc_test( name = "secure_channel_create_test", - srcs = ["secure_channel_create_test.c"], - language = "C", + srcs = ["secure_channel_create_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -141,8 +141,8 @@ grpc_cc_test( grpc_cc_test( name = "sequential_connectivity_test", - srcs = ["sequential_connectivity_test.c"], - language = "C", + srcs = ["sequential_connectivity_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -154,8 +154,8 @@ grpc_cc_test( grpc_cc_test( name = "server_chttp2_test", - srcs = ["server_chttp2_test.c"], - language = "C", + srcs = ["server_chttp2_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -166,8 +166,8 @@ grpc_cc_test( grpc_cc_test( name = "server_test", - srcs = ["server_test.c"], - language = "C", + srcs = ["server_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", diff --git a/test/core/surface/alarm_test.c b/test/core/surface/alarm_test.cc index 4fd7cb93c6..88b0b31478 100644 --- a/test/core/surface/alarm_test.c +++ b/test/core/surface/alarm_test.cc @@ -25,13 +25,13 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) -static void *create_test_tag(void) { +static void* create_test_tag(void) { static intptr_t i = 0; - return (void *)(++i); + return (void*)(++i); } /* helper for tests to shutdown correctly and tersely */ -static void shutdown_and_destroy(grpc_completion_queue *cc) { +static void shutdown_and_destroy(grpc_completion_queue* cc) { grpc_event ev; grpc_completion_queue_shutdown(cc); ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); @@ -40,15 +40,15 @@ static void shutdown_and_destroy(grpc_completion_queue *cc) { } static void test_alarm(void) { - grpc_completion_queue *cc; + grpc_completion_queue* cc; LOG_TEST("test_alarm"); cc = grpc_completion_queue_create_for_next(NULL); { /* regular expiry */ grpc_event ev; - void *tag = create_test_tag(); - grpc_alarm *alarm = grpc_alarm_create(NULL); + void* tag = create_test_tag(); + grpc_alarm* alarm = grpc_alarm_create(NULL); grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(1), tag, NULL); ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(2), @@ -61,8 +61,8 @@ static void test_alarm(void) { { /* cancellation */ grpc_event ev; - void *tag = create_test_tag(); - grpc_alarm *alarm = grpc_alarm_create(NULL); + void* tag = create_test_tag(); + grpc_alarm* alarm = grpc_alarm_create(NULL); grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag, NULL); grpc_alarm_cancel(alarm, NULL); @@ -76,8 +76,8 @@ static void test_alarm(void) { { /* alarm_destroy before cq_next */ grpc_event ev; - void *tag = create_test_tag(); - grpc_alarm *alarm = grpc_alarm_create(NULL); + void* tag = create_test_tag(); + grpc_alarm* alarm = grpc_alarm_create(NULL); grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag, NULL); grpc_alarm_destroy(alarm, NULL); @@ -89,14 +89,14 @@ static void test_alarm(void) { } { /* alarm_destroy before set */ - grpc_alarm *alarm = grpc_alarm_create(NULL); + grpc_alarm* alarm = grpc_alarm_create(NULL); grpc_alarm_destroy(alarm, NULL); } shutdown_and_destroy(cc); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_alarm(); diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.cc index a6b4c86abc..e5d2d7c78d 100644 --- a/test/core/surface/byte_buffer_reader_test.c +++ b/test/core/surface/byte_buffer_reader_test.cc @@ -36,7 +36,7 @@ static void test_read_one_slice(void) { grpc_slice slice; - grpc_byte_buffer *buffer; + grpc_byte_buffer* buffer; grpc_byte_buffer_reader reader; grpc_slice first_slice, second_slice; int first_code, second_code; @@ -58,7 +58,7 @@ static void test_read_one_slice(void) { static void test_read_one_slice_malloc(void) { grpc_slice slice; - grpc_byte_buffer *buffer; + grpc_byte_buffer* buffer; grpc_byte_buffer_reader reader; grpc_slice first_slice, second_slice; int first_code, second_code; @@ -81,7 +81,7 @@ static void test_read_one_slice_malloc(void) { static void test_read_none_compressed_slice(void) { grpc_slice slice; - grpc_byte_buffer *buffer; + grpc_byte_buffer* buffer; grpc_byte_buffer_reader reader; grpc_slice first_slice, second_slice; int first_code, second_code; @@ -103,7 +103,7 @@ static void test_read_none_compressed_slice(void) { static void test_read_corrupted_slice(void) { grpc_slice slice; - grpc_byte_buffer *buffer; + grpc_byte_buffer* buffer; grpc_byte_buffer_reader reader; LOG_TEST("test_read_corrupted_slice"); @@ -120,7 +120,7 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm, grpc_slice input_slice; grpc_slice_buffer sliceb_in; grpc_slice_buffer sliceb_out; - grpc_byte_buffer *buffer; + grpc_byte_buffer* buffer; grpc_byte_buffer_reader reader; grpc_slice read_slice; size_t read_count = 0; @@ -195,10 +195,10 @@ static void test_byte_buffer_from_reader(void) { } static void test_readall(void) { - char *lotsa_as[512]; - char *lotsa_bs[1024]; + char* lotsa_as[512]; + char* lotsa_bs[1024]; grpc_slice slices[2]; - grpc_byte_buffer *buffer; + grpc_byte_buffer* buffer; grpc_byte_buffer_reader reader; grpc_slice slice_out; @@ -229,11 +229,11 @@ static void test_readall(void) { } static void test_byte_buffer_copy(void) { - char *lotsa_as[512]; - char *lotsa_bs[1024]; + char* lotsa_as[512]; + char* lotsa_bs[1024]; grpc_slice slices[2]; - grpc_byte_buffer *buffer; - grpc_byte_buffer *copied_buffer; + grpc_byte_buffer* buffer; + grpc_byte_buffer* copied_buffer; grpc_byte_buffer_reader reader; grpc_slice slice_out; @@ -265,7 +265,7 @@ static void test_byte_buffer_copy(void) { grpc_byte_buffer_destroy(copied_buffer); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_read_one_slice(); test_read_one_slice_malloc(); diff --git a/test/core/surface/channel_create_test.c b/test/core/surface/channel_create_test.cc index a6884750e7..4627c57438 100644 --- a/test/core/surface/channel_create_test.c +++ b/test/core/surface/channel_create_test.cc @@ -27,7 +27,7 @@ #include "test/core/util/test_config.h" void test_unknown_scheme_target(void) { - grpc_channel *chan; + grpc_channel* chan; /* avoid default prefix */ grpc_resolver_registry_shutdown(); grpc_resolver_registry_init(); @@ -36,7 +36,7 @@ void test_unknown_scheme_target(void) { GPR_ASSERT(chan != NULL); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_channel_element *elem = + grpc_channel_element* elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0); GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client")); grpc_exec_ctx_finish(&exec_ctx); @@ -44,7 +44,7 @@ void test_unknown_scheme_target(void) { grpc_channel_destroy(chan); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_unknown_scheme_target(); diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.cc index e4e4c9f1b2..277ffde553 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.cc @@ -27,13 +27,13 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) -static void *create_test_tag(void) { +static void* create_test_tag(void) { static intptr_t i = 0; - return (void *)(++i); + return (void*)(++i); } /* helper for tests to shutdown correctly and tersely */ -static void shutdown_and_destroy(grpc_completion_queue *cc) { +static void shutdown_and_destroy(grpc_completion_queue* cc) { grpc_event ev; grpc_completion_queue_shutdown(cc); @@ -81,7 +81,7 @@ static void test_pollset_conversion(void) { grpc_cq_completion_type completion_types[] = {GRPC_CQ_NEXT, GRPC_CQ_PLUCK}; grpc_cq_polling_type polling_types[] = {GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING}; - grpc_completion_queue *cq; + grpc_completion_queue* cq; grpc_completion_queue_attributes attr; LOG_TEST("test_pollset_conversion"); @@ -102,7 +102,7 @@ static void test_pollset_conversion(void) { static void test_wait_empty(void) { grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; - grpc_completion_queue *cc; + grpc_completion_queue* cc; grpc_completion_queue_attributes attr; grpc_event event; @@ -120,19 +120,19 @@ static void test_wait_empty(void) { } } -static void do_nothing_end_completion(grpc_exec_ctx *exec_ctx, void *arg, - grpc_cq_completion *c) {} +static void do_nothing_end_completion(grpc_exec_ctx* exec_ctx, void* arg, + grpc_cq_completion* c) {} static void test_cq_end_op(void) { grpc_event ev; - grpc_completion_queue *cc; + grpc_completion_queue* cc; grpc_cq_completion completion; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue_attributes attr; grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx; - void *tag = create_test_tag(); + void* tag = create_test_tag(); LOG_TEST("test_cq_end_op"); @@ -160,15 +160,15 @@ static void test_cq_end_op(void) { static void test_cq_tls_cache_full(void) { grpc_event ev; - grpc_completion_queue *cc; + grpc_completion_queue* cc; grpc_cq_completion completion; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue_attributes attr; grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx; - void *tag = create_test_tag(); - void *res_tag; + void* tag = create_test_tag(); + void* res_tag; int ok; LOG_TEST("test_cq_tls_cache_full"); @@ -203,13 +203,13 @@ static void test_cq_tls_cache_full(void) { } static void test_cq_tls_cache_empty(void) { - grpc_completion_queue *cc; + grpc_completion_queue* cc; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue_attributes attr; grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx; - void *res_tag; + void* res_tag; int ok; LOG_TEST("test_cq_tls_cache_empty"); @@ -235,7 +235,7 @@ static void test_cq_tls_cache_empty(void) { static void test_shutdown_then_next_polling(void) { grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; - grpc_completion_queue *cc; + grpc_completion_queue* cc; grpc_completion_queue_attributes attr; grpc_event event; LOG_TEST("test_shutdown_then_next_polling"); @@ -257,7 +257,7 @@ static void test_shutdown_then_next_polling(void) { static void test_shutdown_then_next_with_timeout(void) { grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; - grpc_completion_queue *cc; + grpc_completion_queue* cc; grpc_completion_queue_attributes attr; grpc_event event; LOG_TEST("test_shutdown_then_next_with_timeout"); @@ -279,8 +279,8 @@ static void test_shutdown_then_next_with_timeout(void) { static void test_pluck(void) { grpc_event ev; - grpc_completion_queue *cc; - void *tags[128]; + grpc_completion_queue* cc; + void* tags[128]; grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; @@ -339,7 +339,7 @@ static void test_pluck_after_shutdown(void) { grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_event ev; - grpc_completion_queue *cc; + grpc_completion_queue* cc; grpc_completion_queue_attributes attr; LOG_TEST("test_pluck_after_shutdown"); @@ -359,11 +359,11 @@ static void test_pluck_after_shutdown(void) { } struct thread_state { - grpc_completion_queue *cc; - void *tag; + grpc_completion_queue* cc; + void* tag; }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_no_op(); diff --git a/test/core/surface/completion_queue_threading_test.c b/test/core/surface/completion_queue_threading_test.cc index 9996b6b840..043c5c1617 100644 --- a/test/core/surface/completion_queue_threading_test.c +++ b/test/core/surface/completion_queue_threading_test.cc @@ -28,13 +28,13 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) -static void *create_test_tag(void) { +static void* create_test_tag(void) { static intptr_t i = 0; - return (void *)(++i); + return (void*)(++i); } /* helper for tests to shutdown correctly and tersely */ -static void shutdown_and_destroy(grpc_completion_queue *cc) { +static void shutdown_and_destroy(grpc_completion_queue* cc) { grpc_event ev; grpc_completion_queue_shutdown(cc); @@ -59,24 +59,24 @@ static void shutdown_and_destroy(grpc_completion_queue *cc) { grpc_completion_queue_destroy(cc); } -static void do_nothing_end_completion(grpc_exec_ctx *exec_ctx, void *arg, - grpc_cq_completion *c) {} +static void do_nothing_end_completion(grpc_exec_ctx* exec_ctx, void* arg, + grpc_cq_completion* c) {} struct thread_state { - grpc_completion_queue *cc; - void *tag; + grpc_completion_queue* cc; + void* tag; }; -static void pluck_one(void *arg) { - struct thread_state *state = arg; +static void pluck_one(void* arg) { + struct thread_state* state = static_cast<struct thread_state*>(arg); grpc_completion_queue_pluck(state->cc, state->tag, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); } static void test_too_many_plucks(void) { grpc_event ev; - grpc_completion_queue *cc; - void *tags[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS]; + grpc_completion_queue* cc; + void* tags[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS]; grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; gpr_thd_id thread_ids[GPR_ARRAY_SIZE(tags)]; struct thread_state thread_states[GPR_ARRAY_SIZE(tags)]; @@ -124,68 +124,69 @@ static void test_too_many_plucks(void) { typedef struct test_thread_options { gpr_event on_started; - gpr_event *phase1; + gpr_event* phase1; gpr_event on_phase1_done; - gpr_event *phase2; + gpr_event* phase2; gpr_event on_finished; size_t events_triggered; int id; - grpc_completion_queue *cc; + grpc_completion_queue* cc; } test_thread_options; gpr_timespec ten_seconds_time(void) { return grpc_timeout_seconds_to_deadline(10); } -static void free_completion(grpc_exec_ctx *exec_ctx, void *arg, - grpc_cq_completion *completion) { +static void free_completion(grpc_exec_ctx* exec_ctx, void* arg, + grpc_cq_completion* completion) { gpr_free(completion); } -static void producer_thread(void *arg) { - test_thread_options *opt = arg; +static void producer_thread(void* arg) { + test_thread_options* opt = static_cast<test_thread_options*>(arg); int i; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, "producer %d started", opt->id); - gpr_event_set(&opt->on_started, (void *)(intptr_t)1); + gpr_event_set(&opt->on_started, (void*)(intptr_t)1); GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time())); gpr_log(GPR_INFO, "producer %d phase 1", opt->id); for (i = 0; i < TEST_THREAD_EVENTS; i++) { - GPR_ASSERT(grpc_cq_begin_op(opt->cc, (void *)(intptr_t)1)); + GPR_ASSERT(grpc_cq_begin_op(opt->cc, (void*)(intptr_t)1)); } gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id); - gpr_event_set(&opt->on_phase1_done, (void *)(intptr_t)1); + gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1); GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time())); gpr_log(GPR_INFO, "producer %d phase 2", opt->id); for (i = 0; i < TEST_THREAD_EVENTS; i++) { - grpc_cq_end_op(&exec_ctx, opt->cc, (void *)(intptr_t)1, GRPC_ERROR_NONE, + grpc_cq_end_op(&exec_ctx, opt->cc, (void*)(intptr_t)1, GRPC_ERROR_NONE, free_completion, NULL, - gpr_malloc(sizeof(grpc_cq_completion))); + static_cast<grpc_cq_completion*>( + gpr_malloc(sizeof(grpc_cq_completion)))); opt->events_triggered++; grpc_exec_ctx_finish(&exec_ctx); } gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id); - gpr_event_set(&opt->on_finished, (void *)(intptr_t)1); + gpr_event_set(&opt->on_finished, (void*)(intptr_t)1); grpc_exec_ctx_finish(&exec_ctx); } -static void consumer_thread(void *arg) { - test_thread_options *opt = arg; +static void consumer_thread(void* arg) { + test_thread_options* opt = static_cast<test_thread_options*>(arg); grpc_event ev; gpr_log(GPR_INFO, "consumer %d started", opt->id); - gpr_event_set(&opt->on_started, (void *)(intptr_t)1); + gpr_event_set(&opt->on_started, (void*)(intptr_t)1); GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time())); gpr_log(GPR_INFO, "consumer %d phase 1", opt->id); gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id); - gpr_event_set(&opt->on_phase1_done, (void *)(intptr_t)1); + gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1); GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time())); gpr_log(GPR_INFO, "consumer %d phase 2", opt->id); @@ -199,7 +200,7 @@ static void consumer_thread(void *arg) { break; case GRPC_QUEUE_SHUTDOWN: gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id); - gpr_event_set(&opt->on_finished, (void *)(intptr_t)1); + gpr_event_set(&opt->on_finished, (void*)(intptr_t)1); return; case GRPC_QUEUE_TIMEOUT: gpr_log(GPR_ERROR, "Invalid timeout received"); @@ -209,11 +210,11 @@ static void consumer_thread(void *arg) { } static void test_threading(size_t producers, size_t consumers) { - test_thread_options *options = - gpr_malloc((producers + consumers) * sizeof(test_thread_options)); + test_thread_options* options = static_cast<test_thread_options*>( + gpr_malloc((producers + consumers) * sizeof(test_thread_options))); gpr_event phase1 = GPR_EVENT_INIT; gpr_event phase2 = GPR_EVENT_INIT; - grpc_completion_queue *cc = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cc = grpc_completion_queue_create_for_next(NULL); size_t i; size_t total_consumed = 0; static int optid = 101; @@ -241,7 +242,7 @@ static void test_threading(size_t producers, size_t consumers) { /* start phase1: producers will pre-declare all operations they will complete */ gpr_log(GPR_INFO, "start phase 1"); - gpr_event_set(&phase1, (void *)(intptr_t)1); + gpr_event_set(&phase1, (void*)(intptr_t)1); gpr_log(GPR_INFO, "wait phase 1"); for (i = 0; i < producers + consumers; i++) { @@ -251,7 +252,7 @@ static void test_threading(size_t producers, size_t consumers) { /* start phase2: operations will complete, and consumers will consume them */ gpr_log(GPR_INFO, "start phase 2"); - gpr_event_set(&phase2, (void *)(intptr_t)1); + gpr_event_set(&phase2, (void*)(intptr_t)1); /* in parallel, we shutdown the completion channel - all events should still be consumed */ @@ -280,7 +281,7 @@ static void test_threading(size_t producers, size_t consumers) { gpr_free(options); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_too_many_plucks(); diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.cc index 3595885ff6..6f6a71e6f5 100644 --- a/test/core/surface/concurrent_connectivity_test.c +++ b/test/core/surface/concurrent_connectivity_test.cc @@ -54,13 +54,13 @@ // end after the shorter delay_millis #define POLL_MILLIS_SHORT_TIMEOUTS 30000 -static void *tag(int n) { return (void *)(uintptr_t)n; } -static int detag(void *p) { return (int)(uintptr_t)p; } +static void* tag(int n) { return (void*)(uintptr_t)n; } +static int detag(void* p) { return (int)(uintptr_t)p; } -void create_loop_destroy(void *addr) { +void create_loop_destroy(void* addr) { for (int i = 0; i < NUM_OUTER_LOOPS; ++i) { - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); - grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_channel* chan = grpc_insecure_channel_create((char*)addr, NULL, NULL); for (int j = 0; j < NUM_INNER_LOOPS; ++j) { gpr_timespec later_time = @@ -81,17 +81,17 @@ void create_loop_destroy(void *addr) { } struct server_thread_args { - char *addr; - grpc_server *server; - grpc_completion_queue *cq; - grpc_pollset *pollset; - gpr_mu *mu; + char* addr; + grpc_server* server; + grpc_completion_queue* cq; + grpc_pollset* pollset; + gpr_mu* mu; gpr_event ready; gpr_atm stop; }; -void server_thread(void *vargs) { - struct server_thread_args *args = (struct server_thread_args *)vargs; +void server_thread(void* vargs) { + struct server_thread_args* args = (struct server_thread_args*)vargs; grpc_event ev; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); ev = grpc_completion_queue_next(args->cq, deadline, NULL); @@ -99,11 +99,11 @@ void server_thread(void *vargs) { GPR_ASSERT(detag(ev.tag) == 0xd1e); } -static void on_connect(grpc_exec_ctx *exec_ctx, void *vargs, grpc_endpoint *tcp, - grpc_pollset *accepting_pollset, - grpc_tcp_server_acceptor *acceptor) { +static void on_connect(grpc_exec_ctx* exec_ctx, void* vargs, grpc_endpoint* tcp, + grpc_pollset* accepting_pollset, + grpc_tcp_server_acceptor* acceptor) { gpr_free(acceptor); - struct server_thread_args *args = (struct server_thread_args *)vargs; + struct server_thread_args* args = (struct server_thread_args*)vargs; grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected")); grpc_endpoint_destroy(exec_ctx, tcp); @@ -113,15 +113,15 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *vargs, grpc_endpoint *tcp, gpr_mu_unlock(args->mu); } -void bad_server_thread(void *vargs) { - struct server_thread_args *args = (struct server_thread_args *)vargs; +void bad_server_thread(void* vargs) { + struct server_thread_args* args = (struct server_thread_args*)vargs; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr; + struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr; int port; - grpc_tcp_server *s; - grpc_error *error = grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s); + grpc_tcp_server* s; + grpc_error* error = grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s); GPR_ASSERT(error == GRPC_ERROR_NONE); memset(&resolved_addr, 0, sizeof(resolved_addr)); addr->ss_family = AF_INET; @@ -131,13 +131,13 @@ void bad_server_thread(void *vargs) { gpr_asprintf(&args->addr, "localhost:%d", port); grpc_tcp_server_start(&exec_ctx, s, &args->pollset, 1, on_connect, args); - gpr_event_set(&args->ready, (void *)1); + gpr_event_set(&args->ready, (void*)1); gpr_mu_lock(args->mu); while (gpr_atm_acq_load(&args->stop) == 0) { grpc_millis deadline = grpc_exec_ctx_now(&exec_ctx) + 100; - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, args->pollset, &worker, deadline))) { @@ -156,9 +156,9 @@ void bad_server_thread(void *vargs) { gpr_free(args->addr); } -static void done_pollset_shutdown(grpc_exec_ctx *exec_ctx, void *pollset, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, pollset); +static void done_pollset_shutdown(grpc_exec_ctx* exec_ctx, void* pollset, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(pollset)); gpr_free(pollset); } @@ -171,7 +171,7 @@ int run_concurrent_connectivity_test() { gpr_thd_id threads[NUM_THREADS]; gpr_thd_id server; - char *localhost = gpr_strdup("localhost:54321"); + char* localhost = gpr_strdup("localhost:54321"); gpr_thd_options options = gpr_thd_options_default(); gpr_thd_options_set_joinable(&options); @@ -211,7 +211,7 @@ int run_concurrent_connectivity_test() { /* Third round, bogus tcp server */ gpr_log(GPR_DEBUG, "Wave 3"); - args.pollset = gpr_zalloc(grpc_pollset_size()); + args.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(args.pollset, &args.mu); gpr_event_init(&args.ready); gpr_thd_new(&server, bad_server_thread, &args, &options); @@ -236,10 +236,10 @@ int run_concurrent_connectivity_test() { return 0; } -void watches_with_short_timeouts(void *addr) { +void watches_with_short_timeouts(void* addr) { for (int i = 0; i < NUM_OUTER_LOOPS_SHORT_TIMEOUTS; ++i) { - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); - grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_channel* chan = grpc_insecure_channel_create((char*)addr, NULL, NULL); for (int j = 0; j < NUM_INNER_LOOPS_SHORT_TIMEOUTS; ++j) { gpr_timespec later_time = @@ -269,7 +269,7 @@ int run_concurrent_watches_with_short_timeouts_test() { gpr_thd_id threads[NUM_THREADS]; - char *localhost = gpr_strdup("localhost:54321"); + char* localhost = gpr_strdup("localhost:54321"); gpr_thd_options options = gpr_thd_options_default(); gpr_thd_options_set_joinable(&options); @@ -285,7 +285,7 @@ int run_concurrent_watches_with_short_timeouts_test() { return 0; } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); run_concurrent_connectivity_test(); diff --git a/test/core/surface/init_test.c b/test/core/surface/init_test.cc index b835a2a884..5749bc8b36 100644 --- a/test/core/surface/init_test.c +++ b/test/core/surface/init_test.cc @@ -59,7 +59,7 @@ static void test_repeatedly() { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test(1); test(2); diff --git a/test/core/surface/invalid_channel_args_test.c b/test/core/surface/invalid_channel_args_test.cc index 9c84c30f03..6a58a32e3c 100644 --- a/test/core/surface/invalid_channel_args_test.c +++ b/test/core/surface/invalid_channel_args_test.cc @@ -24,10 +24,10 @@ #include <grpc/support/string_util.h> #include "test/core/util/test_config.h" -static char *g_last_log_error_message = NULL; -static const char *g_file_name = "channel.cc"; +static char* g_last_log_error_message = NULL; +static const char* g_file_name = "channel.cc"; -static int ends_with(const char *src, const char *suffix) { +static int ends_with(const char* src, const char* suffix) { size_t src_len = strlen(src); size_t suffix_len = strlen(suffix); if (src_len < suffix_len) { @@ -36,14 +36,14 @@ static int ends_with(const char *src, const char *suffix) { return strcmp(src + src_len - suffix_len, suffix) == 0; } -static void log_error_sink(gpr_log_func_args *args) { +static void log_error_sink(gpr_log_func_args* args) { if (args->severity == GPR_LOG_SEVERITY_ERROR && ends_with(args->file, g_file_name)) { g_last_log_error_message = gpr_strdup(args->message); } } -static void verify_last_error(const char *message) { +static void verify_last_error(const char* message) { if (message == NULL) { GPR_ASSERT(g_last_log_error_message == NULL); return; @@ -53,14 +53,14 @@ static void verify_last_error(const char *message) { g_last_log_error_message = NULL; } -static char *compose_error_string(const char *key, const char *message) { - char *ret; +static char* compose_error_string(const char* key, const char* message) { + char* ret; gpr_asprintf(&ret, "%s%s", key, message); return ret; } -static void one_test(grpc_channel_args *args, char *expected_error_message) { - grpc_channel *chan = +static void one_test(grpc_channel_args* args, char* expected_error_message) { + grpc_channel* chan = grpc_insecure_channel_create("nonexistant:54321", args, NULL); verify_last_error(expected_error_message); gpr_free(expected_error_message); @@ -72,10 +72,10 @@ static void test_no_error_message(void) { one_test(NULL, NULL); } static void test_default_authority_type(void) { grpc_arg client_arg; grpc_channel_args client_args; - char *expected_error_message; + char* expected_error_message; client_arg.type = GRPC_ARG_INTEGER; - client_arg.key = GRPC_ARG_DEFAULT_AUTHORITY; + client_arg.key = const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY); client_arg.value.integer = 0; client_args.num_args = 1; @@ -88,10 +88,10 @@ static void test_default_authority_type(void) { static void test_ssl_name_override_type(void) { grpc_arg client_arg; grpc_channel_args client_args; - char *expected_error_message; + char* expected_error_message; client_arg.type = GRPC_ARG_INTEGER; - client_arg.key = GRPC_SSL_TARGET_NAME_OVERRIDE_ARG; + client_arg.key = const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG); client_arg.value.integer = 0; client_args.num_args = 1; @@ -104,14 +104,14 @@ static void test_ssl_name_override_type(void) { static void test_ssl_name_override_failed(void) { grpc_arg client_arg[2]; grpc_channel_args client_args; - char *expected_error_message; + char* expected_error_message; client_arg[0].type = GRPC_ARG_STRING; - client_arg[0].key = GRPC_ARG_DEFAULT_AUTHORITY; - client_arg[0].value.string = "default"; + client_arg[0].key = const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY); + client_arg[0].value.string = const_cast<char*>("default"); client_arg[1].type = GRPC_ARG_STRING; - client_arg[1].key = GRPC_SSL_TARGET_NAME_OVERRIDE_ARG; - client_arg[1].value.string = "ssl"; + client_arg[1].key = const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG); + client_arg[1].value.string = const_cast<char*>("ssl"); client_args.num_args = 2; client_args.args = client_arg; @@ -121,7 +121,7 @@ static void test_ssl_name_override_failed(void) { one_test(&client_args, expected_error_message); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); gpr_set_log_function(log_error_sink); diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.cc index f623e1a743..c374adc08d 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.cc @@ -30,20 +30,20 @@ grpc_closure transport_op_cb; -static void *tag(intptr_t x) { return (void *)x; } +static void* tag(intptr_t x) { return (void*)x; } -void verify_connectivity(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - grpc_connectivity_state *state = arg; +void verify_connectivity(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + grpc_connectivity_state* state = static_cast<grpc_connectivity_state*>(arg); GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN == *state); GPR_ASSERT(error == GRPC_ERROR_NONE); } -void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} +void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} -void test_transport_op(grpc_channel *channel) { - grpc_transport_op *op; - grpc_channel_element *elem; +void test_transport_op(grpc_channel* channel) { + grpc_transport_op* op; + grpc_channel_element* elem; grpc_connectivity_state state = GRPC_CHANNEL_IDLE; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -64,19 +64,19 @@ void test_transport_op(grpc_channel *channel) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { - grpc_channel *chan; - grpc_call *call; - grpc_completion_queue *cq; - cq_verifier *cqv; +int main(int argc, char** argv) { + grpc_channel* chan; + grpc_call* call; + grpc_completion_queue* cq; + cq_verifier* cqv; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_status_code status; grpc_call_error error; grpc_slice details; - char *peer; + char* peer; grpc_test_init(argc, argv); grpc_init(); diff --git a/test/core/surface/num_external_connectivity_watchers_test.c b/test/core/surface/num_external_connectivity_watchers_test.cc index 16401bb7ac..89dc364fb8 100644 --- a/test/core/surface/num_external_connectivity_watchers_test.c +++ b/test/core/surface/num_external_connectivity_watchers_test.cc @@ -30,26 +30,26 @@ #include "test/core/util/test_config.h" typedef struct test_fixture { - const char *name; - grpc_channel *(*create_channel)(const char *addr); + const char* name; + grpc_channel* (*create_channel)(const char* addr); } test_fixture; static size_t next_tag = 1; -static void channel_idle_start_watch(grpc_channel *channel, - grpc_completion_queue *cq) { +static void channel_idle_start_watch(grpc_channel* channel, + grpc_completion_queue* cq) { gpr_timespec connect_deadline = grpc_timeout_milliseconds_to_deadline(1); GPR_ASSERT(grpc_channel_check_connectivity_state(channel, 0) == GRPC_CHANNEL_IDLE); grpc_channel_watch_connectivity_state( - channel, GRPC_CHANNEL_IDLE, connect_deadline, cq, (void *)(next_tag++)); + channel, GRPC_CHANNEL_IDLE, connect_deadline, cq, (void*)(next_tag++)); gpr_log(GPR_DEBUG, "number of active connect watchers: %d", grpc_channel_num_external_connectivity_watchers(channel)); } -static void channel_idle_poll_for_timeout(grpc_channel *channel, - grpc_completion_queue *cq) { +static void channel_idle_poll_for_timeout(grpc_channel* channel, + grpc_completion_queue* cq) { grpc_event ev = grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); @@ -63,17 +63,17 @@ static void channel_idle_poll_for_timeout(grpc_channel *channel, /* Test and use the "num_external_watchers" call to make sure * that "connectivity watcher" structs are free'd just after, if * their corresponding timeouts occur. */ -static void run_timeouts_test(const test_fixture *fixture) { +static void run_timeouts_test(const test_fixture* fixture) { gpr_log(GPR_INFO, "TEST: %s", fixture->name); - char *addr; + char* addr; grpc_init(); gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); - grpc_channel *channel = fixture->create_channel(addr); - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); + grpc_channel* channel = fixture->create_channel(addr); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); /* start 1 watcher and then let it time out */ channel_idle_start_watch(channel, cq); @@ -117,17 +117,17 @@ static void run_timeouts_test(const test_fixture *fixture) { /* An edge scenario; sets channel state to explicitly, and outside * of a polling call. */ static void run_channel_shutdown_before_timeout_test( - const test_fixture *fixture) { + const test_fixture* fixture) { gpr_log(GPR_INFO, "TEST: %s", fixture->name); - char *addr; + char* addr; grpc_init(); gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); - grpc_channel *channel = fixture->create_channel(addr); - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); + grpc_channel* channel = fixture->create_channel(addr); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); /* start 1 watcher and then shut down the channel before the timer goes off */ GPR_ASSERT(grpc_channel_num_external_connectivity_watchers(channel) == 0); @@ -138,7 +138,7 @@ static void run_channel_shutdown_before_timeout_test( GRPC_CHANNEL_IDLE); grpc_channel_watch_connectivity_state(channel, GRPC_CHANNEL_IDLE, - connect_deadline, cq, (void *)1); + connect_deadline, cq, (void*)1); grpc_channel_destroy(channel); grpc_event ev = @@ -157,23 +157,25 @@ static void run_channel_shutdown_before_timeout_test( gpr_free(addr); } -static grpc_channel *insecure_test_create_channel(const char *addr) { +static grpc_channel* insecure_test_create_channel(const char* addr) { return grpc_insecure_channel_create(addr, NULL, NULL); } static const test_fixture insecure_test = { - "insecure", insecure_test_create_channel, + "insecure", + insecure_test_create_channel, }; -static grpc_channel *secure_test_create_channel(const char *addr) { - grpc_channel_credentials *ssl_creds = +static grpc_channel* secure_test_create_channel(const char* addr) { + grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(test_root_cert, NULL, NULL); - grpc_arg ssl_name_override = {GRPC_ARG_STRING, - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, - {"foo.test.google.fr"}}; - grpc_channel_args *new_client_args = + grpc_arg ssl_name_override = { + GRPC_ARG_STRING, + const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), + {const_cast<char*>("foo.test.google.fr")}}; + grpc_channel_args* new_client_args = grpc_channel_args_copy_and_add(NULL, &ssl_name_override, 1); - grpc_channel *channel = + grpc_channel* channel = grpc_secure_channel_create(ssl_creds, addr, new_client_args, NULL); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -185,10 +187,11 @@ static grpc_channel *secure_test_create_channel(const char *addr) { } static const test_fixture secure_test = { - "secure", secure_test_create_channel, + "secure", + secure_test_create_channel, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); run_timeouts_test(&insecure_test); diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index d36d116afb..db9f902dbf 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -63,4 +63,291 @@ #include <grpc/support/useful.h> #include <grpc/support/workaround_list.h> -int main(int argc, char **argv) { return 0; } +#include <stdio.h> + +int main(int argc, char **argv) { + if(argc == 12345678) { + printf("%lx", (unsigned long) grpc_compression_algorithm_parse); + printf("%lx", (unsigned long) grpc_compression_algorithm_name); + printf("%lx", (unsigned long) grpc_stream_compression_algorithm_name); + printf("%lx", (unsigned long) grpc_compression_algorithm_for_level); + printf("%lx", (unsigned long) grpc_stream_compression_algorithm_for_level); + printf("%lx", (unsigned long) grpc_compression_options_init); + printf("%lx", (unsigned long) grpc_compression_options_enable_algorithm); + printf("%lx", (unsigned long) grpc_compression_options_disable_algorithm); + printf("%lx", (unsigned long) grpc_compression_options_is_algorithm_enabled); + printf("%lx", (unsigned long) grpc_compression_options_is_stream_compression_algorithm_enabled); + printf("%lx", (unsigned long) grpc_metadata_array_init); + printf("%lx", (unsigned long) grpc_metadata_array_destroy); + printf("%lx", (unsigned long) grpc_call_details_init); + printf("%lx", (unsigned long) grpc_call_details_destroy); + printf("%lx", (unsigned long) grpc_register_plugin); + printf("%lx", (unsigned long) grpc_init); + printf("%lx", (unsigned long) grpc_shutdown); + printf("%lx", (unsigned long) grpc_version_string); + printf("%lx", (unsigned long) grpc_g_stands_for); + printf("%lx", (unsigned long) grpc_completion_queue_factory_lookup); + printf("%lx", (unsigned long) grpc_completion_queue_create_for_next); + printf("%lx", (unsigned long) grpc_completion_queue_create_for_pluck); + printf("%lx", (unsigned long) grpc_completion_queue_create); + printf("%lx", (unsigned long) grpc_completion_queue_next); + printf("%lx", (unsigned long) grpc_completion_queue_pluck); + printf("%lx", (unsigned long) grpc_completion_queue_shutdown); + printf("%lx", (unsigned long) grpc_completion_queue_destroy); + printf("%lx", (unsigned long) grpc_completion_queue_thread_local_cache_init); + printf("%lx", (unsigned long) grpc_completion_queue_thread_local_cache_flush); + printf("%lx", (unsigned long) grpc_alarm_create); + printf("%lx", (unsigned long) grpc_alarm_set); + printf("%lx", (unsigned long) grpc_alarm_cancel); + printf("%lx", (unsigned long) grpc_alarm_destroy); + printf("%lx", (unsigned long) grpc_channel_check_connectivity_state); + printf("%lx", (unsigned long) grpc_channel_num_external_connectivity_watchers); + printf("%lx", (unsigned long) grpc_channel_watch_connectivity_state); + printf("%lx", (unsigned long) grpc_channel_support_connectivity_watcher); + printf("%lx", (unsigned long) grpc_channel_create_call); + printf("%lx", (unsigned long) grpc_channel_ping); + printf("%lx", (unsigned long) grpc_channel_register_call); + printf("%lx", (unsigned long) grpc_channel_create_registered_call); + printf("%lx", (unsigned long) grpc_call_arena_alloc); + printf("%lx", (unsigned long) grpc_call_start_batch); + printf("%lx", (unsigned long) grpc_call_get_peer); + printf("%lx", (unsigned long) grpc_census_call_set_context); + printf("%lx", (unsigned long) grpc_census_call_get_context); + printf("%lx", (unsigned long) grpc_channel_get_target); + printf("%lx", (unsigned long) grpc_channel_get_info); + printf("%lx", (unsigned long) grpc_insecure_channel_create); + printf("%lx", (unsigned long) grpc_lame_client_channel_create); + printf("%lx", (unsigned long) grpc_channel_destroy); + printf("%lx", (unsigned long) grpc_call_cancel); + printf("%lx", (unsigned long) grpc_call_cancel_with_status); + printf("%lx", (unsigned long) grpc_call_ref); + printf("%lx", (unsigned long) grpc_call_unref); + printf("%lx", (unsigned long) grpc_server_request_call); + printf("%lx", (unsigned long) grpc_server_register_method); + printf("%lx", (unsigned long) grpc_server_request_registered_call); + printf("%lx", (unsigned long) grpc_server_create); + printf("%lx", (unsigned long) grpc_server_register_completion_queue); + printf("%lx", (unsigned long) grpc_server_add_insecure_http2_port); + printf("%lx", (unsigned long) grpc_server_start); + printf("%lx", (unsigned long) grpc_server_shutdown_and_notify); + printf("%lx", (unsigned long) grpc_server_cancel_all_calls); + printf("%lx", (unsigned long) grpc_server_destroy); + printf("%lx", (unsigned long) grpc_tracer_set_enabled); + printf("%lx", (unsigned long) grpc_header_key_is_legal); + printf("%lx", (unsigned long) grpc_header_nonbin_value_is_legal); + printf("%lx", (unsigned long) grpc_is_binary_header); + printf("%lx", (unsigned long) grpc_call_error_to_string); + printf("%lx", (unsigned long) grpc_resource_quota_create); + printf("%lx", (unsigned long) grpc_resource_quota_ref); + printf("%lx", (unsigned long) grpc_resource_quota_unref); + printf("%lx", (unsigned long) grpc_resource_quota_resize); + printf("%lx", (unsigned long) grpc_resource_quota_arg_vtable); + printf("%lx", (unsigned long) grpc_auth_property_iterator_next); + printf("%lx", (unsigned long) grpc_auth_context_property_iterator); + printf("%lx", (unsigned long) grpc_auth_context_peer_identity); + printf("%lx", (unsigned long) grpc_auth_context_find_properties_by_name); + printf("%lx", (unsigned long) grpc_auth_context_peer_identity_property_name); + printf("%lx", (unsigned long) grpc_auth_context_peer_is_authenticated); + printf("%lx", (unsigned long) grpc_call_auth_context); + printf("%lx", (unsigned long) grpc_auth_context_release); + printf("%lx", (unsigned long) grpc_auth_context_add_property); + printf("%lx", (unsigned long) grpc_auth_context_add_cstring_property); + printf("%lx", (unsigned long) grpc_auth_context_set_peer_identity_property_name); + printf("%lx", (unsigned long) grpc_channel_credentials_release); + printf("%lx", (unsigned long) grpc_google_default_credentials_create); + printf("%lx", (unsigned long) grpc_set_ssl_roots_override_callback); + printf("%lx", (unsigned long) grpc_ssl_credentials_create); + printf("%lx", (unsigned long) grpc_call_credentials_release); + printf("%lx", (unsigned long) grpc_composite_channel_credentials_create); + printf("%lx", (unsigned long) grpc_composite_call_credentials_create); + printf("%lx", (unsigned long) grpc_google_compute_engine_credentials_create); + printf("%lx", (unsigned long) grpc_max_auth_token_lifetime); + printf("%lx", (unsigned long) grpc_service_account_jwt_access_credentials_create); + printf("%lx", (unsigned long) grpc_google_refresh_token_credentials_create); + printf("%lx", (unsigned long) grpc_access_token_credentials_create); + printf("%lx", (unsigned long) grpc_google_iam_credentials_create); + printf("%lx", (unsigned long) grpc_metadata_credentials_create_from_plugin); + printf("%lx", (unsigned long) grpc_secure_channel_create); + printf("%lx", (unsigned long) grpc_server_credentials_release); + printf("%lx", (unsigned long) grpc_ssl_server_certificate_config_create); + printf("%lx", (unsigned long) grpc_ssl_server_certificate_config_destroy); + printf("%lx", (unsigned long) grpc_ssl_server_credentials_create); + printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_ex); + printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_options_using_config); + printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_options_using_config_fetcher); + printf("%lx", (unsigned long) grpc_ssl_server_credentials_options_destroy); + printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_with_options); + printf("%lx", (unsigned long) grpc_server_add_secure_http2_port); + printf("%lx", (unsigned long) grpc_call_set_credentials); + printf("%lx", (unsigned long) grpc_server_credentials_set_auth_metadata_processor); + printf("%lx", (unsigned long) grpc_raw_byte_buffer_create); + printf("%lx", (unsigned long) grpc_raw_compressed_byte_buffer_create); + printf("%lx", (unsigned long) grpc_byte_buffer_copy); + printf("%lx", (unsigned long) grpc_byte_buffer_length); + printf("%lx", (unsigned long) grpc_byte_buffer_destroy); + printf("%lx", (unsigned long) grpc_byte_buffer_reader_init); + printf("%lx", (unsigned long) grpc_byte_buffer_reader_destroy); + printf("%lx", (unsigned long) grpc_byte_buffer_reader_next); + printf("%lx", (unsigned long) grpc_byte_buffer_reader_readall); + printf("%lx", (unsigned long) grpc_raw_byte_buffer_from_reader); + printf("%lx", (unsigned long) grpc_slice_ref); + printf("%lx", (unsigned long) grpc_slice_unref); + printf("%lx", (unsigned long) grpc_slice_copy); + printf("%lx", (unsigned long) grpc_slice_new); + printf("%lx", (unsigned long) grpc_slice_new_with_user_data); + printf("%lx", (unsigned long) grpc_slice_new_with_len); + printf("%lx", (unsigned long) grpc_slice_malloc); + printf("%lx", (unsigned long) grpc_slice_malloc_large); + printf("%lx", (unsigned long) grpc_slice_intern); + printf("%lx", (unsigned long) grpc_slice_from_copied_string); + printf("%lx", (unsigned long) grpc_slice_from_copied_buffer); + printf("%lx", (unsigned long) grpc_slice_from_static_string); + printf("%lx", (unsigned long) grpc_slice_from_static_buffer); + printf("%lx", (unsigned long) grpc_slice_sub); + printf("%lx", (unsigned long) grpc_slice_sub_no_ref); + printf("%lx", (unsigned long) grpc_slice_split_tail); + printf("%lx", (unsigned long) grpc_slice_split_tail_maybe_ref); + printf("%lx", (unsigned long) grpc_slice_split_head); + printf("%lx", (unsigned long) grpc_empty_slice); + printf("%lx", (unsigned long) grpc_slice_default_hash_impl); + printf("%lx", (unsigned long) grpc_slice_default_eq_impl); + printf("%lx", (unsigned long) grpc_slice_eq); + printf("%lx", (unsigned long) grpc_slice_cmp); + printf("%lx", (unsigned long) grpc_slice_str_cmp); + printf("%lx", (unsigned long) grpc_slice_buf_start_eq); + printf("%lx", (unsigned long) grpc_slice_rchr); + printf("%lx", (unsigned long) grpc_slice_chr); + printf("%lx", (unsigned long) grpc_slice_slice); + printf("%lx", (unsigned long) grpc_slice_hash); + printf("%lx", (unsigned long) grpc_slice_is_equivalent); + printf("%lx", (unsigned long) grpc_slice_dup); + printf("%lx", (unsigned long) grpc_slice_to_c_string); + printf("%lx", (unsigned long) grpc_slice_buffer_init); + printf("%lx", (unsigned long) grpc_slice_buffer_destroy); + printf("%lx", (unsigned long) grpc_slice_buffer_add); + printf("%lx", (unsigned long) grpc_slice_buffer_add_indexed); + printf("%lx", (unsigned long) grpc_slice_buffer_addn); + printf("%lx", (unsigned long) grpc_slice_buffer_tiny_add); + printf("%lx", (unsigned long) grpc_slice_buffer_pop); + printf("%lx", (unsigned long) grpc_slice_buffer_reset_and_unref); + printf("%lx", (unsigned long) grpc_slice_buffer_swap); + printf("%lx", (unsigned long) grpc_slice_buffer_move_into); + printf("%lx", (unsigned long) grpc_slice_buffer_trim_end); + printf("%lx", (unsigned long) grpc_slice_buffer_move_first); + printf("%lx", (unsigned long) grpc_slice_buffer_move_first_no_ref); + printf("%lx", (unsigned long) grpc_slice_buffer_move_first_into_buffer); + printf("%lx", (unsigned long) grpc_slice_buffer_take_first); + printf("%lx", (unsigned long) grpc_slice_buffer_undo_take_first); + printf("%lx", (unsigned long) gpr_malloc); + printf("%lx", (unsigned long) gpr_zalloc); + printf("%lx", (unsigned long) gpr_free); + printf("%lx", (unsigned long) gpr_realloc); + printf("%lx", (unsigned long) gpr_malloc_aligned); + printf("%lx", (unsigned long) gpr_free_aligned); + printf("%lx", (unsigned long) gpr_set_allocation_functions); + printf("%lx", (unsigned long) gpr_get_allocation_functions); + printf("%lx", (unsigned long) gpr_avl_create); + printf("%lx", (unsigned long) gpr_avl_ref); + printf("%lx", (unsigned long) gpr_avl_unref); + printf("%lx", (unsigned long) gpr_avl_add); + printf("%lx", (unsigned long) gpr_avl_remove); + printf("%lx", (unsigned long) gpr_avl_get); + printf("%lx", (unsigned long) gpr_avl_maybe_get); + printf("%lx", (unsigned long) gpr_avl_is_empty); + printf("%lx", (unsigned long) gpr_cmdline_create); + printf("%lx", (unsigned long) gpr_cmdline_add_int); + printf("%lx", (unsigned long) gpr_cmdline_add_flag); + printf("%lx", (unsigned long) gpr_cmdline_add_string); + printf("%lx", (unsigned long) gpr_cmdline_on_extra_arg); + printf("%lx", (unsigned long) gpr_cmdline_set_survive_failure); + printf("%lx", (unsigned long) gpr_cmdline_parse); + printf("%lx", (unsigned long) gpr_cmdline_destroy); + printf("%lx", (unsigned long) gpr_cmdline_usage_string); + printf("%lx", (unsigned long) gpr_cpu_num_cores); + printf("%lx", (unsigned long) gpr_cpu_current_cpu); + printf("%lx", (unsigned long) gpr_histogram_create); + printf("%lx", (unsigned long) gpr_histogram_destroy); + printf("%lx", (unsigned long) gpr_histogram_add); + printf("%lx", (unsigned long) gpr_histogram_merge); + printf("%lx", (unsigned long) gpr_histogram_percentile); + printf("%lx", (unsigned long) gpr_histogram_mean); + printf("%lx", (unsigned long) gpr_histogram_stddev); + printf("%lx", (unsigned long) gpr_histogram_variance); + printf("%lx", (unsigned long) gpr_histogram_maximum); + printf("%lx", (unsigned long) gpr_histogram_minimum); + printf("%lx", (unsigned long) gpr_histogram_count); + printf("%lx", (unsigned long) gpr_histogram_sum); + printf("%lx", (unsigned long) gpr_histogram_sum_of_squares); + printf("%lx", (unsigned long) gpr_histogram_get_contents); + printf("%lx", (unsigned long) gpr_histogram_merge_contents); + printf("%lx", (unsigned long) gpr_join_host_port); + printf("%lx", (unsigned long) gpr_split_host_port); + printf("%lx", (unsigned long) gpr_log_severity_string); + printf("%lx", (unsigned long) gpr_log); + printf("%lx", (unsigned long) gpr_log_message); + printf("%lx", (unsigned long) gpr_set_log_verbosity); + printf("%lx", (unsigned long) gpr_log_verbosity_init); + printf("%lx", (unsigned long) gpr_set_log_function); + printf("%lx", (unsigned long) gpr_strdup); + printf("%lx", (unsigned long) gpr_asprintf); + printf("%lx", (unsigned long) gpr_subprocess_binary_extension); + printf("%lx", (unsigned long) gpr_subprocess_create); + printf("%lx", (unsigned long) gpr_subprocess_destroy); + printf("%lx", (unsigned long) gpr_subprocess_join); + printf("%lx", (unsigned long) gpr_subprocess_interrupt); + printf("%lx", (unsigned long) gpr_mu_init); + printf("%lx", (unsigned long) gpr_mu_destroy); + printf("%lx", (unsigned long) gpr_mu_lock); + printf("%lx", (unsigned long) gpr_mu_unlock); + printf("%lx", (unsigned long) gpr_mu_trylock); + printf("%lx", (unsigned long) gpr_cv_init); + printf("%lx", (unsigned long) gpr_cv_destroy); + printf("%lx", (unsigned long) gpr_cv_wait); + printf("%lx", (unsigned long) gpr_cv_signal); + printf("%lx", (unsigned long) gpr_cv_broadcast); + printf("%lx", (unsigned long) gpr_once_init); + printf("%lx", (unsigned long) gpr_event_init); + printf("%lx", (unsigned long) gpr_event_set); + printf("%lx", (unsigned long) gpr_event_get); + printf("%lx", (unsigned long) gpr_event_wait); + printf("%lx", (unsigned long) gpr_ref_init); + printf("%lx", (unsigned long) gpr_ref); + printf("%lx", (unsigned long) gpr_ref_non_zero); + printf("%lx", (unsigned long) gpr_refn); + printf("%lx", (unsigned long) gpr_unref); + printf("%lx", (unsigned long) gpr_ref_is_unique); + printf("%lx", (unsigned long) gpr_stats_init); + printf("%lx", (unsigned long) gpr_stats_inc); + printf("%lx", (unsigned long) gpr_stats_read); + printf("%lx", (unsigned long) gpr_thd_new); + printf("%lx", (unsigned long) gpr_thd_options_default); + printf("%lx", (unsigned long) gpr_thd_options_set_detached); + printf("%lx", (unsigned long) gpr_thd_options_set_joinable); + printf("%lx", (unsigned long) gpr_thd_options_is_detached); + printf("%lx", (unsigned long) gpr_thd_options_is_joinable); + printf("%lx", (unsigned long) gpr_thd_currentid); + printf("%lx", (unsigned long) gpr_thd_join); + printf("%lx", (unsigned long) gpr_time_0); + printf("%lx", (unsigned long) gpr_inf_future); + printf("%lx", (unsigned long) gpr_inf_past); + printf("%lx", (unsigned long) gpr_time_init); + printf("%lx", (unsigned long) gpr_now); + printf("%lx", (unsigned long) gpr_convert_clock_type); + printf("%lx", (unsigned long) gpr_time_cmp); + printf("%lx", (unsigned long) gpr_time_max); + printf("%lx", (unsigned long) gpr_time_min); + printf("%lx", (unsigned long) gpr_time_add); + printf("%lx", (unsigned long) gpr_time_sub); + printf("%lx", (unsigned long) gpr_time_from_micros); + printf("%lx", (unsigned long) gpr_time_from_nanos); + printf("%lx", (unsigned long) gpr_time_from_millis); + printf("%lx", (unsigned long) gpr_time_from_seconds); + printf("%lx", (unsigned long) gpr_time_from_minutes); + printf("%lx", (unsigned long) gpr_time_from_hours); + printf("%lx", (unsigned long) gpr_time_to_millis); + printf("%lx", (unsigned long) gpr_time_similar); + printf("%lx", (unsigned long) gpr_sleep_until); + printf("%lx", (unsigned long) gpr_timespec_to_micros); + } + return 0; +} diff --git a/test/core/surface/secure_channel_create_test.c b/test/core/surface/secure_channel_create_test.cc index 0c45135501..f3163c1d80 100644 --- a/test/core/surface/secure_channel_create_test.c +++ b/test/core/surface/secure_channel_create_test.cc @@ -30,11 +30,11 @@ void test_unknown_scheme_target(void) { grpc_resolver_registry_shutdown(); grpc_resolver_registry_init(); - grpc_channel_credentials *creds = + grpc_channel_credentials* creds = grpc_fake_transport_security_credentials_create(); - grpc_channel *chan = + grpc_channel* chan = grpc_secure_channel_create(creds, "blah://blah", NULL, NULL); - grpc_channel_element *elem = + grpc_channel_element* elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0); GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client")); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -47,12 +47,12 @@ void test_security_connector_already_in_arg(void) { grpc_arg arg; arg.type = GRPC_ARG_POINTER; arg.value.pointer.p = NULL; - arg.key = GRPC_ARG_SECURITY_CONNECTOR; + arg.key = const_cast<char*>(GRPC_ARG_SECURITY_CONNECTOR); grpc_channel_args args; args.num_args = 1; args.args = &arg; - grpc_channel *chan = grpc_secure_channel_create(NULL, NULL, &args, NULL); - grpc_channel_element *elem = + grpc_channel* chan = grpc_secure_channel_create(NULL, NULL, &args, NULL); + grpc_channel_element* elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0); GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client")); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -61,8 +61,8 @@ void test_security_connector_already_in_arg(void) { } void test_null_creds(void) { - grpc_channel *chan = grpc_secure_channel_create(NULL, NULL, NULL, NULL); - grpc_channel_element *elem = + grpc_channel* chan = grpc_secure_channel_create(NULL, NULL, NULL, NULL); + grpc_channel_element* elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0); GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client")); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -70,7 +70,7 @@ void test_null_creds(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_security_connector_already_in_arg(); diff --git a/test/core/surface/sequential_connectivity_test.c b/test/core/surface/sequential_connectivity_test.cc index d5fd2db81b..9ffbc82667 100644 --- a/test/core/surface/sequential_connectivity_test.c +++ b/test/core/surface/sequential_connectivity_test.cc @@ -30,20 +30,20 @@ #include "test/core/util/test_config.h" typedef struct test_fixture { - const char *name; - void (*add_server_port)(grpc_server *server, const char *addr); - grpc_channel *(*create_channel)(const char *addr); + const char* name; + void (*add_server_port)(grpc_server* server, const char* addr); + grpc_channel* (*create_channel)(const char* addr); } test_fixture; #define NUM_CONNECTIONS 1000 typedef struct { - grpc_server *server; - grpc_completion_queue *cq; + grpc_server* server; + grpc_completion_queue* cq; } server_thread_args; -static void server_thread_func(void *args) { - server_thread_args *a = args; +static void server_thread_func(void* args) { + server_thread_args* a = static_cast<server_thread_args*>(args); grpc_event ev = grpc_completion_queue_next( a->cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); @@ -51,17 +51,17 @@ static void server_thread_func(void *args) { GPR_ASSERT(ev.success == true); } -static void run_test(const test_fixture *fixture) { +static void run_test(const test_fixture* fixture) { gpr_log(GPR_INFO, "TEST: %s", fixture->name); grpc_init(); - char *addr; + char* addr; gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die()); - grpc_server *server = grpc_server_create(NULL, NULL); + grpc_server* server = grpc_server_create(NULL, NULL); fixture->add_server_port(server, addr); - grpc_completion_queue *server_cq = + grpc_completion_queue* server_cq = grpc_completion_queue_create_for_next(NULL); grpc_server_register_completion_queue(server, server_cq, NULL); grpc_server_start(server); @@ -72,8 +72,8 @@ static void run_test(const test_fixture *fixture) { gpr_thd_options_set_joinable(&thdopt); gpr_thd_new(&server_thread, server_thread_func, &sta, &thdopt); - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); - grpc_channel *channels[NUM_CONNECTIONS]; + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_channel* channels[NUM_CONNECTIONS]; for (size_t i = 0; i < NUM_CONNECTIONS; i++) { channels[i] = fixture->create_channel(addr); @@ -121,36 +121,39 @@ static void run_test(const test_fixture *fixture) { gpr_free(addr); } -static void insecure_test_add_port(grpc_server *server, const char *addr) { +static void insecure_test_add_port(grpc_server* server, const char* addr) { grpc_server_add_insecure_http2_port(server, addr); } -static grpc_channel *insecure_test_create_channel(const char *addr) { +static grpc_channel* insecure_test_create_channel(const char* addr) { return grpc_insecure_channel_create(addr, NULL, NULL); } static const test_fixture insecure_test = { - "insecure", insecure_test_add_port, insecure_test_create_channel, + "insecure", + insecure_test_add_port, + insecure_test_create_channel, }; -static void secure_test_add_port(grpc_server *server, const char *addr) { +static void secure_test_add_port(grpc_server* server, const char* addr) { grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key, test_server1_cert}; - grpc_server_credentials *ssl_creds = + grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL); grpc_server_add_secure_http2_port(server, addr, ssl_creds); grpc_server_credentials_release(ssl_creds); } -static grpc_channel *secure_test_create_channel(const char *addr) { - grpc_channel_credentials *ssl_creds = +static grpc_channel* secure_test_create_channel(const char* addr) { + grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(test_root_cert, NULL, NULL); - grpc_arg ssl_name_override = {GRPC_ARG_STRING, - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, - {"foo.test.google.fr"}}; - grpc_channel_args *new_client_args = + grpc_arg ssl_name_override = { + GRPC_ARG_STRING, + const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), + {const_cast<char*>("foo.test.google.fr")}}; + grpc_channel_args* new_client_args = grpc_channel_args_copy_and_add(NULL, &ssl_name_override, 1); - grpc_channel *channel = + grpc_channel* channel = grpc_secure_channel_create(ssl_creds, addr, new_client_args, NULL); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -162,10 +165,12 @@ static grpc_channel *secure_test_create_channel(const char *addr) { } static const test_fixture secure_test = { - "secure", secure_test_add_port, secure_test_create_channel, + "secure", + secure_test_add_port, + secure_test_create_channel, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); run_test(&insecure_test); diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.cc index cd8931e0d7..b0ffb1de3c 100644 --- a/test/core/surface/server_chttp2_test.c +++ b/test/core/surface/server_chttp2_test.cc @@ -30,7 +30,7 @@ void test_unparsable_target(void) { grpc_channel_args args = {0, NULL}; - grpc_server *server = grpc_server_create(&args, NULL); + grpc_server* server = grpc_server_create(&args, NULL); int port = grpc_server_add_insecure_http2_port(server, "["); GPR_ASSERT(port == 0); grpc_server_destroy(server); @@ -39,15 +39,15 @@ void test_unparsable_target(void) { void test_add_same_port_twice() { grpc_arg a; a.type = GRPC_ARG_INTEGER; - a.key = GRPC_ARG_ALLOW_REUSEPORT; + a.key = const_cast<char*>(GRPC_ARG_ALLOW_REUSEPORT); a.value.integer = 0; grpc_channel_args args = {1, &a}; int port = grpc_pick_unused_port_or_die(); - char *addr = NULL; - grpc_completion_queue *cq = grpc_completion_queue_create_for_pluck(NULL); - grpc_server *server = grpc_server_create(&args, NULL); - grpc_server_credentials *fake_creds = + char* addr = NULL; + grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(NULL); + grpc_server* server = grpc_server_create(&args, NULL); + grpc_server_credentials* fake_creds = grpc_fake_transport_security_server_credentials_create(); gpr_join_host_port(&addr, "localhost", port); GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); @@ -62,7 +62,7 @@ void test_add_same_port_twice() { grpc_completion_queue_destroy(cq); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_unparsable_target(); diff --git a/test/core/surface/server_test.c b/test/core/surface/server_test.cc index 4c185cd8ea..240969a121 100644 --- a/test/core/surface/server_test.c +++ b/test/core/surface/server_test.cc @@ -28,9 +28,9 @@ #include "test/core/util/test_config.h" void test_register_method_fail(void) { - grpc_server *server = grpc_server_create(NULL, NULL); - void *method; - void *method_old; + grpc_server* server = grpc_server_create(NULL, NULL); + void* method; + void* method_old; method = grpc_server_register_method(server, NULL, NULL, GRPC_SRM_PAYLOAD_NONE, 0); GPR_ASSERT(method == NULL); @@ -55,8 +55,8 @@ void test_register_method_fail(void) { } void test_request_call_on_no_server_cq(void) { - grpc_completion_queue *cc = grpc_completion_queue_create_for_next(NULL); - grpc_server *server = grpc_server_create(NULL, NULL); + grpc_completion_queue* cc = grpc_completion_queue_create_for_next(NULL); + grpc_server* server = grpc_server_create(NULL, NULL); GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE == grpc_server_request_call(server, NULL, NULL, NULL, cc, cc, NULL)); GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE == @@ -69,14 +69,14 @@ void test_request_call_on_no_server_cq(void) { void test_bind_server_twice(void) { grpc_arg a; a.type = GRPC_ARG_INTEGER; - a.key = GRPC_ARG_ALLOW_REUSEPORT; + a.key = const_cast<char*>(GRPC_ARG_ALLOW_REUSEPORT); a.value.integer = 0; grpc_channel_args args = {1, &a}; - char *addr; - grpc_server *server1 = grpc_server_create(&args, NULL); - grpc_server *server2 = grpc_server_create(&args, NULL); - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); + char* addr; + grpc_server* server1 = grpc_server_create(&args, NULL); + grpc_server* server2 = grpc_server_create(&args, NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); int port = grpc_pick_unused_port_or_die(); gpr_asprintf(&addr, "[::]:%d", port); grpc_server_register_completion_queue(server1, cq, NULL); @@ -84,7 +84,7 @@ void test_bind_server_twice(void) { GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, NULL)); GPR_ASSERT(port == grpc_server_add_insecure_http2_port(server1, addr)); GPR_ASSERT(0 == grpc_server_add_insecure_http2_port(server2, addr)); - grpc_server_credentials *fake_creds = + grpc_server_credentials* fake_creds = grpc_fake_transport_security_server_credentials_create(); GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, fake_creds)); grpc_server_credentials_release(fake_creds); @@ -98,22 +98,22 @@ void test_bind_server_twice(void) { gpr_free(addr); } -void test_bind_server_to_addr(const char *host, bool secure) { +void test_bind_server_to_addr(const char* host, bool secure) { int port = grpc_pick_unused_port_or_die(); - char *addr; + char* addr; gpr_join_host_port(&addr, host, port); gpr_log(GPR_INFO, "Test bind to %s", addr); - grpc_server *server = grpc_server_create(NULL, NULL); + grpc_server* server = grpc_server_create(NULL, NULL); if (secure) { - grpc_server_credentials *fake_creds = + grpc_server_credentials* fake_creds = grpc_fake_transport_security_server_credentials_create(); GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); grpc_server_credentials_release(fake_creds); } else { GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr)); } - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); grpc_server_register_completion_queue(server, cq, NULL); grpc_server_start(server); grpc_server_shutdown_and_notify(server, cq, NULL); @@ -123,9 +123,9 @@ void test_bind_server_to_addr(const char *host, bool secure) { gpr_free(addr); } -static int external_dns_works(const char *host) { - grpc_resolved_addresses *res = NULL; - grpc_error *error = grpc_blocking_resolve_address(host, "80", &res); +static int external_dns_works(const char* host) { + grpc_resolved_addresses* res = NULL; + grpc_error* error = grpc_blocking_resolve_address(host, "80", &res); GRPC_ERROR_UNREF(error); if (res != NULL) { grpc_resolved_addresses_destroy(res); @@ -134,28 +134,29 @@ static int external_dns_works(const char *host) { return 0; } -static void test_bind_server_to_addrs(const char **addrs, size_t n) { +static void test_bind_server_to_addrs(const char** addrs, size_t n) { for (size_t i = 0; i < n; i++) { test_bind_server_to_addr(addrs[i], false); test_bind_server_to_addr(addrs[i], true); } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_register_method_fail(); test_request_call_on_no_server_cq(); test_bind_server_twice(); - static const char *addrs[] = { + static const char* addrs[] = { "::1", "127.0.0.1", "::ffff:127.0.0.1", "localhost", "0.0.0.0", "::", }; test_bind_server_to_addrs(addrs, GPR_ARRAY_SIZE(addrs)); if (external_dns_works("loopback46.unittest.grpc.io")) { - static const char *dns_addrs[] = { - "loopback46.unittest.grpc.io", "loopback4.unittest.grpc.io", + static const char* dns_addrs[] = { + "loopback46.unittest.grpc.io", + "loopback4.unittest.grpc.io", }; test_bind_server_to_addrs(dns_addrs, GPR_ARRAY_SIZE(dns_addrs)); } |