diff options
author | Craig Tiller <ctiller@google.com> | 2017-11-08 09:42:32 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-11-08 09:42:32 -0800 |
commit | 660d4aa2d281dbfbc6c3a3e3349b3e4b6a444285 (patch) | |
tree | 592cecc1d6670bb12b9af81c19cd3cb98cc0eeef /test/core/fling | |
parent | 48d26966646e910f7dd63d428ef831178ca9315e (diff) | |
parent | d9da7387b8057f3bd99a417a5ee905377bce9296 (diff) |
Merge github.com:grpc/grpc into tfix2
Diffstat (limited to 'test/core/fling')
-rw-r--r-- | test/core/fling/BUILD | 12 | ||||
-rw-r--r-- | test/core/fling/client.cc (renamed from test/core/fling/client.c) | 34 | ||||
-rw-r--r-- | test/core/fling/fling_stream_test.cc (renamed from test/core/fling/fling_stream_test.c) | 22 | ||||
-rw-r--r-- | test/core/fling/fling_test.cc (renamed from test/core/fling/fling_test.c) | 22 | ||||
-rw-r--r-- | test/core/fling/server.cc (renamed from test/core/fling/server.c) | 43 |
5 files changed, 67 insertions, 66 deletions
diff --git a/test/core/fling/BUILD b/test/core/fling/BUILD index 27b2b5bec6..268e94aacc 100644 --- a/test/core/fling/BUILD +++ b/test/core/fling/BUILD @@ -23,8 +23,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_cc_binary( name = "client", testonly = 1, - srcs = ["client.c"], - language = "C", + srcs = ["client.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -37,8 +37,8 @@ grpc_cc_binary( grpc_cc_binary( name = "server", testonly = 1, - srcs = ["server.c"], - language = "C", + srcs = ["server.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -50,7 +50,7 @@ grpc_cc_binary( grpc_cc_test( name = "fling", - srcs = ["fling_test.c"], + srcs = ["fling_test.cc"], data = [ ":client", ":server", @@ -66,7 +66,7 @@ grpc_cc_test( grpc_cc_test( name = "fling_stream", - srcs = ["fling_stream_test.c"], + srcs = ["fling_stream_test.cc"], data = [ ":client", ":server", diff --git a/test/core/fling/client.c b/test/core/fling/client.cc index be7bfc2280..64d1dc5089 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.cc @@ -30,20 +30,20 @@ #include "test/core/util/grpc_profiler.h" #include "test/core/util/test_config.h" -static gpr_histogram *histogram; -static grpc_byte_buffer *the_buffer; -static grpc_channel *channel; -static grpc_completion_queue *cq; -static grpc_call *call; +static gpr_histogram* histogram; +static grpc_byte_buffer* the_buffer; +static grpc_channel* channel; +static grpc_completion_queue* cq; +static grpc_call* call; static grpc_op ops[6]; static grpc_op stream_init_ops[2]; static grpc_op stream_step_ops[2]; static grpc_metadata_array initial_metadata_recv; static grpc_metadata_array trailing_metadata_recv; -static grpc_byte_buffer *response_payload_recv = NULL; +static grpc_byte_buffer* response_payload_recv = NULL; static grpc_status_code status; static grpc_slice details; -static grpc_op *op; +static grpc_op* op; static void init_ping_pong_request(void) { grpc_metadata_array_init(&initial_metadata_recv); @@ -81,8 +81,8 @@ static void step_ping_pong_request(void) { grpc_slice_from_static_string("/Reflector/reflectUnary"), &host, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, - (size_t)(op - ops), - (void *)1, NULL)); + (size_t)(op - ops), (void*)1, + NULL)); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_call_unref(call); grpc_byte_buffer_destroy(response_payload_recv); @@ -104,7 +104,7 @@ static void init_ping_pong_stream(void) { stream_init_ops[1].op = GRPC_OP_RECV_INITIAL_METADATA; stream_init_ops[1].data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; - error = grpc_call_start_batch(call, stream_init_ops, 2, (void *)1, NULL); + error = grpc_call_start_batch(call, stream_init_ops, 2, (void*)1, NULL); GPR_ASSERT(GRPC_CALL_OK == error); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); @@ -119,7 +119,7 @@ static void init_ping_pong_stream(void) { static void step_ping_pong_stream(void) { grpc_call_error error; GPR_TIMER_BEGIN("ping_pong", 1); - error = grpc_call_start_batch(call, stream_step_ops, 2, (void *)1, NULL); + error = grpc_call_start_batch(call, stream_step_ops, 2, (void*)1, NULL); GPR_ASSERT(GRPC_CALL_OK == error); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_byte_buffer_destroy(response_payload_recv); @@ -132,7 +132,7 @@ static double now(void) { } typedef struct { - const char *name; + const char* name; void (*init)(); void (*do_one_step)(); } scenario; @@ -142,19 +142,19 @@ static const scenario scenarios[] = { {"ping-pong-stream", init_ping_pong_stream, step_ping_pong_stream}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_slice slice = grpc_slice_from_copied_string("x"); double start, stop; unsigned i; - char *fake_argv[1]; + char* fake_argv[1]; int payload_size = 1; int secure = 0; - char *target = "localhost:443"; - gpr_cmdline *cl; + const char* target = "localhost:443"; + gpr_cmdline* cl; grpc_event event; - char *scenario_name = "ping-pong-request"; + const char* scenario_name = "ping-pong-request"; scenario sc = {NULL, NULL, NULL}; gpr_timers_set_log_filename("latency_trace.fling_client.txt"); diff --git a/test/core/fling/fling_stream_test.c b/test/core/fling/fling_stream_test.cc index 566d9ae6f0..620427e12a 100644 --- a/test/core/fling/fling_stream_test.c +++ b/test/core/fling/fling_stream_test.cc @@ -26,12 +26,12 @@ #include "src/core/lib/support/string.h" #include "test/core/util/port.h" -int main(int argc, char **argv) { - char *me = argv[0]; - char *lslash = strrchr(me, '/'); +int main(int argc, char** argv) { + char* me = argv[0]; + char* lslash = strrchr(me, '/'); char root[1024]; int port = grpc_pick_unused_port_or_die(); - char *args[10]; + char* args[10]; int status; gpr_subprocess *svr, *cli; /* figure out where we are */ @@ -44,22 +44,22 @@ int main(int argc, char **argv) { /* start the server */ gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); - args[1] = "--bind"; + args[1] = const_cast<char*>("--bind"); gpr_join_host_port(&args[2], "::", port); - args[3] = "--no-secure"; - svr = gpr_subprocess_create(4, (const char **)args); + args[3] = const_cast<char*>("--no-secure"); + svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/fling_client%s", root, gpr_subprocess_binary_extension()); - args[1] = "--target"; + args[1] = const_cast<char*>("--target"); gpr_join_host_port(&args[2], "127.0.0.1", port); - args[3] = "--scenario=ping-pong-stream"; - args[4] = "--no-secure"; + args[3] = const_cast<char*>("--scenario=ping-pong-stream"); + args[4] = const_cast<char*>("--no-secure"); args[5] = 0; - cli = gpr_subprocess_create(6, (const char **)args); + cli = gpr_subprocess_create(6, (const char**)args); gpr_free(args[0]); gpr_free(args[2]); diff --git a/test/core/fling/fling_test.c b/test/core/fling/fling_test.cc index 90b48e7737..1d4263ab01 100644 --- a/test/core/fling/fling_test.c +++ b/test/core/fling/fling_test.cc @@ -26,12 +26,12 @@ #include "src/core/lib/support/string.h" #include "test/core/util/port.h" -int main(int argc, char **argv) { - char *me = argv[0]; - char *lslash = strrchr(me, '/'); +int main(int argc, const char** argv) { + const char* me = argv[0]; + const char* lslash = strrchr(me, '/'); char root[1024]; int port = grpc_pick_unused_port_or_die(); - char *args[10]; + char* args[10]; int status; gpr_subprocess *svr, *cli; /* figure out where we are */ @@ -44,22 +44,22 @@ int main(int argc, char **argv) { /* start the server */ gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); - args[1] = "--bind"; + args[1] = const_cast<char*>("--bind"); gpr_join_host_port(&args[2], "::", port); - args[3] = "--no-secure"; - svr = gpr_subprocess_create(4, (const char **)args); + args[3] = const_cast<char*>("--no-secure"); + svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); gpr_free(args[2]); /* start the client */ gpr_asprintf(&args[0], "%s/fling_client%s", root, gpr_subprocess_binary_extension()); - args[1] = "--target"; + args[1] = const_cast<char*>("--target"); gpr_join_host_port(&args[2], "127.0.0.1", port); - args[3] = "--scenario=ping-pong-request"; - args[4] = "--no-secure"; + args[3] = const_cast<char*>("--scenario=ping-pong-request"); + args[4] = const_cast<char*>("--no-secure"); args[5] = 0; - cli = gpr_subprocess_create(6, (const char **)args); + cli = gpr_subprocess_create(6, (const char**)args); gpr_free(args[0]); gpr_free(args[2]); diff --git a/test/core/fling/server.c b/test/core/fling/server.cc index b3a7fa21ec..4dfb30f107 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.cc @@ -40,15 +40,15 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static grpc_completion_queue *cq; -static grpc_server *server; -static grpc_call *call; +static grpc_completion_queue* cq; +static grpc_server* server; +static grpc_call* call; static grpc_call_details call_details; static grpc_metadata_array request_metadata_recv; static grpc_metadata_array initial_metadata_send; -static grpc_byte_buffer *payload_buffer = NULL; +static grpc_byte_buffer* payload_buffer = NULL; /* Used to drain the terminal read in unary calls. */ -static grpc_byte_buffer *terminal_buffer = NULL; +static grpc_byte_buffer* terminal_buffer = NULL; static grpc_op read_op; static grpc_op metadata_send_op; @@ -58,7 +58,7 @@ static int was_cancelled = 2; static grpc_op unary_ops[6]; static int got_sigint = 0; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } typedef enum { FLING_SERVER_NEW_REQUEST = 1, @@ -84,7 +84,7 @@ static void request_call(void) { } static void handle_unary_method(void) { - grpc_op *op; + grpc_op* op; grpc_call_error error; grpc_metadata_array_init(&initial_metadata_send); @@ -118,7 +118,7 @@ static void handle_unary_method(void) { static void send_initial_metadata(void) { grpc_call_error error; - void *tagarg = tag(FLING_SERVER_SEND_INIT_METADATA_FOR_STREAMING); + void* tagarg = tag(FLING_SERVER_SEND_INIT_METADATA_FOR_STREAMING); grpc_metadata_array_init(&initial_metadata_send); metadata_send_op.op = GRPC_OP_SEND_INITIAL_METADATA; metadata_send_op.data.send_initial_metadata.count = 0; @@ -138,7 +138,7 @@ static void start_read_op(int t) { static void start_write_op(void) { grpc_call_error error; - void *tagarg = tag(FLING_SERVER_WRITE_FOR_STREAMING); + void* tagarg = tag(FLING_SERVER_WRITE_FOR_STREAMING); /* Starting write at server */ write_op.op = GRPC_OP_SEND_MESSAGE; if (payload_buffer == NULL) { @@ -151,7 +151,7 @@ static void start_write_op(void) { static void start_send_status(void) { grpc_call_error error; - void *tagarg = tag(FLING_SERVER_SEND_STATUS_FOR_STREAMING); + void* tagarg = tag(FLING_SERVER_SEND_STATUS_FOR_STREAMING); status_op[0].op = GRPC_OP_SEND_STATUS_FROM_SERVER; status_op[0].data.send_status_from_server.status = GRPC_STATUS_OK; status_op[0].data.send_status_from_server.trailing_metadata_count = 0; @@ -167,19 +167,19 @@ static void start_send_status(void) { When that is resolved, please remove the #include <unistd.h> above. */ static void sigint_handler(int x) { _exit(0); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_event ev; - call_state *s; - char *addr_buf = NULL; - gpr_cmdline *cl; - grpc_completion_queue *shutdown_cq; + call_state* s; + char* addr_buf = NULL; + gpr_cmdline* cl; + grpc_completion_queue* shutdown_cq; int shutdown_started = 0; int shutdown_finished = 0; int secure = 0; - char *addr = NULL; + const char* addr = NULL; - char *fake_argv[1]; + char* fake_argv[1]; gpr_timers_set_log_filename("latency_trace.fling_server.txt"); @@ -206,7 +206,7 @@ int main(int argc, char **argv) { if (secure) { grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key, test_server1_cert}; - grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create( + grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create( NULL, &pem_key_cert_pair, 1, 0, NULL); server = grpc_server_create(NULL, NULL); GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds)); @@ -244,10 +244,11 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); - s = ev.tag; + s = static_cast<call_state*>(ev.tag); switch (ev.type) { case GRPC_OP_COMPLETE: switch ((intptr_t)s) { |