diff options
Diffstat (limited to 'test')
329 files changed, 6629 insertions, 6121 deletions
diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc index a29cce6cc7..ef2de8d638 100644 --- a/test/core/backoff/backoff_test.cc +++ b/test/core/backoff/backoff_test.cc @@ -19,125 +19,162 @@ #include "src/core/lib/backoff/backoff.h" #include <grpc/support/log.h> +#include <grpc/support/useful.h> #include "test/core/util/test_config.h" static void test_constant_backoff(void) { grpc_backoff backoff; - grpc_backoff_init(&backoff, 200 /* initial timeout */, 1.0 /* multiplier */, - 0.0 /* jitter */, 100 /* min timeout */, - 1000 /* max timeout */); - + const grpc_millis initial_backoff = 200; + const double multiplier = 1.0; + const double jitter = 0.0; + const grpc_millis min_connect_timeout = 100; + const grpc_millis max_backoff = 1000; + grpc_backoff_init(&backoff, initial_backoff, multiplier, jitter, + min_connect_timeout, max_backoff); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 200); + grpc_backoff_result next_deadlines = grpc_backoff_begin(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx) == + initial_backoff); + GPR_ASSERT(next_deadlines.next_attempt_start_time - + grpc_exec_ctx_now(&exec_ctx) == + initial_backoff); for (int i = 0; i < 10000; i++) { - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 200); - exec_ctx.now = next; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx) == + initial_backoff); + GPR_ASSERT(next_deadlines.next_attempt_start_time - + grpc_exec_ctx_now(&exec_ctx) == + initial_backoff); + exec_ctx.now = next_deadlines.current_deadline; } grpc_exec_ctx_finish(&exec_ctx); } static void test_min_connect(void) { grpc_backoff backoff; - grpc_backoff_init(&backoff, 100 /* initial timeout */, 1.0 /* multiplier */, - 0.0 /* jitter */, 200 /* min timeout */, - 1000 /* max timeout */); - + const grpc_millis initial_backoff = 100; + const double multiplier = 1.0; + const double jitter = 0.0; + const grpc_millis min_connect_timeout = 200; + const grpc_millis max_backoff = 1000; + grpc_backoff_init(&backoff, initial_backoff, multiplier, jitter, + min_connect_timeout, max_backoff); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 200); + grpc_backoff_result next = grpc_backoff_begin(&exec_ctx, &backoff); + // Because the min_connect_timeout > initial_backoff, current_deadline is used + // as the deadline for the current attempt. + GPR_ASSERT(next.current_deadline - grpc_exec_ctx_now(&exec_ctx) == + min_connect_timeout); + // ... while, if the current attempt fails, the next one will happen after + // initial_backoff. + GPR_ASSERT(next.next_attempt_start_time - grpc_exec_ctx_now(&exec_ctx) == + initial_backoff); grpc_exec_ctx_finish(&exec_ctx); } static void test_no_jitter_backoff(void) { grpc_backoff backoff; - grpc_backoff_init(&backoff, 2 /* initial timeout */, 2.0 /* multiplier */, - 0.0 /* jitter */, 1 /* min timeout */, - 513 /* max timeout */); + const grpc_millis initial_backoff = 2; + const double multiplier = 2.0; + const double jitter = 0.0; + const grpc_millis min_connect_timeout = 1; + const grpc_millis max_backoff = 513; + grpc_backoff_init(&backoff, initial_backoff, multiplier, jitter, + min_connect_timeout, max_backoff); // x_1 = 2 // x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 ) grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; exec_ctx.now = 0; exec_ctx.now_is_valid = true; - grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff); - GPR_ASSERT(next == 2); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 6); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 14); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 30); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 62); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 126); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 254); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 510); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 1022); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); + grpc_backoff_result next_deadlines = grpc_backoff_begin(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == + next_deadlines.next_attempt_start_time); + GPR_ASSERT(next_deadlines.current_deadline == 2); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 6); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 14); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 30); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 62); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 126); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 254); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 510); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 1022); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); // Hit the maximum timeout. From this point onwards, retries will increase // only by max timeout. - GPR_ASSERT(next == 1535); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 2048); - exec_ctx.now = next; - next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next == 2561); + GPR_ASSERT(next_deadlines.current_deadline == 1535); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 2048); + exec_ctx.now = next_deadlines.current_deadline; + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline == 2561); grpc_exec_ctx_finish(&exec_ctx); } static void test_jitter_backoff(void) { - const int64_t initial_timeout = 500; + const grpc_millis initial_backoff = 500; + grpc_millis current_backoff = initial_backoff; + const grpc_millis max_backoff = 1000; + const grpc_millis min_connect_timeout = 100; + const double multiplier = 1.0; const double jitter = 0.1; grpc_backoff backoff; - grpc_backoff_init(&backoff, (grpc_millis)initial_timeout, - 1.0 /* multiplier */, jitter, 100 /* min timeout */, - 1000 /* max timeout */); + grpc_backoff_init(&backoff, initial_backoff, multiplier, jitter, + min_connect_timeout, max_backoff); backoff.rng_state = 0; // force consistent PRNG grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 500); - - int64_t expected_next_lower_bound = - (int64_t)((double)initial_timeout * (1 - jitter)); - int64_t expected_next_upper_bound = - (int64_t)((double)initial_timeout * (1 + jitter)); + grpc_backoff_result next_deadlines = grpc_backoff_begin(&exec_ctx, &backoff); + GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx) == + initial_backoff); + GPR_ASSERT(next_deadlines.next_attempt_start_time - + grpc_exec_ctx_now(&exec_ctx) == + initial_backoff); + + grpc_millis expected_next_lower_bound = + (grpc_millis)((double)current_backoff * (1 - jitter)); + grpc_millis expected_next_upper_bound = + (grpc_millis)((double)current_backoff * (1 + jitter)); for (int i = 0; i < 10000; i++) { - next = grpc_backoff_step(&exec_ctx, &backoff); - - // next-now must be within (jitter*100)% of the previous timeout. - const int64_t timeout_millis = next - grpc_exec_ctx_now(&exec_ctx); + next_deadlines = grpc_backoff_step(&exec_ctx, &backoff); + // next-now must be within (jitter*100)% of the current backoff (which + // increases by * multiplier up to max_backoff). + const grpc_millis timeout_millis = + next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx); GPR_ASSERT(timeout_millis >= expected_next_lower_bound); GPR_ASSERT(timeout_millis <= expected_next_upper_bound); - + current_backoff = GPR_MIN( + (grpc_millis)((double)current_backoff * multiplier), max_backoff); expected_next_lower_bound = - (int64_t)((double)timeout_millis * (1 - jitter)); + (grpc_millis)((double)current_backoff * (1 - jitter)); expected_next_upper_bound = - (int64_t)((double)timeout_millis * (1 + jitter)); - exec_ctx.now = next; + (grpc_millis)((double)current_backoff * (1 + jitter)); + exec_ctx.now = next_deadlines.current_deadline; } grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); gpr_time_init(); diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc index b7b28a9ac4..b1944425ba 100644 --- a/test/core/bad_client/bad_client.cc +++ b/test/core/bad_client/bad_client.cc @@ -36,53 +36,53 @@ #include "src/core/lib/surface/server.h" typedef struct { - grpc_server *server; - grpc_completion_queue *cq; + grpc_server* server; + grpc_completion_queue* cq; grpc_bad_client_server_side_validator validator; - void *registered_method; + void* registered_method; gpr_event done_thd; gpr_event done_write; } thd_args; -static void thd_func(void *arg) { - thd_args *a = (thd_args *)arg; +static void thd_func(void* arg) { + thd_args* a = (thd_args*)arg; a->validator(a->server, a->cq, a->registered_method); - gpr_event_set(&a->done_thd, (void *)1); + gpr_event_set(&a->done_thd, (void*)1); } -static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - thd_args *a = (thd_args *)arg; - gpr_event_set(&a->done_write, (void *)1); +static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + thd_args* a = (thd_args*)arg; + gpr_event_set(&a->done_write, (void*)1); } -static void server_setup_transport(void *ts, grpc_transport *transport) { - thd_args *a = (thd_args *)ts; +static void server_setup_transport(void* ts, grpc_transport* transport) { + thd_args* a = (thd_args*)ts; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_server_setup_transport(&exec_ctx, a->server, transport, NULL, grpc_server_get_channel_args(a->server)); grpc_exec_ctx_finish(&exec_ctx); } -static void read_done(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - gpr_event *read_done = (gpr_event *)arg; - gpr_event_set(read_done, (void *)1); +static void read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + gpr_event* read_done = (gpr_event*)arg; + gpr_event_set(read_done, (void*)1); } void grpc_run_bad_client_test( grpc_bad_client_server_side_validator server_validator, grpc_bad_client_client_stream_validator client_validator, - const char *client_payload, size_t client_payload_length, uint32_t flags) { + const char* client_payload, size_t client_payload_length, uint32_t flags) { grpc_endpoint_pair sfd; thd_args a; gpr_thd_id id; - char *hex; - grpc_transport *transport; + char* hex; + grpc_transport* transport; grpc_slice slice = grpc_slice_from_copied_buffer(client_payload, client_payload_length); grpc_slice_buffer outgoing; grpc_closure done_write_closure; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_completion_queue *shutdown_cq; + grpc_completion_queue* shutdown_cq; if (client_payload_length < 4 * 1024) { hex = gpr_dump(client_payload, client_payload_length, diff --git a/test/core/bad_client/bad_client.h b/test/core/bad_client/bad_client.h index a5b01f7f2c..d3abfac2aa 100644 --- a/test/core/bad_client/bad_client.h +++ b/test/core/bad_client/bad_client.h @@ -28,13 +28,13 @@ #define GRPC_BAD_CLIENT_REGISTERED_METHOD "/registered/bar" #define GRPC_BAD_CLIENT_REGISTERED_HOST "localhost" -typedef void (*grpc_bad_client_server_side_validator)(grpc_server *server, - grpc_completion_queue *cq, - void *registered_method); +typedef void (*grpc_bad_client_server_side_validator)(grpc_server* server, + grpc_completion_queue* cq, + void* registered_method); // Returns false if we need to read more data. typedef bool (*grpc_bad_client_client_stream_validator)( - grpc_slice_buffer *incoming); + grpc_slice_buffer* incoming); #define GRPC_BAD_CLIENT_DISCONNECT 1 #define GRPC_BAD_CLIENT_LARGE_REQUEST 2 @@ -47,7 +47,7 @@ typedef bool (*grpc_bad_client_client_stream_validator)( void grpc_run_bad_client_test( grpc_bad_client_server_side_validator server_validator, grpc_bad_client_client_stream_validator client_validator, - const char *client_payload, size_t client_payload_length, uint32_t flags); + const char* client_payload, size_t client_payload_length, uint32_t flags); #define GRPC_RUN_BAD_CLIENT_TEST(server_validator, client_validator, payload, \ flags) \ diff --git a/test/core/bad_client/tests/badreq.cc b/test/core/bad_client/tests/badreq.cc index 7d9a103e43..5273c831e5 100644 --- a/test/core/bad_client/tests/badreq.cc +++ b/test/core/bad_client/tests/badreq.cc @@ -27,8 +27,8 @@ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ -static void verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( cq, grpc_timeout_milliseconds_to_deadline(20), NULL) @@ -36,12 +36,13 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); /* invalid content type */ GRPC_RUN_BAD_CLIENT_TEST( - verifier, NULL, PFX_STR + verifier, NULL, + PFX_STR "\x00\x00\xc2\x01\x04\x00\x00\x00\x01" "\x10\x05:path\x08/foo/bar" "\x10\x07:scheme\x04http" @@ -56,7 +57,8 @@ int main(int argc, char **argv) { /* invalid te */ GRPC_RUN_BAD_CLIENT_TEST( - verifier, NULL, PFX_STR + verifier, NULL, + PFX_STR "\x00\x00\xcb\x01\x04\x00\x00\x00\x01" "\x10\x05:path\x08/foo/bar" "\x10\x07:scheme\x04http" @@ -73,7 +75,8 @@ int main(int argc, char **argv) { /* two path headers */ GRPC_RUN_BAD_CLIENT_TEST( - verifier, NULL, PFX_STR + verifier, NULL, + PFX_STR "\x00\x00\xd9\x01\x04\x00\x00\x00\x01" "\x10\x05:path\x08/foo/bar" "\x10\x05:path\x08/foo/bah" @@ -90,7 +93,8 @@ int main(int argc, char **argv) { /* bad accept-encoding algorithm */ GRPC_RUN_BAD_CLIENT_TEST( - verifier, NULL, PFX_STR + verifier, NULL, + PFX_STR "\x00\x00\xd2\x01\x04\x00\x00\x00\x01" "\x10\x05:path\x08/foo/bar" "\x10\x07:scheme\x04http" @@ -106,7 +110,8 @@ int main(int argc, char **argv) { /* bad grpc-encoding algorithm */ GRPC_RUN_BAD_CLIENT_TEST( - verifier, NULL, PFX_STR + verifier, NULL, + PFX_STR "\x00\x00\xf5\x01\x04\x00\x00\x00\x01" "\x10\x05:path\x08/foo/bar" "\x10\x07:scheme\x04http" diff --git a/test/core/bad_client/tests/connection_prefix.cc b/test/core/bad_client/tests/connection_prefix.cc index 6cc4b72314..a4fd734e04 100644 --- a/test/core/bad_client/tests/connection_prefix.cc +++ b/test/core/bad_client/tests/connection_prefix.cc @@ -19,8 +19,8 @@ #include "src/core/lib/surface/server.h" #include "test/core/bad_client/bad_client.h" -static void verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( cq, grpc_timeout_milliseconds_to_deadline(20), NULL) @@ -28,7 +28,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, "X", 0); diff --git a/test/core/bad_client/tests/head_of_line_blocking.cc b/test/core/bad_client/tests/head_of_line_blocking.cc index cb89423907..aad335cf5b 100644 --- a/test/core/bad_client/tests/head_of_line_blocking.cc +++ b/test/core/bad_client/tests/head_of_line_blocking.cc @@ -65,16 +65,16 @@ static const char prefix[] = "\x01\x00\x00\x27\x10" ""; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -static void verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { grpc_call_error error; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(cq); + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(cq); grpc_metadata_array request_metadata_recv; gpr_timespec deadline; - grpc_byte_buffer *payload = NULL; + grpc_byte_buffer* payload = NULL; grpc_metadata_array_init(&request_metadata_recv); @@ -93,20 +93,20 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, cq_verifier_destroy(cqv); } -char *g_buffer; +char* g_buffer; size_t g_cap = 0; size_t g_count = 0; -static void addbuf(const void *data, size_t len) { +static void addbuf(const void* data, size_t len) { if (g_count + len > g_cap) { g_cap = GPR_MAX(g_count + len, g_cap * 2); - g_buffer = static_cast<char *>(gpr_realloc(g_buffer, g_cap)); + g_buffer = static_cast<char*>(gpr_realloc(g_buffer, g_cap)); } memcpy(g_buffer + g_count, data, len); g_count += len; } -int main(int argc, char **argv) { +int main(int argc, char** argv) { int i; grpc_test_init(argc, argv); diff --git a/test/core/bad_client/tests/headers.cc b/test/core/bad_client/tests/headers.cc index c704dbbcb6..f96c6f0028 100644 --- a/test/core/bad_client/tests/headers.cc +++ b/test/core/bad_client/tests/headers.cc @@ -23,8 +23,8 @@ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" -static void verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( cq, grpc_timeout_milliseconds_to_deadline(20), NULL) @@ -32,7 +32,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); /* partial http2 header prefixes */ @@ -66,194 +66,236 @@ int main(int argc, char **argv) { GRPC_BAD_CLIENT_DISCONNECT); /* test adding prioritization data */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x01\x01\x24\x00\x00\x00\x01" "\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x02\x01\x24\x00\x00\x00\x01" "\x00\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x03\x01\x24\x00\x00\x00\x01" "\x00\x00\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x04\x01\x24\x00\x00\x00\x01" "\x00\x00\x00\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x05\x01\x24\x00\x00\x00\x01" "", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x05\x01\x24\x00\x00\x00\x01" "\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x05\x01\x24\x00\x00\x00\x01" "\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x05\x01\x24\x00\x00\x00\x01" "\x00\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x05\x01\x24\x00\x00\x00\x01" "\x00\x00\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x05\x01\x24\x00\x00\x00\x01" "\x00\x00\x00\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); /* test looking up an invalid index */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x01\x01\x04\x00\x00\x00\x01" "\xfe", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x04\x01\x04\x00\x00\x00\x01" "\x7f\x7f\x01" "a", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x04\x01\x04\x00\x00\x00\x01" "\x0f\x7f\x01" "a", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x04\x01\x04\x00\x00\x00\x01" "\x1f\x7f\x01" "a", 0); /* test nvr, not indexed in static table */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" "\x01\x01" "a", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" "\x11\x01" "a", GRPC_BAD_CLIENT_DISCONNECT); /* illegal op code */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x01\x01\x04\x00\x00\x00\x01" "\x80", 0); /* parse some long indices */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x02\x01\x04\x00\x00\x00\x01" "\xff\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" "\xff\x80\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x04\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x05\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x06\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80\x80\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x07\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80\x80\x80\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x08\x01\x04\x00\x00\x00\x01" "\xff", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x08\x01\x04\x00\x00\x00\x01" "\xff\x80", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x08\x01\x04\x00\x00\x00\x01" "\xff\x80\x80", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x08\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x08\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80\x80", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x08\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80\x80\x80", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x08\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80\x80\x80\x80", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x08\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80\x80\x80\x80\x00", 0); /* overflow on byte 4 */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x06\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80\x80\x7f", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x06\x01\x04\x00\x00\x00\x01" "\xff\xff\xff\xff\xff\x0f", GRPC_BAD_CLIENT_DISCONNECT); /* overflow after byte 4 */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x08\x01\x04\x00\x00\x00\x01" "\xff\x80\x80\x80\x80\x80\x80\x02", 0); /* end of headers mid-opcode */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x01\x01\x04\x00\x00\x00\x01" "\x01", GRPC_BAD_CLIENT_DISCONNECT); /* dynamic table size update: set to default */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" "\x3f\xe1\x1f", GRPC_BAD_CLIENT_DISCONNECT); /* dynamic table size update: set too large */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" "\x3f\xf1\x1f", 0); /* dynamic table size update: set twice */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x04\x01\x04\x00\x00\x00\x01" "\x20\x3f\xe1\x1f", GRPC_BAD_CLIENT_DISCONNECT); /* dynamic table size update: set thrice */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" "\x20\x20\x20", 0); /* non-ending header followed by continuation frame */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x00\x01\x00\x00\x00\x00\x01" "\x00\x00\x00\x09\x04\x00\x00\x00\x01", GRPC_BAD_CLIENT_DISCONNECT); /* non-ending header followed by non-continuation frame */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x00\x01\x00\x00\x00\x00\x01" "\x00\x00\x00\x00\x04\x00\x00\x00\x01", 0); /* non-ending header followed by a continuation frame for a different stream */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x00\x01\x04\x00\x00\x00\x01" "\x00\x00\x00\x01\x00\x00\x00\x00\x03" "\x00\x00\x00\x09\x04\x00\x00\x00\x01", @@ -262,7 +304,8 @@ int main(int argc, char **argv) { GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR "\x00\x00\x00\x09\x04\x00\x00\x00\x01", 0); /* three header frames */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x00\x01\x04\x00\x00\x00\x01" "\x00\x00\x00\x01\x04\x00\x00\x00\x01" "\x00\x00\x00\x01\x04\x00\x00\x00\x01", @@ -274,13 +317,15 @@ int main(int argc, char **argv) { GRPC_BAD_CLIENT_DISCONNECT); /* a badly encoded timeout value */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x19\x01\x04\x00\x00\x00\x01" "\x10\x0cgrpc-timeout\x0a" "15 seconds", GRPC_BAD_CLIENT_DISCONNECT); /* a badly encoded timeout value: twice (catches caching) */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x19\x01\x04\x00\x00\x00\x01" "\x10\x0cgrpc-timeout\x0a" "15 seconds" diff --git a/test/core/bad_client/tests/initial_settings_frame.cc b/test/core/bad_client/tests/initial_settings_frame.cc index 0696ef9383..dde9d4b5d3 100644 --- a/test/core/bad_client/tests/initial_settings_frame.cc +++ b/test/core/bad_client/tests/initial_settings_frame.cc @@ -22,8 +22,8 @@ #define PFX_STR "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" #define ONE_SETTING_HDR "\x00\x00\x06\x04\x00\x00\x00\x00\x00" -static void verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( cq, grpc_timeout_milliseconds_to_deadline(20), NULL) @@ -31,7 +31,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); /* various partial prefixes */ @@ -92,7 +92,8 @@ int main(int argc, char **argv) { PFX_STR ONE_SETTING_HDR "\x00\x04\x00\x01\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); /* ack with data */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x00\x04\x00\x00\x00\x00\x00" "\x00\x00\x01\x04\x01\x00\x00\x00\x00", 0); diff --git a/test/core/bad_client/tests/large_metadata.cc b/test/core/bad_client/tests/large_metadata.cc index ca3d234be9..df7dd8f4b3 100644 --- a/test/core/bad_client/tests/large_metadata.cc +++ b/test/core/bad_client/tests/large_metadata.cc @@ -93,14 +93,14 @@ "\x10\x02te\x08trailers" \ "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -static void server_verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void server_verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { grpc_call_error error; - grpc_call *s; + grpc_call* s; grpc_call_details call_details; - cq_verifier *cqv = cq_verifier_create(cq); + cq_verifier* cqv = cq_verifier_create(cq); grpc_metadata_array request_metadata_recv; grpc_call_details_init(&call_details); @@ -121,13 +121,13 @@ static void server_verifier(grpc_server *server, grpc_completion_queue *cq, cq_verifier_destroy(cqv); } -static void server_verifier_sends_too_much_metadata(grpc_server *server, - grpc_completion_queue *cq, - void *registered_method) { +static void server_verifier_sends_too_much_metadata(grpc_server* server, + grpc_completion_queue* cq, + void* registered_method) { grpc_call_error error; - grpc_call *s; + grpc_call* s; grpc_call_details call_details; - cq_verifier *cqv = cq_verifier_create(cq); + cq_verifier* cqv = cq_verifier_create(cq); grpc_metadata_array request_metadata_recv; grpc_call_details_init(&call_details); @@ -167,10 +167,10 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server, cq_verifier_destroy(cqv); } -static bool client_validator(grpc_slice_buffer *incoming) { +static bool client_validator(grpc_slice_buffer* incoming) { for (size_t i = 0; i < incoming->count; ++i) { - const char *s = (const char *)GRPC_SLICE_START_PTR(incoming->slices[i]); - char *hex = gpr_dump(s, GRPC_SLICE_LENGTH(incoming->slices[i]), + const char* s = (const char*)GRPC_SLICE_START_PTR(incoming->slices[i]); + char* hex = gpr_dump(s, GRPC_SLICE_LENGTH(incoming->slices[i]), GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_INFO, "RESPONSE SLICE %" PRIdPTR ": %s", i, hex); gpr_free(hex); @@ -183,7 +183,7 @@ static bool client_validator(grpc_slice_buffer *incoming) { GPR_ASSERT(last_frame_buffer.count == 1); grpc_slice last_frame = last_frame_buffer.slices[0]; - const uint8_t *p = GRPC_SLICE_START_PTR(last_frame); + const uint8_t* p = GRPC_SLICE_START_PTR(last_frame); bool success = // Length == 4 *p++ != 0 || *p++ != 0 || *p++ != 4 || @@ -204,7 +204,7 @@ static bool client_validator(grpc_slice_buffer *incoming) { return success; } -int main(int argc, char **argv) { +int main(int argc, char** argv) { int i; grpc_test_init(argc, argv); @@ -213,14 +213,14 @@ int main(int argc, char **argv) { gpr_strvec headers; gpr_strvec_init(&headers); for (i = 0; i < NUM_HEADERS; ++i) { - char *str; + char* str; gpr_asprintf(&str, "%s%02d%s", PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_START_STR, i, PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_END_STR); gpr_strvec_add(&headers, str); } size_t headers_len; - const char *client_headers = gpr_strvec_flatten(&headers, &headers_len); + const char* client_headers = gpr_strvec_flatten(&headers, &headers_len); gpr_strvec_destroy(&headers); char client_payload[PFX_TOO_MUCH_METADATA_FROM_CLIENT_PAYLOAD_SIZE] = PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR; @@ -229,7 +229,7 @@ int main(int argc, char **argv) { client_headers, headers_len); GRPC_RUN_BAD_CLIENT_TEST(server_verifier, client_validator, client_payload, 0); - gpr_free((void *)client_headers); + gpr_free((void*)client_headers); // Test sending more metadata than the client will accept. GRPC_RUN_BAD_CLIENT_TEST(server_verifier_sends_too_much_metadata, diff --git a/test/core/bad_client/tests/server_registered_method.cc b/test/core/bad_client/tests/server_registered_method.cc index f52350302b..b1b11235de 100644 --- a/test/core/bad_client/tests/server_registered_method.cc +++ b/test/core/bad_client/tests/server_registered_method.cc @@ -38,16 +38,16 @@ "\x10\x02te\x08trailers" \ "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier_succeeds(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { grpc_call_error error; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(cq); + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(cq); grpc_metadata_array request_metadata_recv; gpr_timespec deadline; - grpc_byte_buffer *payload = NULL; + grpc_byte_buffer* payload = NULL; grpc_metadata_array_init(&request_metadata_recv); @@ -66,8 +66,8 @@ static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq, cq_verifier_destroy(cqv); } -static void verifier_fails(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier_fails(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( cq, grpc_timeout_milliseconds_to_deadline(20), NULL) @@ -75,7 +75,7 @@ static void verifier_fails(grpc_server *server, grpc_completion_queue *cq, } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); /* body generated with @@ -86,10 +86,12 @@ int main(int argc, char **argv) { GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, NULL, PFX_STR "\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, NULL, + PFX_STR "\x00\x00\x02\x00\x00\x00\x00\x00\x01\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, NULL, + PFX_STR "\x00\x00\x03\x00\x00\x00\x00\x00\x01\x00\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); GRPC_RUN_BAD_CLIENT_TEST( @@ -116,7 +118,8 @@ int main(int argc, char **argv) { PFX_STR "\x00\x00\x06\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00", GRPC_BAD_CLIENT_DISCONNECT); GRPC_RUN_BAD_CLIENT_TEST( - verifier_succeeds, NULL, PFX_STR + verifier_succeeds, NULL, + PFX_STR "\x00\x00\x07\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00", 0); diff --git a/test/core/bad_client/tests/simple_request.cc b/test/core/bad_client/tests/simple_request.cc index a516632819..b9cc1e3259 100644 --- a/test/core/bad_client/tests/simple_request.cc +++ b/test/core/bad_client/tests/simple_request.cc @@ -83,14 +83,14 @@ "\x10\x0cgrpc-timeout\x02" \ "5S" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -static void verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { grpc_call_error error; - grpc_call *s; + grpc_call* s; grpc_call_details call_details; - cq_verifier *cqv = cq_verifier_create(cq); + cq_verifier* cqv = cq_verifier_create(cq); grpc_metadata_array request_metadata_recv; grpc_call_details_init(&call_details); @@ -111,8 +111,8 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, cq_verifier_destroy(cqv); } -static void failure_verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void failure_verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( cq, grpc_timeout_milliseconds_to_deadline(20), NULL) @@ -120,7 +120,7 @@ static void failure_verifier(grpc_server *server, grpc_completion_queue *cq, } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); /* basic request: check that things are working */ @@ -129,7 +129,8 @@ int main(int argc, char **argv) { GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR_UNUSUAL2, 0); /* push an illegal data frame */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, NULL, + PFX_STR "\x00\x00\x05\x00\x00\x00\x00\x00\x01" "\x34\x00\x00\x00\x00", 0); @@ -144,7 +145,8 @@ int main(int argc, char **argv) { GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL, PFX_STR "\x00\x00\x00\x08\x10\x00\x00\x00\x01", 0); /* push a window update with bad data */ - GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL, PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, NULL, + PFX_STR "\x00\x00\x04\x08\x00\x00\x00\x00\x01" "\xff\xff\xff\xff", 0); diff --git a/test/core/bad_client/tests/unknown_frame.cc b/test/core/bad_client/tests/unknown_frame.cc index 448803d12b..b8367a2b65 100644 --- a/test/core/bad_client/tests/unknown_frame.cc +++ b/test/core/bad_client/tests/unknown_frame.cc @@ -23,8 +23,8 @@ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" -static void verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( cq, grpc_timeout_milliseconds_to_deadline(20), NULL) @@ -32,7 +32,7 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); /* test adding prioritization data */ diff --git a/test/core/bad_client/tests/window_overflow.cc b/test/core/bad_client/tests/window_overflow.cc index 40552e5345..cb4b790de2 100644 --- a/test/core/bad_client/tests/window_overflow.cc +++ b/test/core/bad_client/tests/window_overflow.cc @@ -42,8 +42,8 @@ "\x10\x02te\x08trailers" \ "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" -static void verifier(grpc_server *server, grpc_completion_queue *cq, - void *registered_method) { +static void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next( cq, grpc_timeout_milliseconds_to_deadline(20), NULL) @@ -51,20 +51,20 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, } } -char *g_buffer; +char* g_buffer; size_t g_cap = 0; size_t g_count = 0; -static void addbuf(const void *data, size_t len) { +static void addbuf(const void* data, size_t len) { if (g_count + len > g_cap) { g_cap = GPR_MAX(g_count + len, g_cap * 2); - g_buffer = static_cast<char *>(gpr_realloc(g_buffer, g_cap)); + g_buffer = static_cast<char*>(gpr_realloc(g_buffer, g_cap)); } memcpy(g_buffer + g_count, data, len); g_count += len; } -int main(int argc, char **argv) { +int main(int argc, char** argv) { int i, j; #define MAX_FRAME_SIZE 16384 #define MESSAGES_PER_FRAME (MAX_FRAME_SIZE / 5) diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 2183fbb633..3cfa2a4a2b 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -32,13 +32,13 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -static void run_test(const char *target, size_t nops) { - grpc_channel_credentials *ssl_creds = +static void run_test(const char* target, size_t nops) { + grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); - grpc_channel *channel; - grpc_call *c; + grpc_channel* channel; + grpc_call* c; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; @@ -46,16 +46,16 @@ static void run_test(const char *target, size_t nops) { grpc_status_code status; grpc_call_error error; gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); - cq_verifier *cqv = cq_verifier_create(cq); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + cq_verifier* cqv = cq_verifier_create(cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_arg ssl_name_override = { GRPC_ARG_STRING, - const_cast<char *>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), - {const_cast<char *>("foo.test.google.fr")}}; + const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), + {const_cast<char*>("foo.test.google.fr")}}; grpc_channel_args args; args.num_args = 1; @@ -112,18 +112,18 @@ static void run_test(const char *target, size_t nops) { grpc_channel_credentials_release(ssl_creds); } -int main(int argc, char **argv) { - char *me = argv[0]; - char *lslash = strrchr(me, '/'); - char *lunder = strrchr(me, '_'); - char *tmp; +int main(int argc, char** argv) { + char* me = argv[0]; + char* lslash = strrchr(me, '/'); + char* lunder = strrchr(me, '_'); + char* tmp; char root[1024]; char test[64]; int port = grpc_pick_unused_port_or_die(); - char *args[10]; + char* args[10]; int status; size_t i; - gpr_subprocess *svr; + gpr_subprocess* svr; /* figure out where we are */ if (lslash) { memcpy(root, me, (size_t)(lslash - me)); @@ -142,9 +142,9 @@ int main(int argc, char **argv) { /* start the server */ gpr_asprintf(&args[0], "%s/bad_ssl_%s_server%s", root, test, gpr_subprocess_binary_extension()); - args[1] = const_cast<char *>("--bind"); + args[1] = const_cast<char*>("--bind"); gpr_join_host_port(&args[2], "::", port); - svr = gpr_subprocess_create(4, (const char **)args); + svr = gpr_subprocess_create(4, (const char**)args); gpr_free(args[0]); for (i = 3; i <= 4; i++) { diff --git a/test/core/bad_ssl/server_common.cc b/test/core/bad_ssl/server_common.cc index 5def618257..0110ed5ad2 100644 --- a/test/core/bad_ssl/server_common.cc +++ b/test/core/bad_ssl/server_common.cc @@ -32,9 +32,9 @@ static int got_sigint = 0; static void sigint_handler(int x) { got_sigint = 1; } -const char *bad_ssl_addr(int argc, char **argv) { - gpr_cmdline *cl; - const char *addr = NULL; +const char* bad_ssl_addr(int argc, char** argv) { + gpr_cmdline* cl; + const char* addr = NULL; cl = gpr_cmdline_create("test server"); gpr_cmdline_add_string(cl, "bind", "Bind host:port", &addr); gpr_cmdline_parse(cl, argc, argv); @@ -43,17 +43,17 @@ const char *bad_ssl_addr(int argc, char **argv) { return addr; } -void bad_ssl_run(grpc_server *server) { +void bad_ssl_run(grpc_server* server) { int shutdown_started = 0; int shutdown_finished = 0; grpc_event ev; grpc_call_error error; - grpc_call *s = NULL; + grpc_call* s = NULL; grpc_call_details call_details; grpc_metadata_array request_metadata_recv; - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); - grpc_completion_queue *shutdown_cq; + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* shutdown_cq; grpc_call_details_init(&call_details); grpc_metadata_array_init(&request_metadata_recv); @@ -62,7 +62,7 @@ void bad_ssl_run(grpc_server *server) { grpc_server_start(server); error = grpc_server_request_call(server, &s, &call_details, - &request_metadata_recv, cq, cq, (void *)1); + &request_metadata_recv, cq, cq, (void*)1); GPR_ASSERT(GRPC_CALL_OK == error); signal(SIGINT, sigint_handler); @@ -80,12 +80,13 @@ void bad_ssl_run(grpc_server *server) { 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); switch (ev.type) { case GRPC_OP_COMPLETE: - GPR_ASSERT(ev.tag == (void *)1); + GPR_ASSERT(ev.tag == (void*)1); GPR_ASSERT(ev.success == 0); break; case GRPC_QUEUE_SHUTDOWN: diff --git a/test/core/bad_ssl/server_common.h b/test/core/bad_ssl/server_common.h index 35d51b1cb4..e1933b973e 100644 --- a/test/core/bad_ssl/server_common.h +++ b/test/core/bad_ssl/server_common.h @@ -21,7 +21,7 @@ #include <grpc/grpc.h> -const char *bad_ssl_addr(int argc, char **argv); -void bad_ssl_run(grpc_server *server); +const char* bad_ssl_addr(int argc, char** argv); +void bad_ssl_run(grpc_server* server); #endif /* GRPC_TEST_CORE_BAD_SSL_SERVER_H */ diff --git a/test/core/bad_ssl/servers/alpn.cc b/test/core/bad_ssl/servers/alpn.cc index 3179054aff..a207516a72 100644 --- a/test/core/bad_ssl/servers/alpn.cc +++ b/test/core/bad_ssl/servers/alpn.cc @@ -31,9 +31,9 @@ * a protocol that the connecting client does not support. It does this by * overriding the functions declared in alpn.c from the core library. */ -static const char *const fake_versions[] = {"not-h2"}; +static const char* const fake_versions[] = {"not-h2"}; -int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size) { +int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size) { size_t i; for (i = 0; i < GPR_ARRAY_SIZE(fake_versions); i++) { if (!strncmp(version, fake_versions[i], size)) return 1; @@ -45,17 +45,17 @@ size_t grpc_chttp2_num_alpn_versions(void) { return GPR_ARRAY_SIZE(fake_versions); } -const char *grpc_chttp2_get_alpn_version_index(size_t i) { +const char* grpc_chttp2_get_alpn_version_index(size_t i) { GPR_ASSERT(i < GPR_ARRAY_SIZE(fake_versions)); return fake_versions[i]; } -int main(int argc, char **argv) { - const char *addr = bad_ssl_addr(argc, argv); +int main(int argc, char** argv) { + const char* addr = bad_ssl_addr(argc, argv); grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key, test_server1_cert}; - grpc_server_credentials *ssl_creds; - grpc_server *server; + grpc_server_credentials* ssl_creds; + grpc_server* server; grpc_init(); ssl_creds = diff --git a/test/core/bad_ssl/servers/cert.cc b/test/core/bad_ssl/servers/cert.cc index a1f3048164..4a8ac93452 100644 --- a/test/core/bad_ssl/servers/cert.cc +++ b/test/core/bad_ssl/servers/cert.cc @@ -31,11 +31,11 @@ /* This server will present an untrusted cert to the connecting client, * causing the SSL handshake to fail */ -int main(int argc, char **argv) { - const char *addr = bad_ssl_addr(argc, argv); +int main(int argc, char** argv) { + const char* addr = bad_ssl_addr(argc, argv); grpc_ssl_pem_key_cert_pair pem_key_cert_pair; - grpc_server_credentials *ssl_creds; - grpc_server *server; + grpc_server_credentials* ssl_creds; + grpc_server* server; grpc_slice cert_slice, key_slice; grpc_init(); @@ -46,8 +46,8 @@ int main(int argc, char **argv) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file("src/core/tsi/test_creds/badserver.key", 1, &key_slice))); - pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice); - pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice); + pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice); + pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice); ssl_creds = grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1, 0, NULL); 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; diff --git a/test/core/client_channel/lb_policies_test.cc b/test/core/client_channel/lb_policies_test.cc index 25b896697e..3b907487b7 100644 --- a/test/core/client_channel/lb_policies_test.cc +++ b/test/core/client_channel/lb_policies_test.cc @@ -41,39 +41,39 @@ typedef struct servers_fixture { size_t num_servers; - grpc_server **servers; - grpc_call **server_calls; - grpc_completion_queue *cq; - grpc_completion_queue *shutdown_cq; - char **servers_hostports; - grpc_metadata_array *request_metadata_recv; + grpc_server** servers; + grpc_call** server_calls; + grpc_completion_queue* cq; + grpc_completion_queue* shutdown_cq; + char** servers_hostports; + grpc_metadata_array* request_metadata_recv; } servers_fixture; typedef struct request_sequences { size_t n; /* number of iterations */ - int *connections; /* indexed by the interation number, value is the index of + int* connections; /* indexed by the interation number, value is the index of the server it connected to or -1 if none */ /* indexed by the interation number, value is the client connectivity state */ - grpc_connectivity_state *connectivity_states; + grpc_connectivity_state* connectivity_states; } request_sequences; -typedef void (*verifier_fn)(const servers_fixture *, grpc_channel *, - const request_sequences *, const size_t); +typedef void (*verifier_fn)(const servers_fixture*, grpc_channel*, + const request_sequences*, const size_t); typedef struct test_spec { size_t num_iters; size_t num_servers; - int **kill_at; - int **revive_at; + int** kill_at; + int** revive_at; - const char *description; + const char* description; verifier_fn verifier; } test_spec; -static void test_spec_reset(test_spec *spec) { +static void test_spec_reset(test_spec* spec) { size_t i, j; for (i = 0; i < spec->num_iters; i++) { @@ -84,27 +84,26 @@ static void test_spec_reset(test_spec *spec) { } } -static test_spec *test_spec_create(size_t num_iters, size_t num_servers) { - test_spec *spec; +static test_spec* test_spec_create(size_t num_iters, size_t num_servers) { + test_spec* spec; size_t i; - spec = static_cast<test_spec *>(gpr_malloc(sizeof(test_spec))); + spec = static_cast<test_spec*>(gpr_malloc(sizeof(test_spec))); spec->num_iters = num_iters; spec->num_servers = num_servers; - spec->kill_at = static_cast<int **>(gpr_malloc(sizeof(int *) * num_iters)); - spec->revive_at = static_cast<int **>(gpr_malloc(sizeof(int *) * num_iters)); + spec->kill_at = static_cast<int**>(gpr_malloc(sizeof(int*) * num_iters)); + spec->revive_at = static_cast<int**>(gpr_malloc(sizeof(int*) * num_iters)); for (i = 0; i < num_iters; i++) { - spec->kill_at[i] = - static_cast<int *>(gpr_malloc(sizeof(int) * num_servers)); + spec->kill_at[i] = static_cast<int*>(gpr_malloc(sizeof(int) * num_servers)); spec->revive_at[i] = - static_cast<int *>(gpr_malloc(sizeof(int) * num_servers)); + static_cast<int*>(gpr_malloc(sizeof(int) * num_servers)); } test_spec_reset(spec); return spec; } -static void test_spec_destroy(test_spec *spec) { +static void test_spec_destroy(test_spec* spec) { size_t i; for (i = 0; i < spec->num_iters; i++) { gpr_free(spec->kill_at[i]); @@ -117,21 +116,21 @@ static void test_spec_destroy(test_spec *spec) { gpr_free(spec); } -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static gpr_timespec n_millis_time(int n) { return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(n, GPR_TIMESPAN)); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, n_millis_time(5000), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void kill_server(const servers_fixture *f, size_t i) { +static void kill_server(const servers_fixture* f, size_t i) { gpr_log(GPR_INFO, "KILLING SERVER %" PRIuPTR, i); GPR_ASSERT(f->servers[i] != NULL); grpc_server_shutdown_and_notify(f->servers[i], f->shutdown_cq, tag(10000)); @@ -147,10 +146,10 @@ typedef struct request_data { grpc_metadata_array trailing_metadata_recv; grpc_slice details; grpc_status_code status; - grpc_call_details *call_details; + grpc_call_details* call_details; } request_data; -static void revive_server(const servers_fixture *f, request_data *rdata, +static void revive_server(const servers_fixture* f, request_data* rdata, size_t i) { int got_port; gpr_log(GPR_INFO, "RAISE AGAIN SERVER %" PRIuPTR, i); @@ -171,23 +170,23 @@ static void revive_server(const servers_fixture *f, request_data *rdata, f->cq, tag(1000 + (int)i))); } -static servers_fixture *setup_servers(const char *server_host, - request_data *rdata, +static servers_fixture* setup_servers(const char* server_host, + request_data* rdata, const size_t num_servers) { - servers_fixture *f = - static_cast<servers_fixture *>(gpr_malloc(sizeof(servers_fixture))); + servers_fixture* f = + static_cast<servers_fixture*>(gpr_malloc(sizeof(servers_fixture))); size_t i; f->num_servers = num_servers; f->server_calls = - static_cast<grpc_call **>(gpr_malloc(sizeof(grpc_call *) * num_servers)); - f->request_metadata_recv = static_cast<grpc_metadata_array *>( + static_cast<grpc_call**>(gpr_malloc(sizeof(grpc_call*) * num_servers)); + f->request_metadata_recv = static_cast<grpc_metadata_array*>( gpr_malloc(sizeof(grpc_metadata_array) * num_servers)); /* Create servers. */ - f->servers = static_cast<grpc_server **>( - gpr_malloc(sizeof(grpc_server *) * num_servers)); + f->servers = static_cast<grpc_server**>( + gpr_malloc(sizeof(grpc_server*) * num_servers)); f->servers_hostports = - static_cast<char **>(gpr_malloc(sizeof(char *) * num_servers)); + static_cast<char**>(gpr_malloc(sizeof(char*) * num_servers)); f->cq = grpc_completion_queue_create_for_next(NULL); f->shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); for (i = 0; i < num_servers; i++) { @@ -200,7 +199,7 @@ static servers_fixture *setup_servers(const char *server_host, return f; } -static void teardown_servers(servers_fixture *f) { +static void teardown_servers(servers_fixture* f) { size_t i; /* Destroy server. */ for (i = 0; i < f->num_servers; i++) { @@ -232,30 +231,29 @@ static void teardown_servers(servers_fixture *f) { static request_sequences request_sequences_create(size_t n) { request_sequences res; res.n = n; - res.connections = - static_cast<int *>(gpr_malloc(sizeof(*res.connections) * n)); - res.connectivity_states = static_cast<grpc_connectivity_state *>( + res.connections = static_cast<int*>(gpr_malloc(sizeof(*res.connections) * n)); + res.connectivity_states = static_cast<grpc_connectivity_state*>( gpr_malloc(sizeof(*res.connectivity_states) * n)); memset(res.connections, 0, sizeof(*res.connections) * n); memset(res.connectivity_states, 0, sizeof(*res.connectivity_states) * n); return res; } -static void request_sequences_destroy(const request_sequences *rseqs) { +static void request_sequences_destroy(const request_sequences* rseqs) { gpr_free(rseqs->connections); gpr_free(rseqs->connectivity_states); } /** Returns connection sequence (server indices), which must be freed */ -static request_sequences perform_request(servers_fixture *f, - grpc_channel *client, - request_data *rdata, - const test_spec *spec) { - grpc_call *c; +static request_sequences perform_request(servers_fixture* f, + grpc_channel* client, + request_data* rdata, + const test_spec* spec) { + grpc_call* c; int s_idx; - int *s_valid; + int* s_valid; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; int was_cancelled; size_t i, iter_num; grpc_event ev; @@ -263,10 +261,10 @@ static request_sequences perform_request(servers_fixture *f, int completed_client; const request_sequences sequences = request_sequences_create(spec->num_iters); - s_valid = static_cast<int *>(gpr_malloc(sizeof(int) * f->num_servers)); + s_valid = static_cast<int*>(gpr_malloc(sizeof(int) * f->num_servers)); for (iter_num = 0; iter_num < spec->num_iters; iter_num++) { - cq_verifier *cqv = cq_verifier_create(f->cq); + cq_verifier* cqv = cq_verifier_create(f->cq); was_cancelled = 2; for (i = 0; i < f->num_servers; i++) { @@ -426,16 +424,16 @@ static request_sequences perform_request(servers_fixture *f, return sequences; } -static grpc_call **perform_multirequest(servers_fixture *f, - grpc_channel *client, +static grpc_call** perform_multirequest(servers_fixture* f, + grpc_channel* client, size_t concurrent_calls) { - grpc_call **calls; + grpc_call** calls; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; size_t i; - calls = static_cast<grpc_call **>( - gpr_malloc(sizeof(grpc_call *) * concurrent_calls)); + calls = static_cast<grpc_call**>( + gpr_malloc(sizeof(grpc_call*) * concurrent_calls)); for (i = 0; i < f->num_servers; i++) { kill_server(f, i); } @@ -466,30 +464,30 @@ static grpc_call **perform_multirequest(servers_fixture *f, return calls; } -void run_spec(const test_spec *spec) { - grpc_channel *client; - char *client_hostport; - char *servers_hostports_str; +void run_spec(const test_spec* spec) { + grpc_channel* client; + char* client_hostport; + char* servers_hostports_str; request_data rdata; - servers_fixture *f; + servers_fixture* f; grpc_channel_args args; grpc_arg arg_array[2]; - rdata.call_details = static_cast<grpc_call_details *>( + rdata.call_details = static_cast<grpc_call_details*>( gpr_malloc(sizeof(grpc_call_details) * spec->num_servers)); f = setup_servers("127.0.0.1", &rdata, spec->num_servers); /* Create client. */ - servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports, + servers_hostports_str = gpr_strjoin_sep((const char**)f->servers_hostports, f->num_servers, ",", NULL); gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str); arg_array[0].type = GRPC_ARG_INTEGER; arg_array[0].key = - const_cast<char *>("grpc.testing.fixed_reconnect_backoff_ms"); + const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms"); arg_array[0].value.integer = RETRY_TIMEOUT; arg_array[1].type = GRPC_ARG_STRING; - arg_array[1].key = const_cast<char *>(GRPC_ARG_LB_POLICY_NAME); - arg_array[1].value.string = const_cast<char *>("round_robin"); + arg_array[1].key = const_cast<char*>(GRPC_ARG_LB_POLICY_NAME); + arg_array[1].value.string = const_cast<char*>("round_robin"); args.num_args = 2; args.args = arg_array; @@ -511,27 +509,27 @@ void run_spec(const test_spec *spec) { teardown_servers(f); } -static grpc_channel *create_client(const servers_fixture *f) { - grpc_channel *client; - char *client_hostport; - char *servers_hostports_str; +static grpc_channel* create_client(const servers_fixture* f) { + grpc_channel* client; + char* client_hostport; + char* servers_hostports_str; grpc_arg arg_array[3]; grpc_channel_args args; - servers_hostports_str = gpr_strjoin_sep((const char **)f->servers_hostports, + servers_hostports_str = gpr_strjoin_sep((const char**)f->servers_hostports, f->num_servers, ",", NULL); gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str); arg_array[0].type = GRPC_ARG_INTEGER; arg_array[0].key = - const_cast<char *>("grpc.testing.fixed_reconnect_backoff_ms"); + const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms"); arg_array[0].value.integer = RETRY_TIMEOUT; arg_array[1].type = GRPC_ARG_STRING; - arg_array[1].key = const_cast<char *>(GRPC_ARG_LB_POLICY_NAME); - arg_array[1].value.string = const_cast<char *>("ROUND_ROBIN"); + arg_array[1].key = const_cast<char*>(GRPC_ARG_LB_POLICY_NAME); + arg_array[1].value.string = const_cast<char*>("ROUND_ROBIN"); arg_array[2].type = GRPC_ARG_INTEGER; arg_array[2].key = - const_cast<char *>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS); + const_cast<char*>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS); arg_array[2].value.integer = 0; args.num_args = GPR_ARRAY_SIZE(arg_array); args.args = arg_array; @@ -544,15 +542,15 @@ static grpc_channel *create_client(const servers_fixture *f) { } static void test_ping() { - grpc_channel *client; + grpc_channel* client; request_data rdata; - servers_fixture *f; - cq_verifier *cqv; + servers_fixture* f; + cq_verifier* cqv; grpc_connectivity_state state = GRPC_CHANNEL_IDLE; const size_t num_servers = 1; int i; - rdata.call_details = static_cast<grpc_call_details *>( + rdata.call_details = static_cast<grpc_call_details*>( gpr_malloc(sizeof(grpc_call_details) * num_servers)); f = setup_servers("127.0.0.1", &rdata, num_servers); cqv = cq_verifier_create(f->cq); @@ -593,12 +591,12 @@ static void test_ping() { static void test_pending_calls(size_t concurrent_calls) { size_t i; - grpc_call **calls; - grpc_channel *client; + grpc_call** calls; + grpc_channel* client; request_data rdata; - servers_fixture *f; - test_spec *spec = test_spec_create(0, 4); - rdata.call_details = static_cast<grpc_call_details *>( + servers_fixture* f; + test_spec* spec = test_spec_create(0, 4); + rdata.call_details = static_cast<grpc_call_details*>( gpr_malloc(sizeof(grpc_call_details) * spec->num_servers)); f = setup_servers("127.0.0.1", &rdata, spec->num_servers); @@ -622,7 +620,7 @@ static void test_pending_calls(size_t concurrent_calls) { } static void test_get_channel_info() { - grpc_channel *channel = + grpc_channel* channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", NULL, NULL); // Ensures that resolver returns. grpc_channel_check_connectivity_state(channel, true /* try_to_connect */); @@ -631,7 +629,7 @@ static void test_get_channel_info() { memset(&channel_info, 0, sizeof(channel_info)); grpc_channel_get_info(channel, &channel_info); // Request LB policy name. - char *lb_policy_name = NULL; + char* lb_policy_name = NULL; channel_info.lb_policy_name = &lb_policy_name; grpc_channel_get_info(channel, &channel_info); GPR_ASSERT(lb_policy_name != NULL); @@ -639,7 +637,7 @@ static void test_get_channel_info() { gpr_free(lb_policy_name); // Request service config, which does not exist, so we'll get nothing back. memset(&channel_info, 0, sizeof(channel_info)); - char *service_config_json = const_cast<char *>("dummy_string"); + char* service_config_json = const_cast<char*>("dummy_string"); channel_info.service_config_json = &service_config_json; grpc_channel_get_info(channel, &channel_info); GPR_ASSERT(service_config_json == NULL); @@ -647,10 +645,10 @@ static void test_get_channel_info() { grpc_channel_destroy(channel); grpc_arg arg; arg.type = GRPC_ARG_STRING; - arg.key = const_cast<char *>(GRPC_ARG_SERVICE_CONFIG); + arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG); arg.value.string = - const_cast<char *>("{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}"); - grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1); + const_cast<char*>("{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}"); + grpc_channel_args* args = grpc_channel_args_copy_and_add(NULL, &arg, 1); channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, NULL); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -668,8 +666,8 @@ static void test_get_channel_info() { grpc_channel_destroy(channel); } -static void print_failed_expectations(const int *expected_connection_sequence, - const int *actual_connection_sequence, +static void print_failed_expectations(const int* expected_connection_sequence, + const int* actual_connection_sequence, const size_t expected_seq_length, const size_t num_iters) { size_t i; @@ -681,16 +679,16 @@ static void print_failed_expectations(const int *expected_connection_sequence, } } -static void verify_vanilla_round_robin(const servers_fixture *f, - grpc_channel *client, - const request_sequences *sequences, +static void verify_vanilla_round_robin(const servers_fixture* f, + grpc_channel* client, + const request_sequences* sequences, const size_t num_iters) { const size_t expected_seq_length = f->num_servers; /* verify conn. seq. expectation */ /* get the first sequence of "num_servers" elements */ - int *expected_connection_sequence = - static_cast<int *>(gpr_malloc(sizeof(int) * expected_seq_length)); + int* expected_connection_sequence = + static_cast<int*>(gpr_malloc(sizeof(int) * expected_seq_length)); memcpy(expected_connection_sequence, sequences->connections, sizeof(int) * expected_seq_length); @@ -728,16 +726,16 @@ static void verify_vanilla_round_robin(const servers_fixture *f, /* At the start of the second iteration, all but the first and last servers (as * given in "f") are killed */ static void verify_vanishing_floor_round_robin( - const servers_fixture *f, grpc_channel *client, - const request_sequences *sequences, const size_t num_iters) { - int *expected_connection_sequence; + const servers_fixture* f, grpc_channel* client, + const request_sequences* sequences, const size_t num_iters) { + int* expected_connection_sequence; const size_t expected_seq_length = 2; size_t i; /* verify conn. seq. expectation */ /* copy the first full sequence (without -1s) */ expected_connection_sequence = - static_cast<int *>(gpr_malloc(sizeof(int) * expected_seq_length)); + static_cast<int*>(gpr_malloc(sizeof(int) * expected_seq_length)); memcpy(expected_connection_sequence, sequences->connections + 2, expected_seq_length * sizeof(int)); @@ -782,9 +780,9 @@ static void verify_vanishing_floor_round_robin( gpr_free(expected_connection_sequence); } -static void verify_total_carnage_round_robin(const servers_fixture *f, - grpc_channel *client, - const request_sequences *sequences, +static void verify_total_carnage_round_robin(const servers_fixture* f, + grpc_channel* client, + const request_sequences* sequences, const size_t num_iters) { for (size_t i = 0; i < num_iters; i++) { const int actual = sequences->connections[i]; @@ -815,16 +813,16 @@ static void verify_total_carnage_round_robin(const servers_fixture *f, } static void verify_partial_carnage_round_robin( - const servers_fixture *f, grpc_channel *client, - const request_sequences *sequences, const size_t num_iters) { - int *expected_connection_sequence; + const servers_fixture* f, grpc_channel* client, + const request_sequences* sequences, const size_t num_iters) { + int* expected_connection_sequence; size_t i; const size_t expected_seq_length = f->num_servers; /* verify conn. seq. expectation */ /* get the first sequence of "num_servers" elements */ expected_connection_sequence = - static_cast<int *>(gpr_malloc(sizeof(int) * expected_seq_length)); + static_cast<int*>(gpr_malloc(sizeof(int) * expected_seq_length)); memcpy(expected_connection_sequence, sequences->connections, sizeof(int) * expected_seq_length); @@ -875,9 +873,9 @@ static void verify_partial_carnage_round_robin( gpr_free(expected_connection_sequence); } -static void dump_array(const char *desc, const int *data, const size_t count) { +static void dump_array(const char* desc, const int* data, const size_t count) { gpr_strvec s; - char *tmp; + char* tmp; size_t i; gpr_strvec_init(&s); gpr_strvec_add(&s, gpr_strdup(desc)); @@ -892,9 +890,9 @@ static void dump_array(const char *desc, const int *data, const size_t count) { gpr_free(tmp); } -static void verify_rebirth_round_robin(const servers_fixture *f, - grpc_channel *client, - const request_sequences *sequences, +static void verify_rebirth_round_robin(const servers_fixture* f, + grpc_channel* client, + const request_sequences* sequences, const size_t num_iters) { dump_array("actual_connection_sequence", sequences->connections, num_iters); @@ -960,9 +958,9 @@ static void verify_rebirth_round_robin(const servers_fixture *f, } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - test_spec *spec; + test_spec* spec; size_t i; const size_t NUM_ITERS = 10; const size_t NUM_SERVERS = 4; diff --git a/test/core/client_channel/parse_address_test.cc b/test/core/client_channel/parse_address_test.cc index d011176869..5ad6c6d015 100644 --- a/test/core/client_channel/parse_address_test.cc +++ b/test/core/client_channel/parse_address_test.cc @@ -32,13 +32,13 @@ #ifdef GRPC_HAVE_UNIX_SOCKET -static void test_grpc_parse_unix(const char *uri_text, const char *pathname) { +static void test_grpc_parse_unix(const char* uri_text, const char* pathname) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); grpc_resolved_address addr; GPR_ASSERT(1 == grpc_parse_unix(uri, &addr)); - struct sockaddr_un *addr_un = (struct sockaddr_un *)addr.addr; + struct sockaddr_un* addr_un = (struct sockaddr_un*)addr.addr; GPR_ASSERT(AF_UNIX == addr_un->sun_family); GPR_ASSERT(0 == strcmp(addr_un->sun_path, pathname)); @@ -48,19 +48,19 @@ static void test_grpc_parse_unix(const char *uri_text, const char *pathname) { #else /* GRPC_HAVE_UNIX_SOCKET */ -static void test_grpc_parse_unix(const char *uri_text, const char *pathname) {} +static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {} #endif /* GRPC_HAVE_UNIX_SOCKET */ -static void test_grpc_parse_ipv4(const char *uri_text, const char *host, +static void test_grpc_parse_ipv4(const char* uri_text, const char* host, unsigned short port) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); grpc_resolved_address addr; char ntop_buf[INET_ADDRSTRLEN]; GPR_ASSERT(1 == grpc_parse_ipv4(uri, &addr)); - struct sockaddr_in *addr_in = (struct sockaddr_in *)addr.addr; + struct sockaddr_in* addr_in = (struct sockaddr_in*)addr.addr; GPR_ASSERT(AF_INET == addr_in->sin_family); GPR_ASSERT(NULL != grpc_inet_ntop(AF_INET, &addr_in->sin_addr, ntop_buf, sizeof(ntop_buf))); @@ -71,15 +71,15 @@ static void test_grpc_parse_ipv4(const char *uri_text, const char *host, grpc_exec_ctx_finish(&exec_ctx); } -static void test_grpc_parse_ipv6(const char *uri_text, const char *host, +static void test_grpc_parse_ipv6(const char* uri_text, const char* host, unsigned short port, uint32_t scope_id) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); grpc_resolved_address addr; char ntop_buf[INET6_ADDRSTRLEN]; GPR_ASSERT(1 == grpc_parse_ipv6(uri, &addr)); - struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr.addr; + struct sockaddr_in6* addr_in6 = (struct sockaddr_in6*)addr.addr; GPR_ASSERT(AF_INET6 == addr_in6->sin6_family); GPR_ASSERT(NULL != grpc_inet_ntop(AF_INET6, &addr_in6->sin6_addr, ntop_buf, sizeof(ntop_buf))); @@ -91,7 +91,7 @@ static void test_grpc_parse_ipv6(const char *uri_text, const char *host, grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_grpc_parse_unix("unix:/path/name", "/path/name"); diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc index 4dfee8cf90..a388b826cf 100644 --- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc @@ -33,40 +33,39 @@ static gpr_mu g_mu; static bool g_fail_resolution = true; -static grpc_combiner *g_combiner; +static grpc_combiner* g_combiner; -static void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, - const char *default_port, - grpc_pollset_set *interested_parties, - grpc_closure *on_done, - grpc_resolved_addresses **addrs) { +static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr, + const char* default_port, + grpc_pollset_set* interested_parties, + grpc_closure* on_done, + grpc_resolved_addresses** addrs) { gpr_mu_lock(&g_mu); GPR_ASSERT(0 == strcmp("test", addr)); - grpc_error *error = GRPC_ERROR_NONE; + grpc_error* error = GRPC_ERROR_NONE; if (g_fail_resolution) { g_fail_resolution = false; gpr_mu_unlock(&g_mu); error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure"); } else { gpr_mu_unlock(&g_mu); - *addrs = - static_cast<grpc_resolved_addresses *>(gpr_malloc(sizeof(**addrs))); + *addrs = static_cast<grpc_resolved_addresses*>(gpr_malloc(sizeof(**addrs))); (*addrs)->naddrs = 1; - (*addrs)->addrs = static_cast<grpc_resolved_address *>( + (*addrs)->addrs = static_cast<grpc_resolved_address*>( gpr_malloc(sizeof(*(*addrs)->addrs))); (*addrs)->addrs[0].len = 123; } GRPC_CLOSURE_SCHED(exec_ctx, on_done, error); } -static grpc_ares_request *my_dns_lookup_ares( - grpc_exec_ctx *exec_ctx, const char *dns_server, const char *addr, - const char *default_port, grpc_pollset_set *interested_parties, - grpc_closure *on_done, grpc_lb_addresses **lb_addrs, bool check_grpclb, - char **service_config_json) { +static grpc_ares_request* my_dns_lookup_ares( + grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr, + const char* default_port, grpc_pollset_set* interested_parties, + grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb, + char** service_config_json) { gpr_mu_lock(&g_mu); GPR_ASSERT(0 == strcmp("test", addr)); - grpc_error *error = GRPC_ERROR_NONE; + grpc_error* error = GRPC_ERROR_NONE; if (g_fail_resolution) { g_fail_resolution = false; gpr_mu_unlock(&g_mu); @@ -80,28 +79,28 @@ static grpc_ares_request *my_dns_lookup_ares( return NULL; } -static grpc_resolver *create_resolver(grpc_exec_ctx *exec_ctx, - const char *name) { - grpc_resolver_factory *factory = grpc_resolver_factory_lookup("dns"); - grpc_uri *uri = grpc_uri_parse(exec_ctx, name, 0); +static grpc_resolver* create_resolver(grpc_exec_ctx* exec_ctx, + const char* name) { + grpc_resolver_factory* factory = grpc_resolver_factory_lookup("dns"); + grpc_uri* uri = grpc_uri_parse(exec_ctx, name, 0); GPR_ASSERT(uri); grpc_resolver_args args; memset(&args, 0, sizeof(args)); args.uri = uri; args.combiner = g_combiner; - grpc_resolver *resolver = + grpc_resolver* resolver = grpc_resolver_factory_create_resolver(exec_ctx, factory, &args); grpc_resolver_factory_unref(factory); grpc_uri_destroy(uri); return resolver; } -static void on_done(grpc_exec_ctx *exec_ctx, void *ev, grpc_error *error) { - gpr_event_set((gpr_event *)ev, (void *)1); +static void on_done(grpc_exec_ctx* exec_ctx, void* ev, grpc_error* error) { + gpr_event_set((gpr_event*)ev, (void*)1); } // interleave waiting for an event with a timer check -static bool wait_loop(int deadline_seconds, gpr_event *ev) { +static bool wait_loop(int deadline_seconds, gpr_event* ev) { while (deadline_seconds) { gpr_log(GPR_DEBUG, "Test: waiting for %d more seconds", deadline_seconds); if (gpr_event_wait(ev, grpc_timeout_seconds_to_deadline(1))) return true; @@ -115,34 +114,35 @@ static bool wait_loop(int deadline_seconds, gpr_event *ev) { } typedef struct next_args { - grpc_resolver *resolver; - grpc_channel_args **result; - grpc_closure *on_complete; + grpc_resolver* resolver; + grpc_channel_args** result; + grpc_closure* on_complete; } next_args; -static void call_resolver_next_now_lock_taken(grpc_exec_ctx *exec_ctx, - void *arg, - grpc_error *error_unused) { - next_args *a = static_cast<next_args *>(arg); +static void call_resolver_next_now_lock_taken(grpc_exec_ctx* exec_ctx, + void* arg, + grpc_error* error_unused) { + next_args* a = static_cast<next_args*>(arg); grpc_resolver_next_locked(exec_ctx, a->resolver, a->result, a->on_complete); gpr_free(a); } -static void call_resolver_next_after_locking(grpc_exec_ctx *exec_ctx, - grpc_resolver *resolver, - grpc_channel_args **result, - grpc_closure *on_complete) { - next_args *a = static_cast<next_args *>(gpr_malloc(sizeof(*a))); +static void call_resolver_next_after_locking(grpc_exec_ctx* exec_ctx, + grpc_resolver* resolver, + grpc_channel_args** result, + grpc_closure* on_complete) { + next_args* a = static_cast<next_args*>(gpr_malloc(sizeof(*a))); a->resolver = resolver; a->result = result; a->on_complete = on_complete; - GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE( - call_resolver_next_now_lock_taken, a, - grpc_combiner_scheduler(resolver->combiner)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED( + exec_ctx, + GRPC_CLOSURE_CREATE(call_resolver_next_now_lock_taken, a, + grpc_combiner_scheduler(resolver->combiner)), + GRPC_ERROR_NONE); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); @@ -150,10 +150,10 @@ int main(int argc, char **argv) { g_combiner = grpc_combiner_create(); grpc_resolve_address = my_resolve_address; grpc_dns_lookup_ares = my_dns_lookup_ares; - grpc_channel_args *result = (grpc_channel_args *)1; + grpc_channel_args* result = (grpc_channel_args*)1; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_resolver *resolver = create_resolver(&exec_ctx, "dns:test"); + grpc_resolver* resolver = create_resolver(&exec_ctx, "dns:test"); gpr_event ev1; gpr_event_init(&ev1); call_resolver_next_after_locking( diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index a14926f173..ef3c1b8216 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -25,13 +25,13 @@ #include "src/core/lib/iomgr/combiner.h" #include "test/core/util/test_config.h" -static grpc_combiner *g_combiner; +static grpc_combiner* g_combiner; -static void test_succeeds(grpc_resolver_factory *factory, const char *string) { +static void test_succeeds(grpc_resolver_factory* factory, const char* string) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0); + grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0); grpc_resolver_args args; - grpc_resolver *resolver; + grpc_resolver* resolver; gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, factory->vtable->scheme); GPR_ASSERT(uri); @@ -45,11 +45,11 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) { grpc_exec_ctx_finish(&exec_ctx); } -static void test_fails(grpc_resolver_factory *factory, const char *string) { +static void test_fails(grpc_resolver_factory* factory, const char* string) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0); + grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0); grpc_resolver_args args; - grpc_resolver *resolver; + grpc_resolver* resolver; gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, factory->vtable->scheme); GPR_ASSERT(uri); @@ -62,8 +62,8 @@ static void test_fails(grpc_resolver_factory *factory, const char *string) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { - grpc_resolver_factory *dns; +int main(int argc, char** argv) { + grpc_resolver_factory* dns; grpc_test_init(argc, argv); grpc_init(); diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc index ed14151ae3..06e8ebdc88 100644 --- a/test/core/client_channel/resolvers/fake_resolver_test.cc +++ b/test/core/client_channel/resolvers/fake_resolver_test.cc @@ -32,10 +32,10 @@ #include "test/core/util/test_config.h" -static grpc_resolver *build_fake_resolver( - grpc_exec_ctx *exec_ctx, grpc_combiner *combiner, - grpc_fake_resolver_response_generator *response_generator) { - grpc_resolver_factory *factory = grpc_resolver_factory_lookup("fake"); +static grpc_resolver* build_fake_resolver( + grpc_exec_ctx* exec_ctx, grpc_combiner* combiner, + grpc_fake_resolver_response_generator* response_generator) { + grpc_resolver_factory* factory = grpc_resolver_factory_lookup("fake"); grpc_arg generator_arg = grpc_fake_resolver_response_generator_arg(response_generator); grpc_resolver_args args; @@ -43,50 +43,50 @@ static grpc_resolver *build_fake_resolver( grpc_channel_args channel_args = {1, &generator_arg}; args.args = &channel_args; args.combiner = combiner; - grpc_resolver *resolver = + grpc_resolver* resolver = grpc_resolver_factory_create_resolver(exec_ctx, factory, &args); grpc_resolver_factory_unref(factory); return resolver; } typedef struct on_resolution_arg { - grpc_channel_args *resolver_result; - grpc_channel_args *expected_resolver_result; + grpc_channel_args* resolver_result; + grpc_channel_args* expected_resolver_result; gpr_event ev; } on_resolution_arg; -void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - on_resolution_arg *res = static_cast<on_resolution_arg *>(arg); +void on_resolution_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + on_resolution_arg* res = static_cast<on_resolution_arg*>(arg); // We only check the addresses channel arg because that's the only one // explicitly set by the test via // grpc_fake_resolver_response_generator_set_response. - const grpc_lb_addresses *actual_lb_addresses = + const grpc_lb_addresses* actual_lb_addresses = grpc_lb_addresses_find_channel_arg(res->resolver_result); - const grpc_lb_addresses *expected_lb_addresses = + const grpc_lb_addresses* expected_lb_addresses = grpc_lb_addresses_find_channel_arg(res->expected_resolver_result); GPR_ASSERT( grpc_lb_addresses_cmp(actual_lb_addresses, expected_lb_addresses) == 0); grpc_channel_args_destroy(exec_ctx, res->resolver_result); grpc_channel_args_destroy(exec_ctx, res->expected_resolver_result); - gpr_event_set(&res->ev, (void *)1); + gpr_event_set(&res->ev, (void*)1); } static void test_fake_resolver() { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_combiner *combiner = grpc_combiner_create(); + grpc_combiner* combiner = grpc_combiner_create(); // Create resolver. - grpc_fake_resolver_response_generator *response_generator = + grpc_fake_resolver_response_generator* response_generator = grpc_fake_resolver_response_generator_create(); - grpc_resolver *resolver = + grpc_resolver* resolver = build_fake_resolver(&exec_ctx, combiner, response_generator); GPR_ASSERT(resolver != NULL); // Setup expectations. - grpc_uri *uris[] = {grpc_uri_parse(&exec_ctx, "ipv4:10.2.1.1:1234", true), + grpc_uri* uris[] = {grpc_uri_parse(&exec_ctx, "ipv4:10.2.1.1:1234", true), grpc_uri_parse(&exec_ctx, "ipv4:127.0.0.1:4321", true)}; - const char *balancer_names[] = {"name1", "name2"}; + const char* balancer_names[] = {"name1", "name2"}; const bool is_balancer[] = {true, false}; - grpc_lb_addresses *addresses = grpc_lb_addresses_create(3, NULL); + grpc_lb_addresses* addresses = grpc_lb_addresses_create(3, NULL); for (size_t i = 0; i < GPR_ARRAY_SIZE(uris); ++i) { grpc_lb_addresses_set_address_from_uri( addresses, i, uris[i], is_balancer[i], balancer_names[i], NULL); @@ -94,14 +94,14 @@ static void test_fake_resolver() { } const grpc_arg addresses_arg = grpc_lb_addresses_create_channel_arg(addresses); - grpc_channel_args *results = + grpc_channel_args* results = grpc_channel_args_copy_and_add(NULL, &addresses_arg, 1); grpc_lb_addresses_destroy(&exec_ctx, addresses); on_resolution_arg on_res_arg; memset(&on_res_arg, 0, sizeof(on_res_arg)); on_res_arg.expected_resolver_result = results; gpr_event_init(&on_res_arg.ev); - grpc_closure *on_resolution = GRPC_CLOSURE_CREATE( + grpc_closure* on_resolution = GRPC_CLOSURE_CREATE( on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); // Set resolver results and trigger first resolution. on_resolution_cb @@ -115,11 +115,11 @@ static void test_fake_resolver() { grpc_timeout_seconds_to_deadline(5)) != NULL); // Setup update. - grpc_uri *uris_update[] = { + grpc_uri* uris_update[] = { grpc_uri_parse(&exec_ctx, "ipv4:192.168.1.0:31416", true)}; - const char *balancer_names_update[] = {"name3"}; + const char* balancer_names_update[] = {"name3"}; const bool is_balancer_update[] = {false}; - grpc_lb_addresses *addresses_update = grpc_lb_addresses_create(1, NULL); + grpc_lb_addresses* addresses_update = grpc_lb_addresses_create(1, NULL); for (size_t i = 0; i < GPR_ARRAY_SIZE(uris_update); ++i) { grpc_lb_addresses_set_address_from_uri(addresses_update, i, uris_update[i], is_balancer_update[i], @@ -129,7 +129,7 @@ static void test_fake_resolver() { grpc_arg addresses_update_arg = grpc_lb_addresses_create_channel_arg(addresses_update); - grpc_channel_args *results_update = + grpc_channel_args* results_update = grpc_channel_args_copy_and_add(NULL, &addresses_update_arg, 1); grpc_lb_addresses_destroy(&exec_ctx, addresses_update); @@ -166,7 +166,7 @@ static void test_fake_resolver() { grpc_fake_resolver_response_generator_unref(response_generator); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc index 254ce59bc2..028a786059 100644 --- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc +++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc @@ -28,23 +28,23 @@ #include "test/core/util/test_config.h" -static grpc_combiner *g_combiner; +static grpc_combiner* g_combiner; typedef struct on_resolution_arg { - char *expected_server_name; - grpc_channel_args *resolver_result; + char* expected_server_name; + grpc_channel_args* resolver_result; } on_resolution_arg; -void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - on_resolution_arg *res = static_cast<on_resolution_arg *>(arg); +void on_resolution_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + on_resolution_arg* res = static_cast<on_resolution_arg*>(arg); grpc_channel_args_destroy(exec_ctx, res->resolver_result); } -static void test_succeeds(grpc_resolver_factory *factory, const char *string) { +static void test_succeeds(grpc_resolver_factory* factory, const char* string) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0); + grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0); grpc_resolver_args args; - grpc_resolver *resolver; + grpc_resolver* resolver; gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, factory->vtable->scheme); GPR_ASSERT(uri); @@ -57,7 +57,7 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) { on_resolution_arg on_res_arg; memset(&on_res_arg, 0, sizeof(on_res_arg)); on_res_arg.expected_server_name = uri->path; - grpc_closure *on_resolution = GRPC_CLOSURE_CREATE( + grpc_closure* on_resolution = GRPC_CLOSURE_CREATE( on_resolution_cb, &on_res_arg, grpc_schedule_on_exec_ctx); grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result, @@ -67,11 +67,11 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) { grpc_uri_destroy(uri); } -static void test_fails(grpc_resolver_factory *factory, const char *string) { +static void test_fails(grpc_resolver_factory* factory, const char* string) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0); + grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0); grpc_resolver_args args; - grpc_resolver *resolver; + grpc_resolver* resolver; gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, factory->vtable->scheme); GPR_ASSERT(uri); @@ -84,7 +84,7 @@ static void test_fails(grpc_resolver_factory *factory, const char *string) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_resolver_factory *ipv4, *ipv6; grpc_test_init(argc, argv); grpc_init(); diff --git a/test/core/client_channel/uri_fuzzer_test.cc b/test/core/client_channel/uri_fuzzer_test.cc index 9674dadf6c..ba31793ff3 100644 --- a/test/core/client_channel/uri_fuzzer_test.cc +++ b/test/core/client_channel/uri_fuzzer_test.cc @@ -28,13 +28,13 @@ bool squelch = true; bool leak_check = true; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - char *s = static_cast<char *>(gpr_malloc(size + 1)); +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + char* s = static_cast<char*>(gpr_malloc(size + 1)); memcpy(s, data, size); s[size] = 0; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri *x; + grpc_uri* x; if ((x = grpc_uri_parse(&exec_ctx, s, 1))) { grpc_uri_destroy(x); } diff --git a/test/core/client_channel/uri_parser_test.cc b/test/core/client_channel/uri_parser_test.cc index f53cae196b..0bdf57ce4b 100644 --- a/test/core/client_channel/uri_parser_test.cc +++ b/test/core/client_channel/uri_parser_test.cc @@ -25,11 +25,11 @@ #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/test_config.h" -static void test_succeeds(const char *uri_text, const char *scheme, - const char *authority, const char *path, - const char *query, const char *fragment) { +static void test_succeeds(const char* uri_text, const char* scheme, + const char* authority, const char* path, + const char* query, const char* fragment) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); GPR_ASSERT(uri); GPR_ASSERT(0 == strcmp(scheme, uri->scheme)); GPR_ASSERT(0 == strcmp(authority, uri->authority)); @@ -40,7 +40,7 @@ static void test_succeeds(const char *uri_text, const char *scheme, grpc_uri_destroy(uri); } -static void test_fails(const char *uri_text) { +static void test_fails(const char* uri_text) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(NULL == grpc_uri_parse(&exec_ctx, uri_text, 0)); grpc_exec_ctx_finish(&exec_ctx); @@ -49,8 +49,8 @@ static void test_fails(const char *uri_text) { static void test_query_parts() { { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - const char *uri_text = "http://foo/path?a&b=B&c=&#frag"; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + const char* uri_text = "http://foo/path?a&b=B&c=&#frag"; + grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); GPR_ASSERT(uri); GPR_ASSERT(0 == strcmp("http", uri->scheme)); @@ -83,8 +83,8 @@ static void test_query_parts() { { /* test the current behavior of multiple query part values */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - const char *uri_text = "http://auth/path?foo=bar=baz&foobar=="; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + const char* uri_text = "http://auth/path?foo=bar=baz&foobar=="; + grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); GPR_ASSERT(uri); GPR_ASSERT(0 == strcmp("http", uri->scheme)); @@ -102,8 +102,8 @@ static void test_query_parts() { { /* empty query */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - const char *uri_text = "http://foo/path"; - grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0); + const char* uri_text = "http://foo/path"; + grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0); GPR_ASSERT(uri); GPR_ASSERT(0 == strcmp("http", uri->scheme)); @@ -119,7 +119,7 @@ static void test_query_parts() { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_succeeds("http://www.google.com", "http", "www.google.com", "", "", ""); test_succeeds("dns:///foo", "dns", "", "/foo", "", ""); diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc index 4ca979e30f..bc3af410c5 100644 --- a/test/core/compression/algorithm_test.cc +++ b/test/core/compression/algorithm_test.cc @@ -35,7 +35,7 @@ static void test_algorithm_mesh(void) { gpr_log(GPR_DEBUG, "test_algorithm_mesh"); for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { - const char *name; + const char* name; grpc_compression_algorithm parsed; grpc_slice mdstr; grpc_mdelem mdelem; @@ -87,7 +87,7 @@ static void test_algorithm_failure(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(); diff --git a/test/core/compression/compression_test.cc b/test/core/compression/compression_test.cc index f4fa3a8d63..a1a9441c8d 100644 --- a/test/core/compression/compression_test.cc +++ b/test/core/compression/compression_test.cc @@ -28,15 +28,15 @@ static void test_compression_algorithm_parse(void) { size_t i; - const char *valid_names[] = {"identity", "gzip", "deflate"}; + const char* valid_names[] = {"identity", "gzip", "deflate"}; const grpc_compression_algorithm valid_algorithms[] = { GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE}; - const char *invalid_names[] = {"gzip2", "foo", "", "2gzip"}; + const char* invalid_names[] = {"gzip2", "foo", "", "2gzip"}; gpr_log(GPR_DEBUG, "test_compression_algorithm_parse"); for (i = 0; i < GPR_ARRAY_SIZE(valid_names); i++) { - const char *valid_name = valid_names[i]; + const char* valid_name = valid_names[i]; grpc_compression_algorithm algorithm; const int success = grpc_compression_algorithm_parse( grpc_slice_from_static_string(valid_name), &algorithm); @@ -45,7 +45,7 @@ static void test_compression_algorithm_parse(void) { } for (i = 0; i < GPR_ARRAY_SIZE(invalid_names); i++) { - const char *invalid_name = invalid_names[i]; + const char* invalid_name = invalid_names[i]; grpc_compression_algorithm algorithm; int success; success = grpc_compression_algorithm_parse( @@ -57,9 +57,9 @@ static void test_compression_algorithm_parse(void) { static void test_compression_algorithm_name(void) { int success; - const char *name; + const char* name; size_t i; - const char *valid_names[] = {"identity", "gzip", "deflate"}; + const char* valid_names[] = {"identity", "gzip", "deflate"}; const grpc_compression_algorithm valid_algorithms[] = { GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE}; @@ -208,7 +208,7 @@ static void test_compression_enable_disable_algorithm(void) { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_init(); test_compression_algorithm_parse(); test_compression_algorithm_name(); diff --git a/test/core/compression/message_compress_test.cc b/test/core/compression/message_compress_test.cc index 1395d42739..676415ba9d 100644 --- a/test/core/compression/message_compress_test.cc +++ b/test/core/compression/message_compress_test.cc @@ -49,17 +49,18 @@ static void assert_passthrough(grpc_slice value, grpc_slice_buffer output; grpc_slice final; int was_compressed; - const char *algorithm_name; + const char* algorithm_name; GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algorithm_name) != 0); - gpr_log( - GPR_INFO, "assert_passthrough: value_length=%" PRIuPTR - " value_hash=0x%08x " - "algorithm='%s' uncompressed_split='%s' compressed_split='%s'", - GRPC_SLICE_LENGTH(value), gpr_murmur_hash3(GRPC_SLICE_START_PTR(value), - GRPC_SLICE_LENGTH(value), 0), - algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode), - grpc_slice_split_mode_name(compressed_split_mode)); + gpr_log(GPR_INFO, + "assert_passthrough: value_length=%" PRIuPTR + " value_hash=0x%08x " + "algorithm='%s' uncompressed_split='%s' compressed_split='%s'", + GRPC_SLICE_LENGTH(value), + gpr_murmur_hash3(GRPC_SLICE_START_PTR(value), + GRPC_SLICE_LENGTH(value), 0), + algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode), + grpc_slice_split_mode_name(compressed_split_mode)); grpc_slice_buffer_init(&input); grpc_slice_buffer_init(&compressed_raw); @@ -253,10 +254,10 @@ static void test_bad_compression_algorithm(void) { &input, &output); GPR_ASSERT(0 == was_compressed); - was_compressed = - grpc_msg_compress(&exec_ctx, static_cast<grpc_compression_algorithm>( - GRPC_COMPRESS_ALGORITHMS_COUNT + 123), - &input, &output); + was_compressed = grpc_msg_compress(&exec_ctx, + static_cast<grpc_compression_algorithm>( + GRPC_COMPRESS_ALGORITHMS_COUNT + 123), + &input, &output); GPR_ASSERT(0 == was_compressed); grpc_exec_ctx_finish(&exec_ctx); @@ -280,8 +281,9 @@ static void test_bad_decompression_algorithm(void) { GPR_ASSERT(0 == was_decompressed); was_decompressed = - grpc_msg_decompress(&exec_ctx, static_cast<grpc_compression_algorithm>( - GRPC_COMPRESS_ALGORITHMS_COUNT + 123), + grpc_msg_decompress(&exec_ctx, + static_cast<grpc_compression_algorithm>( + GRPC_COMPRESS_ALGORITHMS_COUNT + 123), &input, &output); GPR_ASSERT(0 == was_decompressed); grpc_exec_ctx_finish(&exec_ctx); @@ -290,7 +292,7 @@ static void test_bad_decompression_algorithm(void) { grpc_slice_buffer_destroy(&output); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { unsigned i, j, k, m; grpc_slice_split_mode uncompressed_split_modes[] = { GRPC_SLICE_SPLIT_IDENTITY, GRPC_SLICE_SPLIT_ONE_BYTE}; diff --git a/test/core/compression/stream_compression_test.cc b/test/core/compression/stream_compression_test.cc index d136408710..7cb583b88d 100644 --- a/test/core/compression/stream_compression_test.cc +++ b/test/core/compression/stream_compression_test.cc @@ -25,7 +25,7 @@ #include "src/core/lib/compression/stream_compression.h" -static void generate_random_payload(char *payload, size_t size) { +static void generate_random_payload(char* payload, size_t size) { size_t i; static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; for (i = 0; i < size - 1; ++i) { @@ -34,8 +34,8 @@ static void generate_random_payload(char *payload, size_t size) { payload[size - 1] = '\0'; } -static bool slice_buffer_equals_string(grpc_slice_buffer *buf, - const char *str) { +static bool slice_buffer_equals_string(grpc_slice_buffer* buf, + const char* str) { size_t i; if (buf->length != strlen(str)) { return false; @@ -43,8 +43,8 @@ static bool slice_buffer_equals_string(grpc_slice_buffer *buf, size_t pointer = 0; for (i = 0; i < buf->count; i++) { size_t slice_len = GRPC_SLICE_LENGTH(buf->slices[i]); - if (0 != strncmp(str + pointer, - (char *)GRPC_SLICE_START_PTR(buf->slices[i]), slice_len)) { + if (0 != strncmp(str + pointer, (char*)GRPC_SLICE_START_PTR(buf->slices[i]), + slice_len)) { return false; } pointer += slice_len; @@ -58,10 +58,10 @@ static void test_stream_compression_simple_compress_decompress() { grpc_slice_buffer_init(&source); grpc_slice_buffer_init(&relay); grpc_slice_buffer_init(&sink); - grpc_stream_compression_context *compress_ctx = + grpc_stream_compression_context* compress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_COMPRESS); - grpc_stream_compression_context *decompress_ctx = + grpc_stream_compression_context* decompress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS); grpc_slice slice = grpc_slice_from_static_string(test_str); @@ -91,10 +91,10 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint() grpc_slice_buffer_init(&source); grpc_slice_buffer_init(&relay); grpc_slice_buffer_init(&sink); - grpc_stream_compression_context *compress_ctx = + grpc_stream_compression_context* compress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_COMPRESS); - grpc_stream_compression_context *decompress_ctx = + grpc_stream_compression_context* decompress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS); grpc_slice slice = grpc_slice_from_static_string(test_str); @@ -112,7 +112,7 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint() GPR_ASSERT(output_size == max_output_size); GPR_ASSERT(end_of_context == false); grpc_slice slice_recv = grpc_slice_buffer_take_first(&sink); - char *str_recv = (char *)GRPC_SLICE_START_PTR(slice_recv); + char* str_recv = (char*)GRPC_SLICE_START_PTR(slice_recv); GPR_ASSERT(GRPC_SLICE_LENGTH(slice_recv) == max_output_size); GPR_ASSERT(0 == strncmp(test_str, str_recv, max_output_size)); grpc_slice_unref(slice_recv); @@ -134,17 +134,17 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint() #define LARGE_DATA_SIZE (1024 * 1024) static void test_stream_compression_simple_compress_decompress_with_large_data() { - char *test_str = - static_cast<char *>(gpr_malloc(LARGE_DATA_SIZE * sizeof(char))); + char* test_str = + static_cast<char*>(gpr_malloc(LARGE_DATA_SIZE * sizeof(char))); generate_random_payload(test_str, LARGE_DATA_SIZE); grpc_slice_buffer source, relay, sink; grpc_slice_buffer_init(&source); grpc_slice_buffer_init(&relay); grpc_slice_buffer_init(&sink); - grpc_stream_compression_context *compress_ctx = + grpc_stream_compression_context* compress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_COMPRESS); - grpc_stream_compression_context *decompress_ctx = + grpc_stream_compression_context* decompress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS); grpc_slice slice = grpc_slice_from_static_string(test_str); @@ -175,7 +175,7 @@ static void test_stream_compression_drop_context() { grpc_slice_buffer_init(&source); grpc_slice_buffer_init(&relay); grpc_slice_buffer_init(&sink); - grpc_stream_compression_context *compress_ctx = + grpc_stream_compression_context* compress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_COMPRESS); grpc_slice slice = grpc_slice_from_static_string(test_str); @@ -208,7 +208,7 @@ static void test_stream_compression_drop_context() { grpc_slice_unref(slice2); grpc_slice_buffer_add(&relay, slice3); - grpc_stream_compression_context *decompress_ctx = + grpc_stream_compression_context* decompress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS); bool end_of_context; @@ -244,7 +244,7 @@ static void test_stream_compression_sync_flush() { grpc_slice_buffer_init(&source); grpc_slice_buffer_init(&relay); grpc_slice_buffer_init(&sink); - grpc_stream_compression_context *compress_ctx = + grpc_stream_compression_context* compress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_COMPRESS); grpc_slice slice = grpc_slice_from_static_string(test_str); @@ -253,7 +253,7 @@ static void test_stream_compression_sync_flush() { ~(size_t)0, GRPC_STREAM_COMPRESSION_FLUSH_SYNC)); - grpc_stream_compression_context *decompress_ctx = + grpc_stream_compression_context* decompress_ctx = grpc_stream_compression_context_create( GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS); bool end_of_context; @@ -285,7 +285,7 @@ static void test_stream_compression_sync_flush() { grpc_slice_buffer_destroy(&sink); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_init(); test_stream_compression_simple_compress_decompress(); test_stream_compression_simple_compress_decompress_with_output_size_constraint(); diff --git a/test/core/debug/stats_test.cc b/test/core/debug/stats_test.cc index 915254f3ca..c4b0d502e3 100644 --- a/test/core/debug/stats_test.cc +++ b/test/core/debug/stats_test.cc @@ -110,11 +110,9 @@ TEST_P(HistogramTest, IncHistogram) { }; std::vector<int> test_values; for (int j = -1000; - j < - grpc_stats_histo_bucket_boundaries[kHistogram] - [grpc_stats_histo_buckets[kHistogram] - - 1] + - 1000; + j < grpc_stats_histo_bucket_boundaries + [kHistogram][grpc_stats_histo_buckets[kHistogram] - 1] + + 1000; j++) { int expected_bucket = FindExpectedBucket(kHistogram, j); if (cur_bucket != expected_bucket) { diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index 2070fa5b02..ea7857d8d7 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -70,17 +70,17 @@ #define SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD (size_t)200 struct rpc_state { - char *target; - grpc_completion_queue *cq; - grpc_channel *channel; - grpc_call *call; + char* target; + grpc_completion_queue* cq; + grpc_channel* channel; + grpc_call* call; size_t incoming_data_length; grpc_slice_buffer temp_incoming_buffer; grpc_slice_buffer outgoing_buffer; - grpc_endpoint *tcp; + grpc_endpoint* tcp; gpr_atm done_atm; bool write_done; - const char *response_payload; + const char* response_payload; size_t response_payload_length; }; @@ -89,15 +89,15 @@ static struct rpc_state state; static grpc_closure on_read; static grpc_closure on_write; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { GPR_ASSERT(error == GRPC_ERROR_NONE); gpr_atm_rel_store(&state.done_atm, 1); } -static void handle_write(grpc_exec_ctx *exec_ctx) { +static void handle_write(grpc_exec_ctx* exec_ctx) { grpc_slice slice = grpc_slice_from_copied_buffer( state.response_payload, state.response_payload_length); @@ -106,13 +106,13 @@ static void handle_write(grpc_exec_ctx *exec_ctx) { grpc_endpoint_write(exec_ctx, state.tcp, &state.outgoing_buffer, &on_write); } -static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void handle_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { GPR_ASSERT(error == GRPC_ERROR_NONE); state.incoming_data_length += state.temp_incoming_buffer.length; size_t i; for (i = 0; i < state.temp_incoming_buffer.count; i++) { - char *dump = grpc_dump_slice(state.temp_incoming_buffer.slices[i], + char* dump = grpc_dump_slice(state.temp_incoming_buffer.slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_DEBUG, "Server received: %s", dump); gpr_free(dump); @@ -130,11 +130,11 @@ static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { } } -static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, - grpc_pollset *accepting_pollset, - grpc_tcp_server_acceptor *acceptor) { +static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp, + grpc_pollset* accepting_pollset, + grpc_tcp_server_acceptor* acceptor) { gpr_free(acceptor); - test_tcp_server *server = (test_tcp_server *)arg; + test_tcp_server* server = (test_tcp_server*)arg; GRPC_CLOSURE_INIT(&on_read, handle_read, NULL, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&on_write, done_write, NULL, grpc_schedule_on_exec_ctx); grpc_slice_buffer_init(&state.temp_incoming_buffer); @@ -151,14 +151,14 @@ static gpr_timespec n_sec_deadline(int seconds) { } static void start_rpc(int target_port, grpc_status_code expected_status, - const char *expected_detail) { + const char* expected_detail) { 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; - cq_verifier *cqv; + cq_verifier* cqv; grpc_slice details; state.cq = grpc_completion_queue_create_for_next(NULL); @@ -217,7 +217,7 @@ static void start_rpc(int target_port, grpc_status_code expected_status, cq_verifier_destroy(cqv); } -static void cleanup_rpc(grpc_exec_ctx *exec_ctx) { +static void cleanup_rpc(grpc_exec_ctx* exec_ctx) { grpc_event ev; grpc_slice_buffer_destroy_internal(exec_ctx, &state.temp_incoming_buffer); grpc_slice_buffer_destroy_internal(exec_ctx, &state.outgoing_buffer); @@ -232,12 +232,12 @@ static void cleanup_rpc(grpc_exec_ctx *exec_ctx) { } typedef struct { - test_tcp_server *server; - gpr_event *signal_when_done; + test_tcp_server* server; + gpr_event* signal_when_done; } poll_args; -static void actually_poll_server(void *arg) { - poll_args *pa = (poll_args *)arg; +static void actually_poll_server(void* arg) { + poll_args* pa = (poll_args*)arg; gpr_timespec deadline = n_sec_deadline(10); while (true) { bool done = gpr_atm_acq_load(&state.done_atm) != 0; @@ -250,25 +250,25 @@ static void actually_poll_server(void *arg) { } test_tcp_server_poll(pa->server, 1); } - gpr_event_set(pa->signal_when_done, (void *)1); + gpr_event_set(pa->signal_when_done, (void*)1); gpr_free(pa); } -static void poll_server_until_read_done(test_tcp_server *server, - gpr_event *signal_when_done) { +static void poll_server_until_read_done(test_tcp_server* server, + gpr_event* signal_when_done) { gpr_atm_rel_store(&state.done_atm, 0); state.write_done = 0; gpr_thd_id id; - poll_args *pa = (poll_args *)gpr_malloc(sizeof(*pa)); + poll_args* pa = (poll_args*)gpr_malloc(sizeof(*pa)); pa->server = server; pa->signal_when_done = signal_when_done; gpr_thd_new(&id, actually_poll_server, pa, NULL); } -static void run_test(const char *response_payload, +static void run_test(const char* response_payload, size_t response_payload_length, grpc_status_code expected_status, - const char *expected_detail) { + const char* expected_detail) { test_tcp_server test_server; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_event ev; @@ -297,7 +297,7 @@ static void run_test(const char *response_payload, grpc_shutdown(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); /* status defined in hpack static table */ diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index b295682ce8..cea06ae282 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -33,15 +33,15 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static void *tag(intptr_t i) { return (void *)i; } +static void* tag(intptr_t i) { return (void*)i; } static void run_test(bool wait_for_ready, bool use_service_config) { - grpc_channel *chan; - grpc_call *call; - grpc_completion_queue *cq; - cq_verifier *cqv; + 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 trailing_metadata_recv; grpc_status_code status; grpc_slice details; @@ -57,13 +57,13 @@ static void run_test(bool wait_for_ready, bool use_service_config) { cqv = cq_verifier_create(cq); /* if using service config, create channel args */ - grpc_channel_args *args = NULL; + grpc_channel_args* args = NULL; if (use_service_config) { GPR_ASSERT(wait_for_ready); grpc_arg arg; arg.type = GRPC_ARG_STRING; - arg.key = const_cast<char *>(GRPC_ARG_SERVICE_CONFIG); - arg.value.string = const_cast<char *>( + arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG); + arg.value.string = const_cast<char*>( "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" @@ -77,7 +77,7 @@ static void run_test(bool wait_for_ready, bool use_service_config) { /* create a call, channel to a port which will refuse connection */ int port = grpc_pick_unused_port_or_die(); - char *addr; + char* addr; gpr_join_host_port(&addr, "127.0.0.1", port); gpr_log(GPR_INFO, "server: %s", addr); chan = grpc_insecure_channel_create(addr, args, NULL); @@ -139,7 +139,7 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_shutdown(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); run_test(false /* wait_for_ready */, false /* use_service_config */); run_test(true /* wait_for_ready */, false /* use_service_config */); diff --git a/test/core/end2end/cq_verifier.cc b/test/core/end2end/cq_verifier.cc index bb978923b2..fd5193f42c 100644 --- a/test/core/end2end/cq_verifier.cc +++ b/test/core/end2end/cq_verifier.cc @@ -38,43 +38,43 @@ typedef struct metadata { size_t count; size_t cap; - char **keys; - char **values; + char** keys; + char** values; } metadata; /* details what we expect to find on a single event - and forms a linked list to detail other expectations */ typedef struct expectation { - struct expectation *next; - const char *file; + struct expectation* next; + const char* file; int line; grpc_completion_type type; - void *tag; + void* tag; int success; } expectation; /* the verifier itself */ struct cq_verifier { /* bound completion queue */ - grpc_completion_queue *cq; + grpc_completion_queue* cq; /* start of expectation list */ - expectation *first_expectation; + expectation* first_expectation; }; -cq_verifier *cq_verifier_create(grpc_completion_queue *cq) { - cq_verifier *v = (cq_verifier *)gpr_malloc(sizeof(cq_verifier)); +cq_verifier* cq_verifier_create(grpc_completion_queue* cq) { + cq_verifier* v = (cq_verifier*)gpr_malloc(sizeof(cq_verifier)); v->cq = cq; v->first_expectation = NULL; return v; } -void cq_verifier_destroy(cq_verifier *v) { +void cq_verifier_destroy(cq_verifier* v) { cq_verify(v); gpr_free(v); } -static int has_metadata(const grpc_metadata *md, size_t count, const char *key, - const char *value) { +static int has_metadata(const grpc_metadata* md, size_t count, const char* key, + const char* value) { size_t i; for (i = 0; i < count; i++) { if (0 == grpc_slice_str_cmp(md[i].key, key) && @@ -85,12 +85,12 @@ static int has_metadata(const grpc_metadata *md, size_t count, const char *key, return 0; } -int contains_metadata(grpc_metadata_array *array, const char *key, - const char *value) { +int contains_metadata(grpc_metadata_array* array, const char* key, + const char* value) { return has_metadata(array->metadata, array->count, key, value); } -static int has_metadata_slices(const grpc_metadata *md, size_t count, +static int has_metadata_slices(const grpc_metadata* md, size_t count, grpc_slice key, grpc_slice value) { size_t i; for (i = 0; i < count; i++) { @@ -101,15 +101,15 @@ static int has_metadata_slices(const grpc_metadata *md, size_t count, return 0; } -int contains_metadata_slices(grpc_metadata_array *array, grpc_slice key, +int contains_metadata_slices(grpc_metadata_array* array, grpc_slice key, grpc_slice value) { return has_metadata_slices(array->metadata, array->count, key, value); } -static grpc_slice merge_slices(grpc_slice *slices, size_t nslices) { +static grpc_slice merge_slices(grpc_slice* slices, size_t nslices) { size_t i; size_t len = 0; - uint8_t *cursor; + uint8_t* cursor; grpc_slice out; for (i = 0; i < nslices; i++) { @@ -128,7 +128,7 @@ static grpc_slice merge_slices(grpc_slice *slices, size_t nslices) { return out; } -int raw_byte_buffer_eq_slice(grpc_byte_buffer *rbb, grpc_slice b) { +int raw_byte_buffer_eq_slice(grpc_byte_buffer* rbb, grpc_slice b) { grpc_slice a; int ok; @@ -144,9 +144,9 @@ int raw_byte_buffer_eq_slice(grpc_byte_buffer *rbb, grpc_slice b) { return ok; } -int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b) { +int byte_buffer_eq_slice(grpc_byte_buffer* bb, grpc_slice b) { grpc_byte_buffer_reader reader; - grpc_byte_buffer *rbb; + grpc_byte_buffer* rbb; int res; GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb) && @@ -159,9 +159,9 @@ int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b) { return res; } -int byte_buffer_eq_string(grpc_byte_buffer *bb, const char *str) { +int byte_buffer_eq_string(grpc_byte_buffer* bb, const char* str) { grpc_byte_buffer_reader reader; - grpc_byte_buffer *rbb; + grpc_byte_buffer* rbb; int res; GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb) && @@ -174,10 +174,10 @@ int byte_buffer_eq_string(grpc_byte_buffer *bb, const char *str) { return res; } -static bool is_probably_integer(void *p) { return ((uintptr_t)p) < 1000000; } +static bool is_probably_integer(void* p) { return ((uintptr_t)p) < 1000000; } -static void expectation_to_strvec(gpr_strvec *buf, expectation *e) { - char *tmp; +static void expectation_to_strvec(gpr_strvec* buf, expectation* e) { + char* tmp; if (is_probably_integer(e->tag)) { gpr_asprintf(&tmp, "tag(%" PRIdPTR ") ", (intptr_t)e->tag); @@ -200,8 +200,8 @@ static void expectation_to_strvec(gpr_strvec *buf, expectation *e) { } } -static void expectations_to_strvec(gpr_strvec *buf, cq_verifier *v) { - expectation *e; +static void expectations_to_strvec(gpr_strvec* buf, cq_verifier* v) { + expectation* e; for (e = v->first_expectation; e != NULL; e = e->next) { expectation_to_strvec(buf, e); @@ -209,9 +209,9 @@ static void expectations_to_strvec(gpr_strvec *buf, cq_verifier *v) { } } -static void fail_no_event_received(cq_verifier *v) { +static void fail_no_event_received(cq_verifier* v) { gpr_strvec buf; - char *msg; + char* msg; gpr_strvec_init(&buf); gpr_strvec_add(&buf, gpr_strdup("no event received, but expected:\n")); expectations_to_strvec(&buf, v); @@ -222,7 +222,7 @@ static void fail_no_event_received(cq_verifier *v) { abort(); } -static void verify_matches(expectation *e, grpc_event *ev) { +static void verify_matches(expectation* e, grpc_event* ev) { GPR_ASSERT(e->type == ev->type); switch (e->type) { case GRPC_OP_COMPLETE: @@ -230,7 +230,7 @@ static void verify_matches(expectation *e, grpc_event *ev) { gpr_strvec expected; gpr_strvec_init(&expected); expectation_to_strvec(&expected, e); - char *s = gpr_strvec_flatten(&expected, NULL); + char* s = gpr_strvec_flatten(&expected, NULL); gpr_strvec_destroy(&expected); gpr_log(GPR_ERROR, "actual success does not match expected: %s", s); gpr_free(s); @@ -248,7 +248,7 @@ static void verify_matches(expectation *e, grpc_event *ev) { } } -void cq_verify(cq_verifier *v) { +void cq_verify(cq_verifier* v) { const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); while (v->first_expectation != NULL) { grpc_event ev = grpc_completion_queue_next(v->cq, deadline, NULL); @@ -256,8 +256,8 @@ void cq_verify(cq_verifier *v) { fail_no_event_received(v); break; } - expectation *e; - expectation *prev = NULL; + expectation* e; + expectation* prev = NULL; for (e = v->first_expectation; e != NULL; e = e->next) { if (e->tag == ev.tag) { verify_matches(e, &ev); @@ -269,7 +269,7 @@ void cq_verify(cq_verifier *v) { prev = e; } if (e == NULL) { - char *s = grpc_event_string(&ev); + char* s = grpc_event_string(&ev); gpr_log(GPR_ERROR, "cq returned unexpected event: %s", s); gpr_free(s); gpr_strvec expectations; @@ -284,7 +284,7 @@ void cq_verify(cq_verifier *v) { } } -void cq_verify_empty_timeout(cq_verifier *v, int timeout_sec) { +void cq_verify_empty_timeout(cq_verifier* v, int timeout_sec) { gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(timeout_sec, GPR_TIMESPAN)); @@ -294,18 +294,18 @@ void cq_verify_empty_timeout(cq_verifier *v, int timeout_sec) { ev = grpc_completion_queue_next(v->cq, deadline, NULL); if (ev.type != GRPC_QUEUE_TIMEOUT) { - char *s = grpc_event_string(&ev); + char* s = grpc_event_string(&ev); gpr_log(GPR_ERROR, "unexpected event (expected nothing): %s", s); gpr_free(s); abort(); } } -void cq_verify_empty(cq_verifier *v) { cq_verify_empty_timeout(v, 1); } +void cq_verify_empty(cq_verifier* v) { cq_verify_empty_timeout(v, 1); } -static void add(cq_verifier *v, const char *file, int line, - grpc_completion_type type, void *tag, bool success) { - expectation *e = (expectation *)gpr_malloc(sizeof(expectation)); +static void add(cq_verifier* v, const char* file, int line, + grpc_completion_type type, void* tag, bool success) { + expectation* e = (expectation*)gpr_malloc(sizeof(expectation)); e->type = type; e->file = file; e->line = line; @@ -315,7 +315,7 @@ static void add(cq_verifier *v, const char *file, int line, v->first_expectation = e; } -void cq_expect_completion(cq_verifier *v, const char *file, int line, void *tag, +void cq_expect_completion(cq_verifier* v, const char* file, int line, void* tag, bool success) { add(v, file, line, GRPC_OP_COMPLETE, tag, success); } diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index d8a5d491d8..0b3b3fb349 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -34,33 +34,33 @@ extern "C" { typedef struct cq_verifier cq_verifier; /* construct/destroy a cq_verifier */ -cq_verifier *cq_verifier_create(grpc_completion_queue *cq); -void cq_verifier_destroy(cq_verifier *v); +cq_verifier* cq_verifier_create(grpc_completion_queue* cq); +void cq_verifier_destroy(cq_verifier* v); /* ensure all expected events (and only those events) are present on the bound completion queue */ -void cq_verify(cq_verifier *v); +void cq_verify(cq_verifier* v); /* ensure that the completion queue is empty */ -void cq_verify_empty(cq_verifier *v); +void cq_verify_empty(cq_verifier* v); /* ensure that the completion queue is empty, waiting up to \a timeout secs. */ -void cq_verify_empty_timeout(cq_verifier *v, int timeout_sec); +void cq_verify_empty_timeout(cq_verifier* v, int timeout_sec); /* Various expectation matchers Any functions taking ... expect a NULL terminated list of key/value pairs (each pair using two parameter slots) of metadata that MUST be present in the event. */ -void cq_expect_completion(cq_verifier *v, const char *file, int line, void *tag, +void cq_expect_completion(cq_verifier* v, const char* file, int line, void* tag, bool success); #define CQ_EXPECT_COMPLETION(v, tag, success) \ cq_expect_completion(v, __FILE__, __LINE__, tag, success) -int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b); -int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); -int contains_metadata(grpc_metadata_array *array, const char *key, - const char *value); -int contains_metadata_slices(grpc_metadata_array *array, grpc_slice key, +int byte_buffer_eq_slice(grpc_byte_buffer* bb, grpc_slice b); +int byte_buffer_eq_string(grpc_byte_buffer* byte_buffer, const char* string); +int contains_metadata(grpc_metadata_array* array, const char* key, + const char* value); +int contains_metadata_slices(grpc_metadata_array* array, grpc_slice key, grpc_slice value); #ifdef __cplusplus diff --git a/test/core/end2end/cq_verifier_internal.h b/test/core/end2end/cq_verifier_internal.h index 0aa8dc6b1c..0629e0e5a7 100644 --- a/test/core/end2end/cq_verifier_internal.h +++ b/test/core/end2end/cq_verifier_internal.h @@ -23,10 +23,10 @@ typedef struct expectation expectation; -expectation *cq_verifier_get_first_expectation(cq_verifier *v); +expectation* cq_verifier_get_first_expectation(cq_verifier* v); -void cq_verifier_set_first_expectation(cq_verifier *v, expectation *e); +void cq_verifier_set_first_expectation(cq_verifier* v, expectation* e); -grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds); +grpc_event cq_verifier_next_event(cq_verifier* v, int timeout_seconds); #endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_INTERNAL_H */ diff --git a/test/core/end2end/cq_verifier_native.cc b/test/core/end2end/cq_verifier_native.cc index 2bd9401aba..a0a7c832e5 100644 --- a/test/core/end2end/cq_verifier_native.cc +++ b/test/core/end2end/cq_verifier_native.cc @@ -24,33 +24,33 @@ /* the verifier itself */ struct cq_verifier { /* bound completion queue */ - grpc_completion_queue *cq; + grpc_completion_queue* cq; /* start of expectation list */ - expectation *first_expectation; + expectation* first_expectation; uv_timer_t timer; }; -cq_verifier *cq_verifier_create(grpc_completion_queue *cq) { - cq_verifier *v = static_cast<cq_verifier *>(gpr_malloc(sizeof(cq_verifier))); +cq_verifier* cq_verifier_create(grpc_completion_queue* cq) { + cq_verifier* v = static_cast<cq_verifier*>(gpr_malloc(sizeof(cq_verifier))); v->cq = cq; cq_verifier_set_first_expectation(v, NULL); return v; } -void cq_verifier_destroy(cq_verifier *v) { +void cq_verifier_destroy(cq_verifier* v) { cq_verify(v); gpr_free(v); } -expectation *cq_verifier_get_first_expectation(cq_verifier *v) { +expectation* cq_verifier_get_first_expectation(cq_verifier* v) { return v->first_expectation; } -void cq_verifier_set_first_expectation(cq_verifier *v, expectation *e) { +void cq_verifier_set_first_expectation(cq_verifier* v, expectation* e) { v->first_expectation = e; } -grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds) { +grpc_event cq_verifier_next_event(cq_verifier* v, int timeout_seconds) { const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(timeout_seconds); return grpc_completion_queue_next(v->cq, deadline, NULL); diff --git a/test/core/end2end/cq_verifier_uv.cc b/test/core/end2end/cq_verifier_uv.cc index 79e686c8f6..e23b3ae2a0 100644 --- a/test/core/end2end/cq_verifier_uv.cc +++ b/test/core/end2end/cq_verifier_uv.cc @@ -36,51 +36,51 @@ typedef enum timer_state { /* the verifier itself */ struct cq_verifier { /* bound completion queue */ - grpc_completion_queue *cq; + grpc_completion_queue* cq; /* start of expectation list */ - expectation *first_expectation; + expectation* first_expectation; uv_timer_t timer; }; -cq_verifier *cq_verifier_create(grpc_completion_queue *cq) { - cq_verifier *v = static_cast<cq_verifier *>(gpr_malloc(sizeof(cq_verifier))); +cq_verifier* cq_verifier_create(grpc_completion_queue* cq) { + cq_verifier* v = static_cast<cq_verifier*>(gpr_malloc(sizeof(cq_verifier))); v->cq = cq; v->first_expectation = NULL; uv_timer_init(uv_default_loop(), &v->timer); - v->timer.data = (void *)TIMER_STARTED; + v->timer.data = (void*)TIMER_STARTED; return v; } -static void timer_close_cb(uv_handle_t *handle) { - handle->data = (void *)TIMER_CLOSED; +static void timer_close_cb(uv_handle_t* handle) { + handle->data = (void*)TIMER_CLOSED; } -void cq_verifier_destroy(cq_verifier *v) { +void cq_verifier_destroy(cq_verifier* v) { cq_verify(v); - uv_close((uv_handle_t *)&v->timer, timer_close_cb); + uv_close((uv_handle_t*)&v->timer, timer_close_cb); while (reinterpret_cast<timer_state>(v->timer.data) != TIMER_CLOSED) { uv_run(uv_default_loop(), UV_RUN_NOWAIT); } gpr_free(v); } -expectation *cq_verifier_get_first_expectation(cq_verifier *v) { +expectation* cq_verifier_get_first_expectation(cq_verifier* v) { return v->first_expectation; } -void cq_verifier_set_first_expectation(cq_verifier *v, expectation *e) { +void cq_verifier_set_first_expectation(cq_verifier* v, expectation* e) { v->first_expectation = e; } -static void timer_run_cb(uv_timer_t *timer) { - timer->data = (void *)TIMER_TRIGGERED; +static void timer_run_cb(uv_timer_t* timer) { + timer->data = (void*)TIMER_TRIGGERED; } -grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds) { +grpc_event cq_verifier_next_event(cq_verifier* v, int timeout_seconds) { uint64_t timeout_ms = timeout_seconds < 0 ? 0 : (uint64_t)timeout_seconds * 1000; grpc_event ev; - v->timer.data = (void *)TIMER_STARTED; + v->timer.data = (void*)TIMER_STARTED; uv_timer_start(&v->timer, timer_run_cb, timeout_ms, 0); ev = grpc_completion_queue_next(v->cq, gpr_inf_past(GPR_CLOCK_MONOTONIC), NULL); diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc index bfb2e227ac..1e02116e4c 100644 --- a/test/core/end2end/dualstack_socket_test.cc +++ b/test/core/end2end/dualstack_socket_test.cc @@ -39,36 +39,36 @@ /* This test exercises IPv4, IPv6, and dualstack sockets in various ways. */ -static void *tag(intptr_t i) { return (void *)i; } +static void* tag(intptr_t i) { return (void*)i; } static gpr_timespec ms_from_now(int ms) { return grpc_timeout_milliseconds_to_deadline(ms); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, ms_from_now(5000), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void do_nothing(void *ignored) {} +static void do_nothing(void* ignored) {} -void test_connect(const char *server_host, const char *client_host, int port, +void test_connect(const char* server_host, const char* client_host, int port, int expect_ok) { - char *client_hostport; - char *server_hostport; - grpc_channel *client; - grpc_server *server; - grpc_completion_queue *cq; - grpc_completion_queue *shutdown_cq; - grpc_call *c; - grpc_call *s; - cq_verifier *cqv; + char* client_hostport; + char* server_hostport; + grpc_channel* client; + grpc_server* server; + grpc_completion_queue* cq; + grpc_completion_queue* shutdown_cq; + grpc_call* c; + grpc_call* s; + cq_verifier* cqv; gpr_timespec deadline; int got_port; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -77,7 +77,7 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_slice details; int was_cancelled = 2; grpc_call_details call_details; - char *peer; + char* peer; int picked_port = 0; if (port == 0) { @@ -112,20 +112,20 @@ void test_connect(const char *server_host, const char *client_host, int port, size_t i; grpc_slice uri_slice; grpc_slice_buffer uri_parts; - char **hosts_with_port; + char** hosts_with_port; uri_slice = - grpc_slice_new((char *)client_host, strlen(client_host), do_nothing); + grpc_slice_new((char*)client_host, strlen(client_host), do_nothing); grpc_slice_buffer_init(&uri_parts); grpc_slice_split(uri_slice, ",", &uri_parts); hosts_with_port = - static_cast<char **>(gpr_malloc(sizeof(char *) * uri_parts.count)); + static_cast<char**>(gpr_malloc(sizeof(char*) * uri_parts.count)); for (i = 0; i < uri_parts.count; i++) { - char *uri_part_str = grpc_slice_to_c_string(uri_parts.slices[i]); + char* uri_part_str = grpc_slice_to_c_string(uri_parts.slices[i]); gpr_asprintf(&hosts_with_port[i], "%s:%d", uri_part_str, port); gpr_free(uri_part_str); } - client_hostport = gpr_strjoin_sep((const char **)hosts_with_port, + client_hostport = gpr_strjoin_sep((const char**)hosts_with_port, uri_parts.count, ",", NULL); for (i = 0; i < uri_parts.count; i++) { gpr_free(hosts_with_port[i]); @@ -269,9 +269,9 @@ void test_connect(const char *server_host, const char *client_host, int port, } } -int external_dns_works(const char *host) { - grpc_resolved_addresses *res = NULL; - grpc_error *error = grpc_blocking_resolve_address(host, "80", &res); +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); @@ -280,7 +280,7 @@ int external_dns_works(const char *host) { return 0; } -int main(int argc, char **argv) { +int main(int argc, char** argv) { int do_ipv6 = 1; grpc_test_init(argc, argv); @@ -353,6 +353,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/end2end/end2end_nosec_tests.cc b/test/core/end2end/end2end_nosec_tests.cc index 3236feea56..ca63864a9e 100644 --- a/test/core/end2end/end2end_nosec_tests.cc +++ b/test/core/end2end/end2end_nosec_tests.cc @@ -130,11 +130,13 @@ extern void simple_metadata(grpc_end2end_test_config config); extern void simple_metadata_pre_init(void); extern void simple_request(grpc_end2end_test_config config); extern void simple_request_pre_init(void); -extern void stream_compression_compressed_payload(grpc_end2end_test_config config); +extern void stream_compression_compressed_payload( + grpc_end2end_test_config config); extern void stream_compression_compressed_payload_pre_init(void); extern void stream_compression_payload(grpc_end2end_test_config config); extern void stream_compression_payload_pre_init(void); -extern void stream_compression_ping_pong_streaming(grpc_end2end_test_config config); +extern void stream_compression_ping_pong_streaming( + grpc_end2end_test_config config); extern void stream_compression_ping_pong_streaming_pre_init(void); extern void streaming_error_response(grpc_end2end_test_config config); extern void streaming_error_response_pre_init(void); @@ -211,7 +213,7 @@ void grpc_end2end_tests_pre_init(void) { write_buffering_at_end_pre_init(); } -void grpc_end2end_tests(int argc, char **argv, +void grpc_end2end_tests(int argc, char** argv, grpc_end2end_test_config config) { int i; diff --git a/test/core/end2end/end2end_test_utils.cc b/test/core/end2end/end2end_test_utils.cc index c1f119548a..35f086a7f6 100644 --- a/test/core/end2end/end2end_test_utils.cc +++ b/test/core/end2end/end2end_test_utils.cc @@ -22,7 +22,7 @@ #include <grpc/support/log.h> -const char *get_host_override_string(const char *str, +const char* get_host_override_string(const char* str, grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { return str; @@ -31,9 +31,9 @@ const char *get_host_override_string(const char *str, } } -const grpc_slice *get_host_override_slice(const char *str, +const grpc_slice* get_host_override_slice(const char* str, grpc_end2end_test_config config) { - const char *r = get_host_override_string(str, config); + const char* r = get_host_override_string(str, config); if (r != NULL) { static grpc_slice ret; ret = grpc_slice_from_static_string(r); @@ -42,7 +42,7 @@ const grpc_slice *get_host_override_slice(const char *str, return NULL; } -void validate_host_override_string(const char *pattern, grpc_slice str, +void validate_host_override_string(const char* pattern, grpc_slice str, grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { GPR_ASSERT(0 == grpc_slice_str_cmp(str, pattern)); diff --git a/test/core/end2end/end2end_tests.cc b/test/core/end2end/end2end_tests.cc index ca9443b642..5920b532f1 100644 --- a/test/core/end2end/end2end_tests.cc +++ b/test/core/end2end/end2end_tests.cc @@ -132,11 +132,13 @@ extern void simple_metadata(grpc_end2end_test_config config); extern void simple_metadata_pre_init(void); extern void simple_request(grpc_end2end_test_config config); extern void simple_request_pre_init(void); -extern void stream_compression_compressed_payload(grpc_end2end_test_config config); +extern void stream_compression_compressed_payload( + grpc_end2end_test_config config); extern void stream_compression_compressed_payload_pre_init(void); extern void stream_compression_payload(grpc_end2end_test_config config); extern void stream_compression_payload_pre_init(void); -extern void stream_compression_ping_pong_streaming(grpc_end2end_test_config config); +extern void stream_compression_ping_pong_streaming( + grpc_end2end_test_config config); extern void stream_compression_ping_pong_streaming_pre_init(void); extern void streaming_error_response(grpc_end2end_test_config config); extern void streaming_error_response_pre_init(void); @@ -214,7 +216,7 @@ void grpc_end2end_tests_pre_init(void) { write_buffering_at_end_pre_init(); } -void grpc_end2end_tests(int argc, char **argv, +void grpc_end2end_tests(int argc, char** argv, grpc_end2end_test_config config) { int i; diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index 87269ec468..b42d90b55c 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -38,40 +38,40 @@ typedef struct grpc_end2end_test_config grpc_end2end_test_config; #define FAIL_AUTH_CHECK_SERVER_ARG_NAME "fail_auth_check" struct grpc_end2end_test_fixture { - grpc_completion_queue *cq; - grpc_completion_queue *shutdown_cq; - grpc_server *server; - grpc_channel *client; - void *fixture_data; + grpc_completion_queue* cq; + grpc_completion_queue* shutdown_cq; + grpc_server* server; + grpc_channel* client; + void* fixture_data; }; struct grpc_end2end_test_config { /* A descriptive name for this test fixture. */ - const char *name; + const char* name; /* Which features are supported by this fixture. See feature flags above. */ uint32_t feature_mask; - grpc_end2end_test_fixture (*create_fixture)(grpc_channel_args *client_args, - grpc_channel_args *server_args); - void (*init_client)(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args); - void (*init_server)(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args); - void (*tear_down_data)(grpc_end2end_test_fixture *f); + grpc_end2end_test_fixture (*create_fixture)(grpc_channel_args* client_args, + grpc_channel_args* server_args); + void (*init_client)(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args); + void (*init_server)(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args); + void (*tear_down_data)(grpc_end2end_test_fixture* f); }; void grpc_end2end_tests_pre_init(void); -void grpc_end2end_tests(int argc, char **argv, grpc_end2end_test_config config); +void grpc_end2end_tests(int argc, char** argv, grpc_end2end_test_config config); -const char *get_host_override_string(const char *str, +const char* get_host_override_string(const char* str, grpc_end2end_test_config config); /* Returns a pointer to a statically allocated slice: future invocations overwrite past invocations, not threadsafe, etc... */ -const grpc_slice *get_host_override_slice(const char *str, +const grpc_slice* get_host_override_slice(const char* str, grpc_end2end_test_config config); -void validate_host_override_string(const char *pattern, grpc_slice str, +void validate_host_override_string(const char* pattern, grpc_slice str, grpc_end2end_test_config config); #endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */ diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc index d7058187b4..4213140f4a 100644 --- a/test/core/end2end/fixtures/h2_census.cc +++ b/test/core/end2end/fixtures/h2_census.cc @@ -37,14 +37,14 @@ #include "test/core/util/test_config.h" typedef struct fullstack_fixture_data { - char *localaddr; + char* localaddr; } fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data *ffd = static_cast<fullstack_fixture_data *>( + fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>( gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); @@ -60,15 +60,15 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( static grpc_arg make_census_enable_arg(void) { grpc_arg arg; arg.type = GRPC_ARG_INTEGER; - arg.key = const_cast<char *>(GRPC_ARG_ENABLE_CENSUS); + arg.key = const_cast<char*>(GRPC_ARG_ENABLE_CENSUS); arg.value.integer = 1; return arg; } -void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); grpc_arg arg = make_census_enable_arg(); client_args = grpc_channel_args_copy_and_add(client_args, &arg, 1); f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); @@ -80,10 +80,10 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, } } -void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); grpc_arg arg = make_census_enable_arg(); if (f->server) { grpc_server_destroy(f->server); @@ -100,23 +100,24 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+census", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+census", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index bdfeef259d..64e028b950 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -37,17 +37,17 @@ #include "test/core/util/test_config.h" typedef struct fullstack_compression_fixture_data { - char *localaddr; - grpc_channel_args *client_args_compression; - grpc_channel_args *server_args_compression; + char* localaddr; + grpc_channel_args* client_args_compression; + grpc_channel_args* server_args_compression; } fullstack_compression_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_compression_fixture_data *ffd = - static_cast<fullstack_compression_fixture_data *>( + fullstack_compression_fixture_data* ffd = + static_cast<fullstack_compression_fixture_data*>( gpr_malloc(sizeof(fullstack_compression_fixture_data))); memset(ffd, 0, sizeof(fullstack_compression_fixture_data)); @@ -61,10 +61,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( return f; } -void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - fullstack_compression_fixture_data *ffd = - static_cast<fullstack_compression_fixture_data *>(f->fixture_data); +void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + fullstack_compression_fixture_data* ffd = + static_cast<fullstack_compression_fixture_data*>(f->fixture_data); if (ffd->client_args_compression != NULL) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_channel_args_destroy(&exec_ctx, ffd->client_args_compression); @@ -76,10 +76,10 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture *f, ffd->client_args_compression, NULL); } -void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - fullstack_compression_fixture_data *ffd = - static_cast<fullstack_compression_fixture_data *>(f->fixture_data); +void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { + fullstack_compression_fixture_data* ffd = + static_cast<fullstack_compression_fixture_data*>(f->fixture_data); if (ffd->server_args_compression != NULL) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_channel_args_destroy(&exec_ctx, ffd->server_args_compression); @@ -96,10 +96,10 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) { +void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture* f) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - fullstack_compression_fixture_data *ffd = - static_cast<fullstack_compression_fixture_data *>(f->fixture_data); + fullstack_compression_fixture_data* ffd = + static_cast<fullstack_compression_fixture_data*>(f->fixture_data); grpc_channel_args_destroy(&exec_ctx, ffd->client_args_compression); grpc_channel_args_destroy(&exec_ctx, ffd->server_args_compression); gpr_free(ffd->localaddr); @@ -109,16 +109,17 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_compression", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_compression", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack_compression, chttp2_init_client_fullstack_compression, chttp2_init_server_fullstack_compression, chttp2_tear_down_fullstack_compression}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc index 7cbcfcca91..fbf2f49729 100644 --- a/test/core/end2end/fixtures/h2_fakesec.cc +++ b/test/core/end2end/fixtures/h2_fakesec.cc @@ -31,15 +31,15 @@ #include "test/core/util/test_config.h" typedef struct fullstack_secure_fixture_data { - char *localaddr; + char* localaddr; } fullstack_secure_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>( + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>( gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); @@ -52,19 +52,19 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( return f; } -static void process_auth_failure(void *state, grpc_auth_context *ctx, - const grpc_metadata *md, size_t md_count, +static void process_auth_failure(void* state, grpc_auth_context* ctx, + const grpc_metadata* md, size_t md_count, grpc_process_auth_metadata_done_cb cb, - void *user_data) { + void* user_data) { GPR_ASSERT(state == NULL); cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *client_args, - grpc_channel_credentials *creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_channel_credentials* creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); @@ -72,10 +72,10 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *server_args, - grpc_server_credentials *server_creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_server_credentials* server_creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -87,21 +87,21 @@ static void chttp2_init_server_secure_fullstack( grpc_server_start(f->server); } -void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } static void chttp2_init_client_fake_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { - grpc_channel_credentials *fake_ts_creds = + grpc_end2end_test_fixture* f, grpc_channel_args* client_args) { + grpc_channel_credentials* fake_ts_creds = grpc_fake_transport_security_credentials_create(); chttp2_init_client_secure_fullstack(f, client_args, fake_ts_creds); } -static int fail_server_auth_check(grpc_channel_args *server_args) { +static int fail_server_auth_check(grpc_channel_args* server_args) { size_t i; if (server_args == NULL) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -114,8 +114,8 @@ static int fail_server_auth_check(grpc_channel_args *server_args) { } static void chttp2_init_server_fake_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { - grpc_server_credentials *fake_ts_creds = + grpc_end2end_test_fixture* f, grpc_channel_args* server_args) { + grpc_server_credentials* fake_ts_creds = grpc_fake_transport_security_server_credentials_create(); if (fail_server_auth_check(server_args)) { grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL}; @@ -139,7 +139,7 @@ static grpc_end2end_test_config configs[] = { chttp2_tear_down_secure_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); grpc_end2end_tests_pre_init(); diff --git a/test/core/end2end/fixtures/h2_fd.cc b/test/core/end2end/fixtures/h2_fd.cc index 2dc7898d56..7005b969a0 100644 --- a/test/core/end2end/fixtures/h2_fd.cc +++ b/test/core/end2end/fixtures/h2_fd.cc @@ -35,7 +35,9 @@ #include "src/core/lib/iomgr/unix_sockets_posix.h" #include "test/core/util/test_config.h" -typedef struct { int fd_pair[2]; } sp_fixture_data; +typedef struct { + int fd_pair[2]; +} sp_fixture_data; static void create_sockets(int sv[2]) { int flags; @@ -49,9 +51,9 @@ static void create_sockets(int sv[2]) { } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( - grpc_channel_args *client_args, grpc_channel_args *server_args) { - sp_fixture_data *fixture_data = - static_cast<sp_fixture_data *>(gpr_malloc(sizeof(*fixture_data))); + grpc_channel_args* client_args, grpc_channel_args* server_args) { + sp_fixture_data* fixture_data = + static_cast<sp_fixture_data*>(gpr_malloc(sizeof(*fixture_data))); grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); @@ -64,10 +66,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( return f; } -static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { +static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - sp_fixture_data *sfd = static_cast<sp_fixture_data *>(f->fixture_data); + sp_fixture_data* sfd = static_cast<sp_fixture_data*>(f->fixture_data); GPR_ASSERT(!f->client); f->client = grpc_insecure_channel_create_from_fd( @@ -77,10 +79,10 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } -static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { +static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - sp_fixture_data *sfd = static_cast<sp_fixture_data *>(f->fixture_data); + sp_fixture_data* sfd = static_cast<sp_fixture_data*>(f->fixture_data); GPR_ASSERT(!f->server); f->server = grpc_server_create(server_args, NULL); GPR_ASSERT(f->server); @@ -92,7 +94,7 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } -static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { +static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) { gpr_free(f->fixture_data); } @@ -103,7 +105,7 @@ static grpc_end2end_test_config configs[] = { chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); @@ -121,6 +123,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc index beff1be239..0dd650b8e0 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.cc +++ b/test/core/end2end/fixtures/h2_full+pipe.cc @@ -42,14 +42,14 @@ #include "test/core/util/test_config.h" typedef struct fullstack_fixture_data { - char *localaddr; + char* localaddr; } fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data *ffd = static_cast<fullstack_fixture_data *>( + fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>( gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); @@ -62,18 +62,18 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( return f; } -void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client); } -void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -83,23 +83,24 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_allow_specialized_wakeup_fd = 0; @@ -119,6 +120,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_WAKEUP_FD */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_WAKEUP_FD */ diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index efed0c536f..21372c6dee 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -42,14 +42,14 @@ #include "test/core/util/test_config.h" typedef struct fullstack_fixture_data { - char *localaddr; + char* localaddr; } fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data *ffd = static_cast<fullstack_fixture_data *>( + fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>( gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); @@ -62,18 +62,18 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( return f; } -void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client); } -void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -83,23 +83,24 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; /* force tracing on, with a value to force many diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc index d4930ce90d..ebffe2125c 100644 --- a/test/core/end2end/fixtures/h2_full+workarounds.cc +++ b/test/core/end2end/fixtures/h2_full+workarounds.cc @@ -36,18 +36,18 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static char *workarounds_arg[GRPC_MAX_WORKAROUND_ID] = { - const_cast<char *>(GRPC_ARG_WORKAROUND_CRONET_COMPRESSION)}; +static char* workarounds_arg[GRPC_MAX_WORKAROUND_ID] = { + const_cast<char*>(GRPC_ARG_WORKAROUND_CRONET_COMPRESSION)}; typedef struct fullstack_fixture_data { - char *localaddr; + char* localaddr; } fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data *ffd = static_cast<fullstack_fixture_data *>( + fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>( gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); @@ -60,27 +60,27 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( return f; } -void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client); } -void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { +void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { int i; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); grpc_arg args[GRPC_MAX_WORKAROUND_ID]; for (i = 0; i < GRPC_MAX_WORKAROUND_ID; i++) { args[i].key = workarounds_arg[i]; args[i].type = GRPC_ARG_INTEGER; args[i].value.integer = 1; } - grpc_channel_args *server_args_new = + grpc_channel_args* server_args_new = grpc_channel_args_copy_and_add(server_args, args, GRPC_MAX_WORKAROUND_ID); if (f->server) { grpc_server_destroy(f->server); @@ -93,24 +93,25 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } -void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | - FEATURE_MASK_SUPPORTS_WORKAROUNDS, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | + FEATURE_MASK_SUPPORTS_WORKAROUNDS, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc index d132198157..895af67930 100644 --- a/test/core/end2end/fixtures/h2_full.cc +++ b/test/core/end2end/fixtures/h2_full.cc @@ -36,14 +36,14 @@ #include "test/core/util/test_config.h" typedef struct fullstack_fixture_data { - char *localaddr; + char* localaddr; } fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data *ffd = static_cast<fullstack_fixture_data *>( + fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>( gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); @@ -56,18 +56,18 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( return f; } -void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client); } -void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -77,23 +77,24 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index 5630b491b0..a67ce82064 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -39,15 +39,15 @@ #include "test/core/util/test_config.h" typedef struct fullstack_fixture_data { - char *server_addr; - grpc_end2end_http_proxy *proxy; + char* server_addr; + grpc_end2end_http_proxy* proxy; } fullstack_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); - fullstack_fixture_data *ffd = static_cast<fullstack_fixture_data *>( + fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>( gpr_malloc(sizeof(fullstack_fixture_data))); const int server_port = grpc_pick_unused_port_or_die(); gpr_join_host_port(&ffd->server_addr, "localhost", server_port); @@ -63,14 +63,14 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( return f; } -void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); - char *proxy_uri; +void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); + char* proxy_uri; /* If testing for proxy auth, add credentials to proxy uri */ - const grpc_arg *proxy_auth_arg = + const grpc_arg* proxy_auth_arg = grpc_channel_args_find(client_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS); if (proxy_auth_arg == NULL || proxy_auth_arg->type != GRPC_ARG_STRING) { gpr_asprintf(&proxy_uri, "http://%s", @@ -85,10 +85,10 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, GPR_ASSERT(f->client); } -void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -98,9 +98,9 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); gpr_free(ffd->server_addr); grpc_end2end_http_proxy_destroy(ffd->proxy); gpr_free(ffd); @@ -108,14 +108,15 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/h2_load_reporting.cc b/test/core/end2end/fixtures/h2_load_reporting.cc index e461f13e06..b402fc5620 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.cc +++ b/test/core/end2end/fixtures/h2_load_reporting.cc @@ -38,14 +38,14 @@ #include "test/core/util/test_config.h" typedef struct load_reporting_fixture_data { - char *localaddr; + char* localaddr; } load_reporting_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_load_reporting( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - load_reporting_fixture_data *ffd = static_cast<load_reporting_fixture_data *>( + load_reporting_fixture_data* ffd = static_cast<load_reporting_fixture_data*>( gpr_malloc(sizeof(load_reporting_fixture_data))); memset(&f, 0, sizeof(f)); @@ -58,18 +58,18 @@ static grpc_end2end_test_fixture chttp2_create_fixture_load_reporting( return f; } -void chttp2_init_client_load_reporting(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - load_reporting_fixture_data *ffd = - static_cast<load_reporting_fixture_data *>(f->fixture_data); +void chttp2_init_client_load_reporting(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + load_reporting_fixture_data* ffd = + static_cast<load_reporting_fixture_data*>(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client); } -void chttp2_init_server_load_reporting(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - load_reporting_fixture_data *ffd = - static_cast<load_reporting_fixture_data *>(f->fixture_data); +void chttp2_init_server_load_reporting(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { + load_reporting_fixture_data* ffd = + static_cast<load_reporting_fixture_data*>(f->fixture_data); grpc_arg arg = grpc_load_reporting_enable_arg(); if (f->server) { grpc_server_destroy(f->server); @@ -86,9 +86,9 @@ void chttp2_init_server_load_reporting(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void chttp2_tear_down_load_reporting(grpc_end2end_test_fixture *f) { - load_reporting_fixture_data *ffd = - static_cast<load_reporting_fixture_data *>(f->fixture_data); +void chttp2_tear_down_load_reporting(grpc_end2end_test_fixture* f) { + load_reporting_fixture_data* ffd = + static_cast<load_reporting_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } @@ -103,7 +103,7 @@ static grpc_end2end_test_config configs[] = { chttp2_init_server_load_reporting, chttp2_tear_down_load_reporting}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc index f1e49f20cd..88e590a15f 100644 --- a/test/core/end2end/fixtures/h2_oauth2.cc +++ b/test/core/end2end/fixtures/h2_oauth2.cc @@ -32,16 +32,16 @@ #include "test/core/util/test_config.h" static const char oauth2_md[] = "Bearer aaslkfjs424535asdf"; -static const char *client_identity_property_name = "smurf_name"; -static const char *client_identity = "Brainy Smurf"; +static const char* client_identity_property_name = "smurf_name"; +static const char* client_identity = "Brainy Smurf"; typedef struct fullstack_secure_fixture_data { - char *localaddr; + char* localaddr; } fullstack_secure_fixture_data; -static const grpc_metadata *find_metadata(const grpc_metadata *md, - size_t md_count, const char *key, - const char *value) { +static const grpc_metadata* find_metadata(const grpc_metadata* md, + size_t md_count, const char* key, + const char* value) { size_t i; for (i = 0; i < md_count; i++) { if (grpc_slice_str_cmp(md[i].key, key) == 0 && @@ -52,18 +52,20 @@ static const grpc_metadata *find_metadata(const grpc_metadata *md, return NULL; } -typedef struct { size_t pseudo_refcount; } test_processor_state; +typedef struct { + size_t pseudo_refcount; +} test_processor_state; -static void process_oauth2_success(void *state, grpc_auth_context *ctx, - const grpc_metadata *md, size_t md_count, +static void process_oauth2_success(void* state, grpc_auth_context* ctx, + const grpc_metadata* md, size_t md_count, grpc_process_auth_metadata_done_cb cb, - void *user_data) { - const grpc_metadata *oauth2 = + void* user_data) { + const grpc_metadata* oauth2 = find_metadata(md, md_count, "authorization", oauth2_md); - test_processor_state *s; + test_processor_state* s; GPR_ASSERT(state != NULL); - s = (test_processor_state *)state; + s = (test_processor_state*)state; GPR_ASSERT(s->pseudo_refcount == 1); GPR_ASSERT(oauth2 != NULL); grpc_auth_context_add_cstring_property(ctx, client_identity_property_name, @@ -73,26 +75,26 @@ static void process_oauth2_success(void *state, grpc_auth_context *ctx, cb(user_data, oauth2, 1, NULL, 0, GRPC_STATUS_OK, NULL); } -static void process_oauth2_failure(void *state, grpc_auth_context *ctx, - const grpc_metadata *md, size_t md_count, +static void process_oauth2_failure(void* state, grpc_auth_context* ctx, + const grpc_metadata* md, size_t md_count, grpc_process_auth_metadata_done_cb cb, - void *user_data) { - const grpc_metadata *oauth2 = + void* user_data) { + const grpc_metadata* oauth2 = find_metadata(md, md_count, "authorization", oauth2_md); - test_processor_state *s; + test_processor_state* s; GPR_ASSERT(state != NULL); - s = (test_processor_state *)state; + s = (test_processor_state*)state; GPR_ASSERT(s->pseudo_refcount == 1); GPR_ASSERT(oauth2 != NULL); cb(user_data, oauth2, 1, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>( + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>( gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); @@ -106,10 +108,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *client_args, - grpc_channel_credentials *creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_channel_credentials* creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); @@ -117,10 +119,10 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *server_args, - grpc_server_credentials *server_creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_server_credentials* server_creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -132,27 +134,27 @@ static void chttp2_init_server_secure_fullstack( grpc_server_start(f->server); } -void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { + grpc_end2end_test_fixture* f, grpc_channel_args* client_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_channel_credentials *ssl_creds = + grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(test_root_cert, NULL, NULL); - grpc_call_credentials *oauth2_creds = grpc_md_only_test_credentials_create( + grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create( &exec_ctx, "authorization", oauth2_md, true /* is_async */); - grpc_channel_credentials *ssl_oauth2_creds = + grpc_channel_credentials* ssl_oauth2_creds = grpc_composite_channel_credentials_create(ssl_creds, oauth2_creds, NULL); 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 = + 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(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds); grpc_channel_args_destroy(&exec_ctx, new_client_args); @@ -161,7 +163,7 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( grpc_exec_ctx_finish(&exec_ctx); } -static int fail_server_auth_check(grpc_channel_args *server_args) { +static int fail_server_auth_check(grpc_channel_args* server_args) { size_t i; if (server_args == NULL) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -173,15 +175,15 @@ static int fail_server_auth_check(grpc_channel_args *server_args) { return 0; } -static void processor_destroy(void *state) { - test_processor_state *s = (test_processor_state *)state; +static void processor_destroy(void* state) { + test_processor_state* s = (test_processor_state*)state; GPR_ASSERT((s->pseudo_refcount--) == 1); gpr_free(s); } static grpc_auth_metadata_processor test_processor_create(int failing) { - test_processor_state *s = - static_cast<test_processor_state *>(gpr_malloc(sizeof(*s))); + test_processor_state* s = + static_cast<test_processor_state*>(gpr_malloc(sizeof(*s))); grpc_auth_metadata_processor result; s->pseudo_refcount = 1; result.state = s; @@ -195,10 +197,10 @@ static grpc_auth_metadata_processor test_processor_create(int failing) { } static void chttp2_init_server_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { + grpc_end2end_test_fixture* f, grpc_channel_args* server_args) { grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key, test_server1_cert}; - grpc_server_credentials *ssl_creds = + grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1, 0, NULL); grpc_server_credentials_set_auth_metadata_processor( ssl_creds, test_processor_create(fail_server_auth_check(server_args))); @@ -219,7 +221,7 @@ static grpc_end2end_test_config configs[] = { chttp2_tear_down_secure_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); grpc_end2end_tests_pre_init(); diff --git a/test/core/end2end/fixtures/h2_proxy.cc b/test/core/end2end/fixtures/h2_proxy.cc index e1eb9687d0..03ffa02e17 100644 --- a/test/core/end2end/fixtures/h2_proxy.cc +++ b/test/core/end2end/fixtures/h2_proxy.cc @@ -37,18 +37,18 @@ #include "test/core/util/test_config.h" typedef struct fullstack_fixture_data { - grpc_end2end_proxy *proxy; + grpc_end2end_proxy* proxy; } fullstack_fixture_data; -static grpc_server *create_proxy_server(const char *port, - grpc_channel_args *server_args) { - grpc_server *s = grpc_server_create(server_args, NULL); +static grpc_server* create_proxy_server(const char* port, + grpc_channel_args* server_args) { + grpc_server* s = grpc_server_create(server_args, NULL); GPR_ASSERT(grpc_server_add_insecure_http2_port(s, port)); return s; } -static grpc_channel *create_proxy_client(const char *target, - grpc_channel_args *client_args) { +static grpc_channel* create_proxy_client(const char* target, + grpc_channel_args* client_args) { return grpc_insecure_channel_create(target, client_args, NULL); } @@ -56,9 +56,9 @@ static const grpc_end2end_proxy_def proxy_def = {create_proxy_server, create_proxy_client}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; - fullstack_fixture_data *ffd = static_cast<fullstack_fixture_data *>( + fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>( gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); @@ -71,19 +71,19 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( return f; } -void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); f->client = grpc_insecure_channel_create( grpc_end2end_proxy_get_client_target(ffd->proxy), client_args, NULL); GPR_ASSERT(f->client); } -void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -94,24 +94,25 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); grpc_end2end_proxy_destroy(ffd->proxy); gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+proxy", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc index 81d0768969..c5dfe40391 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.cc +++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc @@ -48,10 +48,10 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static void server_setup_transport(void *ts, grpc_transport *transport) { - grpc_end2end_test_fixture *f = static_cast<grpc_end2end_test_fixture *>(ts); +static void server_setup_transport(void* ts, grpc_transport* transport) { + grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_endpoint_pair *sfd = static_cast<grpc_endpoint_pair *>(f->fixture_data); + grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data); grpc_endpoint_add_to_pollset(&exec_ctx, sfd->server, grpc_cq_pollset(f->cq)); grpc_server_setup_transport(&exec_ctx, f->server, transport, NULL, grpc_server_get_channel_args(f->server)); @@ -59,13 +59,13 @@ static void server_setup_transport(void *ts, grpc_transport *transport) { } typedef struct { - grpc_end2end_test_fixture *f; - grpc_channel_args *client_args; + grpc_end2end_test_fixture* f; + grpc_channel_args* client_args; } sp_client_setup; -static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts, - grpc_transport *transport) { - sp_client_setup *cs = static_cast<sp_client_setup *>(ts); +static void client_setup_transport(grpc_exec_ctx* exec_ctx, void* ts, + grpc_transport* transport) { + sp_client_setup* cs = static_cast<sp_client_setup*>(ts); cs->f->client = grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args, @@ -73,9 +73,9 @@ static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts, } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( - grpc_channel_args *client_args, grpc_channel_args *server_args) { - grpc_endpoint_pair *sfd = - static_cast<grpc_endpoint_pair *>(gpr_malloc(sizeof(grpc_endpoint_pair))); + grpc_channel_args* client_args, grpc_channel_args* server_args) { + grpc_endpoint_pair* sfd = + static_cast<grpc_endpoint_pair*>(gpr_malloc(sizeof(grpc_endpoint_pair))); grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); @@ -88,11 +88,11 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( return f; } -static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { +static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_endpoint_pair *sfd = static_cast<grpc_endpoint_pair *>(f->fixture_data); - grpc_transport *transport; + grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data); + grpc_transport* transport; sp_client_setup cs; cs.client_args = client_args; cs.f = f; @@ -104,11 +104,11 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } -static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { +static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_endpoint_pair *sfd = static_cast<grpc_endpoint_pair *>(f->fixture_data); - grpc_transport *transport; + grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data); + grpc_transport* transport; GPR_ASSERT(!f->server); f->server = grpc_server_create(server_args, NULL); grpc_server_register_completion_queue(f->server, f->cq, NULL); @@ -120,7 +120,7 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } -static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { +static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) { gpr_free(f->fixture_data); } @@ -131,7 +131,7 @@ static grpc_end2end_test_config configs[] = { chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; diff --git a/test/core/end2end/fixtures/h2_sockpair.cc b/test/core/end2end/fixtures/h2_sockpair.cc index 78b5ad8877..f07722e52d 100644 --- a/test/core/end2end/fixtures/h2_sockpair.cc +++ b/test/core/end2end/fixtures/h2_sockpair.cc @@ -42,10 +42,10 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static void server_setup_transport(void *ts, grpc_transport *transport) { - grpc_end2end_test_fixture *f = static_cast<grpc_end2end_test_fixture *>(ts); +static void server_setup_transport(void* ts, grpc_transport* transport) { + grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_endpoint_pair *sfd = static_cast<grpc_endpoint_pair *>(f->fixture_data); + grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data); grpc_endpoint_add_to_pollset(&exec_ctx, sfd->server, grpc_cq_pollset(f->cq)); grpc_server_setup_transport(&exec_ctx, f->server, transport, NULL, grpc_server_get_channel_args(f->server)); @@ -53,13 +53,13 @@ static void server_setup_transport(void *ts, grpc_transport *transport) { } typedef struct { - grpc_end2end_test_fixture *f; - grpc_channel_args *client_args; + grpc_end2end_test_fixture* f; + grpc_channel_args* client_args; } sp_client_setup; -static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts, - grpc_transport *transport) { - sp_client_setup *cs = static_cast<sp_client_setup *>(ts); +static void client_setup_transport(grpc_exec_ctx* exec_ctx, void* ts, + grpc_transport* transport) { + sp_client_setup* cs = static_cast<sp_client_setup*>(ts); cs->f->client = grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args, @@ -67,9 +67,9 @@ static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts, } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( - grpc_channel_args *client_args, grpc_channel_args *server_args) { - grpc_endpoint_pair *sfd = - static_cast<grpc_endpoint_pair *>(gpr_malloc(sizeof(grpc_endpoint_pair))); + grpc_channel_args* client_args, grpc_channel_args* server_args) { + grpc_endpoint_pair* sfd = + static_cast<grpc_endpoint_pair*>(gpr_malloc(sizeof(grpc_endpoint_pair))); grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); @@ -82,11 +82,11 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( return f; } -static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { +static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_endpoint_pair *sfd = static_cast<grpc_endpoint_pair *>(f->fixture_data); - grpc_transport *transport; + grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data); + grpc_transport* transport; sp_client_setup cs; cs.client_args = client_args; cs.f = f; @@ -98,11 +98,11 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } -static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { +static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_endpoint_pair *sfd = static_cast<grpc_endpoint_pair *>(f->fixture_data); - grpc_transport *transport; + grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data); + grpc_transport* transport; GPR_ASSERT(!f->server); f->server = grpc_server_create(server_args, NULL); grpc_server_register_completion_queue(f->server, f->cq, NULL); @@ -114,7 +114,7 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } -static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { +static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) { gpr_free(f->fixture_data); } @@ -125,7 +125,7 @@ static grpc_end2end_test_config configs[] = { chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.cc b/test/core/end2end/fixtures/h2_sockpair_1byte.cc index b144771f2a..7d00c69a18 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc @@ -42,10 +42,10 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static void server_setup_transport(void *ts, grpc_transport *transport) { - grpc_end2end_test_fixture *f = static_cast<grpc_end2end_test_fixture *>(ts); +static void server_setup_transport(void* ts, grpc_transport* transport) { + grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_endpoint_pair *sfd = static_cast<grpc_endpoint_pair *>(f->fixture_data); + grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data); grpc_endpoint_add_to_pollset(&exec_ctx, sfd->server, grpc_cq_pollset(f->cq)); grpc_server_setup_transport(&exec_ctx, f->server, transport, NULL, grpc_server_get_channel_args(f->server)); @@ -53,13 +53,13 @@ static void server_setup_transport(void *ts, grpc_transport *transport) { } typedef struct { - grpc_end2end_test_fixture *f; - grpc_channel_args *client_args; + grpc_end2end_test_fixture* f; + grpc_channel_args* client_args; } sp_client_setup; -static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts, - grpc_transport *transport) { - sp_client_setup *cs = static_cast<sp_client_setup *>(ts); +static void client_setup_transport(grpc_exec_ctx* exec_ctx, void* ts, + grpc_transport* transport) { + sp_client_setup* cs = static_cast<sp_client_setup*>(ts); cs->f->client = grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args, @@ -67,9 +67,9 @@ static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts, } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( - grpc_channel_args *client_args, grpc_channel_args *server_args) { - grpc_endpoint_pair *sfd = - static_cast<grpc_endpoint_pair *>(gpr_malloc(sizeof(grpc_endpoint_pair))); + grpc_channel_args* client_args, grpc_channel_args* server_args) { + grpc_endpoint_pair* sfd = + static_cast<grpc_endpoint_pair*>(gpr_malloc(sizeof(grpc_endpoint_pair))); grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); @@ -78,13 +78,13 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_arg a[3]; - a[0].key = const_cast<char *>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); a[0].type = GRPC_ARG_INTEGER; a[0].value.integer = 1; - a[1].key = const_cast<char *>(GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE); + a[1].key = const_cast<char*>(GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE); a[1].type = GRPC_ARG_INTEGER; a[1].value.integer = 1; - a[2].key = const_cast<char *>(GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE); + a[2].key = const_cast<char*>(GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE); a[2].type = GRPC_ARG_INTEGER; a[2].value.integer = 1; grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; @@ -93,11 +93,11 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( return f; } -static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { +static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_endpoint_pair *sfd = static_cast<grpc_endpoint_pair *>(f->fixture_data); - grpc_transport *transport; + grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data); + grpc_transport* transport; sp_client_setup cs; cs.client_args = client_args; cs.f = f; @@ -109,11 +109,11 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } -static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { +static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_endpoint_pair *sfd = static_cast<grpc_endpoint_pair *>(f->fixture_data); - grpc_transport *transport; + grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data); + grpc_transport* transport; GPR_ASSERT(!f->server); f->server = grpc_server_create(server_args, NULL); grpc_server_register_completion_queue(f->server, f->cq, NULL); @@ -125,7 +125,7 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } -static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { +static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) { gpr_free(f->fixture_data); } @@ -137,7 +137,7 @@ static grpc_end2end_test_config configs[] = { chttp2_tear_down_socketpair}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; g_fixture_slowdown_factor = 2; diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index 045a8b7f05..70daefd333 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -35,15 +35,15 @@ #include "test/core/util/test_config.h" typedef struct fullstack_secure_fixture_data { - char *localaddr; + char* localaddr; } fullstack_secure_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>( + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>( gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); @@ -56,19 +56,19 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( return f; } -static void process_auth_failure(void *state, grpc_auth_context *ctx, - const grpc_metadata *md, size_t md_count, +static void process_auth_failure(void* state, grpc_auth_context* ctx, + const grpc_metadata* md, size_t md_count, grpc_process_auth_metadata_done_cb cb, - void *user_data) { + void* user_data) { GPR_ASSERT(state == NULL); cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *client_args, - grpc_channel_credentials *creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_channel_credentials* creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); @@ -76,10 +76,10 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *server_args, - grpc_server_credentials *server_creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_server_credentials* server_creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -91,22 +91,22 @@ static void chttp2_init_server_secure_fullstack( grpc_server_start(f->server); } -void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } static void chttp2_init_client_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { - grpc_channel_credentials *ssl_creds = + grpc_end2end_test_fixture* f, grpc_channel_args* client_args) { + grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); 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 = + 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(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); { @@ -116,7 +116,7 @@ static void chttp2_init_client_simple_ssl_secure_fullstack( } } -static int fail_server_auth_check(grpc_channel_args *server_args) { +static int fail_server_auth_check(grpc_channel_args* server_args) { size_t i; if (server_args == NULL) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -129,10 +129,10 @@ static int fail_server_auth_check(grpc_channel_args *server_args) { } static void chttp2_init_server_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { + grpc_end2end_test_fixture* f, grpc_channel_args* server_args) { 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); if (fail_server_auth_check(server_args)) { grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL}; @@ -155,11 +155,11 @@ static grpc_end2end_test_config configs[] = { chttp2_tear_down_secure_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; - FILE *roots_file; + FILE* roots_file; size_t roots_size = strlen(test_root_cert); - char *roots_filename; + char* roots_filename; grpc_test_init(argc, argv); grpc_end2end_tests_pre_init(); diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index b9b68c8780..b3488a29e5 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -36,31 +36,31 @@ #include "test/core/util/test_config.h" typedef struct fullstack_secure_fixture_data { - grpc_end2end_proxy *proxy; + grpc_end2end_proxy* proxy; } fullstack_secure_fixture_data; -static grpc_server *create_proxy_server(const char *port, - grpc_channel_args *server_args) { - grpc_server *s = grpc_server_create(server_args, NULL); +static grpc_server* create_proxy_server(const char* port, + grpc_channel_args* server_args) { + grpc_server* s = grpc_server_create(server_args, NULL); 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); GPR_ASSERT(grpc_server_add_secure_http2_port(s, port, ssl_creds)); grpc_server_credentials_release(ssl_creds); return s; } -static grpc_channel *create_proxy_client(const char *target, - grpc_channel_args *client_args) { - grpc_channel *channel; - grpc_channel_credentials *ssl_creds = +static grpc_channel* create_proxy_client(const char* target, + grpc_channel_args* client_args) { + grpc_channel* channel; + grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); 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 = + 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(client_args, &ssl_name_override, 1); channel = grpc_secure_channel_create(ssl_creds, target, new_client_args, NULL); @@ -77,10 +77,10 @@ static const grpc_end2end_proxy_def proxy_def = {create_proxy_server, create_proxy_client}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>( + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>( gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); @@ -93,19 +93,19 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( return f; } -static void process_auth_failure(void *state, grpc_auth_context *ctx, - const grpc_metadata *md, size_t md_count, +static void process_auth_failure(void* state, grpc_auth_context* ctx, + const grpc_metadata* md, size_t md_count, grpc_process_auth_metadata_done_cb cb, - void *user_data) { + void* user_data) { GPR_ASSERT(state == NULL); cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *client_args, - grpc_channel_credentials *creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_channel_credentials* creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); f->client = grpc_secure_channel_create( creds, grpc_end2end_proxy_get_client_target(ffd->proxy), client_args, NULL); @@ -114,10 +114,10 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *server_args, - grpc_server_credentials *server_creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_server_credentials* server_creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -129,22 +129,22 @@ static void chttp2_init_server_secure_fullstack( grpc_server_start(f->server); } -void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); grpc_end2end_proxy_destroy(ffd->proxy); gpr_free(ffd); } static void chttp2_init_client_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { - grpc_channel_credentials *ssl_creds = + grpc_end2end_test_fixture* f, grpc_channel_args* client_args) { + grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); 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 = + 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(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); { @@ -154,7 +154,7 @@ static void chttp2_init_client_simple_ssl_secure_fullstack( } } -static int fail_server_auth_check(grpc_channel_args *server_args) { +static int fail_server_auth_check(grpc_channel_args* server_args) { size_t i; if (server_args == NULL) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -167,10 +167,10 @@ static int fail_server_auth_check(grpc_channel_args *server_args) { } static void chttp2_init_server_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { + grpc_end2end_test_fixture* f, grpc_channel_args* server_args) { 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); if (fail_server_auth_check(server_args)) { grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL}; @@ -194,11 +194,11 @@ static grpc_end2end_test_config configs[] = { chttp2_tear_down_secure_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; - FILE *roots_file; + FILE* roots_file; size_t roots_size = strlen(test_root_cert); - char *roots_filename; + char* roots_filename; grpc_test_init(argc, argv); grpc_end2end_tests_pre_init(); diff --git a/test/core/end2end/fixtures/h2_uds.cc b/test/core/end2end/fixtures/h2_uds.cc index f9336b5edc..ba433df57b 100644 --- a/test/core/end2end/fixtures/h2_uds.cc +++ b/test/core/end2end/fixtures/h2_uds.cc @@ -40,15 +40,15 @@ #include "test/core/util/test_config.h" typedef struct fullstack_fixture_data { - char *localaddr; + char* localaddr; } fullstack_fixture_data; static int unique = 1; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; - fullstack_fixture_data *ffd = static_cast<fullstack_fixture_data *>( + fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>( gpr_malloc(sizeof(fullstack_fixture_data))); memset(&f, 0, sizeof(f)); @@ -62,17 +62,17 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( return f; } -void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); } -void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -82,23 +82,24 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { - fullstack_fixture_data *ffd = - static_cast<fullstack_fixture_data *>(f->fixture_data); +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { + fullstack_fixture_data* ffd = + static_cast<fullstack_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_uds", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/inproc.cc b/test/core/end2end/fixtures/inproc.cc index c075dc629f..5107ed2018 100644 --- a/test/core/end2end/fixtures/inproc.cc +++ b/test/core/end2end/fixtures/inproc.cc @@ -40,9 +40,9 @@ typedef struct inproc_fixture_data { } inproc_fixture_data; static grpc_end2end_test_fixture inproc_create_fixture( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; - inproc_fixture_data *ffd = static_cast<inproc_fixture_data *>( + inproc_fixture_data* ffd = static_cast<inproc_fixture_data*>( gpr_malloc(sizeof(inproc_fixture_data))); memset(&f, 0, sizeof(f)); @@ -53,14 +53,14 @@ static grpc_end2end_test_fixture inproc_create_fixture( return f; } -void inproc_init_client(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args) { +void inproc_init_client(grpc_end2end_test_fixture* f, + grpc_channel_args* client_args) { f->client = grpc_inproc_channel_create(f->server, client_args, NULL); GPR_ASSERT(f->client); } -void inproc_init_server(grpc_end2end_test_fixture *f, - grpc_channel_args *server_args) { +void inproc_init_server(grpc_end2end_test_fixture* f, + grpc_channel_args* server_args) { if (f->server) { grpc_server_destroy(f->server); } @@ -69,9 +69,8 @@ void inproc_init_server(grpc_end2end_test_fixture *f, grpc_server_start(f->server); } -void inproc_tear_down(grpc_end2end_test_fixture *f) { - inproc_fixture_data *ffd = - static_cast<inproc_fixture_data *>(f->fixture_data); +void inproc_tear_down(grpc_end2end_test_fixture* f) { + inproc_fixture_data* ffd = static_cast<inproc_fixture_data*>(f->fixture_data); gpr_free(ffd); } @@ -81,7 +80,7 @@ static grpc_end2end_test_config configs[] = { inproc_init_client, inproc_init_server, inproc_tear_down}, }; -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_init(argc, argv); diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index 6a2d75da09..01c9e13538 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -31,37 +31,37 @@ struct grpc_end2end_proxy { gpr_thd_id thd; - char *proxy_port; - char *server_port; - grpc_completion_queue *cq; - grpc_server *server; - grpc_channel *client; + char* proxy_port; + char* server_port; + grpc_completion_queue* cq; + grpc_server* server; + grpc_channel* client; int shutdown; /* requested call */ - grpc_call *new_call; + grpc_call* new_call; grpc_call_details new_call_details; grpc_metadata_array new_call_metadata; }; typedef struct { - void (*func)(void *arg, int success); - void *arg; + void (*func)(void* arg, int success); + void* arg; } closure; typedef struct { gpr_refcount refs; - grpc_end2end_proxy *proxy; + grpc_end2end_proxy* proxy; - grpc_call *c2p; - grpc_call *p2s; + grpc_call* c2p; + grpc_call* p2s; grpc_metadata_array c2p_initial_metadata; grpc_metadata_array p2s_initial_metadata; - grpc_byte_buffer *c2p_msg; - grpc_byte_buffer *p2s_msg; + grpc_byte_buffer* c2p_msg; + grpc_byte_buffer* p2s_msg; grpc_metadata_array p2s_trailing_metadata; grpc_status_code p2s_status; @@ -70,17 +70,17 @@ typedef struct { int c2p_server_cancelled; } proxy_call; -static void thread_main(void *arg); -static void request_call(grpc_end2end_proxy *proxy); +static void thread_main(void* arg); +static void request_call(grpc_end2end_proxy* proxy); -grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { +grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { gpr_thd_options opt = gpr_thd_options_default(); int proxy_port = grpc_pick_unused_port_or_die(); int server_port = grpc_pick_unused_port_or_die(); - grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)gpr_malloc(sizeof(*proxy)); + grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)gpr_malloc(sizeof(*proxy)); memset(proxy, 0, sizeof(*proxy)); gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port); @@ -105,20 +105,20 @@ grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def, return proxy; } -static closure *new_closure(void (*func)(void *arg, int success), void *arg) { - closure *cl = (closure *)gpr_malloc(sizeof(*cl)); +static closure* new_closure(void (*func)(void* arg, int success), void* arg) { + closure* cl = (closure*)gpr_malloc(sizeof(*cl)); cl->func = func; cl->arg = arg; return cl; } -static void shutdown_complete(void *arg, int success) { - grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)arg; +static void shutdown_complete(void* arg, int success) { + grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)arg; proxy->shutdown = 1; grpc_completion_queue_shutdown(proxy->cq); } -void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy) { +void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy) { grpc_server_shutdown_and_notify(proxy->server, proxy->cq, new_closure(shutdown_complete, proxy)); gpr_thd_join(proxy->thd); @@ -131,7 +131,7 @@ void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy) { gpr_free(proxy); } -static void unrefpc(proxy_call *pc, const char *reason) { +static void unrefpc(proxy_call* pc, const char* reason) { if (gpr_unref(&pc->refs)) { grpc_call_unref(pc->c2p); grpc_call_unref(pc->p2s); @@ -143,15 +143,15 @@ static void unrefpc(proxy_call *pc, const char *reason) { } } -static void refpc(proxy_call *pc, const char *reason) { gpr_ref(&pc->refs); } +static void refpc(proxy_call* pc, const char* reason) { gpr_ref(&pc->refs); } -static void on_c2p_sent_initial_metadata(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_c2p_sent_initial_metadata(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; unrefpc(pc, "on_c2p_sent_initial_metadata"); } -static void on_p2s_recv_initial_metadata(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_p2s_recv_initial_metadata(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; grpc_op op; grpc_call_error err; @@ -171,15 +171,15 @@ static void on_p2s_recv_initial_metadata(void *arg, int success) { unrefpc(pc, "on_p2s_recv_initial_metadata"); } -static void on_p2s_sent_initial_metadata(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_p2s_sent_initial_metadata(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; unrefpc(pc, "on_p2s_sent_initial_metadata"); } -static void on_c2p_recv_msg(void *arg, int success); +static void on_c2p_recv_msg(void* arg, int success); -static void on_p2s_sent_message(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_p2s_sent_message(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; grpc_op op; grpc_call_error err; @@ -198,13 +198,13 @@ static void on_p2s_sent_message(void *arg, int success) { unrefpc(pc, "on_p2s_sent_message"); } -static void on_p2s_sent_close(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_p2s_sent_close(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; unrefpc(pc, "on_p2s_sent_close"); } -static void on_c2p_recv_msg(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_c2p_recv_msg(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; grpc_op op; grpc_call_error err; @@ -236,10 +236,10 @@ static void on_c2p_recv_msg(void *arg, int success) { unrefpc(pc, "on_c2p_recv_msg"); } -static void on_p2s_recv_msg(void *arg, int success); +static void on_p2s_recv_msg(void* arg, int success); -static void on_c2p_sent_message(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_c2p_sent_message(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; grpc_op op; grpc_call_error err; @@ -258,8 +258,8 @@ static void on_c2p_sent_message(void *arg, int success) { unrefpc(pc, "on_c2p_sent_message"); } -static void on_p2s_recv_msg(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_p2s_recv_msg(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; grpc_op op; grpc_call_error err; @@ -278,13 +278,13 @@ static void on_p2s_recv_msg(void *arg, int success) { unrefpc(pc, "on_p2s_recv_msg"); } -static void on_c2p_sent_status(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_c2p_sent_status(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; unrefpc(pc, "on_c2p_sent_status"); } -static void on_p2s_status(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_p2s_status(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; grpc_op op; grpc_call_error err; @@ -308,19 +308,19 @@ static void on_p2s_status(void *arg, int success) { unrefpc(pc, "on_p2s_status"); } -static void on_c2p_closed(void *arg, int success) { - proxy_call *pc = (proxy_call *)arg; +static void on_c2p_closed(void* arg, int success) { + proxy_call* pc = (proxy_call*)arg; unrefpc(pc, "on_c2p_closed"); } -static void on_new_call(void *arg, int success) { - grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)arg; +static void on_new_call(void* arg, int success) { + grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)arg; grpc_call_error err; if (success) { grpc_op op; memset(&op, 0, sizeof(op)); - proxy_call *pc = (proxy_call *)gpr_malloc(sizeof(*pc)); + proxy_call* pc = (proxy_call*)gpr_malloc(sizeof(*pc)); memset(pc, 0, sizeof(*pc)); pc->proxy = proxy; GPR_SWAP(grpc_metadata_array, pc->c2p_initial_metadata, @@ -398,7 +398,7 @@ static void on_new_call(void *arg, int success) { } } -static void request_call(grpc_end2end_proxy *proxy) { +static void request_call(grpc_end2end_proxy* proxy) { proxy->new_call = NULL; GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( proxy->server, &proxy->new_call, @@ -407,9 +407,9 @@ static void request_call(grpc_end2end_proxy *proxy) { proxy->cq, new_closure(on_new_call, proxy))); } -static void thread_main(void *arg) { - grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)arg; - closure *cl; +static void thread_main(void* arg) { + grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)arg; + closure* cl; for (;;) { grpc_event ev = grpc_completion_queue_next( proxy->cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL); @@ -420,7 +420,7 @@ static void thread_main(void *arg) { case GRPC_QUEUE_SHUTDOWN: return; case GRPC_OP_COMPLETE: - cl = (closure *)ev.tag; + cl = (closure*)ev.tag; cl->func(cl->arg, ev.success); gpr_free(cl); break; @@ -428,10 +428,10 @@ static void thread_main(void *arg) { } } -const char *grpc_end2end_proxy_get_client_target(grpc_end2end_proxy *proxy) { +const char* grpc_end2end_proxy_get_client_target(grpc_end2end_proxy* proxy) { return proxy->proxy_port; } -const char *grpc_end2end_proxy_get_server_port(grpc_end2end_proxy *proxy) { +const char* grpc_end2end_proxy_get_server_port(grpc_end2end_proxy* proxy) { return proxy->server_port; } diff --git a/test/core/end2end/fixtures/proxy.h b/test/core/end2end/fixtures/proxy.h index 89b965c903..18ad763ea7 100644 --- a/test/core/end2end/fixtures/proxy.h +++ b/test/core/end2end/fixtures/proxy.h @@ -26,18 +26,18 @@ typedef struct grpc_end2end_proxy grpc_end2end_proxy; typedef struct grpc_end2end_proxy_def { - grpc_server *(*create_server)(const char *port, - grpc_channel_args *server_args); - grpc_channel *(*create_client)(const char *target, - grpc_channel_args *client_args); + grpc_server* (*create_server)(const char* port, + grpc_channel_args* server_args); + grpc_channel* (*create_client)(const char* target, + grpc_channel_args* client_args); } grpc_end2end_proxy_def; -grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def, - grpc_channel_args *client_args, - grpc_channel_args *server_args); -void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy); +grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def, + grpc_channel_args* client_args, + grpc_channel_args* server_args); +void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy); -const char *grpc_end2end_proxy_get_client_target(grpc_end2end_proxy *proxy); -const char *grpc_end2end_proxy_get_server_port(grpc_end2end_proxy *proxy); +const char* grpc_end2end_proxy_get_client_target(grpc_end2end_proxy* proxy); +const char* grpc_end2end_proxy_get_server_port(grpc_end2end_proxy* proxy); #endif /* GRPC_TEST_CORE_END2END_FIXTURES_PROXY_H */ diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index 69d25533f1..69a5670d22 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -46,15 +46,15 @@ bool squelch = true; bool leak_check = true; -static void dont_log(gpr_log_func_args *args) {} +static void dont_log(gpr_log_func_args* args) {} //////////////////////////////////////////////////////////////////////////////// // global state static gpr_timespec g_now; -static grpc_server *g_server; -static grpc_channel *g_channel; -static grpc_resource_quota *g_resource_quota; +static grpc_server* g_server; +static grpc_channel* g_channel; +static grpc_resource_quota* g_resource_quota; extern "C" gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type); @@ -70,28 +70,28 @@ static gpr_timespec now_impl(gpr_clock_type clock_type) { // past the end (avoiding needing to check everywhere) typedef struct { - const uint8_t *cur; - const uint8_t *end; + const uint8_t* cur; + const uint8_t* end; } input_stream; -static uint8_t next_byte(input_stream *inp) { +static uint8_t next_byte(input_stream* inp) { if (inp->cur == inp->end) { return 0; } return *inp->cur++; } -static void end(input_stream *inp) { inp->cur = inp->end; } +static void end(input_stream* inp) { inp->cur = inp->end; } -static char *read_string(input_stream *inp, bool *special) { - char *str = NULL; +static char* read_string(input_stream* inp, bool* special) { + char* str = NULL; size_t cap = 0; size_t sz = 0; char c; do { if (cap == sz) { cap = GPR_MAX(3 * cap / 2, cap + 8); - str = static_cast<char *>(gpr_realloc(str, cap)); + str = static_cast<char*>(gpr_realloc(str, cap)); } c = (char)next_byte(inp); str[sz++] = c; @@ -105,8 +105,8 @@ static char *read_string(input_stream *inp, bool *special) { return str; } -static void read_buffer(input_stream *inp, char **buffer, size_t *length, - bool *special) { +static void read_buffer(input_stream* inp, char** buffer, size_t* length, + bool* special) { *length = next_byte(inp); if (*length == 255) { if (special != NULL) *special = true; @@ -114,7 +114,7 @@ static void read_buffer(input_stream *inp, char **buffer, size_t *length, } else { if (special != NULL) *special = false; } - *buffer = static_cast<char *>(gpr_malloc(*length)); + *buffer = static_cast<char*>(gpr_malloc(*length)); for (size_t i = 0; i < *length; i++) { (*buffer)[i] = (char)next_byte(inp); } @@ -126,16 +126,16 @@ static grpc_slice maybe_intern(grpc_slice s, bool intern) { return r; } -static grpc_slice read_string_like_slice(input_stream *inp) { +static grpc_slice read_string_like_slice(input_stream* inp) { bool special; - char *s = read_string(inp, &special); + char* s = read_string(inp, &special); grpc_slice r = maybe_intern(grpc_slice_from_copied_string(s), special); gpr_free(s); return r; } -static grpc_slice read_buffer_like_slice(input_stream *inp) { - char *buffer; +static grpc_slice read_buffer_like_slice(input_stream* inp) { + char* buffer; size_t length; bool special; read_buffer(inp, &buffer, &length, &special); @@ -145,7 +145,7 @@ static grpc_slice read_buffer_like_slice(input_stream *inp) { return r; } -static uint32_t read_uint22(input_stream *inp) { +static uint32_t read_uint22(input_stream* inp) { uint8_t b = next_byte(inp); uint32_t x = b & 0x7f; if (b & 0x80) { @@ -160,7 +160,7 @@ static uint32_t read_uint22(input_stream *inp) { return x; } -static uint32_t read_uint32(input_stream *inp) { +static uint32_t read_uint32(input_stream* inp) { uint8_t b = next_byte(inp); uint32_t x = b & 0x7f; if (b & 0x80) { @@ -184,19 +184,19 @@ static uint32_t read_uint32(input_stream *inp) { return x; } -static grpc_byte_buffer *read_message(input_stream *inp) { +static grpc_byte_buffer* read_message(input_stream* inp) { grpc_slice slice = grpc_slice_malloc(read_uint22(inp)); memset(GRPC_SLICE_START_PTR(slice), 0, GRPC_SLICE_LENGTH(slice)); - grpc_byte_buffer *out = grpc_raw_byte_buffer_create(&slice, 1); + grpc_byte_buffer* out = grpc_raw_byte_buffer_create(&slice, 1); grpc_slice_unref(slice); return out; } -static int read_int(input_stream *inp) { return (int)read_uint32(inp); } +static int read_int(input_stream* inp) { return (int)read_uint32(inp); } -static grpc_channel_args *read_args(input_stream *inp) { +static grpc_channel_args* read_args(input_stream* inp) { size_t n = next_byte(inp); - grpc_arg *args = static_cast<grpc_arg *>(gpr_malloc(sizeof(*args) * n)); + grpc_arg* args = static_cast<grpc_arg*>(gpr_malloc(sizeof(*args) * n)); for (size_t i = 0; i < n; i++) { switch (next_byte(inp)) { case 1: @@ -222,8 +222,8 @@ static grpc_channel_args *read_args(input_stream *inp) { break; } } - grpc_channel_args *a = - static_cast<grpc_channel_args *>(gpr_malloc(sizeof(*a))); + grpc_channel_args* a = + static_cast<grpc_channel_args*>(gpr_malloc(sizeof(*a))); a->args = args; a->num_args = n; return a; @@ -231,21 +231,21 @@ static grpc_channel_args *read_args(input_stream *inp) { typedef struct cred_artifact_ctx { int num_release; - char *release[3]; + char* release[3]; } cred_artifact_ctx; #define CRED_ARTIFACT_CTX_INIT \ { \ 0, { 0 } \ } -static void cred_artifact_ctx_finish(cred_artifact_ctx *ctx) { +static void cred_artifact_ctx_finish(cred_artifact_ctx* ctx) { for (int i = 0; i < ctx->num_release; i++) { gpr_free(ctx->release[i]); } } -static const char *read_cred_artifact(cred_artifact_ctx *ctx, input_stream *inp, - const char **builtins, +static const char* read_cred_artifact(cred_artifact_ctx* ctx, input_stream* inp, + const char** builtins, size_t num_builtins) { uint8_t b = next_byte(inp); if (b == 0) return NULL; @@ -257,28 +257,28 @@ static const char *read_cred_artifact(cred_artifact_ctx *ctx, input_stream *inp, return builtins[b - 1]; } -static grpc_channel_credentials *read_ssl_channel_creds(input_stream *inp) { +static grpc_channel_credentials* read_ssl_channel_creds(input_stream* inp) { cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT; - static const char *builtin_root_certs[] = {test_root_cert}; - static const char *builtin_private_keys[] = { + static const char* builtin_root_certs[] = {test_root_cert}; + static const char* builtin_private_keys[] = { test_server1_key, test_self_signed_client_key, test_signed_client_key}; - static const char *builtin_cert_chains[] = { + static const char* builtin_cert_chains[] = { test_server1_cert, test_self_signed_client_cert, test_signed_client_cert}; - const char *root_certs = read_cred_artifact( + const char* root_certs = read_cred_artifact( &ctx, inp, builtin_root_certs, GPR_ARRAY_SIZE(builtin_root_certs)); - const char *private_key = read_cred_artifact( + const char* private_key = read_cred_artifact( &ctx, inp, builtin_private_keys, GPR_ARRAY_SIZE(builtin_private_keys)); - const char *certs = read_cred_artifact(&ctx, inp, builtin_cert_chains, + const char* certs = read_cred_artifact(&ctx, inp, builtin_cert_chains, GPR_ARRAY_SIZE(builtin_cert_chains)); grpc_ssl_pem_key_cert_pair key_cert_pair = {private_key, certs}; - grpc_channel_credentials *creds = grpc_ssl_credentials_create( + grpc_channel_credentials* creds = grpc_ssl_credentials_create( root_certs, private_key != NULL && certs != NULL ? &key_cert_pair : NULL, NULL); cred_artifact_ctx_finish(&ctx); return creds; } -static grpc_call_credentials *read_call_creds(input_stream *inp) { +static grpc_call_credentials* read_call_creds(input_stream* inp) { switch (next_byte(inp)) { default: end(inp); @@ -286,10 +286,10 @@ static grpc_call_credentials *read_call_creds(input_stream *inp) { case 0: return NULL; case 1: { - grpc_call_credentials *c1 = read_call_creds(inp); - grpc_call_credentials *c2 = read_call_creds(inp); + grpc_call_credentials* c1 = read_call_creds(inp); + grpc_call_credentials* c2 = read_call_creds(inp); if (c1 != NULL && c2 != NULL) { - grpc_call_credentials *out = + grpc_call_credentials* out = grpc_composite_call_credentials_create(c1, c2, NULL); grpc_call_credentials_release(c1); grpc_call_credentials_release(c2); @@ -305,18 +305,19 @@ static grpc_call_credentials *read_call_creds(input_stream *inp) { } case 2: { cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT; - const char *access_token = read_cred_artifact(&ctx, inp, NULL, 0); - grpc_call_credentials *out = - access_token == NULL ? NULL : grpc_access_token_credentials_create( - access_token, NULL); + const char* access_token = read_cred_artifact(&ctx, inp, NULL, 0); + grpc_call_credentials* out = + access_token == NULL + ? NULL + : grpc_access_token_credentials_create(access_token, NULL); cred_artifact_ctx_finish(&ctx); return out; } case 3: { cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT; - const char *auth_token = read_cred_artifact(&ctx, inp, NULL, 0); - const char *auth_selector = read_cred_artifact(&ctx, inp, NULL, 0); - grpc_call_credentials *out = auth_token == NULL || auth_selector == NULL + const char* auth_token = read_cred_artifact(&ctx, inp, NULL, 0); + const char* auth_selector = read_cred_artifact(&ctx, inp, NULL, 0); + grpc_call_credentials* out = auth_token == NULL || auth_selector == NULL ? NULL : grpc_google_iam_credentials_create( auth_token, auth_selector, NULL); @@ -327,16 +328,16 @@ static grpc_call_credentials *read_call_creds(input_stream *inp) { } } -static grpc_channel_credentials *read_channel_creds(input_stream *inp) { +static grpc_channel_credentials* read_channel_creds(input_stream* inp) { switch (next_byte(inp)) { case 0: return read_ssl_channel_creds(inp); break; case 1: { - grpc_channel_credentials *c1 = read_channel_creds(inp); - grpc_call_credentials *c2 = read_call_creds(inp); + grpc_channel_credentials* c1 = read_channel_creds(inp); + grpc_call_credentials* c2 = read_call_creds(inp); if (c1 != NULL && c2 != NULL) { - grpc_channel_credentials *out = + grpc_channel_credentials* out = grpc_composite_channel_credentials_create(c1, c2, NULL); grpc_channel_credentials_release(c1); grpc_call_credentials_release(c2); @@ -359,34 +360,34 @@ static grpc_channel_credentials *read_channel_creds(input_stream *inp) { } } -static bool is_eof(input_stream *inp) { return inp->cur == inp->end; } +static bool is_eof(input_stream* inp) { return inp->cur == inp->end; } //////////////////////////////////////////////////////////////////////////////// // dns resolution typedef struct addr_req { grpc_timer timer; - char *addr; - grpc_closure *on_done; - grpc_resolved_addresses **addrs; - grpc_lb_addresses **lb_addrs; + char* addr; + grpc_closure* on_done; + grpc_resolved_addresses** addrs; + grpc_lb_addresses** lb_addrs; } addr_req; -static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - addr_req *r = static_cast<addr_req *>(arg); +static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + addr_req* r = static_cast<addr_req*>(arg); if (error == GRPC_ERROR_NONE && 0 == strcmp(r->addr, "server")) { if (r->addrs != NULL) { - grpc_resolved_addresses *addrs = - static_cast<grpc_resolved_addresses *>(gpr_malloc(sizeof(*addrs))); + grpc_resolved_addresses* addrs = + static_cast<grpc_resolved_addresses*>(gpr_malloc(sizeof(*addrs))); addrs->naddrs = 1; - addrs->addrs = static_cast<grpc_resolved_address *>( + addrs->addrs = static_cast<grpc_resolved_address*>( gpr_malloc(sizeof(*addrs->addrs))); addrs->addrs[0].len = 0; *r->addrs = addrs; } else if (r->lb_addrs != NULL) { - grpc_lb_addresses *lb_addrs = grpc_lb_addresses_create(1, NULL); + grpc_lb_addresses* lb_addrs = grpc_lb_addresses_create(1, NULL); grpc_lb_addresses_set_address(lb_addrs, 0, NULL, 0, false, NULL, NULL); *r->lb_addrs = lb_addrs; } @@ -401,12 +402,12 @@ static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg, gpr_free(r); } -void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, - const char *default_port, - grpc_pollset_set *interested_parties, - grpc_closure *on_done, - grpc_resolved_addresses **addresses) { - addr_req *r = static_cast<addr_req *>(gpr_malloc(sizeof(*r))); +void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr, + const char* default_port, + grpc_pollset_set* interested_parties, + grpc_closure* on_done, + grpc_resolved_addresses** addresses) { + addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r))); r->addr = gpr_strdup(addr); r->on_done = on_done; r->addrs = addresses; @@ -416,12 +417,12 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx)); } -grpc_ares_request *my_dns_lookup_ares( - grpc_exec_ctx *exec_ctx, const char *dns_server, const char *addr, - const char *default_port, grpc_pollset_set *interested_parties, - grpc_closure *on_done, grpc_lb_addresses **lb_addrs, bool check_grpclb, - char **service_config_json) { - addr_req *r = static_cast<addr_req *>(gpr_malloc(sizeof(*r))); +grpc_ares_request* my_dns_lookup_ares( + grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr, + const char* default_port, grpc_pollset_set* interested_parties, + grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb, + char** service_config_json) { + addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r))); r->addr = gpr_strdup(addr); r->on_done = on_done; r->addrs = NULL; @@ -437,32 +438,32 @@ grpc_ares_request *my_dns_lookup_ares( // defined in tcp_client_posix.c extern "C" void (*grpc_tcp_client_connect_impl)( - grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, - grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, - const grpc_resolved_address *addr, grpc_millis deadline); + grpc_exec_ctx* exec_ctx, grpc_closure* closure, grpc_endpoint** ep, + grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args, + const grpc_resolved_address* addr, grpc_millis deadline); -static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, - grpc_endpoint **ep, gpr_timespec deadline); +static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure, + grpc_endpoint** ep, gpr_timespec deadline); typedef struct { grpc_timer timer; - grpc_closure *closure; - grpc_endpoint **ep; + grpc_closure* closure; + grpc_endpoint** ep; gpr_timespec deadline; } future_connect; -static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - future_connect *fc = static_cast<future_connect *>(arg); +static void do_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + future_connect* fc = static_cast<future_connect*>(arg); if (error != GRPC_ERROR_NONE) { *fc->ep = NULL; GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_REF(error)); } else if (g_server != NULL) { - grpc_endpoint *client; - grpc_endpoint *server; + grpc_endpoint* client; + grpc_endpoint* server; grpc_passthru_endpoint_create(&client, &server, g_resource_quota, NULL); *fc->ep = client; - grpc_transport *transport = + grpc_transport* transport = grpc_create_chttp2_transport(exec_ctx, NULL, server, 0); grpc_server_setup_transport(exec_ctx, g_server, transport, NULL, NULL); grpc_chttp2_transport_start_reading(exec_ctx, transport, NULL); @@ -474,16 +475,17 @@ static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { gpr_free(fc); } -static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, - grpc_endpoint **ep, gpr_timespec deadline) { +static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure, + grpc_endpoint** ep, gpr_timespec deadline) { if (gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) < 0) { *ep = NULL; - GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Connect deadline exceeded")); + GRPC_CLOSURE_SCHED( + exec_ctx, closure, + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connect deadline exceeded")); return; } - future_connect *fc = static_cast<future_connect *>(gpr_malloc(sizeof(*fc))); + future_connect* fc = static_cast<future_connect*>(gpr_malloc(sizeof(*fc))); fc->closure = closure; fc->ep = ep; fc->deadline = deadline; @@ -492,11 +494,11 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx)); } -static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx, - grpc_closure *closure, grpc_endpoint **ep, - grpc_pollset_set *interested_parties, - const grpc_channel_args *channel_args, - const grpc_resolved_address *addr, +static void my_tcp_client_connect(grpc_exec_ctx* exec_ctx, + grpc_closure* closure, grpc_endpoint** ep, + grpc_pollset_set* interested_parties, + const grpc_channel_args* channel_args, + const grpc_resolved_address* addr, grpc_millis deadline) { sched_connect(exec_ctx, closure, ep, grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC)); @@ -506,41 +508,41 @@ static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx, // test driver typedef struct validator { - void (*validate)(void *arg, bool success); - void *arg; + void (*validate)(void* arg, bool success); + void* arg; } validator; -static validator *create_validator(void (*validate)(void *arg, bool success), - void *arg) { - validator *v = static_cast<validator *>(gpr_malloc(sizeof(*v))); +static validator* create_validator(void (*validate)(void* arg, bool success), + void* arg) { + validator* v = static_cast<validator*>(gpr_malloc(sizeof(*v))); v->validate = validate; v->arg = arg; return v; } -static void assert_success_and_decrement(void *counter, bool success) { +static void assert_success_and_decrement(void* counter, bool success) { GPR_ASSERT(success); - --*(int *)counter; + --*(int*)counter; } -static void decrement(void *counter, bool success) { --*(int *)counter; } +static void decrement(void* counter, bool success) { --*(int*)counter; } typedef struct connectivity_watch { - int *counter; + int* counter; gpr_timespec deadline; } connectivity_watch; -static connectivity_watch *make_connectivity_watch(gpr_timespec s, - int *counter) { - connectivity_watch *o = - static_cast<connectivity_watch *>(gpr_malloc(sizeof(*o))); +static connectivity_watch* make_connectivity_watch(gpr_timespec s, + int* counter) { + connectivity_watch* o = + static_cast<connectivity_watch*>(gpr_malloc(sizeof(*o))); o->deadline = s; o->counter = counter; return o; } -static void validate_connectivity_watch(void *p, bool success) { - connectivity_watch *w = static_cast<connectivity_watch *>(p); +static void validate_connectivity_watch(void* p, bool success) { + connectivity_watch* w = static_cast<connectivity_watch*>(p); if (!success) { GPR_ASSERT(gpr_time_cmp(gpr_now(w->deadline.clock_type), w->deadline) >= 0); } @@ -548,7 +550,7 @@ static void validate_connectivity_watch(void *p, bool success) { gpr_free(w); } -static void free_non_null(void *p) { +static void free_non_null(void* p) { GPR_ASSERT(p != NULL); gpr_free(p); } @@ -559,8 +561,8 @@ typedef enum { ROOT, CLIENT, SERVER, PENDING_SERVER } call_state_type; typedef struct call_state { call_state_type type; - grpc_call *call; - grpc_byte_buffer *recv_message; + grpc_call* call; + grpc_byte_buffer* recv_message; grpc_status_code status; grpc_metadata_array recv_initial_metadata; grpc_metadata_array recv_trailing_metadata; @@ -568,7 +570,7 @@ typedef struct call_state { int cancelled; int pending_ops; grpc_call_details call_details; - grpc_byte_buffer *send_message; + grpc_byte_buffer* send_message; // starts at 0, individual flags from DONE_FLAG_xxx are set // as different operations are completed uint64_t done_flags; @@ -576,21 +578,21 @@ typedef struct call_state { // array of pointers to free later size_t num_to_free; size_t cap_to_free; - void **to_free; + void** to_free; // array of slices to unref size_t num_slices_to_unref; size_t cap_slices_to_unref; - grpc_slice **slices_to_unref; + grpc_slice** slices_to_unref; - struct call_state *next; - struct call_state *prev; + struct call_state* next; + struct call_state* prev; } call_state; -static call_state *g_active_call; +static call_state* g_active_call; -static call_state *new_call(call_state *sibling, call_state_type type) { - call_state *c = static_cast<call_state *>(gpr_malloc(sizeof(*c))); +static call_state* new_call(call_state* sibling, call_state_type type) { + call_state* c = static_cast<call_state*>(gpr_malloc(sizeof(*c))); memset(c, 0, sizeof(*c)); if (sibling != NULL) { c->next = sibling; @@ -603,8 +605,8 @@ static call_state *new_call(call_state *sibling, call_state_type type) { return c; } -static call_state *maybe_delete_call_state(call_state *call) { - call_state *next = call->next; +static call_state* maybe_delete_call_state(call_state* call) { + call_state* next = call->next; if (call->call != NULL) return next; if (call->pending_ops != 0) return next; @@ -636,34 +638,34 @@ static call_state *maybe_delete_call_state(call_state *call) { return next; } -static void add_to_free(call_state *call, void *p) { +static void add_to_free(call_state* call, void* p) { if (call->num_to_free == call->cap_to_free) { call->cap_to_free = GPR_MAX(8, 2 * call->cap_to_free); - call->to_free = static_cast<void **>( + call->to_free = static_cast<void**>( gpr_realloc(call->to_free, sizeof(*call->to_free) * call->cap_to_free)); } call->to_free[call->num_to_free++] = p; } -static grpc_slice *add_slice_to_unref(call_state *call, grpc_slice s) { +static grpc_slice* add_slice_to_unref(call_state* call, grpc_slice s) { if (call->num_slices_to_unref == call->cap_slices_to_unref) { call->cap_slices_to_unref = GPR_MAX(8, 2 * call->cap_slices_to_unref); - call->slices_to_unref = static_cast<grpc_slice **>(gpr_realloc( + call->slices_to_unref = static_cast<grpc_slice**>(gpr_realloc( call->slices_to_unref, sizeof(*call->slices_to_unref) * call->cap_slices_to_unref)); } call->slices_to_unref[call->num_slices_to_unref] = - static_cast<grpc_slice *>(gpr_malloc(sizeof(grpc_slice))); + static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice))); *call->slices_to_unref[call->num_slices_to_unref++] = s; return call->slices_to_unref[call->num_slices_to_unref - 1]; } -static void read_metadata(input_stream *inp, size_t *count, - grpc_metadata **metadata, call_state *cs) { +static void read_metadata(input_stream* inp, size_t* count, + grpc_metadata** metadata, call_state* cs) { *count = next_byte(inp); if (*count) { *metadata = - static_cast<grpc_metadata *>(gpr_malloc(*count * sizeof(**metadata))); + static_cast<grpc_metadata*>(gpr_malloc(*count * sizeof(**metadata))); memset(*metadata, 0, *count * sizeof(**metadata)); for (size_t i = 0; i < *count; i++) { (*metadata)[i].key = read_string_like_slice(inp); @@ -673,19 +675,19 @@ static void read_metadata(input_stream *inp, size_t *count, add_slice_to_unref(cs, (*metadata)[i].value); } } else { - *metadata = static_cast<grpc_metadata *>(gpr_malloc(1)); + *metadata = static_cast<grpc_metadata*>(gpr_malloc(1)); } add_to_free(cs, *metadata); } -static call_state *destroy_call(call_state *call) { +static call_state* destroy_call(call_state* call) { grpc_call_unref(call->call); call->call = NULL; return maybe_delete_call_state(call); } -static void finished_request_call(void *csp, bool success) { - call_state *cs = static_cast<call_state *>(csp); +static void finished_request_call(void* csp, bool success) { + call_state* cs = static_cast<call_state*>(csp); GPR_ASSERT(cs->pending_ops > 0); --cs->pending_ops; if (success) { @@ -697,12 +699,12 @@ static void finished_request_call(void *csp, bool success) { } typedef struct { - call_state *cs; + call_state* cs; uint8_t has_ops; } batch_info; -static void finished_batch(void *p, bool success) { - batch_info *bi = static_cast<batch_info *>(p); +static void finished_batch(void* p, bool success) { + batch_info* bi = static_cast<batch_info*>(p); --bi->cs->pending_ops; if ((bi->has_ops & (1u << GRPC_OP_RECV_MESSAGE)) && (bi->cs->done_flags & DONE_FLAG_CALL_CLOSED)) { @@ -725,17 +727,17 @@ static void finished_batch(void *p, bool success) { gpr_free(bi); } -static validator *make_finished_batch_validator(call_state *cs, +static validator* make_finished_batch_validator(call_state* cs, uint8_t has_ops) { - batch_info *bi = static_cast<batch_info *>(gpr_malloc(sizeof(*bi))); + batch_info* bi = static_cast<batch_info*>(gpr_malloc(sizeof(*bi))); bi->cs = cs; bi->has_ops = has_ops; return create_validator(finished_batch, bi); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_test_only_set_slice_hash_seed(0); - char *grpc_trace_fuzzer = gpr_getenv("GRPC_TRACE_FUZZER"); + char* grpc_trace_fuzzer = gpr_getenv("GRPC_TRACE_FUZZER"); if (squelch && grpc_trace_fuzzer == NULL) gpr_set_log_function(dont_log); gpr_free(grpc_trace_fuzzer); input_stream inp = {data, data + size}; @@ -762,7 +764,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { g_active_call = new_call(NULL, ROOT); g_resource_quota = grpc_resource_quota_create("api_fuzzer"); - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); while (!is_eof(&inp) || g_channel != NULL || g_server != NULL || pending_channel_watches > 0 || pending_pings > 0 || @@ -775,8 +777,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (g_server != NULL) { if (!server_shutdown) { grpc_server_shutdown_and_notify( - g_server, cq, create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, + create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); server_shutdown = true; pending_server_shutdowns++; } else if (pending_server_shutdowns == 0) { @@ -784,7 +787,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { g_server = NULL; } } - call_state *s = g_active_call; + call_state* s = g_active_call; do { if (s->type != PENDING_SERVER && s->call != NULL) { s = destroy_call(s); @@ -809,7 +812,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); switch (ev.type) { case GRPC_OP_COMPLETE: { - validator *v = static_cast<validator *>(ev.tag); + validator* v = static_cast<validator*>(ev.tag); v->validate(v->arg, ev.success); gpr_free(v); break; @@ -831,10 +834,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { // create an insecure channel case 2: { if (g_channel == NULL) { - char *target = read_string(&inp, NULL); - char *target_uri; + char* target = read_string(&inp, NULL); + char* target_uri; gpr_asprintf(&target_uri, "dns:%s", target); - grpc_channel_args *args = read_args(&inp); + grpc_channel_args* args = read_args(&inp); g_channel = grpc_insecure_channel_create(target_uri, args, NULL); GPR_ASSERT(g_channel != NULL); { @@ -862,7 +865,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { // bring up a server case 4: { if (g_server == NULL) { - grpc_channel_args *args = read_args(&inp); + grpc_channel_args* args = read_args(&inp); g_server = grpc_server_create(args, NULL); GPR_ASSERT(g_server != NULL); { @@ -883,8 +886,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case 5: { if (g_server != NULL) { grpc_server_shutdown_and_notify( - g_server, cq, create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, + create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); pending_server_shutdowns++; server_shutdown = true; } else { @@ -951,7 +955,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case 10: { bool ok = true; if (g_channel == NULL) ok = false; - grpc_call *parent_call = NULL; + grpc_call* parent_call = NULL; if (g_active_call->type != ROOT) { if (g_active_call->call == NULL || g_active_call->type == CLIENT) { end(&inp); @@ -970,7 +974,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { gpr_time_from_micros(read_uint32(&inp), GPR_TIMESPAN)); if (ok) { - call_state *cs = new_call(g_active_call, CLIENT); + call_state* cs = new_call(g_active_call, CLIENT); cs->call = grpc_channel_create_call(g_channel, parent_call, propagation_mask, cq, method, &host, deadline, NULL); @@ -998,12 +1002,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { end(&inp); break; } - grpc_op *ops = - static_cast<grpc_op *>(gpr_malloc(sizeof(grpc_op) * num_ops)); + grpc_op* ops = + static_cast<grpc_op*>(gpr_malloc(sizeof(grpc_op) * num_ops)); if (num_ops > 0) memset(ops, 0, sizeof(grpc_op) * num_ops); bool ok = true; size_t i; - grpc_op *op; + grpc_op* op; uint8_t has_ops = 0; for (i = 0; i < num_ops; i++) { op = &ops[i]; @@ -1078,7 +1082,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { op->flags = read_uint32(&inp); } if (ok) { - validator *v = make_finished_batch_validator(g_active_call, has_ops); + validator* v = make_finished_batch_validator(g_active_call, has_ops); g_active_call->pending_ops++; grpc_call_error error = grpc_call_start_batch(g_active_call->call, ops, num_ops, v, NULL); @@ -1137,14 +1141,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { } // enable a tracer case 17: { - char *tracer = read_string(&inp, NULL); + char* tracer = read_string(&inp, NULL); grpc_tracer_set_enabled(tracer, 1); gpr_free(tracer); break; } // disable a tracer case 18: { - char *tracer = read_string(&inp, NULL); + char* tracer = read_string(&inp, NULL); grpc_tracer_set_enabled(tracer, 0); gpr_free(tracer); break; @@ -1155,9 +1159,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { end(&inp); break; } - call_state *cs = new_call(g_active_call, PENDING_SERVER); + call_state* cs = new_call(g_active_call, PENDING_SERVER); cs->pending_ops++; - validator *v = create_validator(finished_request_call, cs); + validator* v = create_validator(finished_request_call, cs); grpc_call_error error = grpc_server_request_call(g_server, &cs->call, &cs->call_details, &cs->recv_initial_metadata, cq, cq, v); @@ -1186,11 +1190,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { // create a secure channel case 22: { if (g_channel == NULL) { - char *target = read_string(&inp, NULL); - char *target_uri; + char* target = read_string(&inp, NULL); + char* target_uri; gpr_asprintf(&target_uri, "dns:%s", target); - grpc_channel_args *args = read_args(&inp); - grpc_channel_credentials *creds = read_channel_creds(&inp); + grpc_channel_args* args = read_args(&inp); + grpc_channel_credentials* creds = read_channel_creds(&inp); g_channel = grpc_secure_channel_create(creds, target_uri, args, NULL); GPR_ASSERT(g_channel != NULL); { diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc index bea8ec88b9..d90ec40a27 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.cc +++ b/test/core/end2end/fuzzers/client_fuzzer.cc @@ -33,11 +33,11 @@ bool leak_check = true; static void discard_write(grpc_slice slice) {} -static void *tag(int n) { return (void *)(uintptr_t)n; } +static void* tag(int n) { return (void*)(uintptr_t)n; } -static void dont_log(gpr_log_func_args *args) {} +static void dont_log(gpr_log_func_args* args) {} -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_test_only_set_slice_hash_seed(0); struct grpc_memory_counters counters; if (squelch) gpr_set_log_function(dont_log); @@ -46,27 +46,27 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_executor_set_threading(&exec_ctx, false); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("client_fuzzer"); - grpc_endpoint *mock_endpoint = + grpc_endpoint* mock_endpoint = grpc_mock_endpoint_create(discard_write, resource_quota); grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); - grpc_transport *transport = + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_transport* transport = grpc_create_chttp2_transport(&exec_ctx, NULL, mock_endpoint, 1); grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); - grpc_channel *channel = grpc_channel_create( + grpc_channel* channel = grpc_channel_create( &exec_ctx, "test-target", NULL, GRPC_CLIENT_DIRECT_CHANNEL, transport); grpc_slice host = grpc_slice_from_static_string("localhost"); - grpc_call *call = grpc_channel_create_call( + grpc_call* call = grpc_channel_create_call( channel, NULL, 0, cq, grpc_slice_from_static_string("/foo"), &host, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_metadata_array initial_metadata_recv; grpc_metadata_array_init(&initial_metadata_recv); - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array_init(&trailing_metadata_recv); grpc_status_code status; @@ -74,7 +74,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_op ops[6]; memset(ops, 0, sizeof(ops)); - grpc_op *op = ops; + grpc_op* op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op->flags = 0; @@ -108,7 +108,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_mock_endpoint_put_read( &exec_ctx, mock_endpoint, - grpc_slice_from_copied_buffer((const char *)data, size)); + grpc_slice_from_copied_buffer((const char*)data, size)); grpc_event ev; while (1) { diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc index 36b16afc24..87bccc70cd 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.cc +++ b/test/core/end2end/fuzzers/server_fuzzer.cc @@ -30,12 +30,12 @@ bool leak_check = true; static void discard_write(grpc_slice slice) {} -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; } -static void dont_log(gpr_log_func_args *args) {} +static void dont_log(gpr_log_func_args* args) {} -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_test_only_set_slice_hash_seed(0); struct grpc_memory_counters counters; if (squelch) gpr_set_log_function(dont_log); @@ -44,28 +44,28 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_executor_set_threading(&exec_ctx, false); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("server_fuzzer"); - grpc_endpoint *mock_endpoint = + grpc_endpoint* mock_endpoint = grpc_mock_endpoint_create(discard_write, resource_quota); grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); grpc_mock_endpoint_put_read( &exec_ctx, mock_endpoint, - grpc_slice_from_copied_buffer((const char *)data, size)); + grpc_slice_from_copied_buffer((const char*)data, size)); - grpc_server *server = grpc_server_create(NULL, NULL); - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); + grpc_server* server = grpc_server_create(NULL, NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); grpc_server_register_completion_queue(server, cq, NULL); // TODO(ctiller): add registered methods (one for POST, one for PUT) // void *registered_method = // grpc_server_register_method(server, "/reg", NULL, 0); grpc_server_start(server); - grpc_transport *transport = + grpc_transport* transport = grpc_create_chttp2_transport(&exec_ctx, NULL, mock_endpoint, 0); grpc_server_setup_transport(&exec_ctx, server, transport, NULL, NULL); grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); - grpc_call *call1 = NULL; + grpc_call* call1 = NULL; grpc_call_details call_details1; grpc_metadata_array request_metadata1; grpc_call_details_init(&call_details1); diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc index c0d7fb81b5..12a966d05a 100644 --- a/test/core/end2end/goaway_server_test.cc +++ b/test/core/end2end/goaway_server_test.cc @@ -35,21 +35,21 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static void *tag(intptr_t i) { return (void *)i; } +static void* tag(intptr_t i) { return (void*)i; } static gpr_mu g_mu; static int g_resolve_port = -1; -static void (*iomgr_resolve_address)(grpc_exec_ctx *exec_ctx, const char *addr, - const char *default_port, - grpc_pollset_set *interested_parties, - grpc_closure *on_done, - grpc_resolved_addresses **addresses); - -static grpc_ares_request *(*iomgr_dns_lookup_ares)( - grpc_exec_ctx *exec_ctx, const char *dns_server, const char *addr, - const char *default_port, grpc_pollset_set *interested_parties, - grpc_closure *on_done, grpc_lb_addresses **addresses, bool check_grpclb, - char **service_config_json); +static void (*iomgr_resolve_address)(grpc_exec_ctx* exec_ctx, const char* addr, + const char* default_port, + grpc_pollset_set* interested_parties, + grpc_closure* on_done, + grpc_resolved_addresses** addresses); + +static grpc_ares_request* (*iomgr_dns_lookup_ares)( + grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr, + const char* default_port, grpc_pollset_set* interested_parties, + grpc_closure* on_done, grpc_lb_addresses** addresses, bool check_grpclb, + char** service_config_json); static void set_resolve_port(int port) { gpr_mu_lock(&g_mu); @@ -57,30 +57,29 @@ static void set_resolve_port(int port) { gpr_mu_unlock(&g_mu); } -static void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, - const char *default_port, - grpc_pollset_set *interested_parties, - grpc_closure *on_done, - grpc_resolved_addresses **addrs) { +static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr, + const char* default_port, + grpc_pollset_set* interested_parties, + grpc_closure* on_done, + grpc_resolved_addresses** addrs) { if (0 != strcmp(addr, "test")) { iomgr_resolve_address(exec_ctx, addr, default_port, interested_parties, on_done, addrs); return; } - grpc_error *error = GRPC_ERROR_NONE; + grpc_error* error = GRPC_ERROR_NONE; gpr_mu_lock(&g_mu); if (g_resolve_port < 0) { gpr_mu_unlock(&g_mu); error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure"); } else { - *addrs = - static_cast<grpc_resolved_addresses *>(gpr_malloc(sizeof(**addrs))); + *addrs = static_cast<grpc_resolved_addresses*>(gpr_malloc(sizeof(**addrs))); (*addrs)->naddrs = 1; - (*addrs)->addrs = static_cast<grpc_resolved_address *>( + (*addrs)->addrs = static_cast<grpc_resolved_address*>( gpr_malloc(sizeof(*(*addrs)->addrs))); memset((*addrs)->addrs, 0, sizeof(*(*addrs)->addrs)); - struct sockaddr_in *sa = (struct sockaddr_in *)(*addrs)->addrs[0].addr; + struct sockaddr_in* sa = (struct sockaddr_in*)(*addrs)->addrs[0].addr; sa->sin_family = AF_INET; sa->sin_addr.s_addr = htonl(0x7f000001); sa->sin_port = htons((uint16_t)g_resolve_port); @@ -90,25 +89,25 @@ static void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, GRPC_CLOSURE_SCHED(exec_ctx, on_done, error); } -static grpc_ares_request *my_dns_lookup_ares( - grpc_exec_ctx *exec_ctx, const char *dns_server, const char *addr, - const char *default_port, grpc_pollset_set *interested_parties, - grpc_closure *on_done, grpc_lb_addresses **lb_addrs, bool check_grpclb, - char **service_config_json) { +static grpc_ares_request* my_dns_lookup_ares( + grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr, + const char* default_port, grpc_pollset_set* interested_parties, + grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb, + char** service_config_json) { if (0 != strcmp(addr, "test")) { return iomgr_dns_lookup_ares(exec_ctx, dns_server, addr, default_port, interested_parties, on_done, lb_addrs, check_grpclb, service_config_json); } - grpc_error *error = GRPC_ERROR_NONE; + grpc_error* error = GRPC_ERROR_NONE; gpr_mu_lock(&g_mu); if (g_resolve_port < 0) { gpr_mu_unlock(&g_mu); error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure"); } else { *lb_addrs = grpc_lb_addresses_create(1, NULL); - struct sockaddr_in *sa = static_cast<struct sockaddr_in *>( + struct sockaddr_in* sa = static_cast<struct sockaddr_in*>( gpr_zalloc(sizeof(struct sockaddr_in))); sa->sin_family = AF_INET; sa->sin_addr.s_addr = htonl(0x7f000001); @@ -122,11 +121,11 @@ static grpc_ares_request *my_dns_lookup_ares( return NULL; } -int main(int argc, char **argv) { - grpc_completion_queue *cq; - cq_verifier *cqv; +int main(int argc, char** argv) { + grpc_completion_queue* cq; + cq_verifier* cqv; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_test_init(argc, argv); @@ -165,22 +164,22 @@ int main(int argc, char **argv) { int port1 = grpc_pick_unused_port_or_die(); int port2 = grpc_pick_unused_port_or_die(); - char *addr; + char* addr; grpc_channel_args client_args; grpc_arg arg_array[1]; arg_array[0].type = GRPC_ARG_INTEGER; arg_array[0].key = - const_cast<char *>("grpc.testing.fixed_reconnect_backoff_ms"); + const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms"); arg_array[0].value.integer = 1000; client_args.args = arg_array; client_args.num_args = 1; /* create a channel that picks first amongst the servers */ - grpc_channel *chan = grpc_insecure_channel_create("test", &client_args, NULL); + grpc_channel* chan = grpc_insecure_channel_create("test", &client_args, NULL); /* and an initial call to them */ grpc_slice host = grpc_slice_from_static_string("127.0.0.1"); - grpc_call *call1 = + grpc_call* call1 = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, grpc_slice_from_static_string("/foo"), &host, grpc_timeout_seconds_to_deadline(20), NULL); @@ -210,7 +209,7 @@ int main(int argc, char **argv) { tag(0x102), NULL)); /* bring a server up on the first port */ - grpc_server *server1 = grpc_server_create(NULL, NULL); + grpc_server* server1 = grpc_server_create(NULL, NULL); gpr_asprintf(&addr, "127.0.0.1:%d", port1); grpc_server_add_insecure_http2_port(server1, addr); grpc_server_register_completion_queue(server1, cq, NULL); @@ -218,7 +217,7 @@ int main(int argc, char **argv) { grpc_server_start(server1); /* request a call to the server */ - grpc_call *server_call1; + grpc_call* server_call1; GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(server1, &server_call1, &request_details1, &request_metadata1, cq, cq, tag(0x301))); @@ -256,7 +255,7 @@ int main(int argc, char **argv) { cq_verify_empty(cqv); /* and a new call: should go through to server2 when we start it */ - grpc_call *call2 = + grpc_call* call2 = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, grpc_slice_from_static_string("/foo"), &host, grpc_timeout_seconds_to_deadline(20), NULL); @@ -287,7 +286,7 @@ int main(int argc, char **argv) { /* and bring up second server */ set_resolve_port(port2); - grpc_server *server2 = grpc_server_create(NULL, NULL); + grpc_server* server2 = grpc_server_create(NULL, NULL); gpr_asprintf(&addr, "127.0.0.1:%d", port2); grpc_server_add_insecure_http2_port(server2, addr); grpc_server_register_completion_queue(server2, cq, NULL); @@ -295,7 +294,7 @@ int main(int argc, char **argv) { grpc_server_start(server2); /* request a call to the server */ - grpc_call *server_call2; + grpc_call* server_call2; GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(server2, &server_call2, &request_details2, &request_metadata2, cq, cq, tag(0x401))); diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 515707af92..8994b63e5f 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -41,15 +41,15 @@ namespace grpc { namespace testing { typedef struct fullstack_secure_fixture_data { - char *localaddr; + char* localaddr; } fullstack_secure_fixture_data; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_channel_args* client_args, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>( + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>( gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); @@ -62,19 +62,19 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( return f; } -static void process_auth_failure(void *state, grpc_auth_context *ctx, - const grpc_metadata *md, size_t md_count, +static void process_auth_failure(void* state, grpc_auth_context* ctx, + const grpc_metadata* md, size_t md_count, grpc_process_auth_metadata_done_cb cb, - void *user_data) { + void* user_data) { GPR_ASSERT(state == NULL); cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *client_args, - grpc_channel_credentials *creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_channel_credentials* creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); @@ -82,10 +82,10 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture *f, grpc_channel_args *server_args, - grpc_server_credentials *server_creds) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); + grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_server_credentials* server_creds) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -97,14 +97,14 @@ static void chttp2_init_server_secure_fullstack( grpc_server_start(f->server); } -void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { - fullstack_secure_fixture_data *ffd = - static_cast<fullstack_secure_fixture_data *>(f->fixture_data); +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { + fullstack_secure_fixture_data* ffd = + static_cast<fullstack_secure_fixture_data*>(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } -static int fail_server_auth_check(grpc_channel_args *server_args) { +static int fail_server_auth_check(grpc_channel_args* server_args) { size_t i; if (server_args == NULL) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -124,7 +124,7 @@ static int fail_server_auth_check(grpc_channel_args *server_args) { grpc_end2end_test_fixture * f, grpc_channel_args * server_args) { \ 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_ex( \ test_root_cert, &pem_cert_key_pair, 1, REQUEST_TYPE, NULL); \ if (fail_server_auth_check(server_args)) { \ @@ -150,14 +150,14 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype; #define CLIENT_INIT(cert_type) \ static void CLIENT_INIT_NAME(cert_type)(grpc_end2end_test_fixture * f, \ grpc_channel_args * client_args) { \ - grpc_channel_credentials *ssl_creds = NULL; \ + grpc_channel_credentials* ssl_creds = NULL; \ grpc_ssl_pem_key_cert_pair self_signed_client_key_cert_pair = { \ test_self_signed_client_key, test_self_signed_client_cert}; \ grpc_ssl_pem_key_cert_pair signed_client_key_cert_pair = { \ test_signed_client_key, test_signed_client_cert}; \ grpc_ssl_pem_key_cert_pair bad_client_key_cert_pair = { \ test_self_signed_client_key, test_signed_client_cert}; \ - grpc_ssl_pem_key_cert_pair *key_cert_pair = NULL; \ + grpc_ssl_pem_key_cert_pair* key_cert_pair = NULL; \ switch (cert_type) { \ case SELF_SIGNED: \ key_cert_pair = &self_signed_client_key_cert_pair; \ @@ -175,9 +175,9 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype; grpc_ssl_credentials_create(test_root_cert, key_cert_pair, NULL); \ 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 = \ + 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(client_args, &ssl_name_override, 1); \ chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); \ { \ @@ -197,15 +197,17 @@ CLIENT_INIT(BAD_CERT_PAIR) typedef enum { SUCCESS, FAIL } test_result; -#define SSL_TEST(request_type, cert_type, result) \ - { \ - {TEST_NAME(request_type, cert_type, result), \ - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ - FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ - chttp2_create_fixture_secure_fullstack, CLIENT_INIT_NAME(cert_type), \ - SERVER_INIT_NAME(request_type), chttp2_tear_down_secure_fullstack}, \ - result \ +#define SSL_TEST(request_type, cert_type, result) \ + { \ + {TEST_NAME(request_type, cert_type, result), \ + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ + chttp2_create_fixture_secure_fullstack, \ + CLIENT_INIT_NAME(cert_type), \ + SERVER_INIT_NAME(request_type), \ + chttp2_tear_down_secure_fullstack}, \ + result \ } /* All test configurations */ @@ -254,7 +256,7 @@ static grpc_end2end_test_config_wrapper configs[] = { BAD_CERT_PAIR, FAIL), }; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static gpr_timespec n_seconds_time(int n) { return grpc_timeout_seconds_to_deadline(n); @@ -262,14 +264,14 @@ static gpr_timespec n_seconds_time(int n) { static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -280,13 +282,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -298,11 +300,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_fixture f, test_result expected_result) { - grpc_call *c; + grpc_call* c; gpr_timespec deadline = five_seconds_time(); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_call_error error; grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr:1234"); @@ -356,10 +358,10 @@ INSTANTIATE_TEST_CASE_P(H2SslCert, H2SslCertTest, ::testing::ValuesIn(configs)); } // namespace testing } // namespace grpc -int main(int argc, char **argv) { - FILE *roots_file; +int main(int argc, char** argv) { + FILE* roots_file; size_t roots_size = strlen(test_root_cert); - char *roots_filename; + char* roots_filename; grpc_test_init(argc, argv); /* Set the SSL roots env var. */ diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc index ac704a6bc0..c310a0e9ba 100644 --- a/test/core/end2end/invalid_call_argument_test.cc +++ b/test/core/end2end/invalid_call_argument_test.cc @@ -30,22 +30,22 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static void *tag(intptr_t i) { return (void *)i; } +static void* tag(intptr_t i) { return (void*)i; } struct test_state { int is_client; - grpc_channel *chan; - grpc_call *call; + grpc_channel* chan; + grpc_call* call; gpr_timespec deadline; - grpc_completion_queue *cq; - cq_verifier *cqv; + grpc_completion_queue* cq; + cq_verifier* cqv; grpc_op ops[6]; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_status_code status; grpc_slice details; - grpc_call *server_call; - grpc_server *server; + grpc_call* server_call; + grpc_server* server; grpc_metadata_array server_initial_metadata_recv; grpc_call_details call_details; }; @@ -54,8 +54,8 @@ static struct test_state g_state; static void prepare_test(int is_client) { int port = grpc_pick_unused_port_or_die(); - char *server_hostport; - grpc_op *op; + char* server_hostport; + grpc_op* op; g_state.is_client = is_client; grpc_metadata_array_init(&g_state.initial_metadata_recv); grpc_metadata_array_init(&g_state.trailing_metadata_recv); @@ -110,7 +110,7 @@ static void prepare_test(int is_client) { } static void cleanup_test() { - grpc_completion_queue *shutdown_cq; + grpc_completion_queue* shutdown_cq; grpc_call_unref(g_state.call); cq_verifier_destroy(g_state.cqv); grpc_channel_destroy(g_state.chan); @@ -151,7 +151,7 @@ static void test_non_null_reserved_on_start_batch() { static void test_non_null_reserved_on_op() { gpr_log(GPR_INFO, "test_non_null_reserved_on_op"); - grpc_op *op; + grpc_op* op; prepare_test(1); op = g_state.ops; @@ -169,7 +169,7 @@ static void test_non_null_reserved_on_op() { static void test_send_initial_metadata_more_than_once() { gpr_log(GPR_INFO, "test_send_initial_metadata_more_than_once"); - grpc_op *op; + grpc_op* op; prepare_test(1); op = g_state.ops; @@ -199,7 +199,7 @@ static void test_send_initial_metadata_more_than_once() { static void test_too_many_metadata() { gpr_log(GPR_INFO, "test_too_many_metadata"); - grpc_op *op; + grpc_op* op; prepare_test(1); op = g_state.ops; @@ -217,7 +217,7 @@ static void test_too_many_metadata() { static void test_send_null_message() { gpr_log(GPR_INFO, "test_send_null_message"); - grpc_op *op; + grpc_op* op; prepare_test(1); op = g_state.ops; @@ -240,10 +240,10 @@ static void test_send_null_message() { static void test_send_messages_at_the_same_time() { gpr_log(GPR_INFO, "test_send_messages_at_the_same_time"); - grpc_op *op; + grpc_op* op; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); prepare_test(1); op = g_state.ops; @@ -258,7 +258,7 @@ static void test_send_messages_at_the_same_time() { op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message.send_message = static_cast<grpc_byte_buffer *>(tag(2)); + op->data.send_message.send_message = static_cast<grpc_byte_buffer*>(tag(2)); op->flags = 0; op->reserved = NULL; op++; @@ -272,7 +272,7 @@ static void test_send_messages_at_the_same_time() { static void test_send_server_status_from_client() { gpr_log(GPR_INFO, "test_send_server_status_from_client"); - grpc_op *op; + grpc_op* op; prepare_test(1); op = g_state.ops; @@ -293,7 +293,7 @@ static void test_send_server_status_from_client() { static void test_receive_initial_metadata_twice_at_client() { gpr_log(GPR_INFO, "test_receive_initial_metadata_twice_at_client"); - grpc_op *op; + grpc_op* op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_INITIAL_METADATA; @@ -323,8 +323,8 @@ static void test_receive_initial_metadata_twice_at_client() { static void test_receive_message_with_invalid_flags() { gpr_log(GPR_INFO, "test_receive_message_with_invalid_flags"); - grpc_op *op; - grpc_byte_buffer *payload = NULL; + grpc_op* op; + grpc_byte_buffer* payload = NULL; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_MESSAGE; @@ -341,8 +341,8 @@ static void test_receive_message_with_invalid_flags() { static void test_receive_two_messages_at_the_same_time() { gpr_log(GPR_INFO, "test_receive_two_messages_at_the_same_time"); - grpc_op *op; - grpc_byte_buffer *payload = NULL; + grpc_op* op; + grpc_byte_buffer* payload = NULL; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_RECV_MESSAGE; @@ -364,7 +364,7 @@ static void test_receive_two_messages_at_the_same_time() { static void test_recv_close_on_server_from_client() { gpr_log(GPR_INFO, "test_recv_close_on_server_from_client"); - grpc_op *op; + grpc_op* op; prepare_test(1); op = g_state.ops; @@ -382,7 +382,7 @@ static void test_recv_close_on_server_from_client() { static void test_recv_status_on_client_twice() { gpr_log(GPR_INFO, "test_recv_status_on_client_twice"); - grpc_op *op; + grpc_op* op; prepare_test(1); op = g_state.ops; @@ -417,7 +417,7 @@ static void test_recv_status_on_client_twice() { static void test_send_close_from_client_on_server() { gpr_log(GPR_INFO, "test_send_close_from_client_on_server"); - grpc_op *op; + grpc_op* op; prepare_test(0); op = g_state.ops; @@ -434,7 +434,7 @@ static void test_send_close_from_client_on_server() { static void test_recv_status_on_client_from_server() { gpr_log(GPR_INFO, "test_recv_status_on_client_from_server"); - grpc_op *op; + grpc_op* op; prepare_test(0); op = g_state.ops; @@ -455,7 +455,7 @@ static void test_recv_status_on_client_from_server() { static void test_send_status_from_server_with_invalid_flags() { gpr_log(GPR_INFO, "test_send_status_from_server_with_invalid_flags"); - grpc_op *op; + grpc_op* op; prepare_test(0); op = g_state.ops; @@ -476,7 +476,7 @@ static void test_send_status_from_server_with_invalid_flags() { static void test_too_many_trailing_metadata() { gpr_log(GPR_INFO, "test_too_many_trailing_metadata"); - grpc_op *op; + grpc_op* op; prepare_test(0); op = g_state.ops; @@ -498,7 +498,7 @@ static void test_too_many_trailing_metadata() { static void test_send_server_status_twice() { gpr_log(GPR_INFO, "test_send_server_status_twice"); - grpc_op *op; + grpc_op* op; prepare_test(0); op = g_state.ops; @@ -526,7 +526,7 @@ static void test_send_server_status_twice() { static void test_recv_close_on_server_with_invalid_flags() { gpr_log(GPR_INFO, "test_recv_close_on_server_with_invalid_flags"); - grpc_op *op; + grpc_op* op; prepare_test(0); op = g_state.ops; @@ -544,7 +544,7 @@ static void test_recv_close_on_server_with_invalid_flags() { static void test_recv_close_on_server_twice() { gpr_log(GPR_INFO, "test_recv_close_on_server_twice"); - grpc_op *op; + grpc_op* op; prepare_test(0); op = g_state.ops; @@ -571,7 +571,7 @@ static void test_invalid_initial_metadata_reserved_key() { metadata.key = grpc_slice_from_static_string(":start_with_colon"); metadata.value = grpc_slice_from_static_string("value"); - grpc_op *op; + grpc_op* op; prepare_test(1); op = g_state.ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -586,7 +586,7 @@ static void test_invalid_initial_metadata_reserved_key() { cleanup_test(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_invalid_initial_metadata_reserved_key(); diff --git a/test/core/end2end/multiple_server_queues_test.cc b/test/core/end2end/multiple_server_queues_test.cc index f231c62dd0..8036ca54b2 100644 --- a/test/core/end2end/multiple_server_queues_test.cc +++ b/test/core/end2end/multiple_server_queues_test.cc @@ -19,13 +19,13 @@ #include <grpc/grpc.h> #include "test/core/util/test_config.h" -int main(int argc, char **argv) { - grpc_completion_queue *cq1; - grpc_completion_queue *cq2; - grpc_completion_queue *cq3; +int main(int argc, char** argv) { + grpc_completion_queue* cq1; + grpc_completion_queue* cq2; + grpc_completion_queue* cq3; grpc_completion_queue_attributes attr; - grpc_server *server; + grpc_server* server; grpc_test_init(argc, argv); grpc_init(); diff --git a/test/core/end2end/no_server_test.cc b/test/core/end2end/no_server_test.cc index 962499bb4f..a69b7bc8d6 100644 --- a/test/core/end2end/no_server_test.cc +++ b/test/core/end2end/no_server_test.cc @@ -25,16 +25,16 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/util/test_config.h" -static void *tag(intptr_t i) { return (void *)i; } +static void* tag(intptr_t i) { return (void*)i; } -int main(int argc, char **argv) { - grpc_channel *chan; - grpc_call *call; +int main(int argc, char** argv) { + grpc_channel* chan; + grpc_call* call; gpr_timespec deadline = grpc_timeout_seconds_to_deadline(2); - grpc_completion_queue *cq; - cq_verifier *cqv; + grpc_completion_queue* cq; + cq_verifier* cqv; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array trailing_metadata_recv; grpc_status_code status; grpc_slice details; diff --git a/test/core/end2end/tests/authority_not_supported.cc b/test/core/end2end/tests/authority_not_supported.cc index b54d6d0d6f..62fb02ab56 100644 --- a/test/core/end2end/tests/authority_not_supported.cc +++ b/test/core/end2end/tests/authority_not_supported.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -86,10 +86,10 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Request/response with metadata and payload.*/ static void test_with_authority_header(grpc_end2end_test_config config) { - grpc_call *c; + grpc_call* c; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"), grpc_slice_from_static_string("val1"), @@ -101,12 +101,12 @@ static void test_with_authority_header(grpc_end2end_test_config config) { {{NULL, NULL, NULL, NULL}}}}; grpc_end2end_test_fixture f = begin_test(config, "test_with_authority_header", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_status_code status; grpc_call_error error; grpc_slice details; diff --git a/test/core/end2end/tests/bad_hostname.cc b/test/core/end2end/tests/bad_hostname.cc index 32093f2ecf..c54cb8ed34 100644 --- a/test/core/end2end/tests/bad_hostname.cc +++ b/test/core/end2end/tests/bad_hostname.cc @@ -30,12 +30,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -52,14 +52,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -70,13 +70,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -87,10 +87,10 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void simple_request_body(grpc_end2end_test_fixture f) { - grpc_call *c; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; diff --git a/test/core/end2end/tests/bad_ping.cc b/test/core/end2end/tests/bad_ping.cc index 50e02ed720..648061587c 100644 --- a/test/core/end2end/tests/bad_ping.cc +++ b/test/core/end2end/tests/bad_ping.cc @@ -31,9 +31,9 @@ #define MAX_PING_STRIKES 1 -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5), @@ -41,19 +41,19 @@ static void drain_cq(grpc_completion_queue *cq) { } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_destroy(f->server); f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -65,28 +65,28 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_bad_ping(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_arg client_a[3]; client_a[0].type = GRPC_ARG_INTEGER; client_a[0].key = - const_cast<char *>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS); + const_cast<char*>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS); client_a[0].value.integer = 10; client_a[1].type = GRPC_ARG_INTEGER; - client_a[1].key = const_cast<char *>(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA); + client_a[1].key = const_cast<char*>(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA); client_a[1].value.integer = 0; client_a[2].type = GRPC_ARG_INTEGER; - client_a[2].key = const_cast<char *>(GRPC_ARG_HTTP2_BDP_PROBE); + client_a[2].key = const_cast<char*>(GRPC_ARG_HTTP2_BDP_PROBE); client_a[2].value.integer = 0; grpc_arg server_a[3]; server_a[0].type = GRPC_ARG_INTEGER; server_a[0].key = - const_cast<char *>(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS); + const_cast<char*>(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS); server_a[0].value.integer = 300000 /* 5 minutes */; server_a[1].type = GRPC_ARG_INTEGER; - server_a[1].key = const_cast<char *>(GRPC_ARG_HTTP2_MAX_PING_STRIKES); + server_a[1].key = const_cast<char*>(GRPC_ARG_HTTP2_MAX_PING_STRIKES); server_a[1].value.integer = MAX_PING_STRIKES; server_a[2].type = GRPC_ARG_INTEGER; - server_a[2].key = const_cast<char *>(GRPC_ARG_HTTP2_BDP_PROBE); + server_a[2].key = const_cast<char*>(GRPC_ARG_HTTP2_BDP_PROBE); server_a[2].value.integer = 0; grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a}; grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a}; @@ -94,11 +94,11 @@ static void test_bad_ping(grpc_end2end_test_config config) { config.init_client(&f, &client_args); config.init_server(&f, &server_args); - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; diff --git a/test/core/end2end/tests/binary_metadata.cc b/test/core/end2end/tests/binary_metadata.cc index e949daee1d..52f0c70862 100644 --- a/test/core/end2end/tests/binary_metadata.cc +++ b/test/core/end2end/tests/binary_metadata.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -87,15 +87,15 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Request/response with metadata and payload.*/ static void test_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); grpc_metadata meta_c[2] = { {grpc_slice_from_static_string("key1-bin"), @@ -121,14 +121,14 @@ static void test_request_response_with_metadata_and_payload( {{NULL, NULL, NULL, NULL}}}}; grpc_end2end_test_fixture f = begin_test( config, "test_request_response_with_metadata_and_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/call_creds.cc b/test/core/end2end/tests/call_creds.cc index dfe6d19160..fc550b7733 100644 --- a/test/core/end2end/tests/call_creds.cc +++ b/test/core/end2end/tests/call_creds.cc @@ -38,10 +38,10 @@ static const char overridden_iam_selector[] = "overridden_selector"; typedef enum { NONE, OVERRIDE, DESTROY } override_mode; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, + const char* test_name, int fail_server_auth_check) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); @@ -50,7 +50,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, if (fail_server_auth_check) { grpc_arg fail_auth_arg = { GRPC_ARG_STRING, - const_cast<char *>(FAIL_AUTH_CHECK_SERVER_ARG_NAME), + const_cast<char*>(FAIL_AUTH_CHECK_SERVER_ARG_NAME), {NULL}}; grpc_channel_args args; args.num_args = 1; @@ -70,14 +70,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -88,13 +88,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -104,8 +104,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->shutdown_cq); } -static void print_auth_context(int is_client, const grpc_auth_context *ctx) { - const grpc_auth_property *p; +static void print_auth_context(int is_client, const grpc_auth_context* ctx) { + const grpc_auth_property* p; grpc_auth_property_iterator it; gpr_log(GPR_INFO, "%s peer:", is_client ? "client" : "server"); gpr_log(GPR_INFO, "\tauthenticated: %s", @@ -122,35 +122,35 @@ static void print_auth_context(int is_client, const grpc_auth_context *ctx) { } static void request_response_with_payload_and_call_creds( - const char *test_name, grpc_end2end_test_config config, + const char* test_name, grpc_end2end_test_config config, override_mode mode) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); grpc_end2end_test_fixture f; - cq_verifier *cqv; + 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_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; grpc_slice details; int was_cancelled = 2; - grpc_call_credentials *creds = NULL; - grpc_auth_context *s_auth_context = NULL; - grpc_auth_context *c_auth_context = NULL; + grpc_call_credentials* creds = NULL; + grpc_auth_context* s_auth_context = NULL; + grpc_auth_context* c_auth_context = NULL; f = begin_test(config, test_name, 0); cqv = cq_verifier_create(f.cq); @@ -371,11 +371,11 @@ static void test_request_response_with_payload_and_deleted_call_creds( static void test_request_with_server_rejecting_client_creds( grpc_end2end_test_config config) { grpc_op ops[6]; - grpc_op *op; - grpc_call *c; + grpc_op* op; + grpc_call* c; grpc_end2end_test_fixture f; gpr_timespec deadline = five_seconds_from_now(); - cq_verifier *cqv; + cq_verifier* cqv; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -383,12 +383,12 @@ static void test_request_with_server_rejecting_client_creds( grpc_status_code status; grpc_call_error error; grpc_slice details; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_call_credentials *creds; + grpc_call_credentials* creds; f = begin_test(config, "test_request_with_server_rejecting_client_creds", 1); cqv = cq_verifier_create(f.cq); diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc index 58e807b83b..e2ad5bd721 100644 --- a/test/core/end2end/tests/cancel_after_accept.cc +++ b/test/core/end2end/tests/cancel_after_accept.cc @@ -35,14 +35,14 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, + const char* test_name, cancellation_mode mode, bool use_service_config, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s/%s/%s", test_name, config.name, mode.name, use_service_config ? "service_config" : "client_api"); @@ -60,14 +60,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -78,13 +78,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -99,9 +99,9 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, cancellation_mode mode, bool use_service_config) { grpc_op ops[6]; - grpc_op *op; - grpc_call *c; - grpc_call *s; + grpc_op* op; + grpc_call* c; + grpc_call* s; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -109,28 +109,29 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, grpc_status_code status; grpc_call_error error; grpc_slice details; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); int was_cancelled = 2; - grpc_channel_args *args = NULL; + grpc_channel_args* args = NULL; if (use_service_config) { grpc_arg arg; arg.type = GRPC_ARG_STRING; - arg.key = const_cast<char *>(GRPC_ARG_SERVICE_CONFIG); - arg.value.string = const_cast<char *>( + arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG); + arg.value.string = const_cast<char*>( "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" - " { \"service\": \"service\", \"method\": \"method\" }\n" + " { \"service\": \"service\", \"method\": \"method\" },\n" + " { \"service\": \"unused\" }\n" " ],\n" " \"timeout\": \"5s\"\n" " } ]\n" @@ -140,7 +141,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, grpc_end2end_test_fixture f = begin_test(config, "cancel_after_accept", mode, use_service_config, args, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); gpr_timespec deadline = use_service_config ? gpr_inf_future(GPR_CLOCK_MONOTONIC) diff --git a/test/core/end2end/tests/cancel_after_client_done.cc b/test/core/end2end/tests/cancel_after_client_done.cc index 0e2a751d83..90db7f51b2 100644 --- a/test/core/end2end/tests/cancel_after_client_done.cc +++ b/test/core/end2end/tests/cancel_after_client_done.cc @@ -29,13 +29,13 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, + const char* test_name, cancellation_mode mode, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s/%s", test_name, config.name, mode.name); @@ -53,14 +53,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -71,13 +71,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -91,12 +91,12 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_cancel_after_accept_and_writes_closed( grpc_end2end_test_config config, cancellation_mode mode) { grpc_op ops[6]; - grpc_op *op; - grpc_call *c; - grpc_call *s; + grpc_op* op; + grpc_call* c; + grpc_call* s; grpc_end2end_test_fixture f = begin_test( config, "test_cancel_after_accept_and_writes_closed", mode, NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -104,15 +104,15 @@ static void test_cancel_after_accept_and_writes_closed( grpc_status_code status; grpc_call_error error; grpc_slice details; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); int was_cancelled = 2; diff --git a/test/core/end2end/tests/cancel_after_invoke.cc b/test/core/end2end/tests/cancel_after_invoke.cc index aad9fdbf94..7f0c4e7af9 100644 --- a/test/core/end2end/tests/cancel_after_invoke.cc +++ b/test/core/end2end/tests/cancel_after_invoke.cc @@ -29,14 +29,14 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, + const char* test_name, cancellation_mode mode, size_t test_ops, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s/%s [%" PRIdPTR " ops]", test_name, config.name, mode.name, test_ops); @@ -54,14 +54,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); grpc_event ev = grpc_completion_queue_next( @@ -72,13 +72,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -92,11 +92,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_cancel_after_invoke(grpc_end2end_test_config config, cancellation_mode mode, size_t test_ops) { grpc_op ops[6]; - grpc_op *op; - grpc_call *c; + grpc_op* op; + grpc_call* c; grpc_end2end_test_fixture f = begin_test(config, "test_cancel_after_invoke", mode, test_ops, NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -104,10 +104,10 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_status_code status; grpc_call_error error; grpc_slice details; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_from_now(); diff --git a/test/core/end2end/tests/cancel_after_round_trip.cc b/test/core/end2end/tests/cancel_after_round_trip.cc index 202eeb5fb6..35b5214fac 100644 --- a/test/core/end2end/tests/cancel_after_round_trip.cc +++ b/test/core/end2end/tests/cancel_after_round_trip.cc @@ -35,14 +35,14 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, + const char* test_name, cancellation_mode mode, bool use_service_config, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s/%s/%s", test_name, config.name, mode.name, use_service_config ? "service_config" : "client_api"); @@ -60,14 +60,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -78,13 +78,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -99,9 +99,9 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config, cancellation_mode mode, bool use_service_config) { grpc_op ops[6]; - grpc_op *op; - grpc_call *c; - grpc_call *s; + grpc_op* op; + grpc_call* c; + grpc_call* s; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -109,26 +109,26 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config, grpc_status_code status; grpc_call_error error; grpc_slice details; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload1 = + grpc_byte_buffer* response_payload1 = grpc_raw_byte_buffer_create(&response_payload_slice, 1); - grpc_byte_buffer *response_payload2 = + grpc_byte_buffer* response_payload2 = grpc_raw_byte_buffer_create(&response_payload_slice, 1); int was_cancelled = 2; - grpc_channel_args *args = NULL; + grpc_channel_args* args = NULL; if (use_service_config) { grpc_arg arg; arg.type = GRPC_ARG_STRING; - arg.key = const_cast<char *>(GRPC_ARG_SERVICE_CONFIG); - arg.value.string = const_cast<char *>( + arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG); + arg.value.string = const_cast<char*>( "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" @@ -142,7 +142,7 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config, grpc_end2end_test_fixture f = begin_test( config, "cancel_after_round_trip", mode, use_service_config, args, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); gpr_timespec deadline = use_service_config ? gpr_inf_future(GPR_CLOCK_MONOTONIC) diff --git a/test/core/end2end/tests/cancel_before_invoke.cc b/test/core/end2end/tests/cancel_before_invoke.cc index 397e8b8ba6..9504aae5e6 100644 --- a/test/core/end2end/tests/cancel_before_invoke.cc +++ b/test/core/end2end/tests/cancel_before_invoke.cc @@ -28,13 +28,13 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, + const char* test_name, size_t num_ops, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s [%" PRIdPTR " ops]", test_name, config.name, num_ops); @@ -52,14 +52,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -70,13 +70,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -90,11 +90,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_cancel_before_invoke(grpc_end2end_test_config config, size_t test_ops) { grpc_op ops[6]; - grpc_op *op; - grpc_call *c; + grpc_op* op; + grpc_call* c; grpc_end2end_test_fixture f = begin_test(config, "cancel_before_invoke", test_ops, NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -102,10 +102,10 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, grpc_status_code status; grpc_call_error error; grpc_slice details; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_from_now(); diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.cc b/test/core/end2end/tests/cancel_in_a_vacuum.cc index cd9551bef9..090ee2fbb2 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.cc +++ b/test/core/end2end/tests/cancel_in_a_vacuum.cc @@ -29,13 +29,13 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, + const char* test_name, cancellation_mode mode, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s/%s", test_name, config.name, mode.name); @@ -53,14 +53,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -71,13 +71,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -90,10 +90,10 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Cancel and do nothing */ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, cancellation_mode mode) { - grpc_call *c; + grpc_call* c; grpc_end2end_test_fixture f = begin_test(config, "test_cancel_in_a_vacuum", mode, NULL, NULL); - cq_verifier *v_client = cq_verifier_create(f.cq); + cq_verifier* v_client = cq_verifier_create(f.cq); gpr_timespec deadline = five_seconds_from_now(); c = grpc_channel_create_call( diff --git a/test/core/end2end/tests/cancel_test_helpers.h b/test/core/end2end/tests/cancel_test_helpers.h index d85616b153..477d19929d 100644 --- a/test/core/end2end/tests/cancel_test_helpers.h +++ b/test/core/end2end/tests/cancel_test_helpers.h @@ -20,13 +20,13 @@ #define GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H typedef struct { - const char *name; - grpc_call_error (*initiate_cancel)(grpc_call *call, void *reserved); + const char* name; + grpc_call_error (*initiate_cancel)(grpc_call* call, void* reserved); grpc_status_code expect_status; - const char *expect_details; + const char* expect_details; } cancellation_mode; -static grpc_call_error wait_for_deadline(grpc_call *call, void *reserved) { +static grpc_call_error wait_for_deadline(grpc_call* call, void* reserved) { (void)reserved; return GRPC_CALL_OK; } diff --git a/test/core/end2end/tests/cancel_with_status.cc b/test/core/end2end/tests/cancel_with_status.cc index ab8c4f4187..bc3c4c3ebd 100644 --- a/test/core/end2end/tests/cancel_with_status.cc +++ b/test/core/end2end/tests/cancel_with_status.cc @@ -31,13 +31,13 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, + const char* test_name, size_t num_ops, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s [%" PRIdPTR " ops]", test_name, config.name, num_ops); @@ -55,14 +55,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); grpc_event ev = grpc_completion_queue_next( @@ -73,13 +73,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -91,10 +91,10 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, size_t num_ops) { - grpc_call *c; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + cq_verifier* cqv = cq_verifier_create(f.cq); 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; @@ -141,9 +141,9 @@ static void simple_request_body(grpc_end2end_test_config config, error = grpc_call_start_batch(c, ops, num_ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - char *dynamic_string = gpr_strdup("xyz"); + char* dynamic_string = gpr_strdup("xyz"); grpc_call_cancel_with_status(c, GRPC_STATUS_UNIMPLEMENTED, - (const char *)dynamic_string, NULL); + (const char*)dynamic_string, NULL); // The API of \a description allows for it to be a dynamic/non-const // string, test this guarantee. gpr_free(dynamic_string); diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc index ba03773036..b5fc1898b5 100644 --- a/test/core/end2end/tests/compressed_payload.cc +++ b/test/core/end2end/tests/compressed_payload.cc @@ -36,12 +36,12 @@ #include "src/core/lib/transport/static_metadata.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -58,14 +58,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -76,13 +76,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -93,30 +93,30 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void request_for_disabled_algorithm( - grpc_end2end_test_config config, const char *test_name, + grpc_end2end_test_config config, const char* test_name, uint32_t send_flags_bitmask, grpc_compression_algorithm algorithm_to_disable, grpc_compression_algorithm requested_client_compression_algorithm, - grpc_status_code expected_error, grpc_metadata *client_metadata) { - grpc_call *c; - grpc_call *s; + grpc_status_code expected_error, grpc_metadata* client_metadata) { + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice; - grpc_byte_buffer *request_payload; - grpc_channel_args *client_args; - grpc_channel_args *server_args; + grpc_byte_buffer* request_payload; + grpc_channel_args* client_args; + grpc_channel_args* server_args; grpc_end2end_test_fixture f; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; grpc_slice details; int was_cancelled = 2; - cq_verifier *cqv; + cq_verifier* cqv; char str[1024]; memset(str, 'x', 1023); @@ -229,9 +229,9 @@ static void request_for_disabled_algorithm( /* with a certain error */ GPR_ASSERT(status == expected_error); - const char *algo_name = NULL; + const char* algo_name = NULL; GPR_ASSERT(grpc_compression_algorithm_name(algorithm_to_disable, &algo_name)); - char *expected_details = NULL; + char* expected_details = NULL; gpr_asprintf(&expected_details, "Compression algorithm '%s' is disabled.", algo_name); /* and we expect a specific reason for it */ @@ -268,36 +268,36 @@ static void request_for_disabled_algorithm( } static void request_with_payload_template( - grpc_end2end_test_config config, const char *test_name, + grpc_end2end_test_config config, const char* test_name, uint32_t client_send_flags_bitmask, grpc_compression_algorithm default_client_channel_compression_algorithm, grpc_compression_algorithm default_server_channel_compression_algorithm, grpc_compression_algorithm expected_algorithm_from_client, grpc_compression_algorithm expected_algorithm_from_server, - grpc_metadata *client_init_metadata, bool set_server_level, + grpc_metadata* client_init_metadata, bool set_server_level, grpc_compression_level server_compression_level, bool send_message_before_initial_metadata) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice; - grpc_byte_buffer *request_payload = NULL; - grpc_channel_args *client_args; - grpc_channel_args *server_args; + grpc_byte_buffer* request_payload = NULL; + grpc_channel_args* client_args; + grpc_channel_args* server_args; grpc_end2end_test_fixture f; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload; - grpc_byte_buffer *response_payload_recv; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload; + grpc_byte_buffer* response_payload_recv; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; grpc_slice details; int was_cancelled = 2; - cq_verifier *cqv; + cq_verifier* cqv; char request_str[1024]; char response_str[1024]; diff --git a/test/core/end2end/tests/connectivity.cc b/test/core/end2end/tests/connectivity.cc index 2cba25965a..4f302d11dc 100644 --- a/test/core/end2end/tests/connectivity.cc +++ b/test/core/end2end/tests/connectivity.cc @@ -25,18 +25,18 @@ #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } typedef struct { gpr_event started; - grpc_channel *channel; - grpc_completion_queue *cq; + grpc_channel* channel; + grpc_completion_queue* cq; } child_events; -static void child_thread(void *arg) { - child_events *ce = (child_events *)arg; +static void child_thread(void* arg) { + child_events* ce = (child_events*)arg; grpc_event ev; - gpr_event_set(&ce->started, (void *)1); + gpr_event_set(&ce->started, (void*)1); gpr_log(GPR_DEBUG, "verifying"); ev = grpc_completion_queue_next(ce->cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL); @@ -48,7 +48,7 @@ static void child_thread(void *arg) { static void test_connectivity(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); grpc_connectivity_state state; - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); child_events ce; gpr_thd_options thdopt = gpr_thd_options_default(); gpr_thd_id thdid; @@ -57,7 +57,7 @@ static void test_connectivity(grpc_end2end_test_config config) { grpc_arg arg_array[1]; arg_array[0].type = GRPC_ARG_INTEGER; arg_array[0].key = - const_cast<char *>("grpc.testing.fixed_reconnect_backoff_ms"); + const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms"); arg_array[0].value.integer = 1000; client_args.args = arg_array; client_args.num_args = 1; diff --git a/test/core/end2end/tests/default_host.cc b/test/core/end2end/tests/default_host.cc index d1db9b342a..166f22aec9 100644 --- a/test/core/end2end/tests/default_host.cc +++ b/test/core/end2end/tests/default_host.cc @@ -30,12 +30,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -52,14 +52,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -70,13 +70,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -87,11 +87,11 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void simple_request_body(grpc_end2end_test_fixture f) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -100,7 +100,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call_error error; grpc_slice details; int was_cancelled = 2; - char *peer; + char* peer; gpr_timespec deadline = five_seconds_from_now(); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, diff --git a/test/core/end2end/tests/disappearing_server.cc b/test/core/end2end/tests/disappearing_server.cc index 19e4c05605..a0b34dd805 100644 --- a/test/core/end2end/tests/disappearing_server.cc +++ b/test/core/end2end/tests/disappearing_server.cc @@ -28,7 +28,7 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static gpr_timespec n_seconds_from_now(int n) { return grpc_timeout_seconds_to_deadline(n); @@ -38,26 +38,26 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_destroy(f->server); f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -70,12 +70,12 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void do_request_and_shutdown_server(grpc_end2end_test_config config, - grpc_end2end_test_fixture *f, - cq_verifier *cqv) { - grpc_call *c; - grpc_call *s; + grpc_end2end_test_fixture* f, + cq_verifier* cqv) { + grpc_call* c; + grpc_call* s; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -182,7 +182,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config, static void disappearing_server_test(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); gpr_log(GPR_INFO, "Running test: %s/%s", "disappearing_server_test", config.name); diff --git a/test/core/end2end/tests/empty_batch.cc b/test/core/end2end/tests/empty_batch.cc index ee57c16780..59d0025239 100644 --- a/test/core/end2end/tests/empty_batch.cc +++ b/test/core/end2end/tests/empty_batch.cc @@ -30,12 +30,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -52,14 +52,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -70,13 +70,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -88,10 +88,10 @@ static void end_test(grpc_end2end_test_fixture *f) { static void empty_batch_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { - grpc_call *c; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_call_error error; - grpc_op *op = NULL; + grpc_op* op = NULL; gpr_timespec deadline = five_seconds_from_now(); c = grpc_channel_create_call( diff --git a/test/core/end2end/tests/filter_call_init_fails.cc b/test/core/end2end/tests/filter_call_init_fails.cc index 09e9dbcd7b..ecf0cc3aca 100644 --- a/test/core/end2end/tests/filter_call_init_fails.cc +++ b/test/core/end2end/tests/filter_call_init_fails.cc @@ -38,12 +38,12 @@ static bool g_enable_server_channel_filter = false; static bool g_enable_client_channel_filter = false; static bool g_enable_client_subchannel_filter = false; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -60,14 +60,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -78,13 +78,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -97,21 +97,21 @@ static void end_test(grpc_end2end_test_fixture *f) { // Simple request via a SERVER_CHANNEL filter that always fails to // initialize the call. static void test_server_channel_filter(grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_end2end_test_fixture f = begin_test(config, "filter_call_init_fails", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; @@ -193,21 +193,21 @@ static void test_server_channel_filter(grpc_end2end_test_config config) { // Simple request via a CLIENT_CHANNEL or CLIENT_DIRECT_CHANNEL filter // that always fails to initialize the call. static void test_client_channel_filter(grpc_end2end_test_config config) { - grpc_call *c; + grpc_call* c; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_from_now(); grpc_end2end_test_fixture f = begin_test(config, "filter_call_init_fails", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; @@ -283,21 +283,21 @@ static void test_client_channel_filter(grpc_end2end_test_config config) { // Simple request via a CLIENT_SUBCHANNEL filter that always fails to // initialize the call. static void test_client_subchannel_filter(grpc_end2end_test_config config) { - grpc_call *c; + grpc_call* c; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_from_now(); grpc_end2end_test_fixture f = begin_test(config, "filter_call_init_fails", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; @@ -399,26 +399,26 @@ static void test_client_subchannel_filter(grpc_end2end_test_config config) { * Test filter - always fails to initialize a call */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { +static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_element_args* args) { return grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("access denied"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_PERMISSION_DENIED); } -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) {} +static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) {} -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { +static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, + grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) {} +static void destroy_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem) {} static const grpc_channel_filter test_filter = { grpc_call_next_op, @@ -437,15 +437,15 @@ static const grpc_channel_filter test_filter = { * Registration */ -static bool maybe_add_server_channel_filter(grpc_exec_ctx *exec_ctx, - grpc_channel_stack_builder *builder, - void *arg) { +static bool maybe_add_server_channel_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, + void* arg) { if (g_enable_server_channel_filter) { // Want to add the filter as close to the end as possible, to make // sure that all of the filters work well together. However, we // can't add it at the very end, because the connected channel filter // must be the last one. So we add it right before the last one. - grpc_channel_stack_builder_iterator *it = + grpc_channel_stack_builder_iterator* it = grpc_channel_stack_builder_create_iterator_at_last(builder); GPR_ASSERT(grpc_channel_stack_builder_move_prev(it)); const bool retval = grpc_channel_stack_builder_add_filter_before( @@ -457,15 +457,15 @@ static bool maybe_add_server_channel_filter(grpc_exec_ctx *exec_ctx, } } -static bool maybe_add_client_channel_filter(grpc_exec_ctx *exec_ctx, - grpc_channel_stack_builder *builder, - void *arg) { +static bool maybe_add_client_channel_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, + void* arg) { if (g_enable_client_channel_filter) { // Want to add the filter as close to the end as possible, to make // sure that all of the filters work well together. However, we // can't add it at the very end, because the connected channel filter // must be the last one. So we add it right before the last one. - grpc_channel_stack_builder_iterator *it = + grpc_channel_stack_builder_iterator* it = grpc_channel_stack_builder_create_iterator_at_last(builder); GPR_ASSERT(grpc_channel_stack_builder_move_prev(it)); const bool retval = grpc_channel_stack_builder_add_filter_before( @@ -478,13 +478,13 @@ static bool maybe_add_client_channel_filter(grpc_exec_ctx *exec_ctx, } static bool maybe_add_client_subchannel_filter( - grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) { + grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) { if (g_enable_client_subchannel_filter) { // Want to add the filter as close to the end as possible, to make // sure that all of the filters work well together. However, we // can't add it at the very end, because the client channel filter // must be the last one. So we add it right before the last one. - grpc_channel_stack_builder_iterator *it = + grpc_channel_stack_builder_iterator* it = grpc_channel_stack_builder_create_iterator_at_last(builder); GPR_ASSERT(grpc_channel_stack_builder_move_prev(it)); const bool retval = grpc_channel_stack_builder_add_filter_before( diff --git a/test/core/end2end/tests/filter_causes_close.cc b/test/core/end2end/tests/filter_causes_close.cc index ee7aeb3f33..b6cceabdd5 100644 --- a/test/core/end2end/tests/filter_causes_close.cc +++ b/test/core/end2end/tests/filter_causes_close.cc @@ -33,12 +33,12 @@ static bool g_enable_filter = false; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -55,14 +55,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -73,13 +73,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -91,21 +91,21 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Simple request via a server filter that always closes the stream.*/ static void test_request(grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_end2end_test_fixture f = begin_test(config, "filter_causes_close", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; @@ -189,14 +189,18 @@ static void test_request(grpc_end2end_test_config config) { * Test filter - always closes incoming requests */ -typedef struct { grpc_closure *recv_im_ready; } call_data; +typedef struct { + grpc_closure* recv_im_ready; +} call_data; -typedef struct { uint8_t unused; } channel_data; +typedef struct { + uint8_t unused; +} channel_data; -static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - grpc_call_element *elem = (grpc_call_element *)arg; - call_data *calld = (call_data *)elem->call_data; +static void recv_im_ready(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + grpc_call_element* elem = (grpc_call_element*)arg; + call_data* calld = (call_data*)elem->call_data; GRPC_CLOSURE_RUN( exec_ctx, calld->recv_im_ready, grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( @@ -206,9 +210,9 @@ static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg, } static void start_transport_stream_op_batch( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_transport_stream_op_batch *op) { - call_data *calld = (call_data *)elem->call_data; + grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + grpc_transport_stream_op_batch* op) { + call_data* calld = (call_data*)elem->call_data; if (op->recv_initial_metadata) { calld->recv_im_ready = op->payload->recv_initial_metadata.recv_initial_metadata_ready; @@ -218,24 +222,24 @@ static void start_transport_stream_op_batch( grpc_call_next_op(exec_ctx, elem, op); } -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { +static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_element_args* args) { return GRPC_ERROR_NONE; } -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) {} +static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) {} -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { +static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, + grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) {} +static void destroy_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem) {} static const grpc_channel_filter test_filter = { start_transport_stream_op_batch, @@ -254,8 +258,8 @@ static const grpc_channel_filter test_filter = { * Registration */ -static bool maybe_add_filter(grpc_exec_ctx *exec_ctx, - grpc_channel_stack_builder *builder, void *arg) { +static bool maybe_add_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, void* arg) { if (g_enable_filter) { return grpc_channel_stack_builder_prepend_filter(builder, &test_filter, NULL, NULL); diff --git a/test/core/end2end/tests/filter_latency.cc b/test/core/end2end/tests/filter_latency.cc index c24934f05d..e8ec188ec3 100644 --- a/test/core/end2end/tests/filter_latency.cc +++ b/test/core/end2end/tests/filter_latency.cc @@ -40,12 +40,12 @@ static gpr_mu g_mu; static gpr_timespec g_client_latency; static gpr_timespec g_server_latency; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -62,14 +62,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -80,13 +80,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -98,21 +98,21 @@ static void end_test(grpc_end2end_test_fixture *f) { // Simple request via a server filter that saves the reported latency value. static void test_request(grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_end2end_test_fixture f = begin_test(config, "filter_latency", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; @@ -247,38 +247,38 @@ static void test_request(grpc_end2end_test_config config) { * Test latency filter */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { +static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_element_args* args) { return GRPC_ERROR_NONE; } -static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) { +static void client_destroy_call_elem(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { gpr_mu_lock(&g_mu); g_client_latency = final_info->stats.latency; gpr_mu_unlock(&g_mu); } -static void server_destroy_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) { +static void server_destroy_call_elem(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { gpr_mu_lock(&g_mu); g_server_latency = final_info->stats.latency; gpr_mu_unlock(&g_mu); } -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { +static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, + grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) {} +static void destroy_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem) {} static const grpc_channel_filter test_client_filter = { grpc_call_next_op, @@ -310,15 +310,15 @@ static const grpc_channel_filter test_server_filter = { * Registration */ -static bool maybe_add_filter(grpc_exec_ctx *exec_ctx, - grpc_channel_stack_builder *builder, void *arg) { - grpc_channel_filter *filter = (grpc_channel_filter *)arg; +static bool maybe_add_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, void* arg) { + grpc_channel_filter* filter = (grpc_channel_filter*)arg; if (g_enable_filter) { // Want to add the filter as close to the end as possible, to make // sure that all of the filters work well together. However, we // can't add it at the very end, because the connected channel filter // must be the last one. So we add it right before the last one. - grpc_channel_stack_builder_iterator *it = + grpc_channel_stack_builder_iterator* it = grpc_channel_stack_builder_create_iterator_at_last(builder); GPR_ASSERT(grpc_channel_stack_builder_move_prev(it)); const bool retval = @@ -334,13 +334,13 @@ static void init_plugin(void) { gpr_mu_init(&g_mu); grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, maybe_add_filter, - (void *)&test_client_filter); + (void*)&test_client_filter); grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, maybe_add_filter, - (void *)&test_client_filter); + (void*)&test_client_filter); grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, maybe_add_filter, - (void *)&test_server_filter); + (void*)&test_server_filter); } static void destroy_plugin(void) { gpr_mu_destroy(&g_mu); } diff --git a/test/core/end2end/tests/graceful_server_shutdown.cc b/test/core/end2end/tests/graceful_server_shutdown.cc index 9b3ff98195..22bdac4032 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.cc +++ b/test/core/end2end/tests/graceful_server_shutdown.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,26 +50,26 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_destroy(f->server); f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -82,13 +82,13 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_early_server_shutdown_finishes_inflight_calls( grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_end2end_test_fixture f = begin_test( config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; diff --git a/test/core/end2end/tests/high_initial_seqno.cc b/test/core/end2end/tests/high_initial_seqno.cc index 2b72d09e68..72f1d0fd3d 100644 --- a/test/core/end2end/tests/high_initial_seqno.cc +++ b/test/core/end2end/tests/high_initial_seqno.cc @@ -32,12 +32,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -54,14 +54,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -72,13 +72,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -90,11 +90,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -208,10 +208,10 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config, grpc_end2end_test_fixture f; grpc_arg client_arg; grpc_channel_args client_args; - char *name; + char* name; client_arg.type = GRPC_ARG_INTEGER; - client_arg.key = const_cast<char *>(GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER); + client_arg.key = const_cast<char*>(GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER); client_arg.value.integer = initial_sequence_number; client_args.num_args = 1; diff --git a/test/core/end2end/tests/hpack_size.cc b/test/core/end2end/tests/hpack_size.cc index e838be9f8b..b2c683ec8e 100644 --- a/test/core/end2end/tests/hpack_size.cc +++ b/test/core/end2end/tests/hpack_size.cc @@ -32,9 +32,9 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -const char *hobbits[][2] = { +const char* hobbits[][2] = { {"Adaldrida", "Brandybuck"}, {"Adamanta", "Took"}, {"Adalgrim", "Took"}, {"Adelard", "Took"}, {"Amaranth", "Brandybuck"}, {"Andwise", "Roper"}, @@ -171,13 +171,13 @@ const char *hobbits[][2] = { {"Wiseman", "Gamwich"}*/ }; -const char *dragons[] = {"Ancalagon", "Glaurung", "Scatha", +const char* dragons[] = {"Ancalagon", "Glaurung", "Scatha", "Smaug the Magnificent"}; static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -194,14 +194,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -212,13 +212,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -230,11 +230,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, size_t index) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -357,16 +357,16 @@ static void test_size(grpc_end2end_test_config config, int encode_size, grpc_channel_args server_args; grpc_arg client_arg; grpc_channel_args client_args; - char *name; + char* name; server_arg.type = GRPC_ARG_INTEGER; - server_arg.key = const_cast<char *>(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER); + server_arg.key = const_cast<char*>(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER); server_arg.value.integer = decode_size; server_args.num_args = 1; server_args.args = &server_arg; client_arg.type = GRPC_ARG_INTEGER; - client_arg.key = const_cast<char *>(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER); + client_arg.key = const_cast<char*>(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER); client_arg.value.integer = encode_size; client_args.num_args = 1; client_args.args = &client_arg; diff --git a/test/core/end2end/tests/idempotent_request.cc b/test/core/end2end/tests/idempotent_request.cc index 829ece6631..4f61caa6df 100644 --- a/test/core/end2end/tests/idempotent_request.cc +++ b/test/core/end2end/tests/idempotent_request.cc @@ -30,12 +30,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -52,14 +52,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -70,13 +70,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -88,11 +88,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -101,7 +101,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_error error; grpc_slice details; int was_cancelled = 2; - char *peer; + char* peer; gpr_timespec deadline = five_seconds_from_now(); c = grpc_channel_create_call( diff --git a/test/core/end2end/tests/invoke_large_request.cc b/test/core/end2end/tests/invoke_large_request.cc index c0e63103a8..ade61ac91d 100644 --- a/test/core/end2end/tests/invoke_large_request.cc +++ b/test/core/end2end/tests/invoke_large_request.cc @@ -29,12 +29,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -47,14 +47,14 @@ static gpr_timespec n_seconds_from_now(int n) { return grpc_timeout_seconds_to_deadline(n); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, n_seconds_from_now(5), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -65,13 +65,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -89,17 +89,17 @@ static grpc_slice large_slice(void) { static void test_invoke_large_request(grpc_end2end_test_config config, int max_frame_size, int lookahead_bytes) { - char *name; + char* name; gpr_asprintf(&name, "test_invoke_large_request:max_frame_size=%d:lookahead_bytes=%d", max_frame_size, lookahead_bytes); grpc_arg args[2]; args[0].type = GRPC_ARG_INTEGER; - args[0].key = const_cast<char *>(GRPC_ARG_HTTP2_MAX_FRAME_SIZE); + args[0].key = const_cast<char*>(GRPC_ARG_HTTP2_MAX_FRAME_SIZE); args[0].value.integer = max_frame_size; args[1].type = GRPC_ARG_INTEGER; - args[1].key = const_cast<char *>(GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES); + args[1].key = const_cast<char*>(GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES); args[1].value.integer = lookahead_bytes; grpc_channel_args channel_args = {GPR_ARRAY_SIZE(args), args}; @@ -109,20 +109,20 @@ static void test_invoke_large_request(grpc_end2end_test_config config, grpc_slice request_payload_slice = large_slice(); grpc_slice response_payload_slice = large_slice(); - grpc_call *c; - grpc_call *s; - grpc_byte_buffer *request_payload = + grpc_call* c; + grpc_call* s; + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc index 721c1364d0..d071254a98 100644 --- a/test/core/end2end/tests/keepalive_timeout.cc +++ b/test/core/end2end/tests/keepalive_timeout.cc @@ -32,12 +32,12 @@ #include "src/core/lib/support/env.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "%s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -54,14 +54,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); @@ -72,13 +72,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -91,36 +91,35 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Client sends a request, server replies with a payload, then waits for the keepalive watchdog timeouts before returning status. */ static void test_keepalive_timeout(grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); grpc_arg keepalive_arg_elems[3]; keepalive_arg_elems[0].type = GRPC_ARG_INTEGER; - keepalive_arg_elems[0].key = const_cast<char *>(GRPC_ARG_KEEPALIVE_TIME_MS); + keepalive_arg_elems[0].key = const_cast<char*>(GRPC_ARG_KEEPALIVE_TIME_MS); keepalive_arg_elems[0].value.integer = 1500; keepalive_arg_elems[1].type = GRPC_ARG_INTEGER; - keepalive_arg_elems[1].key = - const_cast<char *>(GRPC_ARG_KEEPALIVE_TIMEOUT_MS); + keepalive_arg_elems[1].key = const_cast<char*>(GRPC_ARG_KEEPALIVE_TIMEOUT_MS); keepalive_arg_elems[1].value.integer = 0; keepalive_arg_elems[2].type = GRPC_ARG_INTEGER; - keepalive_arg_elems[2].key = const_cast<char *>(GRPC_ARG_HTTP2_BDP_PROBE); + keepalive_arg_elems[2].key = const_cast<char*>(GRPC_ARG_HTTP2_BDP_PROBE); keepalive_arg_elems[2].value.integer = 0; grpc_channel_args keepalive_args = {GPR_ARRAY_SIZE(keepalive_arg_elems), keepalive_arg_elems}; grpc_end2end_test_fixture f = begin_test(config, "keepalive_timeout", &keepalive_args, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; @@ -192,8 +191,8 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) { CQ_EXPECT_COMPLETION(cqv, tag(3), 1); cq_verify(cqv); - char *details_str = grpc_slice_to_c_string(details); - char *method_str = grpc_slice_to_c_string(call_details.method); + char* details_str = grpc_slice_to_c_string(details); + char* method_str = grpc_slice_to_c_string(call_details.method); GPR_ASSERT(status == GRPC_STATUS_INTERNAL); GPR_ASSERT(0 == grpc_slice_str_cmp(details, "keepalive watchdog timeout")); GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); diff --git a/test/core/end2end/tests/large_metadata.cc b/test/core/end2end/tests/large_metadata.cc index c2aa4d187b..4afd9f31ba 100644 --- a/test/core/end2end/tests/large_metadata.cc +++ b/test/core/end2end/tests/large_metadata.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -86,28 +86,28 @@ static void end_test(grpc_end2end_test_fixture *f) { // Request with a large amount of metadata. static void test_request_with_large_metadata(grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_metadata meta; const size_t large_size = 64 * 1024; grpc_arg arg; arg.type = GRPC_ARG_INTEGER; - arg.key = const_cast<char *>(GRPC_ARG_MAX_METADATA_SIZE); + arg.key = const_cast<char*>(GRPC_ARG_MAX_METADATA_SIZE); arg.value.integer = (int)large_size + 1024; grpc_channel_args args = {1, &arg}; grpc_end2end_test_fixture f = begin_test(config, "test_request_with_large_metadata", &args, &args); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/load_reporting_hook.cc b/test/core/end2end/tests/load_reporting_hook.cc index 7b503790db..5c2c3b497c 100644 --- a/test/core/end2end/tests/load_reporting_hook.cc +++ b/test/core/end2end/tests/load_reporting_hook.cc @@ -36,16 +36,16 @@ enum { TIMEOUT = 200000 }; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } typedef struct { gpr_mu mu; intptr_t channel_id; intptr_t call_id; - char *initial_md_str; - char *trailing_md_str; - char *method_name; + char* initial_md_str; + char* trailing_md_str; + char* method_name; uint64_t incoming_bytes; uint64_t outgoing_bytes; @@ -56,9 +56,9 @@ typedef struct { } load_reporting_data; static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); @@ -77,14 +77,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -95,13 +95,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -113,25 +113,25 @@ static void end_test(grpc_end2end_test_fixture *f) { static void request_response_with_payload( grpc_end2end_test_config config, grpc_end2end_test_fixture f, - const char *method_name, const char *request_msg, const char *response_msg, - grpc_metadata *initial_lr_metadata, grpc_metadata *trailing_lr_metadata) { + const char* method_name, const char* request_msg, const char* response_msg, + grpc_metadata* initial_lr_metadata, grpc_metadata* trailing_lr_metadata) { grpc_slice request_payload_slice = grpc_slice_from_static_string(request_msg); grpc_slice response_payload_slice = grpc_slice_from_static_string(response_msg); - grpc_call *c; - grpc_call *s; - grpc_byte_buffer *request_payload = + grpc_call* c; + grpc_call* s; + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; @@ -264,7 +264,7 @@ static void request_response_with_payload( /* override the default for testing purposes */ extern void (*g_load_reporting_fn)( - const grpc_load_reporting_call_data *call_data); + const grpc_load_reporting_call_data* call_data); static void test_load_reporting_hook(grpc_end2end_test_config config) { /* TODO(dgq): this test is currently a noop until LR is fully defined. @@ -272,15 +272,15 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) { /* Introduce load reporting for the server through its arguments */ grpc_arg arg = grpc_load_reporting_enable_arg(); - grpc_channel_args *lr_server_args = + grpc_channel_args* lr_server_args = grpc_channel_args_copy_and_add(NULL, &arg, 1); grpc_end2end_test_fixture f = begin_test(config, "test_load_reporting_hook", NULL, lr_server_args); - const char *method_name = "/gRPCFTW"; - const char *request_msg = "the msg from the client"; - const char *response_msg = "... and the response from the server"; + const char* method_name = "/gRPCFTW"; + const char* request_msg = "the msg from the client"; + const char* response_msg = "... and the response from the server"; grpc_metadata initial_lr_metadata; grpc_metadata trailing_lr_metadata; diff --git a/test/core/end2end/tests/max_concurrent_streams.cc b/test/core/end2end/tests/max_concurrent_streams.cc index deb44bbc3e..b8b49d65fb 100644 --- a/test/core/end2end/tests/max_concurrent_streams.cc +++ b/test/core/end2end/tests/max_concurrent_streams.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -86,11 +86,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -196,13 +196,13 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; grpc_arg server_arg; grpc_channel_args server_args; - grpc_call *c1; - grpc_call *c2; - grpc_call *s1; - grpc_call *s2; + grpc_call* c1; + grpc_call* c2; + grpc_call* s1; + grpc_call* s2; int live_call; gpr_timespec deadline; - cq_verifier *cqv; + cq_verifier* cqv; grpc_event ev; grpc_call_details call_details; grpc_metadata_array request_metadata_recv; @@ -216,12 +216,12 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { grpc_status_code status2; grpc_slice details2; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; int was_cancelled; int got_client_start; int got_server_start; - server_arg.key = const_cast<char *>(GRPC_ARG_MAX_CONCURRENT_STREAMS); + server_arg.key = const_cast<char*>(GRPC_ARG_MAX_CONCURRENT_STREAMS); server_arg.type = GRPC_ARG_INTEGER; server_arg.value.integer = 1; @@ -441,11 +441,11 @@ static void test_max_concurrent_streams_with_timeout_on_first( grpc_end2end_test_fixture f; grpc_arg server_arg; grpc_channel_args server_args; - grpc_call *c1; - grpc_call *c2; - grpc_call *s1; - grpc_call *s2; - cq_verifier *cqv; + grpc_call* c1; + grpc_call* c2; + grpc_call* s1; + grpc_call* s2; + cq_verifier* cqv; grpc_call_details call_details; grpc_metadata_array request_metadata_recv; grpc_metadata_array initial_metadata_recv1; @@ -458,10 +458,10 @@ static void test_max_concurrent_streams_with_timeout_on_first( grpc_status_code status2; grpc_slice details2 = grpc_empty_slice(); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; int was_cancelled; - server_arg.key = const_cast<char *>(GRPC_ARG_MAX_CONCURRENT_STREAMS); + server_arg.key = const_cast<char*>(GRPC_ARG_MAX_CONCURRENT_STREAMS); server_arg.type = GRPC_ARG_INTEGER; server_arg.value.integer = 1; @@ -636,10 +636,10 @@ static void test_max_concurrent_streams_with_timeout_on_second( grpc_end2end_test_fixture f; grpc_arg server_arg; grpc_channel_args server_args; - grpc_call *c1; - grpc_call *c2; - grpc_call *s1; - cq_verifier *cqv; + grpc_call* c1; + grpc_call* c2; + grpc_call* s1; + cq_verifier* cqv; grpc_call_details call_details; grpc_metadata_array request_metadata_recv; grpc_metadata_array initial_metadata_recv1; @@ -652,10 +652,10 @@ static void test_max_concurrent_streams_with_timeout_on_second( grpc_status_code status2; grpc_slice details2 = grpc_empty_slice(); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; int was_cancelled; - server_arg.key = const_cast<char *>(GRPC_ARG_MAX_CONCURRENT_STREAMS); + server_arg.key = const_cast<char*>(GRPC_ARG_MAX_CONCURRENT_STREAMS); server_arg.type = GRPC_ARG_INTEGER; server_arg.value.integer = 1; diff --git a/test/core/end2end/tests/max_connection_age.cc b/test/core/end2end/tests/max_connection_age.cc index 01cae9e3e0..b5d4dcf963 100644 --- a/test/core/end2end/tests/max_connection_age.cc +++ b/test/core/end2end/tests/max_connection_age.cc @@ -45,9 +45,9 @@ /* The grace period for the test to observe the channel shutdown process */ #define IMMEDIATE_SHUTDOWN_GRACE_TIME_MS 3000 -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5), @@ -55,19 +55,19 @@ static void drain_cq(grpc_completion_queue *cq) { } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_destroy(f->server); f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -79,27 +79,27 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_max_age_forcibly_close(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_arg server_a[3]; server_a[0].type = GRPC_ARG_INTEGER; - server_a[0].key = const_cast<char *>(GRPC_ARG_MAX_CONNECTION_AGE_MS); + server_a[0].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_MS); server_a[0].value.integer = MAX_CONNECTION_AGE_MS; server_a[1].type = GRPC_ARG_INTEGER; - server_a[1].key = const_cast<char *>(GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS); + server_a[1].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS); server_a[1].value.integer = MAX_CONNECTION_AGE_GRACE_MS; server_a[2].type = GRPC_ARG_INTEGER; - server_a[2].key = const_cast<char *>(GRPC_ARG_MAX_CONNECTION_IDLE_MS); + server_a[2].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_IDLE_MS); server_a[2].value.integer = MAX_CONNECTION_IDLE_MS; grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a}; config.init_client(&f, NULL); config.init_server(&f, &server_args); - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; gpr_timespec deadline = grpc_timeout_seconds_to_deadline(CALL_DEADLINE_S); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -222,27 +222,27 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) { static void test_max_age_gracefully_close(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_arg server_a[3]; server_a[0].type = GRPC_ARG_INTEGER; - server_a[0].key = const_cast<char *>(GRPC_ARG_MAX_CONNECTION_AGE_MS); + server_a[0].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_MS); server_a[0].value.integer = MAX_CONNECTION_AGE_MS; server_a[1].type = GRPC_ARG_INTEGER; - server_a[1].key = const_cast<char *>(GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS); + server_a[1].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS); server_a[1].value.integer = INT_MAX; server_a[2].type = GRPC_ARG_INTEGER; - server_a[2].key = const_cast<char *>(GRPC_ARG_MAX_CONNECTION_IDLE_MS); + server_a[2].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_IDLE_MS); server_a[2].value.integer = MAX_CONNECTION_IDLE_MS; grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a}; config.init_client(&f, NULL); config.init_server(&f, &server_args); - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; gpr_timespec deadline = grpc_timeout_seconds_to_deadline(CALL_DEADLINE_S); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; diff --git a/test/core/end2end/tests/max_connection_idle.cc b/test/core/end2end/tests/max_connection_idle.cc index a44d15452c..d850e4267b 100644 --- a/test/core/end2end/tests/max_connection_idle.cc +++ b/test/core/end2end/tests/max_connection_idle.cc @@ -32,9 +32,9 @@ #define MAX_CONNECTION_IDLE_MS 500 #define MAX_CONNECTION_AGE_MS 9999 -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5), @@ -43,12 +43,12 @@ static void drain_cq(grpc_completion_queue *cq) { } static void simple_request_body(grpc_end2end_test_config config, - grpc_end2end_test_fixture *f) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f->cq); + grpc_end2end_test_fixture* f) { + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f->cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -57,7 +57,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_error error; grpc_slice details; int was_cancelled = 2; - char *peer; + char* peer; gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); c = grpc_channel_create_call( @@ -169,19 +169,19 @@ static void simple_request_body(grpc_end2end_test_config config, static void test_max_connection_idle(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); grpc_connectivity_state state = GRPC_CHANNEL_IDLE; - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_arg client_a[1]; client_a[0].type = GRPC_ARG_INTEGER; client_a[0].key = - const_cast<char *>("grpc.testing.fixed_reconnect_backoff_ms"); + const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms"); client_a[0].value.integer = 1000; grpc_arg server_a[2]; server_a[0].type = GRPC_ARG_INTEGER; - server_a[0].key = const_cast<char *>(GRPC_ARG_MAX_CONNECTION_IDLE_MS); + server_a[0].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_IDLE_MS); server_a[0].value.integer = MAX_CONNECTION_IDLE_MS; server_a[1].type = GRPC_ARG_INTEGER; - server_a[1].key = const_cast<char *>(GRPC_ARG_MAX_CONNECTION_AGE_MS); + server_a[1].key = const_cast<char*>(GRPC_ARG_MAX_CONNECTION_AGE_MS); server_a[1].value.integer = MAX_CONNECTION_AGE_MS; grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a}; grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a}; diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc index 2ee7b0be42..3d677f1d8f 100644 --- a/test/core/end2end/tests/max_message_length.cc +++ b/test/core/end2end/tests/max_message_length.cc @@ -34,12 +34,12 @@ #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); // We intentionally do not pass the client and server args to @@ -59,14 +59,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); grpc_event ev = grpc_completion_queue_next( @@ -77,13 +77,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -106,16 +106,16 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, send_limit, use_service_config, use_string_json_value); grpc_end2end_test_fixture f; - grpc_call *c = NULL; - grpc_call *s = NULL; - cq_verifier *cqv; + grpc_call* c = NULL; + grpc_call* s = NULL; + cq_verifier* cqv; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *recv_payload = NULL; + grpc_byte_buffer* recv_payload = NULL; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -125,17 +125,17 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, grpc_slice details; int was_cancelled = 2; - grpc_channel_args *client_args = NULL; - grpc_channel_args *server_args = NULL; + grpc_channel_args* client_args = NULL; + grpc_channel_args* server_args = NULL; if (use_service_config) { // We don't currently support service configs on the server side. GPR_ASSERT(send_limit); grpc_arg arg; arg.type = GRPC_ARG_STRING; - arg.key = const_cast<char *>(GRPC_ARG_SERVICE_CONFIG); + arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG); arg.value.string = use_string_json_value - ? const_cast<char *>( + ? const_cast<char*>( "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" @@ -144,7 +144,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, " \"maxRequestMessageBytes\": \"5\"\n" " } ]\n" "}") - : const_cast<char *>( + : const_cast<char*>( "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" @@ -158,11 +158,11 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, // Set limit via channel args. grpc_arg arg; arg.key = send_limit - ? const_cast<char *>(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH) - : const_cast<char *>(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH); + ? const_cast<char*>(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH) + : const_cast<char*>(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH); arg.type = GRPC_ARG_INTEGER; arg.value.integer = 5; - grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1); + grpc_channel_args* args = grpc_channel_args_copy_and_add(NULL, &arg, 1); if (send_limit) { client_args = args; } else { @@ -299,16 +299,16 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, send_limit, use_service_config, use_string_json_value); grpc_end2end_test_fixture f; - grpc_call *c = NULL; - grpc_call *s = NULL; - cq_verifier *cqv; + grpc_call* c = NULL; + grpc_call* s = NULL; + cq_verifier* cqv; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); - grpc_byte_buffer *recv_payload = NULL; + grpc_byte_buffer* recv_payload = NULL; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -318,15 +318,15 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, grpc_slice details; int was_cancelled = 2; - grpc_channel_args *client_args = NULL; - grpc_channel_args *server_args = NULL; + grpc_channel_args* client_args = NULL; + grpc_channel_args* server_args = NULL; if (use_service_config) { // We don't currently support service configs on the server side. GPR_ASSERT(!send_limit); grpc_arg arg; arg.type = GRPC_ARG_STRING; - arg.key = const_cast<char *>(GRPC_ARG_SERVICE_CONFIG); - arg.value.string = const_cast<char *>( + arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG); + arg.value.string = const_cast<char*>( use_string_json_value ? "{\n" " \"methodConfig\": [ {\n" @@ -349,11 +349,11 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, // Set limit via channel args. grpc_arg arg; arg.key = send_limit - ? const_cast<char *>(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH) - : const_cast<char *>(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH); + ? const_cast<char*>(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH) + : const_cast<char*>(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH); arg.type = GRPC_ARG_INTEGER; arg.value.integer = 5; - grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1); + grpc_channel_args* args = grpc_channel_args_copy_and_add(NULL, &arg, 1); if (send_limit) { server_args = args; } else { diff --git a/test/core/end2end/tests/negative_deadline.cc b/test/core/end2end/tests/negative_deadline.cc index c8667f4f4d..0d56038684 100644 --- a/test/core/end2end/tests/negative_deadline.cc +++ b/test/core/end2end/tests/negative_deadline.cc @@ -30,12 +30,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -52,14 +52,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -70,13 +70,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -88,10 +88,10 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, size_t num_ops) { - grpc_call *c; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + cq_verifier* cqv = cq_verifier_create(f.cq); 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; diff --git a/test/core/end2end/tests/network_status_change.cc b/test/core/end2end/tests/network_status_change.cc index 4d77174e22..088563cb2c 100644 --- a/test/core/end2end/tests/network_status_change.cc +++ b/test/core/end2end/tests/network_status_change.cc @@ -31,12 +31,12 @@ /* this is a private API but exposed here for testing*/ extern void grpc_network_status_shutdown_all_endpoints(); -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -53,14 +53,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(500); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -71,13 +71,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -89,21 +89,21 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Client sends a request with payload, server reads then returns status. */ static void test_invoke_network_status_change(grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_with_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/no_logging.cc b/test/core/end2end/tests/no_logging.cc index d898ef0581..1a7b57cd84 100644 --- a/test/core/end2end/tests/no_logging.cc +++ b/test/core/end2end/tests/no_logging.cc @@ -34,12 +34,12 @@ enum { TIMEOUT = 200000 }; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } -extern "C" void gpr_default_log(gpr_log_func_args *args); +extern "C" void gpr_default_log(gpr_log_func_args* args); -static void test_no_log(gpr_log_func_args *args) { - char *message = NULL; +static void test_no_log(gpr_log_func_args* args) { + char* message = NULL; gpr_asprintf(&message, "Unwanted log: %s", args->message); args->message = message; gpr_default_log(args); @@ -47,7 +47,7 @@ static void test_no_log(gpr_log_func_args *args) { abort(); } -static void test_no_error_log(gpr_log_func_args *args) { +static void test_no_error_log(gpr_log_func_args* args) { if (args->severity == GPR_LOG_SEVERITY_ERROR) { test_no_log(args); } @@ -55,15 +55,15 @@ static void test_no_error_log(gpr_log_func_args *args) { static gpr_atm g_log_func = (gpr_atm)gpr_default_log; -static void log_dispatcher_func(gpr_log_func_args *args) { +static void log_dispatcher_func(gpr_log_func_args* args) { gpr_log_func log_func = (gpr_log_func)gpr_atm_no_barrier_load(&g_log_func); log_func(args); } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -80,14 +80,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -98,13 +98,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -116,11 +116,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -129,7 +129,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_error error; grpc_slice details; int was_cancelled = 2; - char *peer; + char* peer; gpr_timespec deadline = five_seconds_from_now(); c = grpc_channel_create_call( diff --git a/test/core/end2end/tests/no_op.cc b/test/core/end2end/tests/no_op.cc index 8400c27486..98cf5eb9dc 100644 --- a/test/core/end2end/tests/no_op.cc +++ b/test/core/end2end/tests/no_op.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); diff --git a/test/core/end2end/tests/payload.cc b/test/core/end2end/tests/payload.cc index d98eed68e0..0ff9461a47 100644 --- a/test/core/end2end/tests/payload.cc +++ b/test/core/end2end/tests/payload.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -89,9 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) { static grpc_slice generate_random_slice() { size_t i; static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; - char *output; + char* output; const size_t output_size = 1024 * 1024; - output = (char *)gpr_malloc(output_size); + output = (char*)gpr_malloc(output_size); for (i = 0; i < output_size - 1; ++i) { output[i] = chars[rand() % (int)(sizeof(chars) - 1)]; } @@ -109,20 +109,20 @@ static void request_response_with_payload(grpc_end2end_test_config config, grpc_slice request_payload_slice = generate_random_slice(); grpc_slice response_payload_slice = generate_random_slice(); - grpc_call *c; - grpc_call *s; - grpc_byte_buffer *request_payload = + grpc_call* c; + grpc_call* s; + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/ping.cc b/test/core/end2end/tests/ping.cc index e6b0e55b01..88f62c0a2b 100644 --- a/test/core/end2end/tests/ping.cc +++ b/test/core/end2end/tests/ping.cc @@ -28,33 +28,33 @@ #define PING_NUM 5 -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static void test_ping(grpc_end2end_test_config config, int min_time_between_pings_ms) { grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_connectivity_state state = GRPC_CHANNEL_IDLE; int i; grpc_arg client_a[3]; client_a[0].type = GRPC_ARG_INTEGER; client_a[0].key = - const_cast<char *>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS); + const_cast<char*>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS); client_a[0].value.integer = 10; client_a[1].type = GRPC_ARG_INTEGER; - client_a[1].key = const_cast<char *>(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA); + client_a[1].key = const_cast<char*>(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA); client_a[1].value.integer = 0; client_a[2].type = GRPC_ARG_INTEGER; - client_a[2].key = const_cast<char *>(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS); + client_a[2].key = const_cast<char*>(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS); client_a[2].value.integer = 1; grpc_arg server_a[2]; server_a[0].type = GRPC_ARG_INTEGER; server_a[0].key = - const_cast<char *>(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS); + const_cast<char*>(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS); server_a[0].value.integer = 0; server_a[1].type = GRPC_ARG_INTEGER; - server_a[1].key = const_cast<char *>(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS); + server_a[1].key = const_cast<char*>(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS); server_a[1].value.integer = 1; grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a}; grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a}; diff --git a/test/core/end2end/tests/ping_pong_streaming.cc b/test/core/end2end/tests/ping_pong_streaming.cc index 1c44262c3d..3c2e76b9f9 100644 --- a/test/core/end2end/tests/ping_pong_streaming.cc +++ b/test/core/end2end/tests/ping_pong_streaming.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -89,11 +89,11 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, int messages) { grpc_end2end_test_fixture f = begin_test(config, "test_pingpong_streaming", NULL, NULL); - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -102,10 +102,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_call_error error; grpc_slice details; int was_cancelled = 2; - grpc_byte_buffer *request_payload; - grpc_byte_buffer *request_payload_recv; - grpc_byte_buffer *response_payload; - grpc_byte_buffer *response_payload_recv; + grpc_byte_buffer* request_payload; + grpc_byte_buffer* request_payload_recv; + grpc_byte_buffer* response_payload; + grpc_byte_buffer* response_payload_recv; int i; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); diff --git a/test/core/end2end/tests/proxy_auth.cc b/test/core/end2end/tests/proxy_auth.cc index fe87399f03..d5dce7c6de 100644 --- a/test/core/end2end/tests/proxy_auth.cc +++ b/test/core/end2end/tests/proxy_auth.cc @@ -35,12 +35,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -57,14 +57,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -75,13 +75,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -93,11 +93,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -106,7 +106,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_error error; grpc_slice details; int was_cancelled = 2; - char *peer; + char* peer; gpr_timespec deadline = five_seconds_from_now(); c = grpc_channel_create_call( @@ -219,8 +219,8 @@ static void test_invoke_proxy_auth(grpc_end2end_test_config config) { /* Indicate that the proxy requires user auth */ grpc_arg client_arg; client_arg.type = GRPC_ARG_STRING; - client_arg.key = const_cast<char *>(GRPC_ARG_HTTP_PROXY_AUTH_CREDS); - client_arg.value.string = const_cast<char *>(GRPC_TEST_HTTP_PROXY_AUTH_CREDS); + client_arg.key = const_cast<char*>(GRPC_ARG_HTTP_PROXY_AUTH_CREDS); + client_arg.value.string = const_cast<char*>(GRPC_TEST_HTTP_PROXY_AUTH_CREDS); grpc_channel_args client_args = {1, &client_arg}; grpc_end2end_test_fixture f = begin_test(config, "test_invoke_proxy_auth", &client_args, NULL); diff --git a/test/core/end2end/tests/registered_call.cc b/test/core/end2end/tests/registered_call.cc index 4598029818..b43ca04766 100644 --- a/test/core/end2end/tests/registered_call.cc +++ b/test/core/end2end/tests/registered_call.cc @@ -30,12 +30,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -52,14 +52,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -70,13 +70,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -87,12 +87,12 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void simple_request_body(grpc_end2end_test_config config, - grpc_end2end_test_fixture f, void *rc) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_end2end_test_fixture f, void* rc) { + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -194,7 +194,7 @@ static void simple_request_body(grpc_end2end_test_config config, static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test(config, "test_invoke_simple_request", NULL, NULL); - void *rc = grpc_channel_register_call( + void* rc = grpc_channel_register_call( f.client, "/foo", get_host_override_string("foo.test.google.fr:1234", config), NULL); @@ -207,7 +207,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { int i; grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); - void *rc = grpc_channel_register_call( + void* rc = grpc_channel_register_call( f.client, "/foo", get_host_override_string("foo.test.google.fr:1234", config), NULL); diff --git a/test/core/end2end/tests/request_with_flags.cc b/test/core/end2end/tests/request_with_flags.cc index dfb7d58743..77c931844c 100644 --- a/test/core/end2end/tests/request_with_flags.cc +++ b/test/core/end2end/tests/request_with_flags.cc @@ -29,12 +29,12 @@ #include "src/core/lib/transport/byte_stream.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -51,14 +51,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -69,13 +69,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -86,22 +86,22 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void test_invoke_request_with_flags( - grpc_end2end_test_config config, uint32_t *flags_for_op, + grpc_end2end_test_config config, uint32_t* flags_for_op, grpc_call_error call_start_batch_expected_result) { - grpc_call *c; + grpc_call* c; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_with_flags", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/request_with_payload.cc b/test/core/end2end/tests/request_with_payload.cc index 575e54c7d9..946144239c 100644 --- a/test/core/end2end/tests/request_with_payload.cc +++ b/test/core/end2end/tests/request_with_payload.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -86,21 +86,21 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Client sends a request with payload, server reads then returns status. */ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_with_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/resource_quota_server.cc b/test/core/end2end/tests/resource_quota_server.cc index e710e39e1d..dd00c9843f 100644 --- a/test/core/end2end/tests/resource_quota_server.cc +++ b/test/core/end2end/tests/resource_quota_server.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -89,9 +89,9 @@ static void end_test(grpc_end2end_test_fixture *f) { static grpc_slice generate_random_slice() { size_t i; static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; - char *output; + char* output; const size_t output_size = 1024 * 1024; - output = (char *)gpr_malloc(output_size); + output = (char*)gpr_malloc(output_size); for (i = 0; i < output_size - 1; ++i) { output[i] = chars[rand() % (int)(sizeof(chars) - 1)]; } @@ -106,7 +106,7 @@ void resource_quota_server(grpc_end2end_test_config config) { FEATURE_MASK_DOES_NOT_SUPPORT_RESOURCE_QUOTA_SERVER) { return; } - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_server"); grpc_resource_quota_resize(resource_quota, 5 * 1024 * 1024); @@ -117,7 +117,7 @@ void resource_quota_server(grpc_end2end_test_config config) { #define SERVER_END_BASE_TAG 0x4000 grpc_arg arg; - arg.key = const_cast<char *>(GRPC_ARG_RESOURCE_QUOTA); + arg.key = const_cast<char*>(GRPC_ARG_RESOURCE_QUOTA); arg.type = GRPC_ARG_POINTER; arg.value.pointer.p = resource_quota; arg.value.pointer.vtable = grpc_resource_quota_arg_vtable(); @@ -131,26 +131,26 @@ void resource_quota_server(grpc_end2end_test_config config) { * will be verified on completion. */ grpc_slice request_payload_slice = generate_random_slice(); - grpc_call **client_calls = - (grpc_call **)malloc(sizeof(grpc_call *) * NUM_CALLS); - grpc_call **server_calls = - (grpc_call **)malloc(sizeof(grpc_call *) * NUM_CALLS); - grpc_metadata_array *initial_metadata_recv = - (grpc_metadata_array *)malloc(sizeof(grpc_metadata_array) * NUM_CALLS); - grpc_metadata_array *trailing_metadata_recv = - (grpc_metadata_array *)malloc(sizeof(grpc_metadata_array) * NUM_CALLS); - grpc_metadata_array *request_metadata_recv = - (grpc_metadata_array *)malloc(sizeof(grpc_metadata_array) * NUM_CALLS); - grpc_call_details *call_details = - (grpc_call_details *)malloc(sizeof(grpc_call_details) * NUM_CALLS); - grpc_status_code *status = - (grpc_status_code *)malloc(sizeof(grpc_status_code) * NUM_CALLS); - grpc_slice *details = (grpc_slice *)malloc(sizeof(grpc_slice) * NUM_CALLS); - grpc_byte_buffer **request_payload = - (grpc_byte_buffer **)malloc(sizeof(grpc_byte_buffer *) * NUM_CALLS); - grpc_byte_buffer **request_payload_recv = - (grpc_byte_buffer **)malloc(sizeof(grpc_byte_buffer *) * NUM_CALLS); - int *was_cancelled = (int *)malloc(sizeof(int) * NUM_CALLS); + grpc_call** client_calls = + (grpc_call**)malloc(sizeof(grpc_call*) * NUM_CALLS); + grpc_call** server_calls = + (grpc_call**)malloc(sizeof(grpc_call*) * NUM_CALLS); + grpc_metadata_array* initial_metadata_recv = + (grpc_metadata_array*)malloc(sizeof(grpc_metadata_array) * NUM_CALLS); + grpc_metadata_array* trailing_metadata_recv = + (grpc_metadata_array*)malloc(sizeof(grpc_metadata_array) * NUM_CALLS); + grpc_metadata_array* request_metadata_recv = + (grpc_metadata_array*)malloc(sizeof(grpc_metadata_array) * NUM_CALLS); + grpc_call_details* call_details = + (grpc_call_details*)malloc(sizeof(grpc_call_details) * NUM_CALLS); + grpc_status_code* status = + (grpc_status_code*)malloc(sizeof(grpc_status_code) * NUM_CALLS); + grpc_slice* details = (grpc_slice*)malloc(sizeof(grpc_slice) * NUM_CALLS); + grpc_byte_buffer** request_payload = + (grpc_byte_buffer**)malloc(sizeof(grpc_byte_buffer*) * NUM_CALLS); + grpc_byte_buffer** request_payload_recv = + (grpc_byte_buffer**)malloc(sizeof(grpc_byte_buffer*) * NUM_CALLS); + int* was_cancelled = (int*)malloc(sizeof(int) * NUM_CALLS); grpc_call_error error; int pending_client_calls = 0; int pending_server_start_calls = 0; @@ -162,7 +162,7 @@ void resource_quota_server(grpc_end2end_test_config config) { int unavailable = 0; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; for (int i = 0; i < NUM_CALLS; i++) { grpc_metadata_array_init(&initial_metadata_recv[i]); diff --git a/test/core/end2end/tests/server_finishes_request.cc b/test/core/end2end/tests/server_finishes_request.cc index 49b9f27396..50544a6759 100644 --- a/test/core/end2end/tests/server_finishes_request.cc +++ b/test/core/end2end/tests/server_finishes_request.cc @@ -30,12 +30,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -52,14 +52,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -70,13 +70,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -88,11 +88,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; diff --git a/test/core/end2end/tests/shutdown_finishes_calls.cc b/test/core/end2end/tests/shutdown_finishes_calls.cc index f90359f09a..26a53e5161 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.cc +++ b/test/core/end2end/tests/shutdown_finishes_calls.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,20 +50,20 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_client(f); grpc_completion_queue_shutdown(f->cq); @@ -75,13 +75,13 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_early_server_shutdown_finishes_inflight_calls( grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_end2end_test_fixture f = begin_test( config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; diff --git a/test/core/end2end/tests/shutdown_finishes_tags.cc b/test/core/end2end/tests/shutdown_finishes_tags.cc index 7914cc95ba..0275a1e4ef 100644 --- a/test/core/end2end/tests/shutdown_finishes_tags.cc +++ b/test/core/end2end/tests/shutdown_finishes_tags.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,20 +50,20 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_client(f); grpc_completion_queue_shutdown(f->cq); @@ -77,8 +77,8 @@ static void test_early_server_shutdown_finishes_tags( grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test( config, "test_early_server_shutdown_finishes_tags", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); - grpc_call *s = (grpc_call *)(uintptr_t)1; + cq_verifier* cqv = cq_verifier_create(f.cq); + grpc_call* s = (grpc_call*)(uintptr_t)1; grpc_call_details call_details; grpc_metadata_array request_metadata_recv; diff --git a/test/core/end2end/tests/simple_cacheable_request.cc b/test/core/end2end/tests/simple_cacheable_request.cc index faa5c193dc..e2ee7bf35a 100644 --- a/test/core/end2end/tests/simple_cacheable_request.cc +++ b/test/core/end2end/tests/simple_cacheable_request.cc @@ -30,12 +30,12 @@ enum { TIMEOUT = 200000 }; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -52,14 +52,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -70,13 +70,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -89,15 +89,15 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Request/response with metadata and payload.*/ static void test_cacheable_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"), grpc_slice_from_static_string("val1"), @@ -118,14 +118,14 @@ static void test_cacheable_request_response_with_metadata_and_payload( grpc_end2end_test_fixture f = begin_test( config, "test_cacheable_request_response_with_metadata_and_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/simple_delayed_request.cc b/test/core/end2end/tests/simple_delayed_request.cc index a4cbcbfedf..eef36c9710 100644 --- a/test/core/end2end/tests/simple_delayed_request.cc +++ b/test/core/end2end/tests/simple_delayed_request.cc @@ -28,7 +28,7 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static gpr_timespec n_seconds_from_now(int n) { return grpc_timeout_seconds_to_deadline(n); @@ -38,14 +38,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -56,13 +56,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -73,15 +73,15 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void simple_delayed_request_body(grpc_end2end_test_config config, - grpc_end2end_test_fixture *f, - grpc_channel_args *client_args, - grpc_channel_args *server_args, + grpc_end2end_test_fixture* f, + grpc_channel_args* client_args, + grpc_channel_args* server_args, long delay_us) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f->cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f->cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -192,7 +192,7 @@ static void test_simple_delayed_request_short(grpc_end2end_test_config config) { grpc_arg arg_array[1]; arg_array[0].type = GRPC_ARG_INTEGER; arg_array[0].key = - const_cast<char *>("grpc.testing.fixed_reconnect_backoff_ms"); + const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms"); arg_array[0].value.integer = 1000; client_args.args = arg_array; client_args.num_args = 1; @@ -212,7 +212,7 @@ static void test_simple_delayed_request_long(grpc_end2end_test_config config) { grpc_arg arg_array[1]; arg_array[0].type = GRPC_ARG_INTEGER; arg_array[0].key = - const_cast<char *>("grpc.testing.fixed_reconnect_backoff_ms"); + const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms"); arg_array[0].value.integer = 1000; client_args.args = arg_array; client_args.num_args = 1; diff --git a/test/core/end2end/tests/simple_metadata.cc b/test/core/end2end/tests/simple_metadata.cc index 17e7f696e2..3b3d5ad64c 100644 --- a/test/core/end2end/tests/simple_metadata.cc +++ b/test/core/end2end/tests/simple_metadata.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -87,15 +87,15 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Request/response with metadata and payload.*/ static void test_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"), grpc_slice_from_static_string("val1"), @@ -115,14 +115,14 @@ static void test_request_response_with_metadata_and_payload( {{NULL, NULL, NULL, NULL}}}}; grpc_end2end_test_fixture f = begin_test( config, "test_request_response_with_metadata_and_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index 48c9824894..d48010ba87 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -31,12 +31,12 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -53,14 +53,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -71,13 +71,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -89,11 +89,11 @@ static void end_test(grpc_end2end_test_fixture *f) { static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -102,11 +102,11 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_call_error error; grpc_slice details; int was_cancelled = 2; - char *peer; - grpc_stats_data *before = - static_cast<grpc_stats_data *>(gpr_malloc(sizeof(grpc_stats_data))); - grpc_stats_data *after = - static_cast<grpc_stats_data *>(gpr_malloc(sizeof(grpc_stats_data))); + char* peer; + grpc_stats_data* before = + static_cast<grpc_stats_data*>(gpr_malloc(sizeof(grpc_stats_data))); + grpc_stats_data* after = + static_cast<grpc_stats_data*>(gpr_malloc(sizeof(grpc_stats_data))); grpc_stats_collect(before); @@ -218,7 +218,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_stats_collect(after); - char *stats = grpc_stats_data_as_json(after); + char* stats = grpc_stats_data_as_json(after); gpr_log(GPR_DEBUG, "%s", stats); gpr_free(stats); diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc index 8b47741cd4..3fe5200045 100644 --- a/test/core/end2end/tests/stream_compression_compressed_payload.cc +++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc @@ -36,12 +36,12 @@ #include "src/core/lib/transport/static_metadata.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -58,14 +58,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -76,13 +76,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -93,30 +93,30 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void request_for_disabled_algorithm( - grpc_end2end_test_config config, const char *test_name, + grpc_end2end_test_config config, const char* test_name, uint32_t send_flags_bitmask, grpc_stream_compression_algorithm algorithm_to_disable, grpc_stream_compression_algorithm requested_client_compression_algorithm, - grpc_status_code expected_error, grpc_metadata *client_metadata) { - grpc_call *c; - grpc_call *s; + grpc_status_code expected_error, grpc_metadata* client_metadata) { + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice; - grpc_byte_buffer *request_payload; - grpc_channel_args *client_args; - grpc_channel_args *server_args; + grpc_byte_buffer* request_payload; + grpc_channel_args* client_args; + grpc_channel_args* server_args; grpc_end2end_test_fixture f; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; grpc_slice details; int was_cancelled = 2; - cq_verifier *cqv; + cq_verifier* cqv; char str[1024]; memset(str, 'x', 1023); @@ -229,10 +229,10 @@ static void request_for_disabled_algorithm( /* with a certain error */ GPR_ASSERT(status == expected_error); - const char *algo_name = NULL; + const char* algo_name = NULL; GPR_ASSERT( grpc_stream_compression_algorithm_name(algorithm_to_disable, &algo_name)); - char *expected_details = NULL; + char* expected_details = NULL; gpr_asprintf(&expected_details, "Stream compression algorithm '%s' is disabled.", algo_name); /* and we expect a specific reason for it */ @@ -269,7 +269,7 @@ static void request_for_disabled_algorithm( } static void request_with_payload_template( - grpc_end2end_test_config config, const char *test_name, + grpc_end2end_test_config config, const char* test_name, uint32_t client_send_flags_bitmask, grpc_stream_compression_algorithm default_client_channel_compression_algorithm, @@ -277,32 +277,32 @@ static void request_with_payload_template( default_server_channel_compression_algorithm, grpc_stream_compression_algorithm expected_client_compression_algorithm, grpc_stream_compression_algorithm expected_server_compression_algorithm, - grpc_metadata *client_init_metadata, bool set_server_level, + grpc_metadata* client_init_metadata, bool set_server_level, grpc_stream_compression_level server_compression_level, bool send_message_before_initial_metadata, bool set_default_server_message_compression_algorithm, grpc_compression_algorithm default_server_message_compression_algorithm) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice; - grpc_byte_buffer *request_payload = NULL; - grpc_channel_args *client_args; - grpc_channel_args *server_args; + grpc_byte_buffer* request_payload = NULL; + grpc_channel_args* client_args; + grpc_channel_args* server_args; grpc_end2end_test_fixture f; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload; - grpc_byte_buffer *response_payload_recv; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload; + grpc_byte_buffer* response_payload_recv; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; grpc_slice details; int was_cancelled = 2; - cq_verifier *cqv; + cq_verifier* cqv; char request_str[1024]; char response_str[1024]; diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc index e47d2aa93c..038f0be738 100644 --- a/test/core/end2end/tests/stream_compression_payload.cc +++ b/test/core/end2end/tests/stream_compression_payload.cc @@ -23,7 +23,6 @@ #include <grpc/byte_buffer.h> #include <grpc/compression.h> -#include <grpc/compression.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> @@ -32,12 +31,12 @@ #include "src/core/lib/surface/call.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -54,14 +53,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -72,13 +71,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -93,9 +92,9 @@ static void end_test(grpc_end2end_test_fixture *f) { static grpc_slice generate_random_slice() { size_t i; static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; - char *output; + char* output; const size_t output_size = 1024 * 1024; - output = (char *)gpr_malloc(output_size); + output = (char*)gpr_malloc(output_size); for (i = 0; i < output_size - 1; ++i) { output[i] = chars[rand() % (int)(sizeof(chars) - 1)]; } @@ -113,20 +112,20 @@ static void request_response_with_payload(grpc_end2end_test_config config, grpc_slice request_payload_slice = generate_random_slice(); grpc_slice response_payload_slice = generate_random_slice(); - grpc_call *c; - grpc_call *s; - grpc_byte_buffer *request_payload = + grpc_call* c; + grpc_call* s; + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; @@ -265,10 +264,10 @@ static void request_response_with_payload(grpc_end2end_test_config config, payload and status. */ static void test_invoke_request_response_with_payload( grpc_end2end_test_config config) { - grpc_channel_args *client_args = + grpc_channel_args* client_args = grpc_channel_args_set_stream_compression_algorithm( NULL, GRPC_STREAM_COMPRESS_GZIP); - grpc_channel_args *server_args = + grpc_channel_args* server_args = grpc_channel_args_set_stream_compression_algorithm( NULL, GRPC_STREAM_COMPRESS_GZIP); grpc_end2end_test_fixture f = diff --git a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc index 4c1a34cc64..a5321bfc61 100644 --- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc +++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc @@ -31,12 +31,12 @@ #include "src/core/lib/surface/call.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -53,14 +53,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -71,13 +71,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -90,19 +90,19 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Client pings and server pongs. Repeat messages rounds before finishing. */ static void test_pingpong_streaming(grpc_end2end_test_config config, int messages) { - grpc_channel_args *client_args = + grpc_channel_args* client_args = grpc_channel_args_set_stream_compression_algorithm( NULL, GRPC_STREAM_COMPRESS_GZIP); - grpc_channel_args *server_args = + grpc_channel_args* server_args = grpc_channel_args_set_stream_compression_algorithm( NULL, GRPC_STREAM_COMPRESS_GZIP); grpc_end2end_test_fixture f = begin_test(config, "test_pingpong_streaming", client_args, server_args); - grpc_call *c; - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call* c; + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -111,10 +111,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_call_error error; grpc_slice details; int was_cancelled = 2; - grpc_byte_buffer *request_payload; - grpc_byte_buffer *request_payload_recv; - grpc_byte_buffer *response_payload; - grpc_byte_buffer *response_payload_recv; + grpc_byte_buffer* request_payload; + grpc_byte_buffer* request_payload_recv; + grpc_byte_buffer* response_payload; + grpc_byte_buffer* response_payload_recv; int i; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); diff --git a/test/core/end2end/tests/streaming_error_response.cc b/test/core/end2end/tests/streaming_error_response.cc index 8891b8674c..f87fd2c4c3 100644 --- a/test/core/end2end/tests/streaming_error_response.cc +++ b/test/core/end2end/tests/streaming_error_response.cc @@ -31,12 +31,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args, + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args, bool request_status_early) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s/request_status_early=%s", test_name, @@ -55,14 +55,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -73,13 +73,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -91,24 +91,24 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Client sends a request with payload, server reads then returns status. */ static void test(grpc_end2end_test_config config, bool request_status_early) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice response_payload1_slice = grpc_slice_from_copied_string("hello"); - grpc_byte_buffer *response_payload1 = + grpc_byte_buffer* response_payload1 = grpc_raw_byte_buffer_create(&response_payload1_slice, 1); grpc_slice response_payload2_slice = grpc_slice_from_copied_string("world"); - grpc_byte_buffer *response_payload2 = + grpc_byte_buffer* response_payload2 = grpc_raw_byte_buffer_create(&response_payload2_slice, 1); grpc_end2end_test_fixture f = begin_test(config, "streaming_error_response", NULL, NULL, request_status_early); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *response_payload1_recv = NULL; - grpc_byte_buffer *response_payload2_recv = NULL; + grpc_byte_buffer* response_payload1_recv = NULL; + grpc_byte_buffer* response_payload2_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/trailing_metadata.cc b/test/core/end2end/tests/trailing_metadata.cc index 7aa78a04b8..0da02a56db 100644 --- a/test/core/end2end/tests/trailing_metadata.cc +++ b/test/core/end2end/tests/trailing_metadata.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -87,15 +87,15 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Request/response with metadata and payload.*/ static void test_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_byte_buffer *response_payload = + grpc_byte_buffer* response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"), grpc_slice_from_static_string("val1"), @@ -123,14 +123,14 @@ static void test_request_response_with_metadata_and_payload( {{NULL, NULL, NULL, NULL}}}}; grpc_end2end_test_fixture f = begin_test( config, "test_request_response_with_metadata_and_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/workaround_cronet_compression.cc b/test/core/end2end/tests/workaround_cronet_compression.cc index 17e59ad6d4..8f8ca16a9e 100644 --- a/test/core/end2end/tests/workaround_cronet_compression.cc +++ b/test/core/end2end/tests/workaround_cronet_compression.cc @@ -36,12 +36,12 @@ #include "src/core/lib/transport/static_metadata.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -58,14 +58,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -76,13 +76,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -93,36 +93,36 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void request_with_payload_template( - grpc_end2end_test_config config, const char *test_name, + grpc_end2end_test_config config, const char* test_name, uint32_t client_send_flags_bitmask, grpc_compression_algorithm default_client_channel_compression_algorithm, grpc_compression_algorithm default_server_channel_compression_algorithm, grpc_compression_algorithm expected_algorithm_from_client, grpc_compression_algorithm expected_algorithm_from_server, - grpc_metadata *client_init_metadata, bool set_server_level, + grpc_metadata* client_init_metadata, bool set_server_level, grpc_compression_level server_compression_level, - char *user_agent_override) { - grpc_call *c; - grpc_call *s; + char* user_agent_override) { + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice; - grpc_byte_buffer *request_payload; - grpc_channel_args *client_args; - grpc_channel_args *server_args; + grpc_byte_buffer* request_payload; + grpc_channel_args* client_args; + grpc_channel_args* server_args; grpc_end2end_test_fixture f; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv = NULL; - grpc_byte_buffer *response_payload; - grpc_byte_buffer *response_payload_recv; + grpc_byte_buffer* request_payload_recv = NULL; + grpc_byte_buffer* response_payload; + grpc_byte_buffer* response_payload_recv; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; grpc_slice details; int was_cancelled = 2; - cq_verifier *cqv; + cq_verifier* cqv; char request_str[1024]; char response_str[1024]; @@ -143,9 +143,9 @@ static void request_with_payload_template( if (user_agent_override) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_channel_args *client_args_old = client_args; + grpc_channel_args* client_args_old = client_args; grpc_arg arg; - arg.key = const_cast<char *>(GRPC_ARG_PRIMARY_USER_AGENT_STRING); + arg.key = const_cast<char*>(GRPC_ARG_PRIMARY_USER_AGENT_STRING); arg.type = GRPC_ARG_STRING; arg.value.string = user_agent_override; client_args = grpc_channel_args_copy_and_add(client_args_old, &arg, 1); @@ -360,19 +360,19 @@ static void request_with_payload_template( } typedef struct workaround_cronet_compression_config { - char *user_agent_override; + char* user_agent_override; grpc_compression_algorithm expected_algorithm_from_server; } workaround_cronet_compression_config; static workaround_cronet_compression_config workaround_configs[] = { {NULL, GRPC_COMPRESS_GZIP}, - {const_cast<char *>( + {const_cast<char*>( "grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; cronet_http; gentle)"), GRPC_COMPRESS_NONE}, - {const_cast<char *>( + {const_cast<char*>( "grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; chttp2; gentle)"), GRPC_COMPRESS_GZIP}, - {const_cast<char *>( + {const_cast<char*>( "grpc-objc/1.4.0 grpc-c/3.0.0-dev (ios; cronet_http; gentle)"), GRPC_COMPRESS_GZIP}}; static const size_t workaround_configs_num = diff --git a/test/core/end2end/tests/write_buffering.cc b/test/core/end2end/tests/write_buffering.cc index d7d1e5fa3d..5e92e598b3 100644 --- a/test/core/end2end/tests/write_buffering.cc +++ b/test/core/end2end/tests/write_buffering.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -86,25 +86,25 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Client sends a request with payload, server reads then returns status. */ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice1 = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload1 = + grpc_byte_buffer* request_payload1 = grpc_raw_byte_buffer_create(&request_payload_slice1, 1); grpc_slice request_payload_slice2 = grpc_slice_from_copied_string("abc123"); - grpc_byte_buffer *request_payload2 = + grpc_byte_buffer* request_payload2 = grpc_raw_byte_buffer_create(&request_payload_slice2, 1); grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_with_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv1 = NULL; - grpc_byte_buffer *request_payload_recv2 = NULL; + grpc_byte_buffer* request_payload_recv1 = NULL; + grpc_byte_buffer* request_payload_recv2 = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/end2end/tests/write_buffering_at_end.cc b/test/core/end2end/tests/write_buffering_at_end.cc index 6113843390..01dacdfd12 100644 --- a/test/core/end2end/tests/write_buffering_at_end.cc +++ b/test/core/end2end/tests/write_buffering_at_end.cc @@ -28,12 +28,12 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { + const char* test_name, + grpc_channel_args* client_args, + grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -50,14 +50,14 @@ static gpr_timespec five_seconds_from_now(void) { return n_seconds_from_now(5); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void shutdown_server(grpc_end2end_test_fixture *f) { +static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), @@ -68,13 +68,13 @@ static void shutdown_server(grpc_end2end_test_fixture *f) { f->server = NULL; } -static void shutdown_client(grpc_end2end_test_fixture *f) { +static void shutdown_client(grpc_end2end_test_fixture* f) { if (!f->client) return; grpc_channel_destroy(f->client); f->client = NULL; } -static void end_test(grpc_end2end_test_fixture *f) { +static void end_test(grpc_end2end_test_fixture* f) { shutdown_server(f); shutdown_client(f); @@ -86,22 +86,22 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Client sends a request with payload, server reads then returns status. */ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { - grpc_call *c; - grpc_call *s; + grpc_call* c; + grpc_call* s; grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_byte_buffer *request_payload = + grpc_byte_buffer* request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_with_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create(f.cq); + cq_verifier* cqv = cq_verifier_create(f.cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; - grpc_byte_buffer *request_payload_recv1 = NULL; - grpc_byte_buffer *request_payload_recv2 = NULL; + grpc_byte_buffer* request_payload_recv1 = NULL; + grpc_byte_buffer* request_payload_recv2 = NULL; grpc_call_details call_details; grpc_status_code status; grpc_call_error error; diff --git a/test/core/fling/client.cc b/test/core/fling/client.cc index 356ec4bb28..64d1dc5089 100644 --- a/test/core/fling/client.cc +++ 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; - const char *target = "localhost:443"; - gpr_cmdline *cl; + const char* target = "localhost:443"; + gpr_cmdline* cl; grpc_event event; - const 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.cc b/test/core/fling/fling_stream_test.cc index 4e3b63e192..620427e12a 100644 --- a/test/core/fling/fling_stream_test.cc +++ 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] = const_cast<char *>("--bind"); + args[1] = const_cast<char*>("--bind"); gpr_join_host_port(&args[2], "::", port); - args[3] = const_cast<char *>("--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] = const_cast<char *>("--target"); + args[1] = const_cast<char*>("--target"); gpr_join_host_port(&args[2], "127.0.0.1", port); - args[3] = const_cast<char *>("--scenario=ping-pong-stream"); - args[4] = const_cast<char *>("--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.cc b/test/core/fling/fling_test.cc index a7681d572a..1d4263ab01 100644 --- a/test/core/fling/fling_test.cc +++ 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, const char **argv) { - const char *me = argv[0]; - const 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, const char **argv) { /* start the server */ gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); - args[1] = const_cast<char *>("--bind"); + args[1] = const_cast<char*>("--bind"); gpr_join_host_port(&args[2], "::", port); - args[3] = const_cast<char *>("--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] = const_cast<char *>("--target"); + args[1] = const_cast<char*>("--target"); gpr_join_host_port(&args[2], "127.0.0.1", port); - args[3] = const_cast<char *>("--scenario=ping-pong-request"); - args[4] = const_cast<char *>("--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.cc b/test/core/fling/server.cc index 34e5f79f0b..4dfb30f107 100644 --- a/test/core/fling/server.cc +++ 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; - const 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 = static_cast<call_state *>(ev.tag); + s = static_cast<call_state*>(ev.tag); switch (ev.type) { case GRPC_OP_COMPLETE: switch ((intptr_t)s) { diff --git a/test/core/handshake/client_ssl.cc b/test/core/handshake/client_ssl.cc index f501948b96..b8cfd627a9 100644 --- a/test/core/handshake/client_ssl.cc +++ b/test/core/handshake/client_ssl.cc @@ -46,13 +46,13 @@ // Arguments for TLS server thread. typedef struct { int socket; - char *alpn_preferred; + char* alpn_preferred; } server_args; // Based on https://wiki.openssl.org/index.php/Simple_TLS_Server. // Pick an arbitrary unused port and return it in *out_port. Return // an fd>=0 on success. -static int create_socket(int *out_port) { +static int create_socket(int* out_port) { int s; struct sockaddr_in addr; socklen_t addr_len; @@ -68,7 +68,7 @@ static int create_socket(int *out_port) { return -1; } - if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + if (bind(s, (struct sockaddr*)&addr, sizeof(addr)) < 0) { perror("Unable to bind"); gpr_log(GPR_ERROR, "%s", "Unable to bind to any port"); close(s); @@ -82,7 +82,7 @@ static int create_socket(int *out_port) { } addr_len = sizeof(addr); - if (getsockname(s, (struct sockaddr *)&addr, &addr_len) != 0 || + if (getsockname(s, (struct sockaddr*)&addr, &addr_len) != 0 || addr_len > sizeof(addr)) { perror("getsockname"); gpr_log(GPR_ERROR, "%s", "Unable to get socket local address"); @@ -96,19 +96,19 @@ static int create_socket(int *out_port) { // Server callback during ALPN negotiation. See man page for // SSL_CTX_set_alpn_select_cb. -static int alpn_select_cb(SSL *ssl, const uint8_t **out, uint8_t *out_len, - const uint8_t *in, unsigned in_len, void *arg) { - const uint8_t *alpn_preferred = (const uint8_t *)arg; +static int alpn_select_cb(SSL* ssl, const uint8_t** out, uint8_t* out_len, + const uint8_t* in, unsigned in_len, void* arg) { + const uint8_t* alpn_preferred = (const uint8_t*)arg; *out = alpn_preferred; - *out_len = (uint8_t)strlen((char *)alpn_preferred); + *out_len = (uint8_t)strlen((char*)alpn_preferred); // Validate that the ALPN list includes "h2" and "grpc-exp", that "grpc-exp" // precedes "h2". bool grpc_exp_seen = false; bool h2_seen = false; - const char *inp = (const char *)in; - const char *in_end = inp + in_len; + const char* inp = (const char*)in; + const char* in_end = inp + in_len; while (inp < in_end) { const size_t length = (size_t)*inp++; if (length == strlen("grpc-exp") && strncmp(inp, "grpc-exp", length) == 0) { @@ -132,14 +132,14 @@ static int alpn_select_cb(SSL *ssl, const uint8_t **out, uint8_t *out_len, // Minimal TLS server. This is largely based on the example at // https://wiki.openssl.org/index.php/Simple_TLS_Server and the gRPC core // internals in src/core/tsi/ssl_transport_security.c. -static void server_thread(void *arg) { - const server_args *args = (server_args *)arg; +static void server_thread(void* arg) { + const server_args* args = (server_args*)arg; SSL_load_error_strings(); OpenSSL_add_ssl_algorithms(); - const SSL_METHOD *method = TLSv1_2_server_method(); - SSL_CTX *ctx = SSL_CTX_new(method); + const SSL_METHOD* method = TLSv1_2_server_method(); + SSL_CTX* ctx = SSL_CTX_new(method); if (!ctx) { perror("Unable to create SSL context"); ERR_print_errors_fp(stderr); @@ -158,7 +158,7 @@ static void server_thread(void *arg) { // Set the cipher list to match the one expressed in // src/core/tsi/ssl_transport_security.c. - const char *cipher_list = + const char* cipher_list = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-" "SHA384:ECDHE-RSA-AES256-GCM-SHA384"; if (!SSL_CTX_set_cipher_list(ctx, cipher_list)) { @@ -175,14 +175,14 @@ static void server_thread(void *arg) { gpr_log(GPR_INFO, "Server listening"); struct sockaddr_in addr; socklen_t len = sizeof(addr); - const int client = accept(sock, (struct sockaddr *)&addr, &len); + const int client = accept(sock, (struct sockaddr*)&addr, &len); if (client < 0) { perror("Unable to accept"); abort(); } // Establish a SSL* and accept at SSL layer. - SSL *ssl = SSL_new(ctx); + SSL* ssl = SSL_new(ctx); GPR_ASSERT(ssl); SSL_set_fd(ssl, client); if (SSL_accept(ssl) <= 0) { @@ -208,7 +208,7 @@ static void server_thread(void *arg) { // establishes a TLS handshake via the core library to the server. The TLS // server validates ALPN aspects of the handshake and supplies the protocol // specified in the server_alpn_preferred argument to the client. -static bool client_ssl_test(char *server_alpn_preferred) { +static bool client_ssl_test(char* server_alpn_preferred) { bool success = true; grpc_init(); @@ -242,24 +242,24 @@ static bool client_ssl_test(char *server_alpn_preferred) { grpc_load_file(SSL_CERT_PATH, 1, &cert_slice))); GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", grpc_load_file(SSL_KEY_PATH, 1, &key_slice))); - const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice); - pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice); - pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice); - grpc_channel_credentials *ssl_creds = + const char* ca_cert = (const char*)GRPC_SLICE_START_PTR(ca_slice); + pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice); + pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice); + grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(ca_cert, &pem_key_cert_pair, NULL); // Establish a channel pointing at the TLS server. Since the gRPC runtime is // lazy, this won't necessarily establish a connection yet. - char *target; + char* target; gpr_asprintf(&target, "127.0.0.1:%d", port); grpc_arg ssl_name_override = { GRPC_ARG_STRING, - const_cast<char *>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), - {const_cast<char *>("foo.test.google.fr")}}; + const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), + {const_cast<char*>("foo.test.google.fr")}}; grpc_channel_args grpc_args; grpc_args.num_args = 1; grpc_args.args = &ssl_name_override; - grpc_channel *channel = + grpc_channel* channel = grpc_secure_channel_create(ssl_creds, target, &grpc_args, NULL); GPR_ASSERT(channel); gpr_free(target); @@ -274,7 +274,7 @@ static bool client_ssl_test(char *server_alpn_preferred) { // completed and we know that the client's ALPN list satisfied the server. int retries = 10; grpc_connectivity_state state = GRPC_CHANNEL_IDLE; - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); while (state != GRPC_CHANNEL_READY && retries-- > 0) { grpc_channel_watch_connectivity_state( @@ -303,21 +303,21 @@ static bool client_ssl_test(char *server_alpn_preferred) { return success; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { // Handshake succeeeds when the server has grpc-exp as the ALPN preference. - GPR_ASSERT(client_ssl_test(const_cast<char *>("grpc-exp"))); + GPR_ASSERT(client_ssl_test(const_cast<char*>("grpc-exp"))); // Handshake succeeeds when the server has h2 as the ALPN preference. This // covers legacy gRPC servers which don't support grpc-exp. - GPR_ASSERT(client_ssl_test(const_cast<char *>("h2"))); + GPR_ASSERT(client_ssl_test(const_cast<char*>("h2"))); // Handshake fails when the server uses a fake protocol as its ALPN // preference. This validates the client is correctly validating ALPN returns // and sanity checks the client_ssl_test. - GPR_ASSERT(!client_ssl_test(const_cast<char *>("foo"))); + GPR_ASSERT(!client_ssl_test(const_cast<char*>("foo"))); return 0; } #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/handshake/server_ssl.cc b/test/core/handshake/server_ssl.cc index 7b24459688..bb92c8435a 100644 --- a/test/core/handshake/server_ssl.cc +++ b/test/core/handshake/server_ssl.cc @@ -55,7 +55,7 @@ static int create_socket(int port) { return -1; } - if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + if (connect(s, (struct sockaddr*)&addr, sizeof(addr)) < 0) { perror("Unable to connect"); return -1; } @@ -64,8 +64,8 @@ static int create_socket(int port) { } // Simple gRPC server. This listens until client_handshake_complete occurs. -static void server_thread(void *arg) { - const int port = *(int *)arg; +static void server_thread(void* arg) { + const int port = *(int*)arg; // Load key pair and establish server SSL credentials. grpc_ssl_pem_key_cert_pair pem_key_cert_pair; @@ -76,20 +76,20 @@ static void server_thread(void *arg) { grpc_load_file(SSL_CERT_PATH, 1, &cert_slice))); GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", grpc_load_file(SSL_KEY_PATH, 1, &key_slice))); - const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice); - pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice); - pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice); - grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create( + const char* ca_cert = (const char*)GRPC_SLICE_START_PTR(ca_slice); + pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice); + pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice); + grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create( ca_cert, &pem_key_cert_pair, 1, 0, NULL); // Start server listening on local port. - char *addr; + char* addr; gpr_asprintf(&addr, "127.0.0.1:%d", port); - grpc_server *server = grpc_server_create(NULL, NULL); + grpc_server* server = grpc_server_create(NULL, NULL); GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds)); free(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); @@ -123,8 +123,8 @@ static void server_thread(void *arg) { // TLS handshake via a minimal TLS client. The TLS client has configurable (via // alpn_list) ALPN settings and can probe at the supported ALPN preferences // using this (via alpn_expected). -static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len, - const char *alpn_expected) { +static bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len, + const char* alpn_expected) { bool success = true; grpc_init(); @@ -140,8 +140,8 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len, SSL_load_error_strings(); OpenSSL_add_ssl_algorithms(); - const SSL_METHOD *method = TLSv1_2_client_method(); - SSL_CTX *ctx = SSL_CTX_new(method); + const SSL_METHOD* method = TLSv1_2_client_method(); + SSL_CTX* ctx = SSL_CTX_new(method); if (!ctx) { perror("Unable to create SSL context"); ERR_print_errors_fp(stderr); @@ -160,7 +160,7 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len, // Set the cipher list to match the one expressed in // src/core/tsi/ssl_transport_security.c. - const char *cipher_list = + const char* cipher_list = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-" "SHA384:ECDHE-RSA-AES256-GCM-SHA384"; if (!SSL_CTX_set_cipher_list(ctx, cipher_list)) { @@ -175,9 +175,9 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len, for (unsigned int i = 0; i < alpn_list_len; ++i) { alpn_protos_len += (unsigned int)strlen(alpn_list[i]); } - unsigned char *alpn_protos = - static_cast<unsigned char *>(gpr_malloc(alpn_protos_len)); - unsigned char *p = alpn_protos; + unsigned char* alpn_protos = + static_cast<unsigned char*>(gpr_malloc(alpn_protos_len)); + unsigned char* p = alpn_protos; for (unsigned int i = 0; i < alpn_list_len; ++i) { const uint8_t len = (uint8_t)strlen(alpn_list[i]); *p++ = len; @@ -200,7 +200,7 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len, gpr_log(GPR_INFO, "Connected to server on port %d", port); // Establish a SSL* and connect at SSL layer. - SSL *ssl = SSL_new(ctx); + SSL* ssl = SSL_new(ctx); GPR_ASSERT(ssl); SSL_set_fd(ssl, sock); if (SSL_connect(ssl) <= 0) { @@ -210,12 +210,12 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len, } else { gpr_log(GPR_INFO, "Handshake successful."); // Validate ALPN preferred by server matches alpn_expected. - const unsigned char *alpn_selected; + const unsigned char* alpn_selected; unsigned int alpn_selected_len; SSL_get0_alpn_selected(ssl, &alpn_selected, &alpn_selected_len); if (strlen(alpn_expected) != alpn_selected_len || - strncmp((const char *)alpn_selected, alpn_expected, - alpn_selected_len) != 0) { + strncmp((const char*)alpn_selected, alpn_expected, alpn_selected_len) != + 0) { gpr_log(GPR_ERROR, "Unexpected ALPN protocol preference"); success = false; } @@ -235,22 +235,22 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len, return success; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { // Handshake succeeeds when the client supplies the standard ALPN list. - const char *full_alpn_list[] = {"grpc-exp", "h2"}; + const char* full_alpn_list[] = {"grpc-exp", "h2"}; GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp")); // Handshake succeeeds when the client supplies only h2 as the ALPN list. This // covers legacy gRPC clients which don't support grpc-exp. - const char *h2_only_alpn_list[] = {"h2"}; + const char* h2_only_alpn_list[] = {"h2"}; GPR_ASSERT(server_ssl_test(h2_only_alpn_list, 1, "h2")); // Handshake succeeds when the client supplies superfluous ALPN entries and // also when h2 precedes gprc-exp. - const char *extra_alpn_list[] = {"foo", "h2", "bar", "grpc-exp"}; + const char* extra_alpn_list[] = {"foo", "h2", "bar", "grpc-exp"}; GPR_ASSERT(server_ssl_test(extra_alpn_list, 4, "h2")); // Handshake fails when the client uses a fake protocol as its only ALPN // preference. This validates the server is correctly validating ALPN // and sanity checks the server_ssl_test. - const char *fake_alpn_list[] = {"foo"}; + const char* fake_alpn_list[] = {"foo"}; GPR_ASSERT(!server_ssl_test(fake_alpn_list, 1, "foo")); return 0; } diff --git a/test/core/http/format_request_test.cc b/test/core/http/format_request_test.cc index b2d903458d..253e59135d 100644 --- a/test/core/http/format_request_test.cc +++ b/test/core/http/format_request_test.cc @@ -24,14 +24,13 @@ #include "test/core/util/test_config.h" static void test_format_get_request(void) { - grpc_http_header hdr = {const_cast<char *>("x-yz"), - const_cast<char *>("abc")}; + grpc_http_header hdr = {const_cast<char*>("x-yz"), const_cast<char*>("abc")}; grpc_httpcli_request req; grpc_slice slice; memset(&req, 0, sizeof(req)); - req.host = const_cast<char *>("example.com"); - req.http.path = const_cast<char *>("/index.html"); + req.host = const_cast<char*>("example.com"); + req.http.path = const_cast<char*>("/index.html"); req.http.hdr_count = 1; req.http.hdrs = &hdr; @@ -50,16 +49,15 @@ static void test_format_get_request(void) { } static void test_format_post_request(void) { - grpc_http_header hdr = {const_cast<char *>("x-yz"), - const_cast<char *>("abc")}; + grpc_http_header hdr = {const_cast<char*>("x-yz"), const_cast<char*>("abc")}; grpc_httpcli_request req; grpc_slice slice; char body_bytes[] = "fake body"; size_t body_len = 9; memset(&req, 0, sizeof(req)); - req.host = const_cast<char *>("example.com"); - req.http.path = const_cast<char *>("/index.html"); + req.host = const_cast<char*>("example.com"); + req.http.path = const_cast<char*>("/index.html"); req.http.hdr_count = 1; req.http.hdrs = &hdr; @@ -81,14 +79,13 @@ static void test_format_post_request(void) { } static void test_format_post_request_no_body(void) { - grpc_http_header hdr = {const_cast<char *>("x-yz"), - const_cast<char *>("abc")}; + grpc_http_header hdr = {const_cast<char*>("x-yz"), const_cast<char*>("abc")}; grpc_httpcli_request req; grpc_slice slice; memset(&req, 0, sizeof(req)); - req.host = const_cast<char *>("example.com"); - req.http.path = const_cast<char *>("/index.html"); + req.host = const_cast<char*>("example.com"); + req.http.path = const_cast<char*>("/index.html"); req.http.hdr_count = 1; req.http.hdrs = &hdr; @@ -113,13 +110,13 @@ static void test_format_post_request_content_type_override(void) { char body_bytes[] = "fake%20body"; size_t body_len = 11; - hdrs[0].key = const_cast<char *>("x-yz"); - hdrs[0].value = const_cast<char *>("abc"); - hdrs[1].key = const_cast<char *>("Content-Type"); - hdrs[1].value = const_cast<char *>("application/x-www-form-urlencoded"); + hdrs[0].key = const_cast<char*>("x-yz"); + hdrs[0].value = const_cast<char*>("abc"); + hdrs[1].key = const_cast<char*>("Content-Type"); + hdrs[1].value = const_cast<char*>("application/x-www-form-urlencoded"); memset(&req, 0, sizeof(req)); - req.host = const_cast<char *>("example.com"); - req.http.path = const_cast<char *>("/index.html"); + req.host = const_cast<char*>("example.com"); + req.http.path = const_cast<char*>("/index.html"); req.http.hdr_count = 2; req.http.hdrs = hdrs; @@ -140,7 +137,7 @@ static void test_format_post_request_content_type_override(void) { grpc_slice_unref(slice); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_format_get_request(); diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc index 925f63decc..ac3c6a2ce5 100644 --- a/test/core/http/httpcli_test.cc +++ b/test/core/http/httpcli_test.cc @@ -32,7 +32,7 @@ static int g_done = 0; static grpc_httpcli_context g_context; -static gpr_mu *g_mu; +static gpr_mu* g_mu; static grpc_polling_entity g_pops; static grpc_millis n_seconds_time(int seconds) { @@ -40,11 +40,11 @@ static grpc_millis n_seconds_time(int seconds) { grpc_timeout_seconds_to_deadline(seconds)); } -static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - const char *expect = +static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + const char* expect = "<html><head><title>Hello world!</title></head>" "<body><p>This is a test</p></body></html>"; - grpc_http_response *response = static_cast<grpc_http_response *>(arg); + grpc_http_response* response = static_cast<grpc_http_response*>(arg); GPR_ASSERT(response); GPR_ASSERT(response->status == 200); GPR_ASSERT(response->body_length == strlen(expect)); @@ -59,7 +59,7 @@ static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { static void test_get(int port) { grpc_httpcli_request req; - char *host; + char* host; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; g_done = 0; @@ -70,12 +70,12 @@ static void test_get(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.http.path = const_cast<char *>("/get"); + req.http.path = const_cast<char*>("/get"); req.handshaker = &grpc_httpcli_plaintext; grpc_http_response response; memset(&response, 0, sizeof(response)); - grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get"); + grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get"); grpc_httpcli_get( &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15), GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx), @@ -83,7 +83,7 @@ static void test_get(int port) { grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); gpr_mu_lock(g_mu); while (!g_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops), @@ -99,7 +99,7 @@ static void test_get(int port) { static void test_post(int port) { grpc_httpcli_request req; - char *host; + char* host; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; g_done = 0; @@ -110,12 +110,12 @@ static void test_post(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.http.path = const_cast<char *>("/post"); + req.http.path = const_cast<char*>("/post"); req.handshaker = &grpc_httpcli_plaintext; grpc_http_response response; memset(&response, 0, sizeof(response)); - grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post"); + grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post"); grpc_httpcli_post( &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15), @@ -124,7 +124,7 @@ static void test_post(int port) { grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); gpr_mu_lock(g_mu); while (!g_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops), @@ -138,24 +138,24 @@ static void test_post(int port) { grpc_http_response_destroy(&response); } -static void destroy_pops(grpc_exec_ctx *exec_ctx, void *p, grpc_error *error) { +static void destroy_pops(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) { grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset( - static_cast<grpc_polling_entity *>(p))); + static_cast<grpc_polling_entity*>(p))); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_subprocess *server; - char *me = argv[0]; - char *lslash = strrchr(me, '/'); - char *args[4]; + gpr_subprocess* server; + char* me = argv[0]; + char* lslash = strrchr(me, '/'); + char* args[4]; int port = grpc_pick_unused_port_or_die(); int arg_shift = 0; /* figure out where we are */ - char *root; + char* root; if (lslash) { - root = static_cast<char *>(gpr_malloc((size_t)(lslash - me + 1))); + root = static_cast<char*>(gpr_malloc((size_t)(lslash - me + 1))); memcpy(root, me, (size_t)(lslash - me)); root[lslash - me] = 0; } else { @@ -172,9 +172,9 @@ int main(int argc, char **argv) { } /* start the server */ - args[1 + arg_shift] = const_cast<char *>("--port"); + args[1 + arg_shift] = const_cast<char*>("--port"); gpr_asprintf(&args[2 + arg_shift], "%d", port); - server = gpr_subprocess_create(3 + arg_shift, (const char **)args); + server = gpr_subprocess_create(3 + arg_shift, (const char**)args); GPR_ASSERT(server); gpr_free(args[0]); if (arg_shift) gpr_free(args[1]); @@ -187,8 +187,8 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); grpc_httpcli_context_init(&g_context); - grpc_pollset *pollset = - static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + grpc_pollset* pollset = + static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollset, &g_mu); g_pops = grpc_polling_entity_create_from_pollset(pollset); diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index 179b3a720b..bf851b1175 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -32,7 +32,7 @@ static int g_done = 0; static grpc_httpcli_context g_context; -static gpr_mu *g_mu; +static gpr_mu* g_mu; static grpc_polling_entity g_pops; static grpc_millis n_seconds_time(int seconds) { @@ -40,11 +40,11 @@ static grpc_millis n_seconds_time(int seconds) { grpc_timeout_seconds_to_deadline(seconds)); } -static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - const char *expect = +static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + const char* expect = "<html><head><title>Hello world!</title></head>" "<body><p>This is a test</p></body></html>"; - grpc_http_response *response = static_cast<grpc_http_response *>(arg); + grpc_http_response* response = static_cast<grpc_http_response*>(arg); GPR_ASSERT(response); GPR_ASSERT(response->status == 200); GPR_ASSERT(response->body_length == strlen(expect)); @@ -59,7 +59,7 @@ static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { static void test_get(int port) { grpc_httpcli_request req; - char *host; + char* host; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; g_done = 0; @@ -70,13 +70,13 @@ static void test_get(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.ssl_host_override = const_cast<char *>("foo.test.google.fr"); - req.http.path = const_cast<char *>("/get"); + req.ssl_host_override = const_cast<char*>("foo.test.google.fr"); + req.http.path = const_cast<char*>("/get"); req.handshaker = &grpc_httpcli_ssl; grpc_http_response response; memset(&response, 0, sizeof(response)); - grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get"); + grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get"); grpc_httpcli_get( &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15), GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx), @@ -84,7 +84,7 @@ static void test_get(int port) { grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); gpr_mu_lock(g_mu); while (!g_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops), @@ -100,7 +100,7 @@ static void test_get(int port) { static void test_post(int port) { grpc_httpcli_request req; - char *host; + char* host; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; g_done = 0; @@ -111,13 +111,13 @@ static void test_post(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.ssl_host_override = const_cast<char *>("foo.test.google.fr"); - req.http.path = const_cast<char *>("/post"); + req.ssl_host_override = const_cast<char*>("foo.test.google.fr"); + req.http.path = const_cast<char*>("/post"); req.handshaker = &grpc_httpcli_ssl; grpc_http_response response; memset(&response, 0, sizeof(response)); - grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post"); + grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post"); grpc_httpcli_post( &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15), @@ -126,7 +126,7 @@ static void test_post(int port) { grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); gpr_mu_lock(g_mu); while (!g_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops), @@ -140,24 +140,24 @@ static void test_post(int port) { grpc_http_response_destroy(&response); } -static void destroy_pops(grpc_exec_ctx *exec_ctx, void *p, grpc_error *error) { +static void destroy_pops(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) { grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset( - static_cast<grpc_polling_entity *>(p))); + static_cast<grpc_polling_entity*>(p))); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_subprocess *server; - char *me = argv[0]; - char *lslash = strrchr(me, '/'); - char *args[5]; + gpr_subprocess* server; + char* me = argv[0]; + char* lslash = strrchr(me, '/'); + char* args[5]; int port = grpc_pick_unused_port_or_die(); int arg_shift = 0; /* figure out where we are */ - char *root; + char* root; if (lslash) { - root = static_cast<char *>(gpr_malloc((size_t)(lslash - me + 1))); + root = static_cast<char*>(gpr_malloc((size_t)(lslash - me + 1))); memcpy(root, me, (size_t)(lslash - me)); root[lslash - me] = 0; } else { @@ -174,10 +174,10 @@ int main(int argc, char **argv) { } /* start the server */ - args[1 + arg_shift] = const_cast<char *>("--port"); + args[1 + arg_shift] = const_cast<char*>("--port"); gpr_asprintf(&args[2 + arg_shift], "%d", port); - args[3 + arg_shift] = const_cast<char *>("--ssl"); - server = gpr_subprocess_create(4 + arg_shift, (const char **)args); + args[3 + arg_shift] = const_cast<char*>("--ssl"); + server = gpr_subprocess_create(4 + arg_shift, (const char**)args); GPR_ASSERT(server); gpr_free(args[0]); if (arg_shift) gpr_free(args[1]); @@ -190,8 +190,8 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); grpc_httpcli_context_init(&g_context); - grpc_pollset *pollset = - static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + grpc_pollset* pollset = + static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollset, &g_mu); g_pops = grpc_polling_entity_create_from_pollset(pollset); diff --git a/test/core/http/parser_test.cc b/test/core/http/parser_test.cc index 9eff49122c..d0d2559cdf 100644 --- a/test/core/http/parser_test.cc +++ b/test/core/http/parser_test.cc @@ -29,16 +29,16 @@ #include "test/core/util/test_config.h" static void test_request_succeeds(grpc_slice_split_mode split_mode, - const char *request_text, - const char *expect_method, + const char* request_text, + const char* expect_method, grpc_http_version expect_version, - const char *expect_path, - const char *expect_body, ...) { + const char* expect_path, + const char* expect_body, ...) { grpc_http_parser parser; grpc_slice input_slice = grpc_slice_from_copied_string(request_text); size_t num_slices; size_t i; - grpc_slice *slices; + grpc_slice* slices; va_list args; grpc_http_request request; memset(&request, 0, sizeof(request)); @@ -70,12 +70,12 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode, va_start(args, expect_body); i = 0; for (;;) { - char *expect_key; - char *expect_value; - expect_key = va_arg(args, char *); + char* expect_key; + char* expect_value; + expect_key = va_arg(args, char*); if (!expect_key) break; GPR_ASSERT(i < request.hdr_count); - expect_value = va_arg(args, char *); + expect_value = va_arg(args, char*); GPR_ASSERT(expect_value); GPR_ASSERT(0 == strcmp(expect_key, request.hdrs[i].key)); GPR_ASSERT(0 == strcmp(expect_value, request.hdrs[i].value)); @@ -90,13 +90,13 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode, } static void test_succeeds(grpc_slice_split_mode split_mode, - const char *response_text, int expect_status, - const char *expect_body, ...) { + const char* response_text, int expect_status, + const char* expect_body, ...) { grpc_http_parser parser; grpc_slice input_slice = grpc_slice_from_copied_string(response_text); size_t num_slices; size_t i; - grpc_slice *slices; + grpc_slice* slices; va_list args; grpc_http_response response; memset(&response, 0, sizeof(response)); @@ -125,12 +125,12 @@ static void test_succeeds(grpc_slice_split_mode split_mode, va_start(args, expect_body); i = 0; for (;;) { - char *expect_key; - char *expect_value; - expect_key = va_arg(args, char *); + char* expect_key; + char* expect_value; + expect_key = va_arg(args, char*); if (!expect_key) break; GPR_ASSERT(i < response.hdr_count); - expect_value = va_arg(args, char *); + expect_value = va_arg(args, char*); GPR_ASSERT(expect_value); GPR_ASSERT(0 == strcmp(expect_key, response.hdrs[i].key)); GPR_ASSERT(0 == strcmp(expect_value, response.hdrs[i].value)); @@ -145,13 +145,13 @@ static void test_succeeds(grpc_slice_split_mode split_mode, } static void test_fails(grpc_slice_split_mode split_mode, - const char *response_text) { + const char* response_text) { grpc_http_parser parser; grpc_slice input_slice = grpc_slice_from_copied_string(response_text); size_t num_slices; size_t i; - grpc_slice *slices; - grpc_error *error = GRPC_ERROR_NONE; + grpc_slice* slices; + grpc_error* error = GRPC_ERROR_NONE; grpc_http_response response; memset(&response, 0, sizeof(response)); @@ -178,13 +178,13 @@ static void test_fails(grpc_slice_split_mode split_mode, } static void test_request_fails(grpc_slice_split_mode split_mode, - const char *request_text) { + const char* request_text) { grpc_http_parser parser; grpc_slice input_slice = grpc_slice_from_copied_string(request_text); size_t num_slices; size_t i; - grpc_slice *slices; - grpc_error *error = GRPC_ERROR_NONE; + grpc_slice* slices; + grpc_error* error = GRPC_ERROR_NONE; grpc_http_request request; memset(&request, 0, sizeof(request)); @@ -210,7 +210,7 @@ static void test_request_fails(grpc_slice_split_mode split_mode, gpr_free(slices); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; const grpc_slice_split_mode split_modes[] = {GRPC_SLICE_SPLIT_IDENTITY, GRPC_SLICE_SPLIT_ONE_BYTE}; @@ -291,7 +291,7 @@ int main(int argc, char **argv) { test_request_fails(split_modes[i], "GET / HTTP/1.0\n"); tmp1 = - static_cast<char *>(gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH)); + static_cast<char*>(gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH)); memset(tmp1, 'a', 2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1); tmp1[2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1] = 0; gpr_asprintf(&tmp2, "HTTP/1.0 200 OK\r\nxyz: %s\r\n\r\n", tmp1); diff --git a/test/core/http/request_fuzzer.cc b/test/core/http/request_fuzzer.cc index 8677fd213a..dfdb5792ac 100644 --- a/test/core/http/request_fuzzer.cc +++ b/test/core/http/request_fuzzer.cc @@ -27,12 +27,12 @@ bool squelch = true; bool leak_check = true; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_http_parser parser; grpc_http_request request; memset(&request, 0, sizeof(request)); grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request); - grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); + grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL)); GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser)); grpc_slice_unref(slice); diff --git a/test/core/http/response_fuzzer.cc b/test/core/http/response_fuzzer.cc index e84353f45c..89ee676b49 100644 --- a/test/core/http/response_fuzzer.cc +++ b/test/core/http/response_fuzzer.cc @@ -26,12 +26,12 @@ bool squelch = true; bool leak_check = true; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_http_parser parser; grpc_http_response response; memset(&response, 0, sizeof(response)); grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response); - grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); + grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL)); GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser)); grpc_slice_unref(slice); diff --git a/test/core/iomgr/combiner_test.cc b/test/core/iomgr/combiner_test.cc index 7d2d098d2b..5a825368f7 100644 --- a/test/core/iomgr/combiner_test.cc +++ b/test/core/iomgr/combiner_test.cc @@ -33,15 +33,15 @@ static void test_no_op(void) { grpc_exec_ctx_finish(&exec_ctx); } -static void set_event_to_true(grpc_exec_ctx *exec_ctx, void *value, - grpc_error *error) { - gpr_event_set(static_cast<gpr_event *>(value), (void *)1); +static void set_event_to_true(grpc_exec_ctx* exec_ctx, void* value, + grpc_error* error) { + gpr_event_set(static_cast<gpr_event*>(value), (void*)1); } static void test_execute_one(void) { gpr_log(GPR_DEBUG, "test_execute_one"); - grpc_combiner *lock = grpc_combiner_create(); + grpc_combiner* lock = grpc_combiner_create(); gpr_event done; gpr_event_init(&done); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -58,29 +58,29 @@ static void test_execute_one(void) { typedef struct { size_t ctr; - grpc_combiner *lock; + grpc_combiner* lock; gpr_event done; } thd_args; typedef struct { - size_t *ctr; + size_t* ctr; size_t value; } ex_args; -static void check_one(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) { - ex_args *args = static_cast<ex_args *>(a); +static void check_one(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) { + ex_args* args = static_cast<ex_args*>(a); GPR_ASSERT(*args->ctr == args->value - 1); *args->ctr = args->value; gpr_free(a); } -static void execute_many_loop(void *a) { - thd_args *args = static_cast<thd_args *>(a); +static void execute_many_loop(void* a) { + thd_args* args = static_cast<thd_args*>(a); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; size_t n = 1; for (size_t i = 0; i < 10; i++) { for (size_t j = 0; j < 10000; j++) { - ex_args *c = static_cast<ex_args *>(gpr_malloc(sizeof(*c))); + ex_args* c = static_cast<ex_args*>(gpr_malloc(sizeof(*c))); c->ctr = &args->ctr; c->value = n++; GRPC_CLOSURE_SCHED(&exec_ctx, @@ -103,7 +103,7 @@ static void execute_many_loop(void *a) { static void test_execute_many(void) { gpr_log(GPR_DEBUG, "test_execute_many"); - grpc_combiner *lock = grpc_combiner_create(); + grpc_combiner* lock = grpc_combiner_create(); gpr_thd_id thds[100]; thd_args ta[GPR_ARRAY_SIZE(thds)]; for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { @@ -126,22 +126,22 @@ static void test_execute_many(void) { static gpr_event got_in_finally; -static void in_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - gpr_event_set(&got_in_finally, (void *)1); +static void in_finally(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + gpr_event_set(&got_in_finally, (void*)1); } -static void add_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - GRPC_CLOSURE_SCHED( - exec_ctx, GRPC_CLOSURE_CREATE(in_finally, arg, - grpc_combiner_finally_scheduler( - static_cast<grpc_combiner *>(arg))), - GRPC_ERROR_NONE); +static void add_finally(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + GRPC_CLOSURE_SCHED(exec_ctx, + GRPC_CLOSURE_CREATE(in_finally, arg, + grpc_combiner_finally_scheduler( + static_cast<grpc_combiner*>(arg))), + GRPC_ERROR_NONE); } static void test_execute_finally(void) { gpr_log(GPR_DEBUG, "test_execute_finally"); - grpc_combiner *lock = grpc_combiner_create(); + grpc_combiner* lock = grpc_combiner_create(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_event_init(&got_in_finally); GRPC_CLOSURE_SCHED( @@ -155,7 +155,7 @@ static void test_execute_finally(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_no_op(); diff --git a/test/core/iomgr/endpoint_pair_test.cc b/test/core/iomgr/endpoint_pair_test.cc index c7ce6c0419..30a0cb5924 100644 --- a/test/core/iomgr/endpoint_pair_test.cc +++ b/test/core/iomgr/endpoint_pair_test.cc @@ -25,8 +25,8 @@ #include "test/core/iomgr/endpoint_tests.h" #include "test/core/util/test_config.h" -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static void clean_up(void) {} @@ -35,7 +35,7 @@ static grpc_endpoint_test_fixture create_fixture_endpoint_pair( grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_endpoint_test_fixture f; grpc_arg a[1]; - a[0].key = const_cast<char *>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); a[0].type = GRPC_ARG_INTEGER; a[0].value.integer = (int)slice_size; grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; @@ -54,17 +54,17 @@ static grpc_endpoint_test_config configs[] = { {"tcp/tcp_socketpair", create_fixture_endpoint_pair, clean_up}, }; -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset *>(p)); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); grpc_endpoint_tests(configs[0], g_pollset, g_mu); GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset, diff --git a/test/core/iomgr/endpoint_tests.cc b/test/core/iomgr/endpoint_tests.cc index 61e901f645..8e859ba909 100644 --- a/test/core/iomgr/endpoint_tests.cc +++ b/test/core/iomgr/endpoint_tests.cc @@ -46,14 +46,14 @@ */ -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; -size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) { +size_t count_slices(grpc_slice* slices, size_t nslices, int* current_data) { size_t num_bytes = 0; size_t i; size_t j; - unsigned char *buf; + unsigned char* buf; for (i = 0; i < nslices; ++i) { buf = GRPC_SLICE_START_PTR(slices[i]); for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { @@ -66,7 +66,7 @@ size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) { } static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config, - const char *test_name, + const char* test_name, size_t slice_size) { gpr_log(GPR_INFO, "%s/%s", test_name, config.name); return config.create_fixture(slice_size); @@ -74,14 +74,14 @@ static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config, static void end_test(grpc_endpoint_test_config config) { config.clean_up(); } -static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, - size_t *num_blocks, uint8_t *current_data) { +static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size, + size_t* num_blocks, uint8_t* current_data) { size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0); - grpc_slice *slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * nslices); + grpc_slice* slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * nslices); size_t num_bytes_left = num_bytes; size_t i; size_t j; - unsigned char *buf; + unsigned char* buf; *num_blocks = nslices; for (i = 0; i < nslices; ++i) { @@ -99,8 +99,8 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, } struct read_and_write_test_state { - grpc_endpoint *read_ep; - grpc_endpoint *write_ep; + grpc_endpoint* read_ep; + grpc_endpoint* write_ep; size_t target_bytes; size_t bytes_read; size_t current_write_size; @@ -115,10 +115,10 @@ struct read_and_write_test_state { grpc_closure done_write; }; -static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx, - void *data, grpc_error *error) { - struct read_and_write_test_state *state = - (struct read_and_write_test_state *)data; +static void read_and_write_test_read_handler(grpc_exec_ctx* exec_ctx, + void* data, grpc_error* error) { + struct read_and_write_test_state* state = + (struct read_and_write_test_state*)data; state->bytes_read += count_slices( state->incoming.slices, state->incoming.count, &state->current_read_data); @@ -135,11 +135,11 @@ static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx, } } -static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx, - void *data, grpc_error *error) { - struct read_and_write_test_state *state = - (struct read_and_write_test_state *)data; - grpc_slice *slices = NULL; +static void read_and_write_test_write_handler(grpc_exec_ctx* exec_ctx, + void* data, grpc_error* error) { + struct read_and_write_test_state* state = + (struct read_and_write_test_state*)data; + grpc_slice* slices = NULL; size_t nslices; if (error == GRPC_ERROR_NONE) { @@ -181,15 +181,17 @@ static void read_and_write_test(grpc_endpoint_test_config config, grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20)); - gpr_log(GPR_DEBUG, "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR - " slice_size=%" PRIuPTR " shutdown=%d", + gpr_log(GPR_DEBUG, + "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR " slice_size=%" PRIuPTR + " shutdown=%d", num_bytes, write_size, slice_size, shutdown); if (shutdown) { gpr_log(GPR_INFO, "Start read and write shutdown test"); } else { - gpr_log(GPR_INFO, "Start read and write test with %" PRIuPTR - " bytes, slice size %" PRIuPTR, + gpr_log(GPR_INFO, + "Start read and write test with %" PRIuPTR + " bytes, slice size %" PRIuPTR, num_bytes, slice_size); } @@ -235,7 +237,7 @@ static void read_and_write_test(grpc_endpoint_test_config config, gpr_mu_lock(g_mu); while (!state.read_done || !state.write_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(grpc_exec_ctx_now(&exec_ctx) < deadline); GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", @@ -252,16 +254,16 @@ static void read_and_write_test(grpc_endpoint_test_config config, grpc_exec_ctx_finish(&exec_ctx); } -static void inc_on_failure(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void inc_on_failure(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { gpr_mu_lock(g_mu); - *(int *)arg += (error != GRPC_ERROR_NONE); + *(int*)arg += (error != GRPC_ERROR_NONE); GPR_ASSERT( GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(exec_ctx, g_pollset, NULL))); gpr_mu_unlock(g_mu); } -static void wait_for_fail_count(grpc_exec_ctx *exec_ctx, int *fail_count, +static void wait_for_fail_count(grpc_exec_ctx* exec_ctx, int* fail_count, int want_fail_count) { grpc_exec_ctx_flush(exec_ctx); gpr_mu_lock(g_mu); @@ -269,7 +271,7 @@ static void wait_for_fail_count(grpc_exec_ctx *exec_ctx, int *fail_count, grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); while (grpc_exec_ctx_now(exec_ctx) < deadline && *fail_count < want_fail_count) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline))); @@ -319,7 +321,7 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) { } void grpc_endpoint_tests(grpc_endpoint_test_config config, - grpc_pollset *pollset, gpr_mu *mu) { + grpc_pollset* pollset, gpr_mu* mu) { size_t i; g_pollset = pollset; g_mu = mu; diff --git a/test/core/iomgr/endpoint_tests.h b/test/core/iomgr/endpoint_tests.h index def29d3224..227eeb997c 100644 --- a/test/core/iomgr/endpoint_tests.h +++ b/test/core/iomgr/endpoint_tests.h @@ -27,17 +27,17 @@ typedef struct grpc_endpoint_test_config grpc_endpoint_test_config; typedef struct grpc_endpoint_test_fixture grpc_endpoint_test_fixture; struct grpc_endpoint_test_fixture { - grpc_endpoint *client_ep; - grpc_endpoint *server_ep; + grpc_endpoint* client_ep; + grpc_endpoint* server_ep; }; struct grpc_endpoint_test_config { - const char *name; + const char* name; grpc_endpoint_test_fixture (*create_fixture)(size_t slice_size); void (*clean_up)(); }; void grpc_endpoint_tests(grpc_endpoint_test_config config, - grpc_pollset *pollset, gpr_mu *mu); + grpc_pollset* pollset, gpr_mu* mu); #endif /* GRPC_TEST_CORE_IOMGR_ENDPOINT_TESTS_H */ diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc index 23079c12c6..3ee607d97e 100644 --- a/test/core/iomgr/ev_epollsig_linux_test.cc +++ b/test/core/iomgr/ev_epollsig_linux_test.cc @@ -36,17 +36,17 @@ #include "test/core/util/test_config.h" typedef struct test_pollset { - grpc_pollset *pollset; - gpr_mu *mu; + grpc_pollset* pollset; + gpr_mu* mu; } test_pollset; typedef struct test_fd { int inner_fd; - grpc_fd *fd; + grpc_fd* fd; } test_fd; /* num_fds should be an even number */ -static void test_fd_init(test_fd *tfds, int *fds, int num_fds) { +static void test_fd_init(test_fd* tfds, int* fds, int num_fds) { int i; int r; @@ -70,7 +70,7 @@ static void test_fd_init(test_fd *tfds, int *fds, int num_fds) { } } -static void test_fd_cleanup(grpc_exec_ctx *exec_ctx, test_fd *tfds, +static void test_fd_cleanup(grpc_exec_ctx* exec_ctx, test_fd* tfds, int num_fds) { int release_fd; int i; @@ -89,22 +89,22 @@ static void test_fd_cleanup(grpc_exec_ctx *exec_ctx, test_fd *tfds, } } -static void test_pollset_init(test_pollset *pollsets, int num_pollsets) { +static void test_pollset_init(test_pollset* pollsets, int num_pollsets) { int i; for (i = 0; i < num_pollsets; i++) { pollsets[i].pollset = - static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollsets[i].pollset, &pollsets[i].mu); } } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, (grpc_pollset *)p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p); } -static void test_pollset_cleanup(grpc_exec_ctx *exec_ctx, - test_pollset *pollsets, int num_pollsets) { +static void test_pollset_cleanup(grpc_exec_ctx* exec_ctx, + test_pollset* pollsets, int num_pollsets) { grpc_closure destroyed; int i; @@ -118,16 +118,16 @@ static void test_pollset_cleanup(grpc_exec_ctx *exec_ctx, } } -/* - * Cases to test: - * case 1) Polling islands of both fd and pollset are NULL - * case 2) Polling island of fd is NULL but that of pollset is not-NULL - * case 3) Polling island of fd is not-NULL but that of pollset is NULL - * case 4) Polling islands of both fd and pollset are not-NULL and: - * case 4.1) Polling islands of fd and pollset are equal - * case 4.2) Polling islands of fd and pollset are NOT-equal (This results - * in a merge) - * */ + /* + * Cases to test: + * case 1) Polling islands of both fd and pollset are NULL + * case 2) Polling island of fd is NULL but that of pollset is not-NULL + * case 3) Polling island of fd is not-NULL but that of pollset is NULL + * case 4) Polling islands of both fd and pollset are not-NULL and: + * case 4.1) Polling islands of fd and pollset are equal + * case 4.2) Polling islands of fd and pollset are NOT-equal (This results + * in a merge) + * */ #define NUM_FDS 8 #define NUM_POLLSETS 4 @@ -137,7 +137,7 @@ static void test_add_fd_to_pollset() { test_fd tfds[NUM_FDS]; int fds[NUM_FDS]; test_pollset pollsets[NUM_POLLSETS]; - void *expected_pi = NULL; + void* expected_pi = NULL; int i; test_fd_init(tfds, fds, NUM_FDS); @@ -222,21 +222,21 @@ static void test_add_fd_to_pollset() { #undef NUM_POLLSETS typedef struct threading_shared { - gpr_mu *mu; - grpc_pollset *pollset; - grpc_wakeup_fd *wakeup_fd; - grpc_fd *wakeup_desc; + gpr_mu* mu; + grpc_pollset* pollset; + grpc_wakeup_fd* wakeup_fd; + grpc_fd* wakeup_desc; grpc_closure on_wakeup; int wakeups; } threading_shared; static __thread int thread_wakeups = 0; -static void test_threading_loop(void *arg) { - threading_shared *shared = static_cast<threading_shared *>(arg); +static void test_threading_loop(void* arg) { + threading_shared* shared = static_cast<threading_shared*>(arg); while (thread_wakeups < 1000000) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker; + grpc_pollset_worker* worker; gpr_mu_lock(shared->mu); GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, shared->pollset, &worker, @@ -246,9 +246,9 @@ static void test_threading_loop(void *arg) { } } -static void test_threading_wakeup(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - threading_shared *shared = static_cast<threading_shared *>(arg); +static void test_threading_wakeup(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + threading_shared* shared = static_cast<threading_shared*>(arg); ++shared->wakeups; ++thread_wakeups; if (error == GRPC_ERROR_NONE) { @@ -262,7 +262,7 @@ static void test_threading_wakeup(grpc_exec_ctx *exec_ctx, void *arg, static void test_threading(void) { threading_shared shared; - shared.pollset = static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + shared.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(shared.pollset, &shared.mu); gpr_thd_id thds[10]; @@ -305,8 +305,8 @@ static void test_threading(void) { gpr_free(shared.pollset); } -int main(int argc, char **argv) { - const char *poll_strategy = NULL; +int main(int argc, char** argv) { + const char* poll_strategy = NULL; grpc_test_init(argc, argv); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -326,6 +326,6 @@ int main(int argc, char **argv) { grpc_shutdown(); return 0; } -#else /* defined(GRPC_LINUX_EPOLL) */ -int main(int argc, char **argv) { return 0; } +#else /* defined(GRPC_LINUX_EPOLL) */ +int main(int argc, char** argv) { return 0; } #endif /* !defined(GRPC_LINUX_EPOLL) */ diff --git a/test/core/iomgr/fd_conservation_posix_test.cc b/test/core/iomgr/fd_conservation_posix_test.cc index d29b1e8e41..b76c247fb8 100644 --- a/test/core/iomgr/fd_conservation_posix_test.cc +++ b/test/core/iomgr/fd_conservation_posix_test.cc @@ -24,7 +24,7 @@ #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" -int main(int argc, char **argv) { +int main(int argc, char** argv) { int i; struct rlimit rlim; grpc_endpoint_pair p; @@ -38,7 +38,7 @@ int main(int argc, char **argv) { of descriptors */ rlim.rlim_cur = rlim.rlim_max = 10; GPR_ASSERT(0 == setrlimit(RLIMIT_NOFILE, &rlim)); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("fd_conservation_posix_test"); for (i = 0; i < 100; i++) { diff --git a/test/core/iomgr/fd_posix_test.cc b/test/core/iomgr/fd_posix_test.cc index 63363a43a5..c70187ce91 100644 --- a/test/core/iomgr/fd_posix_test.cc +++ b/test/core/iomgr/fd_posix_test.cc @@ -46,8 +46,8 @@ #include "src/core/lib/iomgr/socket_utils_posix.h" #include "test/core/util/test_config.h" -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; /* buffer size used to send and receive data. 1024 is the minimal value to set TCP send and receive buffer. */ @@ -56,8 +56,8 @@ static grpc_pollset *g_pollset; /* Create a test socket with the right properties for testing. port is the TCP port to listen or connect to. Return a socket FD and sockaddr_in. */ -static void create_test_socket(int port, int *socket_fd, - struct sockaddr_in *sin) { +static void create_test_socket(int port, int* socket_fd, + struct sockaddr_in* sin) { int fd; int one = 1; int buffer_size_bytes = BUF_SIZE; @@ -82,20 +82,20 @@ static void create_test_socket(int port, int *socket_fd, } /* Dummy gRPC callback */ -void no_op_cb(void *arg, int success) {} +void no_op_cb(void* arg, int success) {} /* =======An upload server to test notify_on_read=========== The server simply reads and counts a stream of bytes. */ /* An upload server. */ typedef struct { - grpc_fd *em_fd; /* listening fd */ + grpc_fd* em_fd; /* listening fd */ ssize_t read_bytes_total; /* total number of received bytes */ int done; /* set to 1 when a server finishes serving */ grpc_closure listen_closure; } server; -static void server_init(server *sv) { +static void server_init(server* sv) { sv->read_bytes_total = 0; sv->done = 0; } @@ -103,18 +103,18 @@ static void server_init(server *sv) { /* An upload session. Created when a new upload request arrives in the server. */ typedef struct { - server *sv; /* not owned by a single session */ - grpc_fd *em_fd; /* fd to read upload bytes */ + server* sv; /* not owned by a single session */ + grpc_fd* em_fd; /* fd to read upload bytes */ char read_buf[BUF_SIZE]; /* buffer to store upload bytes */ grpc_closure session_read_closure; } session; /* Called when an upload session can be safely shutdown. Close session FD and start to shutdown listen FD. */ -static void session_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */ +static void session_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */ bool success) { - session *se = static_cast<session *>(arg); - server *sv = se->sv; + session* se = static_cast<session*>(arg); + server* sv = se->sv; grpc_fd_orphan(exec_ctx, se->em_fd, NULL, NULL, false /* already_closed */, "a"); gpr_free(se); @@ -124,9 +124,9 @@ static void session_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */ } /* Called when data become readable in a session. */ -static void session_read_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */ - grpc_error *error) { - session *se = static_cast<session *>(arg); +static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */ + grpc_error* error) { + session* se = static_cast<session*>(arg); int fd = grpc_fd_wrapped_fd(se->em_fd); ssize_t read_once = 0; @@ -169,9 +169,9 @@ static void session_read_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */ /* Called when the listen FD can be safely shutdown. Close listen FD and signal that server can be shutdown. */ -static void listen_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg /*server */, +static void listen_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg /*server */, int success) { - server *sv = static_cast<server *>(arg); + server* sv = static_cast<server*>(arg); grpc_fd_orphan(exec_ctx, sv->em_fd, NULL, NULL, false /* already_closed */, "b"); @@ -184,27 +184,27 @@ static void listen_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg /*server */, } /* Called when a new TCP connection request arrives in the listening port. */ -static void listen_cb(grpc_exec_ctx *exec_ctx, void *arg, /*=sv_arg*/ - grpc_error *error) { - server *sv = static_cast<server *>(arg); +static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/ + grpc_error* error) { + server* sv = static_cast<server*>(arg); int fd; int flags; - session *se; + session* se; struct sockaddr_storage ss; socklen_t slen = sizeof(ss); - grpc_fd *listen_em_fd = sv->em_fd; + grpc_fd* listen_em_fd = sv->em_fd; if (error != GRPC_ERROR_NONE) { listen_shutdown_cb(exec_ctx, arg, 1); return; } - fd = accept(grpc_fd_wrapped_fd(listen_em_fd), (struct sockaddr *)&ss, &slen); + fd = accept(grpc_fd_wrapped_fd(listen_em_fd), (struct sockaddr*)&ss, &slen); GPR_ASSERT(fd >= 0); GPR_ASSERT(fd < FD_SETSIZE); flags = fcntl(fd, F_GETFL, 0); fcntl(fd, F_SETFL, flags | O_NONBLOCK); - se = static_cast<session *>(gpr_malloc(sizeof(*se))); + se = static_cast<session*>(gpr_malloc(sizeof(*se))); se->sv = sv; se->em_fd = grpc_fd_create(fd, "listener"); grpc_pollset_add_fd(exec_ctx, g_pollset, se->em_fd); @@ -222,7 +222,7 @@ static void listen_cb(grpc_exec_ctx *exec_ctx, void *arg, /*=sv_arg*/ listen_cb() is registered to be interested in reading from listen_fd. When connection request arrives, listen_cb() is called to accept the connection request. */ -static int server_start(grpc_exec_ctx *exec_ctx, server *sv) { +static int server_start(grpc_exec_ctx* exec_ctx, server* sv) { int port = 0; int fd; struct sockaddr_in sin; @@ -230,8 +230,8 @@ static int server_start(grpc_exec_ctx *exec_ctx, server *sv) { create_test_socket(port, &fd, &sin); addr_len = sizeof(sin); - GPR_ASSERT(bind(fd, (struct sockaddr *)&sin, addr_len) == 0); - GPR_ASSERT(getsockname(fd, (struct sockaddr *)&sin, &addr_len) == 0); + GPR_ASSERT(bind(fd, (struct sockaddr*)&sin, addr_len) == 0); + GPR_ASSERT(getsockname(fd, (struct sockaddr*)&sin, &addr_len) == 0); port = ntohs(sin.sin_port); GPR_ASSERT(listen(fd, MAX_NUM_FD) == 0); @@ -246,11 +246,11 @@ static int server_start(grpc_exec_ctx *exec_ctx, server *sv) { } /* Wait and shutdown a sever. */ -static void server_wait_and_shutdown(server *sv) { +static void server_wait_and_shutdown(server* sv) { gpr_mu_lock(g_mu); while (!sv->done) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, GRPC_MILLIS_INF_FUTURE))); @@ -270,7 +270,7 @@ static void server_wait_and_shutdown(server *sv) { /* An upload client. */ typedef struct { - grpc_fd *em_fd; + grpc_fd* em_fd; char write_buf[CLIENT_WRITE_BUF_SIZE]; ssize_t write_bytes_total; /* Number of times that the client fills up the write buffer and calls @@ -281,7 +281,7 @@ typedef struct { grpc_closure write_closure; } client; -static void client_init(client *cl) { +static void client_init(client* cl) { memset(cl->write_buf, 0, sizeof(cl->write_buf)); cl->write_bytes_total = 0; cl->client_write_cnt = 0; @@ -289,9 +289,9 @@ static void client_init(client *cl) { } /* Called when a client upload session is ready to shutdown. */ -static void client_session_shutdown_cb(grpc_exec_ctx *exec_ctx, - void *arg /*client */, int success) { - client *cl = static_cast<client *>(arg); +static void client_session_shutdown_cb(grpc_exec_ctx* exec_ctx, + void* arg /*client */, int success) { + client* cl = static_cast<client*>(arg); grpc_fd_orphan(exec_ctx, cl->em_fd, NULL, NULL, false /* already_closed */, "c"); cl->done = 1; @@ -300,9 +300,9 @@ static void client_session_shutdown_cb(grpc_exec_ctx *exec_ctx, } /* Write as much as possible, then register notify_on_write. */ -static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */ - grpc_error *error) { - client *cl = static_cast<client *>(arg); +static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */ + grpc_error* error) { + client* cl = static_cast<client*>(arg); int fd = grpc_fd_wrapped_fd(cl->em_fd); ssize_t write_once = 0; @@ -336,11 +336,11 @@ static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */ } /* Start a client to send a stream of bytes. */ -static void client_start(grpc_exec_ctx *exec_ctx, client *cl, int port) { +static void client_start(grpc_exec_ctx* exec_ctx, client* cl, int port) { int fd; struct sockaddr_in sin; create_test_socket(port, &fd, &sin); - if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) { + if (connect(fd, (struct sockaddr*)&sin, sizeof(sin)) == -1) { if (errno == EINPROGRESS) { struct pollfd pfd; pfd.fd = fd; @@ -363,10 +363,10 @@ static void client_start(grpc_exec_ctx *exec_ctx, client *cl, int port) { } /* Wait for the signal to shutdown a client. */ -static void client_wait_and_shutdown(client *cl) { +static void client_wait_and_shutdown(client* cl) { gpr_mu_lock(g_mu); while (!cl->done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, @@ -402,14 +402,14 @@ typedef struct fd_change_data { grpc_iomgr_cb_func cb_that_ran; } fd_change_data; -void init_change_data(fd_change_data *fdc) { fdc->cb_that_ran = NULL; } +void init_change_data(fd_change_data* fdc) { fdc->cb_that_ran = NULL; } -void destroy_change_data(fd_change_data *fdc) {} +void destroy_change_data(fd_change_data* fdc) {} -static void first_read_callback(grpc_exec_ctx *exec_ctx, - void *arg /* fd_change_data */, - grpc_error *error) { - fd_change_data *fdc = static_cast<fd_change_data *>(arg); +static void first_read_callback(grpc_exec_ctx* exec_ctx, + void* arg /* fd_change_data */, + grpc_error* error) { + fd_change_data* fdc = static_cast<fd_change_data*>(arg); gpr_mu_lock(g_mu); fdc->cb_that_ran = first_read_callback; @@ -418,10 +418,10 @@ static void first_read_callback(grpc_exec_ctx *exec_ctx, gpr_mu_unlock(g_mu); } -static void second_read_callback(grpc_exec_ctx *exec_ctx, - void *arg /* fd_change_data */, - grpc_error *error) { - fd_change_data *fdc = static_cast<fd_change_data *>(arg); +static void second_read_callback(grpc_exec_ctx* exec_ctx, + void* arg /* fd_change_data */, + grpc_error* error) { + fd_change_data* fdc = static_cast<fd_change_data*>(arg); gpr_mu_lock(g_mu); fdc->cb_that_ran = second_read_callback; @@ -435,7 +435,7 @@ static void second_read_callback(grpc_exec_ctx *exec_ctx, point is to have two different function pointers and two different data pointers and make sure that changing both really works. */ static void test_grpc_fd_change(void) { - grpc_fd *em_fd; + grpc_fd* em_fd; fd_change_data a, b; int flags; int sv[2]; @@ -471,7 +471,7 @@ static void test_grpc_fd_change(void) { /* And now wait for it to run. */ gpr_mu_lock(g_mu); while (a.cb_that_ran == NULL) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, GRPC_MILLIS_INF_FUTURE))); @@ -495,7 +495,7 @@ static void test_grpc_fd_change(void) { gpr_mu_lock(g_mu); while (b.cb_that_ran == NULL) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, GRPC_MILLIS_INF_FUTURE))); @@ -514,17 +514,17 @@ static void test_grpc_fd_change(void) { close(sv[1]); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset *>(p)); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); test_grpc_fd(); test_grpc_fd_change(); @@ -540,6 +540,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/load_file_test.cc b/test/core/iomgr/load_file_test.cc index 5fb8266b10..2c9e7c33f4 100644 --- a/test/core/iomgr/load_file_test.cc +++ b/test/core/iomgr/load_file_test.cc @@ -33,11 +33,11 @@ static const char prefix[] = "file_test"; static void test_load_empty_file(void) { - FILE *tmp = NULL; + FILE* tmp = NULL; grpc_slice slice; grpc_slice slice_with_null_term; - grpc_error *error; - char *tmp_name; + grpc_error* error; + char* tmp_name; LOG_TEST_NAME("test_load_empty_file"); @@ -62,10 +62,10 @@ static void test_load_empty_file(void) { } static void test_load_failure(void) { - FILE *tmp = NULL; + FILE* tmp = NULL; grpc_slice slice; - grpc_error *error; - char *tmp_name; + grpc_error* error; + char* tmp_name; LOG_TEST_NAME("test_load_failure"); @@ -84,12 +84,12 @@ static void test_load_failure(void) { } static void test_load_small_file(void) { - FILE *tmp = NULL; + FILE* tmp = NULL; grpc_slice slice; grpc_slice slice_with_null_term; - grpc_error *error; - char *tmp_name; - const char *blah = "blah"; + grpc_error* error; + char* tmp_name; + const char* blah = "blah"; LOG_TEST_NAME("test_load_small_file"); @@ -107,7 +107,7 @@ static void test_load_small_file(void) { error = grpc_load_file(tmp_name, 1, &slice_with_null_term); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1)); - GPR_ASSERT(strcmp((const char *)GRPC_SLICE_START_PTR(slice_with_null_term), + GPR_ASSERT(strcmp((const char*)GRPC_SLICE_START_PTR(slice_with_null_term), blah) == 0); remove(tmp_name); @@ -117,13 +117,13 @@ static void test_load_small_file(void) { } static void test_load_big_file(void) { - FILE *tmp = NULL; + FILE* tmp = NULL; grpc_slice slice; - grpc_error *error; - char *tmp_name; + grpc_error* error; + char* tmp_name; static const size_t buffer_size = 124631; - unsigned char *buffer = static_cast<unsigned char *>(gpr_malloc(buffer_size)); - unsigned char *current; + unsigned char* buffer = static_cast<unsigned char*>(gpr_malloc(buffer_size)); + unsigned char* current; size_t i; LOG_TEST_NAME("test_load_big_file"); @@ -150,7 +150,7 @@ static void test_load_big_file(void) { gpr_free(buffer); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_load_empty_file(); test_load_failure(); diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc index ae19c81d6d..8d0198cace 100644 --- a/test/core/iomgr/pollset_set_test.cc +++ b/test/core/iomgr/pollset_set_test.cc @@ -37,16 +37,18 @@ * test_pollset_set */ -typedef struct test_pollset_set { grpc_pollset_set *pss; } test_pollset_set; +typedef struct test_pollset_set { + grpc_pollset_set* pss; +} test_pollset_set; -void init_test_pollset_sets(test_pollset_set *pollset_sets, const int num_pss) { +void init_test_pollset_sets(test_pollset_set* pollset_sets, const int num_pss) { for (int i = 0; i < num_pss; i++) { pollset_sets[i].pss = grpc_pollset_set_create(); } } -void cleanup_test_pollset_sets(grpc_exec_ctx *exec_ctx, - test_pollset_set *pollset_sets, +void cleanup_test_pollset_sets(grpc_exec_ctx* exec_ctx, + test_pollset_set* pollset_sets, const int num_pss) { for (int i = 0; i < num_pss; i++) { grpc_pollset_set_destroy(exec_ctx, pollset_sets[i].pss); @@ -59,25 +61,25 @@ void cleanup_test_pollset_sets(grpc_exec_ctx *exec_ctx, */ typedef struct test_pollset { - grpc_pollset *ps; - gpr_mu *mu; + grpc_pollset* ps; + gpr_mu* mu; } test_pollset; -static void init_test_pollsets(test_pollset *pollsets, const int num_pollsets) { +static void init_test_pollsets(test_pollset* pollsets, const int num_pollsets) { for (int i = 0; i < num_pollsets; i++) { pollsets[i].ps = - static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollsets[i].ps, &pollsets[i].mu); } } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset *>(p)); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx, - test_pollset *pollsets, +static void cleanup_test_pollsets(grpc_exec_ctx* exec_ctx, + test_pollset* pollsets, const int num_pollsets) { grpc_closure destroyed; for (int i = 0; i < num_pollsets; i++) { @@ -96,18 +98,18 @@ static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx, */ typedef struct test_fd { - grpc_fd *fd; + grpc_fd* fd; grpc_wakeup_fd wakeup_fd; bool is_on_readable_called; /* Is on_readable closure is called ? */ grpc_closure on_readable; /* Closure to call when this fd is readable */ } test_fd; -void on_readable(grpc_exec_ctx *exec_ctx, void *tfd, grpc_error *error) { - ((test_fd *)tfd)->is_on_readable_called = true; +void on_readable(grpc_exec_ctx* exec_ctx, void* tfd, grpc_error* error) { + ((test_fd*)tfd)->is_on_readable_called = true; } -static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) { +static void reset_test_fd(grpc_exec_ctx* exec_ctx, test_fd* tfd) { tfd->is_on_readable_called = false; GRPC_CLOSURE_INIT(&tfd->on_readable, on_readable, tfd, @@ -115,7 +117,7 @@ static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) { grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable); } -static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, +static void init_test_fds(grpc_exec_ctx* exec_ctx, test_fd* tfds, const int num_fds) { for (int i = 0; i < num_fds; i++) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd)); @@ -125,7 +127,7 @@ static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, } } -static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, +static void cleanup_test_fds(grpc_exec_ctx* exec_ctx, test_fd* tfds, const int num_fds) { int release_fd; @@ -147,13 +149,13 @@ static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, } } -static void make_test_fds_readable(test_fd *tfds, const int num_fds) { +static void make_test_fds_readable(test_fd* tfds, const int num_fds) { for (int i = 0; i < num_fds; i++) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_wakeup(&tfds[i].wakeup_fd)); } } -static void verify_readable_and_reset(grpc_exec_ctx *exec_ctx, test_fd *tfds, +static void verify_readable_and_reset(grpc_exec_ctx* exec_ctx, test_fd* tfds, const int num_fds) { for (int i = 0; i < num_fds; i++) { /* Verify that the on_readable callback was called */ @@ -204,7 +206,7 @@ static void pollset_set_test_basic() { * +---> FD9 (Added after PS2 is added to PSS0) */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker; + grpc_pollset_worker* worker; grpc_millis deadline; test_fd tfds[10]; @@ -309,7 +311,7 @@ void pollset_set_test_dup_fds() { * +---> FD1 */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker; + grpc_pollset_worker* worker; grpc_millis deadline; test_fd tfds[3]; @@ -382,7 +384,7 @@ void pollset_set_test_empty_pollset() { * +---> FD2 */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker; + grpc_pollset_worker* worker; grpc_millis deadline; test_fd tfds[3]; @@ -431,11 +433,11 @@ void pollset_set_test_empty_pollset() { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - const char *poll_strategy = grpc_get_poll_strategy_name(); + const char* poll_strategy = grpc_get_poll_strategy_name(); if (poll_strategy != NULL && (strcmp(poll_strategy, "epollsig") == 0 || @@ -454,6 +456,6 @@ int main(int argc, char **argv) { grpc_shutdown(); return 0; } -#else /* defined(GRPC_LINUX_EPOLL) */ -int main(int argc, char **argv) { return 0; } +#else /* defined(GRPC_LINUX_EPOLL) */ +int main(int argc, char** argv) { return 0; } #endif /* !defined(GRPC_LINUX_EPOLL) */ diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc index 572b4222b5..ba89fc8ad5 100644 --- a/test/core/iomgr/resolve_address_posix_test.cc +++ b/test/core/iomgr/resolve_address_posix_test.cc @@ -39,25 +39,25 @@ static gpr_timespec test_deadline(void) { typedef struct args_struct { gpr_event ev; - grpc_resolved_addresses *addrs; + grpc_resolved_addresses* addrs; gpr_atm done_atm; - gpr_mu *mu; - grpc_pollset *pollset; - grpc_pollset_set *pollset_set; + gpr_mu* mu; + grpc_pollset* pollset; + grpc_pollset_set* pollset_set; } args_struct; -static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} +static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} -void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) { +void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) { gpr_event_init(&args->ev); - args->pollset = static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(args->pollset, &args->mu); args->pollset_set = grpc_pollset_set_create(); grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset); args->addrs = NULL; } -void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { +void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) { GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline())); grpc_resolved_addresses_destroy(args->addrs); grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset); @@ -77,8 +77,8 @@ static grpc_millis n_sec_deadline(int seconds) { grpc_timeout_seconds_to_deadline(seconds)); } -static void actually_poll(void *argsp) { - args_struct *args = static_cast<args_struct *>(argsp); +static void actually_poll(void* argsp) { + args_struct* args = static_cast<args_struct*>(argsp); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = n_sec_deadline(10); while (true) { @@ -89,7 +89,7 @@ static void actually_poll(void *argsp) { grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx); gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left); GPR_ASSERT(time_left >= 0); - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; gpr_mu_lock(args->mu); GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(&exec_ctx, args->pollset, &worker, @@ -97,27 +97,27 @@ static void actually_poll(void *argsp) { gpr_mu_unlock(args->mu); grpc_exec_ctx_flush(&exec_ctx); } - gpr_event_set(&args->ev, (void *)1); + gpr_event_set(&args->ev, (void*)1); grpc_exec_ctx_finish(&exec_ctx); } -static void poll_pollset_until_request_done(args_struct *args) { +static void poll_pollset_until_request_done(args_struct* args) { gpr_atm_rel_store(&args->done_atm, 0); gpr_thd_id id; gpr_thd_new(&id, actually_poll, args, NULL); } -static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp, - grpc_error *err) { - args_struct *args = static_cast<args_struct *>(argsp); +static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp, + grpc_error* err) { + args_struct* args = static_cast<args_struct*>(argsp); GPR_ASSERT(err == GRPC_ERROR_NONE); GPR_ASSERT(args->addrs != NULL); GPR_ASSERT(args->addrs->naddrs > 0); gpr_atm_rel_store(&args->done_atm, 1); } -static void must_fail(grpc_exec_ctx *exec_ctx, void *argsp, grpc_error *err) { - args_struct *args = static_cast<args_struct *>(argsp); +static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) { + args_struct* args = static_cast<args_struct*>(argsp); GPR_ASSERT(err != GRPC_ERROR_NONE); gpr_atm_rel_store(&args->done_atm, 1); } @@ -141,9 +141,9 @@ static void test_unix_socket_path_name_too_long(void) { args_init(&exec_ctx, &args); const char prefix[] = "unix:/path/name"; size_t path_name_length = - GPR_ARRAY_SIZE(((struct sockaddr_un *)0)->sun_path) + 6; - char *path_name = - static_cast<char *>(gpr_malloc(sizeof(char) * path_name_length)); + GPR_ARRAY_SIZE(((struct sockaddr_un*)0)->sun_path) + 6; + char* path_name = + static_cast<char*>(gpr_malloc(sizeof(char) * path_name_length)); memset(path_name, 'a', path_name_length); memcpy(path_name, prefix, strlen(prefix) - 1); path_name[path_name_length - 1] = '\0'; @@ -158,7 +158,7 @@ static void test_unix_socket_path_name_too_long(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(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc index da6aab3518..0aa3e5f0f0 100644 --- a/test/core/iomgr/resolve_address_test.cc +++ b/test/core/iomgr/resolve_address_test.cc @@ -32,18 +32,18 @@ static gpr_timespec test_deadline(void) { typedef struct args_struct { gpr_event ev; - grpc_resolved_addresses *addrs; + grpc_resolved_addresses* addrs; gpr_atm done_atm; - gpr_mu *mu; - grpc_pollset *pollset; - grpc_pollset_set *pollset_set; + gpr_mu* mu; + grpc_pollset* pollset; + grpc_pollset_set* pollset_set; } args_struct; -static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} +static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} -void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) { +void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) { gpr_event_init(&args->ev); - args->pollset = static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(args->pollset, &args->mu); args->pollset_set = grpc_pollset_set_create(); grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset); @@ -51,7 +51,7 @@ void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) { gpr_atm_rel_store(&args->done_atm, 0); } -void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { +void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) { GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline())); grpc_resolved_addresses_destroy(args->addrs); grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset); @@ -73,7 +73,7 @@ static grpc_millis n_sec_deadline(int seconds) { grpc_timeout_seconds_to_deadline(seconds)); } -static void poll_pollset_until_request_done(args_struct *args) { +static void poll_pollset_until_request_done(args_struct* args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = n_sec_deadline(10); while (true) { @@ -84,7 +84,7 @@ static void poll_pollset_until_request_done(args_struct *args) { grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx); gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left); GPR_ASSERT(time_left >= 0); - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; gpr_mu_lock(args->mu); GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(&exec_ctx, args->pollset, &worker, @@ -92,13 +92,13 @@ static void poll_pollset_until_request_done(args_struct *args) { gpr_mu_unlock(args->mu); grpc_exec_ctx_flush(&exec_ctx); } - gpr_event_set(&args->ev, (void *)1); + gpr_event_set(&args->ev, (void*)1); grpc_exec_ctx_finish(&exec_ctx); } -static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp, - grpc_error *err) { - args_struct *args = static_cast<args_struct *>(argsp); +static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp, + grpc_error* err) { + args_struct* args = static_cast<args_struct*>(argsp); GPR_ASSERT(err == GRPC_ERROR_NONE); GPR_ASSERT(args->addrs != NULL); GPR_ASSERT(args->addrs->naddrs > 0); @@ -109,8 +109,8 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp, gpr_mu_unlock(args->mu); } -static void must_fail(grpc_exec_ctx *exec_ctx, void *argsp, grpc_error *err) { - args_struct *args = static_cast<args_struct *>(argsp); +static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) { + args_struct* args = static_cast<args_struct*>(argsp); GPR_ASSERT(err != GRPC_ERROR_NONE); gpr_atm_rel_store(&args->done_atm, 1); gpr_mu_lock(args->mu); @@ -190,8 +190,10 @@ static void test_ipv6_with_port(void) { } static void test_ipv6_without_port(void) { - const char *const kCases[] = { - "2001:db8::1", "2001:db8::1.2.3.4", "[2001:db8::1]", + const char* const kCases[] = { + "2001:db8::1", + "2001:db8::1.2.3.4", + "[2001:db8::1]", }; unsigned i; for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { @@ -210,8 +212,9 @@ static void test_ipv6_without_port(void) { } static void test_invalid_ip_addresses(void) { - const char *const kCases[] = { - "293.283.1238.3:1", "[2001:db8::11111]:1", + const char* const kCases[] = { + "293.283.1238.3:1", + "[2001:db8::11111]:1", }; unsigned i; for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { @@ -230,7 +233,7 @@ static void test_invalid_ip_addresses(void) { } static void test_unparseable_hostports(void) { - const char *const kCases[] = { + const char* const kCases[] = { "[", "[::1", "[::1]bad", "[1.2.3.4]", "[localhost]", "[localhost]:1", }; unsigned i; @@ -249,7 +252,7 @@ static void test_unparseable_hostports(void) { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc index f0002e0947..8a2faaed02 100644 --- a/test/core/iomgr/resource_quota_test.cc +++ b/test/core/iomgr/resource_quota_test.cc @@ -27,14 +27,14 @@ gpr_mu g_mu; gpr_cv g_cv; -static void inc_int_cb(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) { +static void inc_int_cb(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) { gpr_mu_lock(&g_mu); - ++*(int *)a; + ++*(int*)a; gpr_cv_signal(&g_cv); gpr_mu_unlock(&g_mu); } -static void assert_counter_becomes(int *ctr, int value) { +static void assert_counter_becomes(int* ctr, int value) { gpr_mu_lock(&g_mu); gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); while (*ctr != value) { @@ -43,47 +43,49 @@ static void assert_counter_becomes(int *ctr, int value) { gpr_mu_unlock(&g_mu); } -static void set_event_cb(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) { - gpr_event_set((gpr_event *)a, (void *)1); +static void set_event_cb(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) { + gpr_event_set((gpr_event*)a, (void*)1); } -grpc_closure *set_event(gpr_event *ev) { +grpc_closure* set_event(gpr_event* ev) { return GRPC_CLOSURE_CREATE(set_event_cb, ev, grpc_schedule_on_exec_ctx); } typedef struct { size_t size; - grpc_resource_user *resource_user; - grpc_closure *then; + grpc_resource_user* resource_user; + grpc_closure* then; } reclaimer_args; -static void reclaimer_cb(grpc_exec_ctx *exec_ctx, void *args, - grpc_error *error) { + +static void reclaimer_cb(grpc_exec_ctx* exec_ctx, void* args, + grpc_error* error) { GPR_ASSERT(error == GRPC_ERROR_NONE); - reclaimer_args *a = static_cast<reclaimer_args *>(args); + reclaimer_args* a = static_cast<reclaimer_args*>(args); grpc_resource_user_free(exec_ctx, a->resource_user, a->size); grpc_resource_user_finish_reclamation(exec_ctx, a->resource_user); GRPC_CLOSURE_RUN(exec_ctx, a->then, GRPC_ERROR_NONE); gpr_free(a); } -grpc_closure *make_reclaimer(grpc_resource_user *resource_user, size_t size, - grpc_closure *then) { - reclaimer_args *a = static_cast<reclaimer_args *>(gpr_malloc(sizeof(*a))); + +grpc_closure* make_reclaimer(grpc_resource_user* resource_user, size_t size, + grpc_closure* then) { + reclaimer_args* a = static_cast<reclaimer_args*>(gpr_malloc(sizeof(*a))); a->size = size; a->resource_user = resource_user; a->then = then; return GRPC_CLOSURE_CREATE(reclaimer_cb, a, grpc_schedule_on_exec_ctx); } -static void unused_reclaimer_cb(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void unused_reclaimer_cb(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { GPR_ASSERT(error == GRPC_ERROR_CANCELLED); - GRPC_CLOSURE_RUN(exec_ctx, static_cast<grpc_closure *>(arg), GRPC_ERROR_NONE); + GRPC_CLOSURE_RUN(exec_ctx, static_cast<grpc_closure*>(arg), GRPC_ERROR_NONE); } -grpc_closure *make_unused_reclaimer(grpc_closure *then) { +grpc_closure* make_unused_reclaimer(grpc_closure* then) { return GRPC_CLOSURE_CREATE(unused_reclaimer_cb, then, grpc_schedule_on_exec_ctx); } -static void destroy_user(grpc_resource_user *usr) { +static void destroy_user(grpc_resource_user* usr) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resource_user_unref(&exec_ctx, usr); grpc_exec_ctx_finish(&exec_ctx); @@ -96,7 +98,7 @@ static void test_no_op(void) { static void test_resize_then_destroy(void) { gpr_log(GPR_INFO, "** test_resize_then_destroy **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_resize_then_destroy"); grpc_resource_quota_resize(q, 1024 * 1024); grpc_resource_quota_unref(q); @@ -104,19 +106,19 @@ static void test_resize_then_destroy(void) { static void test_resource_user_no_op(void) { gpr_log(GPR_INFO, "** test_resource_user_no_op **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_resource_user_no_op"); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); grpc_resource_quota_unref(q); destroy_user(usr); } static void test_instant_alloc_then_free(void) { gpr_log(GPR_INFO, "** test_instant_alloc_then_free **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_instant_alloc_then_free"); grpc_resource_quota_resize(q, 1024 * 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resource_user_alloc(&exec_ctx, usr, 1024, NULL); @@ -133,10 +135,10 @@ static void test_instant_alloc_then_free(void) { static void test_instant_alloc_free_pair(void) { gpr_log(GPR_INFO, "** test_instant_alloc_free_pair **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_instant_alloc_free_pair"); grpc_resource_quota_resize(q, 1024 * 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resource_user_alloc(&exec_ctx, usr, 1024, NULL); @@ -149,10 +151,10 @@ static void test_instant_alloc_free_pair(void) { static void test_simple_async_alloc(void) { gpr_log(GPR_INFO, "** test_simple_async_alloc **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_simple_async_alloc"); grpc_resource_quota_resize(q, 1024 * 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { gpr_event ev; gpr_event_init(&ev); @@ -173,10 +175,10 @@ static void test_simple_async_alloc(void) { static void test_async_alloc_blocked_by_size(void) { gpr_log(GPR_INFO, "** test_async_alloc_blocked_by_size **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_async_alloc_blocked_by_size"); grpc_resource_quota_resize(q, 1); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event ev; gpr_event_init(&ev); { @@ -200,10 +202,10 @@ static void test_async_alloc_blocked_by_size(void) { static void test_scavenge(void) { gpr_log(GPR_INFO, "** test_scavenge **"); - grpc_resource_quota *q = grpc_resource_quota_create("test_scavenge"); + grpc_resource_quota* q = grpc_resource_quota_create("test_scavenge"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1"); - grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2"); + grpc_resource_user* usr1 = grpc_resource_user_create(q, "usr1"); + grpc_resource_user* usr2 = grpc_resource_user_create(q, "usr2"); { gpr_event ev; gpr_event_init(&ev); @@ -241,10 +243,10 @@ static void test_scavenge(void) { static void test_scavenge_blocked(void) { gpr_log(GPR_INFO, "** test_scavenge_blocked **"); - grpc_resource_quota *q = grpc_resource_quota_create("test_scavenge_blocked"); + grpc_resource_quota* q = grpc_resource_quota_create("test_scavenge_blocked"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1"); - grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2"); + grpc_resource_user* usr1 = grpc_resource_user_create(q, "usr1"); + grpc_resource_user* usr2 = grpc_resource_user_create(q, "usr2"); gpr_event ev; { gpr_event_init(&ev); @@ -283,10 +285,10 @@ static void test_scavenge_blocked(void) { static void test_blocked_until_scheduled_reclaim(void) { gpr_log(GPR_INFO, "** test_blocked_until_scheduled_reclaim **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_blocked_until_scheduled_reclaim"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { gpr_event ev; gpr_event_init(&ev); @@ -329,11 +331,11 @@ static void test_blocked_until_scheduled_reclaim(void) { static void test_blocked_until_scheduled_reclaim_and_scavenge(void) { gpr_log(GPR_INFO, "** test_blocked_until_scheduled_reclaim_and_scavenge **"); - grpc_resource_quota *q = grpc_resource_quota_create( + grpc_resource_quota* q = grpc_resource_quota_create( "test_blocked_until_scheduled_reclaim_and_scavenge"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1"); - grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2"); + grpc_resource_user* usr1 = grpc_resource_user_create(q, "usr1"); + grpc_resource_user* usr2 = grpc_resource_user_create(q, "usr2"); { gpr_event ev; gpr_event_init(&ev); @@ -377,10 +379,10 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) { static void test_blocked_until_scheduled_destructive_reclaim(void) { gpr_log(GPR_INFO, "** test_blocked_until_scheduled_destructive_reclaim **"); - grpc_resource_quota *q = grpc_resource_quota_create( + grpc_resource_quota* q = grpc_resource_quota_create( "test_blocked_until_scheduled_destructive_reclaim"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { gpr_event ev; gpr_event_init(&ev); @@ -423,10 +425,10 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) { static void test_unused_reclaim_is_cancelled(void) { gpr_log(GPR_INFO, "** test_unused_reclaim_is_cancelled **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_unused_reclaim_is_cancelled"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event benign_done; gpr_event_init(&benign_done); gpr_event destructive_done; @@ -456,10 +458,10 @@ static void test_unused_reclaim_is_cancelled(void) { static void test_benign_reclaim_is_preferred(void) { gpr_log(GPR_INFO, "** test_benign_reclaim_is_preferred **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_benign_reclaim_is_preferred"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event benign_done; gpr_event_init(&benign_done); gpr_event destructive_done; @@ -519,10 +521,10 @@ static void test_benign_reclaim_is_preferred(void) { static void test_multiple_reclaims_can_be_triggered(void) { gpr_log(GPR_INFO, "** test_multiple_reclaims_can_be_triggered **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_multiple_reclaims_can_be_triggered"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event benign_done; gpr_event_init(&benign_done); gpr_event destructive_done; @@ -583,10 +585,10 @@ static void test_multiple_reclaims_can_be_triggered(void) { static void test_resource_user_stays_allocated_until_memory_released(void) { gpr_log(GPR_INFO, "** test_resource_user_stays_allocated_until_memory_released **"); - grpc_resource_quota *q = grpc_resource_quota_create( + grpc_resource_quota* q = grpc_resource_quota_create( "test_resource_user_stays_allocated_until_memory_released"); grpc_resource_quota_resize(q, 1024 * 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resource_user_alloc(&exec_ctx, usr, 1024, NULL); @@ -612,12 +614,12 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released( "** " "test_resource_user_stays_allocated_and_reclaimers_unrun_until_" "memory_released **"); - grpc_resource_quota *q = grpc_resource_quota_create( + grpc_resource_quota* q = grpc_resource_quota_create( "test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_" "released"); grpc_resource_quota_resize(q, 1024); for (int i = 0; i < 10; i++) { - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event reclaimer_cancelled; gpr_event_init(&reclaimer_cancelled); { @@ -663,10 +665,10 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released( static void test_reclaimers_can_be_posted_repeatedly(void) { gpr_log(GPR_INFO, "** test_reclaimers_can_be_posted_repeatedly **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_reclaimers_can_be_posted_repeatedly"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { gpr_event allocated; gpr_event_init(&allocated); @@ -713,10 +715,10 @@ static void test_reclaimers_can_be_posted_repeatedly(void) { static void test_one_slice(void) { gpr_log(GPR_INFO, "** test_one_slice **"); - grpc_resource_quota *q = grpc_resource_quota_create("test_one_slice"); + grpc_resource_quota* q = grpc_resource_quota_create("test_one_slice"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); grpc_resource_user_slice_allocator alloc; int num_allocs = 0; @@ -745,11 +747,11 @@ static void test_one_slice(void) { static void test_one_slice_deleted_late(void) { gpr_log(GPR_INFO, "** test_one_slice_deleted_late **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_one_slice_deleted_late"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); grpc_resource_user_slice_allocator alloc; int num_allocs = 0; @@ -782,18 +784,18 @@ static void test_one_slice_deleted_late(void) { static void test_resize_to_zero(void) { gpr_log(GPR_INFO, "** test_resize_to_zero **"); - grpc_resource_quota *q = grpc_resource_quota_create("test_resize_to_zero"); + grpc_resource_quota* q = grpc_resource_quota_create("test_resize_to_zero"); grpc_resource_quota_resize(q, 0); grpc_resource_quota_unref(q); } static void test_negative_rq_free_pool(void) { gpr_log(GPR_INFO, "** test_negative_rq_free_pool **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_negative_rq_free_pool"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); grpc_resource_user_slice_allocator alloc; int num_allocs = 0; @@ -830,7 +832,7 @@ static void test_negative_rq_free_pool(void) { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); gpr_mu_init(&g_mu); diff --git a/test/core/iomgr/sockaddr_utils_test.cc b/test/core/iomgr/sockaddr_utils_test.cc index e4a4ddaa99..40f2157ba3 100644 --- a/test/core/iomgr/sockaddr_utils_test.cc +++ b/test/core/iomgr/sockaddr_utils_test.cc @@ -20,8 +20,8 @@ using that endpoint. Because of various transitive includes in uv.h, including windows.h on Windows, uv.h must be included before other system headers. Therefore, sockaddr.h must always be included first */ -#include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" +#include "src/core/lib/iomgr/sockaddr.h" #include <errno.h> #include <string.h> @@ -31,9 +31,9 @@ #include <grpc/support/port_platform.h> #include "test/core/util/test_config.h" -static grpc_resolved_address make_addr4(const uint8_t *data, size_t data_len) { +static grpc_resolved_address make_addr4(const uint8_t* data, size_t data_len) { grpc_resolved_address resolved_addr4; - struct sockaddr_in *addr4 = (struct sockaddr_in *)resolved_addr4.addr; + struct sockaddr_in* addr4 = (struct sockaddr_in*)resolved_addr4.addr; memset(&resolved_addr4, 0, sizeof(resolved_addr4)); addr4->sin_family = AF_INET; GPR_ASSERT(data_len == sizeof(addr4->sin_addr.s_addr)); @@ -43,9 +43,9 @@ static grpc_resolved_address make_addr4(const uint8_t *data, size_t data_len) { return resolved_addr4; } -static grpc_resolved_address make_addr6(const uint8_t *data, size_t data_len) { +static grpc_resolved_address make_addr6(const uint8_t* data, size_t data_len) { grpc_resolved_address resolved_addr6; - struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)resolved_addr6.addr; + struct sockaddr_in6* addr6 = (struct sockaddr_in6*)resolved_addr6.addr; memset(&resolved_addr6, 0, sizeof(resolved_addr6)); addr6->sin6_family = AF_INET6; GPR_ASSERT(data_len == sizeof(addr6->sin6_addr.s6_addr)); @@ -55,8 +55,8 @@ static grpc_resolved_address make_addr6(const uint8_t *data, size_t data_len) { return resolved_addr6; } -static void set_addr6_scope_id(grpc_resolved_address *addr, uint32_t scope_id) { - struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr->addr; +static void set_addr6_scope_id(grpc_resolved_address* addr, uint32_t scope_id) { + struct sockaddr_in6* addr6 = (struct sockaddr_in6*)addr->addr; GPR_ASSERT(addr6->sin6_family == AF_INET6); addr6->sin6_scope_id = scope_id; } @@ -128,9 +128,9 @@ static void test_sockaddr_is_wildcard(void) { grpc_resolved_address wild6; grpc_resolved_address wild_mapped; grpc_resolved_address dummy; - struct sockaddr_in *wild4_addr; - struct sockaddr_in6 *wild6_addr; - struct sockaddr_in6 *wild_mapped_addr; + struct sockaddr_in* wild4_addr; + struct sockaddr_in6* wild6_addr; + struct sockaddr_in6* wild_mapped_addr; int port; gpr_log(GPR_INFO, "%s", "test_sockaddr_is_wildcard"); @@ -143,7 +143,7 @@ static void test_sockaddr_is_wildcard(void) { port = -1; GPR_ASSERT(grpc_sockaddr_is_wildcard(&wild4, &port)); GPR_ASSERT(port == 555); - wild4_addr = (struct sockaddr_in *)&wild4.addr; + wild4_addr = (struct sockaddr_in*)&wild4.addr; memset(&wild4_addr->sin_addr.s_addr, 0xbd, 1); GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild4, &port)); @@ -151,7 +151,7 @@ static void test_sockaddr_is_wildcard(void) { port = -1; GPR_ASSERT(grpc_sockaddr_is_wildcard(&wild6, &port)); GPR_ASSERT(port == 555); - wild6_addr = (struct sockaddr_in6 *)&wild6.addr; + wild6_addr = (struct sockaddr_in6*)&wild6.addr; memset(&wild6_addr->sin6_addr.s6_addr, 0xbd, 1); GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild6, &port)); @@ -159,7 +159,7 @@ static void test_sockaddr_is_wildcard(void) { port = -1; GPR_ASSERT(grpc_sockaddr_is_wildcard(&wild_mapped, &port)); GPR_ASSERT(port == 555); - wild_mapped_addr = (struct sockaddr_in6 *)&wild_mapped.addr; + wild_mapped_addr = (struct sockaddr_in6*)&wild_mapped.addr; memset(&wild_mapped_addr->sin6_addr.s6_addr, 0xbd, 1); GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild_mapped, &port)); @@ -170,10 +170,10 @@ static void test_sockaddr_is_wildcard(void) { GPR_ASSERT(port == -1); } -static void expect_sockaddr_str(const char *expected, - grpc_resolved_address *addr, int normalize) { +static void expect_sockaddr_str(const char* expected, + grpc_resolved_address* addr, int normalize) { int result; - char *str; + char* str; gpr_log(GPR_INFO, " expect_sockaddr_str(%s)", expected); result = grpc_sockaddr_to_string(&str, addr, normalize); GPR_ASSERT(str != NULL); @@ -183,9 +183,9 @@ static void expect_sockaddr_str(const char *expected, gpr_free(str); } -static void expect_sockaddr_uri(const char *expected, - grpc_resolved_address *addr) { - char *str; +static void expect_sockaddr_uri(const char* expected, + grpc_resolved_address* addr) { + char* str; gpr_log(GPR_INFO, " expect_sockaddr_uri(%s)", expected); str = grpc_sockaddr_to_uri(addr); GPR_ASSERT(str != NULL); @@ -197,7 +197,7 @@ static void test_sockaddr_to_string(void) { grpc_resolved_address input4; grpc_resolved_address input6; grpc_resolved_address dummy; - struct sockaddr *dummy_addr; + struct sockaddr* dummy_addr; gpr_log(GPR_INFO, "%s", "test_sockaddr_to_string"); @@ -234,7 +234,7 @@ static void test_sockaddr_to_string(void) { expect_sockaddr_uri("ipv6:[::fffe:c000:263]:12345", &input6); memset(&dummy, 0, sizeof(dummy)); - dummy_addr = (struct sockaddr *)dummy.addr; + dummy_addr = (struct sockaddr*)dummy.addr; dummy_addr->sa_family = 123; expect_sockaddr_str("(sockaddr family=123)", &dummy, 0); expect_sockaddr_str("(sockaddr family=123)", &dummy, 1); @@ -245,7 +245,7 @@ static void test_sockaddr_set_get_port(void) { grpc_resolved_address input4; grpc_resolved_address input6; grpc_resolved_address dummy; - struct sockaddr *dummy_addr; + struct sockaddr* dummy_addr; gpr_log(GPR_DEBUG, "test_sockaddr_set_get_port"); @@ -260,13 +260,13 @@ static void test_sockaddr_set_get_port(void) { GPR_ASSERT(grpc_sockaddr_get_port(&input6) == 54321); memset(&dummy, 0, sizeof(dummy)); - dummy_addr = (struct sockaddr *)dummy.addr; + dummy_addr = (struct sockaddr*)dummy.addr; dummy_addr->sa_family = 123; GPR_ASSERT(grpc_sockaddr_get_port(&dummy) == 0); GPR_ASSERT(grpc_sockaddr_set_port(&dummy, 1234) == 0); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_sockaddr_is_v4mapped(); diff --git a/test/core/iomgr/socket_utils_test.cc b/test/core/iomgr/socket_utils_test.cc index 30f0c943dc..49c6f799e7 100644 --- a/test/core/iomgr/socket_utils_test.cc +++ b/test/core/iomgr/socket_utils_test.cc @@ -39,10 +39,10 @@ struct test_socket_mutator { int option_value; }; -static bool mutate_fd(int fd, grpc_socket_mutator *mutator) { +static bool mutate_fd(int fd, grpc_socket_mutator* mutator) { int newval; socklen_t intlen = sizeof(newval); - struct test_socket_mutator *m = (struct test_socket_mutator *)mutator; + struct test_socket_mutator* m = (struct test_socket_mutator*)mutator; if (0 != setsockopt(fd, IPPROTO_IP, IP_TOS, &m->option_value, sizeof(m->option_value))) { @@ -57,24 +57,24 @@ static bool mutate_fd(int fd, grpc_socket_mutator *mutator) { return true; } -static void destroy_test_mutator(grpc_socket_mutator *mutator) { - struct test_socket_mutator *m = (struct test_socket_mutator *)mutator; +static void destroy_test_mutator(grpc_socket_mutator* mutator) { + struct test_socket_mutator* m = (struct test_socket_mutator*)mutator; gpr_free(m); } -static int compare_test_mutator(grpc_socket_mutator *a, - grpc_socket_mutator *b) { - struct test_socket_mutator *ma = (struct test_socket_mutator *)a; - struct test_socket_mutator *mb = (struct test_socket_mutator *)b; +static int compare_test_mutator(grpc_socket_mutator* a, + grpc_socket_mutator* b) { + struct test_socket_mutator* ma = (struct test_socket_mutator*)a; + struct test_socket_mutator* mb = (struct test_socket_mutator*)b; return GPR_ICMP(ma->option_value, mb->option_value); } static const grpc_socket_mutator_vtable mutator_vtable = { mutate_fd, compare_test_mutator, destroy_test_mutator}; -int main(int argc, char **argv) { +int main(int argc, char** argv) { int sock; - grpc_error *err; + grpc_error* err; grpc_test_init(argc, argv); sock = socket(PF_INET, SOCK_STREAM, 0); @@ -103,20 +103,20 @@ int main(int argc, char **argv) { mutator.option_value = IPTOS_LOWDELAY; GPR_ASSERT(GRPC_LOG_IF_ERROR( "set_socket_with_mutator", - grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator))); + grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator))); mutator.option_value = IPTOS_THROUGHPUT; GPR_ASSERT(GRPC_LOG_IF_ERROR( "set_socket_with_mutator", - grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator))); + grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator))); mutator.option_value = IPTOS_RELIABILITY; GPR_ASSERT(GRPC_LOG_IF_ERROR( "set_socket_with_mutator", - grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator))); + grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator))); mutator.option_value = -1; - err = grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator); + err = grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator); GPR_ASSERT(err != GRPC_ERROR_NONE); GRPC_ERROR_UNREF(err); @@ -127,6 +127,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/tcp_client_posix_test.cc b/test/core/iomgr/tcp_client_posix_test.cc index b2dcb1d04f..206fa5de01 100644 --- a/test/core/iomgr/tcp_client_posix_test.cc +++ b/test/core/iomgr/tcp_client_posix_test.cc @@ -40,11 +40,11 @@ #include "src/core/lib/iomgr/timer.h" #include "test/core/util/test_config.h" -static grpc_pollset_set *g_pollset_set; -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static grpc_pollset_set* g_pollset_set; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static int g_connections_complete = 0; -static grpc_endpoint *g_connecting = NULL; +static grpc_endpoint* g_connecting = NULL; static grpc_millis test_deadline(void) { return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); @@ -60,8 +60,8 @@ static void finish_connection() { gpr_mu_unlock(g_mu); } -static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { GPR_ASSERT(g_connecting != NULL); GPR_ASSERT(error == GRPC_ERROR_NONE); grpc_endpoint_shutdown( @@ -72,7 +72,7 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, finish_connection(); } -static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { GPR_ASSERT(g_connecting == NULL); GPR_ASSERT(error != GRPC_ERROR_NONE); finish_connection(); @@ -80,7 +80,7 @@ static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { void test_succeeds(void) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; int svr_fd; int r; int connections_complete_before; @@ -97,7 +97,7 @@ void test_succeeds(void) { svr_fd = socket(AF_INET, SOCK_STREAM, 0); GPR_ASSERT(svr_fd >= 0); GPR_ASSERT( - 0 == bind(svr_fd, (struct sockaddr *)addr, (socklen_t)resolved_addr.len)); + 0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr.len)); GPR_ASSERT(0 == listen(svr_fd, 1)); gpr_mu_lock(g_mu); @@ -105,8 +105,8 @@ void test_succeeds(void) { gpr_mu_unlock(g_mu); /* connect to it */ - GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)addr, - (socklen_t *)&resolved_addr.len) == 0); + GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, + (socklen_t*)&resolved_addr.len) == 0); GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx); grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL, &resolved_addr, GRPC_MILLIS_INF_FUTURE); @@ -114,8 +114,7 @@ void test_succeeds(void) { /* await the connection */ do { resolved_addr.len = sizeof(addr); - r = accept(svr_fd, (struct sockaddr *)addr, - (socklen_t *)&resolved_addr.len); + r = accept(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr.len); } while (r == -1 && errno == EINTR); GPR_ASSERT(r >= 0); close(r); @@ -123,7 +122,7 @@ void test_succeeds(void) { gpr_mu_lock(g_mu); while (g_connections_complete == connections_complete_before) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, @@ -141,7 +140,7 @@ void test_succeeds(void) { void test_fails(void) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; int connections_complete_before; grpc_closure done; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -165,7 +164,7 @@ void test_fails(void) { /* wait for the connection callback to finish */ while (g_connections_complete == connections_complete_before) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; grpc_millis polling_deadline = test_deadline(); switch (grpc_timer_check(&exec_ctx, &polling_deadline)) { case GRPC_TIMERS_FIRED: @@ -188,18 +187,18 @@ void test_fails(void) { grpc_exec_ctx_finish(&exec_ctx); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset *>(p)); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); g_pollset_set = grpc_pollset_set_create(); - g_pollset = static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); grpc_pollset_set_add_pollset(&exec_ctx, g_pollset_set, g_pollset); grpc_exec_ctx_finish(&exec_ctx); @@ -218,6 +217,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/tcp_client_uv_test.cc b/test/core/iomgr/tcp_client_uv_test.cc index 7eb4bd5e4a..101d7bf6b5 100644 --- a/test/core/iomgr/tcp_client_uv_test.cc +++ b/test/core/iomgr/tcp_client_uv_test.cc @@ -37,16 +37,16 @@ #include "src/core/lib/iomgr/timer.h" #include "test/core/util/test_config.h" -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static int g_connections_complete = 0; -static grpc_endpoint *g_connecting = NULL; +static grpc_endpoint* g_connecting = NULL; static grpc_millis test_deadline(void) { return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); } -static void finish_connection(grpc_exec_ctx *exec_ctx) { +static void finish_connection(grpc_exec_ctx* exec_ctx) { gpr_mu_lock(g_mu); g_connections_complete++; GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick", @@ -54,8 +54,8 @@ static void finish_connection(grpc_exec_ctx *exec_ctx) { gpr_mu_unlock(g_mu); } -static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { GPR_ASSERT(g_connecting != NULL); GPR_ASSERT(error == GRPC_ERROR_NONE); grpc_endpoint_shutdown( @@ -66,27 +66,27 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, finish_connection(exec_ctx); } -static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { GPR_ASSERT(g_connecting == NULL); GPR_ASSERT(error != GRPC_ERROR_NONE); finish_connection(exec_ctx); } -static void close_cb(uv_handle_t *handle) { gpr_free(handle); } +static void close_cb(uv_handle_t* handle) { gpr_free(handle); } -static void connection_cb(uv_stream_t *server, int status) { - uv_tcp_t *client_handle = - static_cast<uv_tcp_t *>(gpr_malloc(sizeof(uv_tcp_t))); +static void connection_cb(uv_stream_t* server, int status) { + uv_tcp_t* client_handle = + static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t))); GPR_ASSERT(0 == status); GPR_ASSERT(0 == uv_tcp_init(uv_default_loop(), client_handle)); - GPR_ASSERT(0 == uv_accept(server, (uv_stream_t *)client_handle)); - uv_close((uv_handle_t *)client_handle, close_cb); + GPR_ASSERT(0 == uv_accept(server, (uv_stream_t*)client_handle)); + uv_close((uv_handle_t*)client_handle, close_cb); } void test_succeeds(void) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - uv_tcp_t *svr_handle = static_cast<uv_tcp_t *>(gpr_malloc(sizeof(uv_tcp_t))); + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + uv_tcp_t* svr_handle = static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t))); int connections_complete_before; grpc_closure done; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -99,16 +99,16 @@ void test_succeeds(void) { /* create a dummy server */ GPR_ASSERT(0 == uv_tcp_init(uv_default_loop(), svr_handle)); - GPR_ASSERT(0 == uv_tcp_bind(svr_handle, (struct sockaddr *)addr, 0)); - GPR_ASSERT(0 == uv_listen((uv_stream_t *)svr_handle, 1, connection_cb)); + GPR_ASSERT(0 == uv_tcp_bind(svr_handle, (struct sockaddr*)addr, 0)); + GPR_ASSERT(0 == uv_listen((uv_stream_t*)svr_handle, 1, connection_cb)); gpr_mu_lock(g_mu); connections_complete_before = g_connections_complete; gpr_mu_unlock(g_mu); /* connect to it */ - GPR_ASSERT(uv_tcp_getsockname(svr_handle, (struct sockaddr *)addr, - (int *)&resolved_addr.len) == 0); + GPR_ASSERT(uv_tcp_getsockname(svr_handle, (struct sockaddr*)addr, + (int*)&resolved_addr.len) == 0); GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx); grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL, &resolved_addr, GRPC_MILLIS_INF_FUTURE); @@ -116,7 +116,7 @@ void test_succeeds(void) { gpr_mu_lock(g_mu); while (g_connections_complete == connections_complete_before) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, @@ -128,7 +128,7 @@ void test_succeeds(void) { } // This will get cleaned up when the pollset runs again or gets shutdown - uv_close((uv_handle_t *)svr_handle, close_cb); + uv_close((uv_handle_t*)svr_handle, close_cb); gpr_mu_unlock(g_mu); @@ -137,7 +137,7 @@ void test_succeeds(void) { void test_fails(void) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; int connections_complete_before; grpc_closure done; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -161,7 +161,7 @@ void test_fails(void) { /* wait for the connection callback to finish */ while (g_connections_complete == connections_complete_before) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); grpc_millis polling_deadline = test_deadline(); switch (grpc_timer_check(&exec_ctx, &polling_deadline)) { @@ -185,17 +185,17 @@ void test_fails(void) { grpc_exec_ctx_finish(&exec_ctx); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset *>(p)); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = static_cast<grpc_pollset *>(gpr_malloc(grpc_pollset_size())); + g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); grpc_exec_ctx_finish(&exec_ctx); test_succeeds(); @@ -212,6 +212,6 @@ int main(int argc, char **argv) { #else /* GRPC_UV */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_UV */ diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc index 8a4433b55c..51ab0bfc6a 100644 --- a/test/core/iomgr/tcp_posix_test.cc +++ b/test/core/iomgr/tcp_posix_test.cc @@ -40,8 +40,8 @@ #include "test/core/iomgr/endpoint_tests.h" #include "test/core/util/test_config.h" -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; /* General test notes: @@ -89,7 +89,7 @@ static ssize_t fill_socket(int fd) { static size_t fill_socket_partial(int fd, size_t bytes) { ssize_t write_bytes; size_t total_bytes = 0; - unsigned char *buf = (unsigned char *)gpr_malloc(bytes); + unsigned char* buf = (unsigned char*)gpr_malloc(bytes); unsigned i; for (i = 0; i < bytes; ++i) { buf[i] = (uint8_t)(i % 256); @@ -108,18 +108,18 @@ static size_t fill_socket_partial(int fd, size_t bytes) { } struct read_socket_state { - grpc_endpoint *ep; + grpc_endpoint* ep; size_t read_bytes; size_t target_read_bytes; grpc_slice_buffer incoming; grpc_closure read_cb; }; -static size_t count_slices(grpc_slice *slices, size_t nslices, - int *current_data) { +static size_t count_slices(grpc_slice* slices, size_t nslices, + int* current_data) { size_t num_bytes = 0; unsigned i, j; - unsigned char *buf; + unsigned char* buf; for (i = 0; i < nslices; ++i) { buf = GRPC_SLICE_START_PTR(slices[i]); for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { @@ -131,9 +131,9 @@ static size_t count_slices(grpc_slice *slices, size_t nslices, return num_bytes; } -static void read_cb(grpc_exec_ctx *exec_ctx, void *user_data, - grpc_error *error) { - struct read_socket_state *state = (struct read_socket_state *)user_data; +static void read_cb(grpc_exec_ctx* exec_ctx, void* user_data, + grpc_error* error) { + struct read_socket_state* state = (struct read_socket_state*)user_data; size_t read_bytes; int current_data; @@ -159,7 +159,7 @@ static void read_cb(grpc_exec_ctx *exec_ctx, void *user_data, /* Write to a socket, then read from it using the grpc_tcp API. */ static void read_test(size_t num_bytes, size_t slice_size) { int sv[2]; - grpc_endpoint *ep; + grpc_endpoint* ep; struct read_socket_state state; size_t written_bytes; grpc_millis deadline = @@ -172,7 +172,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { create_sockets(sv); grpc_arg a[1]; - a[0].key = const_cast<char *>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size; grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "read_test"), &args, @@ -192,7 +192,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { gpr_mu_lock(g_mu); while (state.read_bytes < state.target_read_bytes) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -212,7 +212,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { API. */ static void large_read_test(size_t slice_size) { int sv[2]; - grpc_endpoint *ep; + grpc_endpoint* ep; struct read_socket_state state; ssize_t written_bytes; grpc_millis deadline = @@ -224,7 +224,7 @@ static void large_read_test(size_t slice_size) { create_sockets(sv); grpc_arg a[1]; - a[0].key = const_cast<char *>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); a[0].type = GRPC_ARG_INTEGER; a[0].value.integer = (int)slice_size; grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; @@ -245,7 +245,7 @@ static void large_read_test(size_t slice_size) { gpr_mu_lock(g_mu); while (state.read_bytes < state.target_read_bytes) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -262,17 +262,17 @@ static void large_read_test(size_t slice_size) { } struct write_socket_state { - grpc_endpoint *ep; + grpc_endpoint* ep; int write_done; }; -static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, - size_t *num_blocks, uint8_t *current_data) { +static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size, + size_t* num_blocks, uint8_t* current_data) { size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1u : 0u); - grpc_slice *slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * nslices); + grpc_slice* slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * nslices); size_t num_bytes_left = num_bytes; unsigned i, j; - unsigned char *buf; + unsigned char* buf; *num_blocks = nslices; for (i = 0; i < nslices; ++i) { @@ -289,10 +289,10 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, return slices; } -static void write_done(grpc_exec_ctx *exec_ctx, - void *user_data /* write_socket_state */, - grpc_error *error) { - struct write_socket_state *state = (struct write_socket_state *)user_data; +static void write_done(grpc_exec_ctx* exec_ctx, + void* user_data /* write_socket_state */, + grpc_error* error) { + struct write_socket_state* state = (struct write_socket_state*)user_data; gpr_log(GPR_INFO, "Write done callback called"); gpr_mu_lock(g_mu); gpr_log(GPR_INFO, "Signalling write done"); @@ -303,7 +303,7 @@ static void write_done(grpc_exec_ctx *exec_ctx, } void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) { - unsigned char *buf = (unsigned char *)gpr_malloc(read_size); + unsigned char* buf = (unsigned char*)gpr_malloc(read_size); ssize_t bytes_read; size_t bytes_left = num_bytes; int flags; @@ -315,7 +315,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) { GPR_ASSERT(fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) == 0); for (;;) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; gpr_mu_lock(g_mu); GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", @@ -347,10 +347,10 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) { socket in parallel with the read. */ static void write_test(size_t num_bytes, size_t slice_size) { int sv[2]; - grpc_endpoint *ep; + grpc_endpoint* ep; struct write_socket_state state; size_t num_blocks; - grpc_slice *slices; + grpc_slice* slices; uint8_t current_data = 0; grpc_slice_buffer outgoing; grpc_closure write_done_closure; @@ -365,7 +365,7 @@ static void write_test(size_t num_bytes, size_t slice_size) { create_sockets(sv); grpc_arg a[1]; - a[0].key = const_cast<char *>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size; grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "write_test"), &args, @@ -386,7 +386,7 @@ static void write_test(size_t num_bytes, size_t slice_size) { drain_socket_blocking(sv[0], num_bytes, num_bytes); gpr_mu_lock(g_mu); for (;;) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (state.write_done) { break; } @@ -405,8 +405,8 @@ static void write_test(size_t num_bytes, size_t slice_size) { grpc_exec_ctx_finish(&exec_ctx); } -void on_fd_released(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *errors) { - int *done = (int *)arg; +void on_fd_released(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* errors) { + int* done = (int*)arg; *done = 1; GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, NULL))); @@ -416,7 +416,7 @@ void on_fd_released(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *errors) { grpc_tcp_fd() is available before the fd is released. */ static void release_fd_test(size_t num_bytes, size_t slice_size) { int sv[2]; - grpc_endpoint *ep; + grpc_endpoint* ep; struct read_socket_state state; size_t written_bytes; int fd; @@ -435,7 +435,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { create_sockets(sv); grpc_arg a[1]; - a[0].key = const_cast<char *>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); a[0].type = GRPC_ARG_INTEGER; a[0].value.integer = (int)slice_size; grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; @@ -457,7 +457,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { gpr_mu_lock(g_mu); while (state.read_bytes < state.target_read_bytes) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -475,7 +475,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(g_mu); while (!fd_released_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -525,10 +525,10 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair( grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; create_sockets(sv); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("tcp_posix_test_socketpair"); grpc_arg a[1]; - a[0].key = const_cast<char *>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); a[0].type = GRPC_ARG_INTEGER; a[0].value.integer = (int)slice_size; grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; @@ -549,17 +549,17 @@ static grpc_endpoint_test_config configs[] = { {"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up}, }; -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, (grpc_pollset *)p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); + g_pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(g_pollset, &g_mu); grpc_endpoint_tests(configs[0], g_pollset, g_mu); run_tests(); @@ -575,6 +575,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/tcp_server_posix_test.cc b/test/core/iomgr/tcp_server_posix_test.cc index a44e3954f2..6efa74c706 100644 --- a/test/core/iomgr/tcp_server_posix_test.cc +++ b/test/core/iomgr/tcp_server_posix_test.cc @@ -47,20 +47,20 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x) -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static int g_nconnects = 0; typedef struct { /* Owns a ref to server. */ - grpc_tcp_server *server; + grpc_tcp_server* server; unsigned port_index; unsigned fd_index; int server_fd; } on_connect_result; typedef struct { - grpc_tcp_server *server; + grpc_tcp_server* server; /* arg is this server_weak_ref. */ grpc_closure server_shutdown; @@ -81,7 +81,7 @@ typedef struct { static on_connect_result g_result = {NULL, 0, 0, -1}; static char family_name_buf[1024]; -static const char *sock_family_name(int family) { +static const char* sock_family_name(int family) { if (family == AF_INET) { return "AF_INET"; } else if (family == AF_INET6) { @@ -94,15 +94,15 @@ static const char *sock_family_name(int family) { } } -static void on_connect_result_init(on_connect_result *result) { +static void on_connect_result_init(on_connect_result* result) { result->server = NULL; result->port_index = 0; result->fd_index = 0; result->server_fd = -1; } -static void on_connect_result_set(on_connect_result *result, - const grpc_tcp_server_acceptor *acceptor) { +static void on_connect_result_set(on_connect_result* result, + const grpc_tcp_server_acceptor* acceptor) { result->server = grpc_tcp_server_ref(acceptor->from_server); result->port_index = acceptor->port_index; result->fd_index = acceptor->fd_index; @@ -110,13 +110,13 @@ static void on_connect_result_set(on_connect_result *result, result->server, acceptor->port_index, acceptor->fd_index); } -static void server_weak_ref_shutdown(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - server_weak_ref *weak_ref = static_cast<server_weak_ref *>(arg); +static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg); weak_ref->server = NULL; } -static void server_weak_ref_init(server_weak_ref *weak_ref) { +static void server_weak_ref_init(server_weak_ref* weak_ref) { weak_ref->server = NULL; GRPC_CLOSURE_INIT(&weak_ref->server_shutdown, server_weak_ref_shutdown, weak_ref, grpc_schedule_on_exec_ctx); @@ -127,14 +127,14 @@ static void server_weak_ref_init(server_weak_ref *weak_ref) { weak_ref->server_shutdown has returned. A strong ref on grpc_tcp_server should be held until server_weak_ref_set() returns to avoid a race where the server is deleted before the shutdown_starting cb is added. */ -static void server_weak_ref_set(server_weak_ref *weak_ref, - grpc_tcp_server *server) { +static void server_weak_ref_set(server_weak_ref* weak_ref, + grpc_tcp_server* server) { grpc_tcp_server_shutdown_starting_add(server, &weak_ref->server_shutdown); weak_ref->server = server; } -static void test_addr_init_str(test_addr *addr) { - char *str = NULL; +static void test_addr_init_str(test_addr* addr) { + char* str = NULL; if (grpc_sockaddr_to_string(&str, &addr->addr, 0) != -1) { size_t str_len; memcpy(addr->str, str, (str_len = strnlen(str, sizeof(addr->str) - 1))); @@ -145,9 +145,9 @@ static void test_addr_init_str(test_addr *addr) { } } -static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, - grpc_pollset *pollset, - grpc_tcp_server_acceptor *acceptor) { +static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp, + grpc_pollset* pollset, + grpc_tcp_server_acceptor* acceptor) { grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected")); grpc_endpoint_destroy(exec_ctx, tcp); @@ -166,7 +166,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, static void test_no_op(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); grpc_tcp_server_unref(&exec_ctx, s); @@ -175,7 +175,7 @@ static void test_no_op(void) { static void test_no_op_with_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_start"); @@ -187,8 +187,8 @@ static void test_no_op_with_start(void) { static void test_no_op_with_port(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_tcp_server *s; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_port"); @@ -208,8 +208,8 @@ static void test_no_op_with_port(void) { static void test_no_op_with_port_and_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_tcp_server *s; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_port_and_start"); @@ -228,14 +228,14 @@ static void test_no_op_with_port_and_start(void) { grpc_exec_ctx_finish(&exec_ctx); } -static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote, - on_connect_result *result) { +static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote, + on_connect_result* result) { grpc_millis deadline = grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); int clifd; int nconnects_before; - const struct sockaddr *remote_addr = - (const struct sockaddr *)remote->addr.addr; + const struct sockaddr* remote_addr = + (const struct sockaddr*)remote->addr.addr; gpr_log(GPR_INFO, "Connecting to %s", remote->str); gpr_mu_lock(g_mu); @@ -255,8 +255,8 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote, gpr_log(GPR_DEBUG, "wait"); while (g_nconnects == nconnects_before && deadline > grpc_exec_ctx_now(exec_ctx)) { - grpc_pollset_worker *worker = NULL; - grpc_error *err; + grpc_pollset_worker* worker = NULL; + grpc_error* err; if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline)) != GRPC_ERROR_NONE) { gpr_mu_unlock(g_mu); @@ -290,21 +290,21 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote, each destination address, set grpc_resolved_address::len=0 for failures, but don't fail the overall unitest. */ static void test_connect(size_t num_connects, - const grpc_channel_args *channel_args, - test_addrs *dst_addrs, bool test_dst_addrs) { + const grpc_channel_args* channel_args, + test_addrs* dst_addrs, bool test_dst_addrs) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; grpc_resolved_address resolved_addr1; - struct sockaddr_storage *const addr = - (struct sockaddr_storage *)resolved_addr.addr; - struct sockaddr_storage *const addr1 = - (struct sockaddr_storage *)resolved_addr1.addr; + struct sockaddr_storage* const addr = + (struct sockaddr_storage*)resolved_addr.addr; + struct sockaddr_storage* const addr1 = + (struct sockaddr_storage*)resolved_addr1.addr; unsigned svr_fd_count; int port; int svr_port; unsigned svr1_fd_count; int svr1_port; - grpc_tcp_server *s; + grpc_tcp_server* s; const unsigned num_ports = 2; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, channel_args, &s)); @@ -362,7 +362,7 @@ static void test_connect(size_t num_connects, for (dst_idx = 0; dst_idx < dst_addrs->naddrs; ++dst_idx) { test_addr dst = dst_addrs->addrs[dst_idx]; on_connect_result result; - grpc_error *err; + grpc_error* err; if (dst.addr.len == 0) { gpr_log(GPR_DEBUG, "Skipping test of non-functional local IP %s", dst.str); @@ -394,8 +394,8 @@ static void test_connect(size_t num_connects, test_addr dst; GPR_ASSERT(fd >= 0); dst.addr.len = sizeof(dst.addr.addr); - GPR_ASSERT(getsockname(fd, (struct sockaddr *)dst.addr.addr, - (socklen_t *)&dst.addr.len) == 0); + GPR_ASSERT(getsockname(fd, (struct sockaddr*)dst.addr.addr, + (socklen_t*)&dst.addr.len) == 0); GPR_ASSERT(dst.addr.len <= sizeof(dst.addr.addr)); test_addr_init_str(&dst); gpr_log(GPR_INFO, "(%d, %d) fd %d family %s listening on %s", port_num, @@ -427,27 +427,27 @@ static void test_connect(size_t num_connects, GPR_ASSERT(weak_ref.server == NULL); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset *>(p)); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_arg chan_args[1]; chan_args[0].type = GRPC_ARG_INTEGER; - chan_args[0].key = const_cast<char *>(GRPC_ARG_EXPAND_WILDCARD_ADDRS); + chan_args[0].key = const_cast<char*>(GRPC_ARG_EXPAND_WILDCARD_ADDRS); chan_args[0].value.integer = 1; const grpc_channel_args channel_args = {1, chan_args}; - struct ifaddrs *ifa = NULL; - struct ifaddrs *ifa_it; + struct ifaddrs* ifa = NULL; + struct ifaddrs* ifa_it; // Zalloc dst_addrs to avoid oversized frames. - test_addrs *dst_addrs = - static_cast<test_addrs *>(gpr_zalloc(sizeof(*dst_addrs))); + test_addrs* dst_addrs = + static_cast<test_addrs*>(gpr_zalloc(sizeof(*dst_addrs))); grpc_test_init(argc, argv); grpc_init(); - g_pollset = static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); test_no_op(); @@ -507,6 +507,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/tcp_server_uv_test.cc b/test/core/iomgr/tcp_server_uv_test.cc index 3fcbd4085c..dd047a0498 100644 --- a/test/core/iomgr/tcp_server_uv_test.cc +++ b/test/core/iomgr/tcp_server_uv_test.cc @@ -41,19 +41,19 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x) -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static int g_nconnects = 0; typedef struct on_connect_result { /* Owns a ref to server. */ - grpc_tcp_server *server; + grpc_tcp_server* server; unsigned port_index; unsigned fd_index; } on_connect_result; typedef struct server_weak_ref { - grpc_tcp_server *server; + grpc_tcp_server* server; /* arg is this server_weak_ref. */ grpc_closure server_shutdown; @@ -61,26 +61,26 @@ typedef struct server_weak_ref { static on_connect_result g_result = {NULL, 0, 0}; -static void on_connect_result_init(on_connect_result *result) { +static void on_connect_result_init(on_connect_result* result) { result->server = NULL; result->port_index = 0; result->fd_index = 0; } -static void on_connect_result_set(on_connect_result *result, - const grpc_tcp_server_acceptor *acceptor) { +static void on_connect_result_set(on_connect_result* result, + const grpc_tcp_server_acceptor* acceptor) { result->server = grpc_tcp_server_ref(acceptor->from_server); result->port_index = acceptor->port_index; result->fd_index = acceptor->fd_index; } -static void server_weak_ref_shutdown(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - server_weak_ref *weak_ref = static_cast<server_weak_ref *>(arg); +static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg); weak_ref->server = NULL; } -static void server_weak_ref_init(server_weak_ref *weak_ref) { +static void server_weak_ref_init(server_weak_ref* weak_ref) { weak_ref->server = NULL; GRPC_CLOSURE_INIT(&weak_ref->server_shutdown, server_weak_ref_shutdown, weak_ref, grpc_schedule_on_exec_ctx); @@ -91,15 +91,15 @@ static void server_weak_ref_init(server_weak_ref *weak_ref) { weak_ref->server_shutdown has returned. A strong ref on grpc_tcp_server should be held until server_weak_ref_set() returns to avoid a race where the server is deleted before the shutdown_starting cb is added. */ -static void server_weak_ref_set(server_weak_ref *weak_ref, - grpc_tcp_server *server) { +static void server_weak_ref_set(server_weak_ref* weak_ref, + grpc_tcp_server* server) { grpc_tcp_server_shutdown_starting_add(server, &weak_ref->server_shutdown); weak_ref->server = server; } -static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, - grpc_pollset *pollset, - grpc_tcp_server_acceptor *acceptor) { +static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp, + grpc_pollset* pollset, + grpc_tcp_server_acceptor* acceptor) { grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected")); grpc_endpoint_destroy(exec_ctx, tcp); @@ -118,7 +118,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, static void test_no_op(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); grpc_tcp_server_unref(&exec_ctx, s); @@ -127,7 +127,7 @@ static void test_no_op(void) { static void test_no_op_with_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_start"); @@ -139,8 +139,8 @@ static void test_no_op_with_start(void) { static void test_no_op_with_port(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_tcp_server *s; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_port"); @@ -160,8 +160,8 @@ static void test_no_op_with_port(void) { static void test_no_op_with_port_and_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_tcp_server *s; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_port_and_start"); @@ -180,20 +180,20 @@ static void test_no_op_with_port_and_start(void) { grpc_exec_ctx_finish(&exec_ctx); } -static void connect_cb(uv_connect_t *req, int status) { +static void connect_cb(uv_connect_t* req, int status) { GPR_ASSERT(status == 0); gpr_free(req); } -static void close_cb(uv_handle_t *handle) { gpr_free(handle); } +static void close_cb(uv_handle_t* handle) { gpr_free(handle); } -static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, - socklen_t remote_len, on_connect_result *result) { +static void tcp_connect(grpc_exec_ctx* exec_ctx, const struct sockaddr* remote, + socklen_t remote_len, on_connect_result* result) { gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); - uv_tcp_t *client_handle = - static_cast<uv_tcp_t *>(gpr_malloc(sizeof(uv_tcp_t))); - uv_connect_t *req = - static_cast<uv_connect_t *>(gpr_malloc(sizeof(uv_connect_t))); + uv_tcp_t* client_handle = + static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t))); + uv_connect_t* req = + static_cast<uv_connect_t*>(gpr_malloc(sizeof(uv_connect_t))); int nconnects_before; gpr_mu_lock(g_mu); @@ -205,7 +205,7 @@ static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, gpr_log(GPR_DEBUG, "wait"); while (g_nconnects == nconnects_before && gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(exec_ctx, g_pollset, &worker, @@ -216,7 +216,7 @@ static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, } gpr_log(GPR_DEBUG, "wait done"); GPR_ASSERT(g_nconnects == nconnects_before + 1); - uv_close((uv_handle_t *)client_handle, close_cb); + uv_close((uv_handle_t*)client_handle, close_cb); *result = g_result; gpr_mu_unlock(g_mu); @@ -227,12 +227,12 @@ static void test_connect(unsigned n) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; grpc_resolved_address resolved_addr1; - struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr; - struct sockaddr_storage *addr1 = - (struct sockaddr_storage *)resolved_addr1.addr; + struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr; + struct sockaddr_storage* addr1 = + (struct sockaddr_storage*)resolved_addr1.addr; int svr_port; int svr1_port; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); unsigned i; @@ -248,7 +248,7 @@ static void test_connect(unsigned n) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_add_port(s, &resolved_addr, &svr_port)); GPR_ASSERT(svr_port > 0); - GPR_ASSERT((uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr)) == 0); + GPR_ASSERT((uv_ip6_addr("::", svr_port, (struct sockaddr_in6*)addr)) == 0); /* Cannot use wildcard (port==0), because add_port() will try to reuse the same port as a previous add_port(). */ svr1_port = grpc_pick_unused_port_or_die(); @@ -259,13 +259,13 @@ static void test_connect(unsigned n) { grpc_tcp_server_start(&exec_ctx, s, &g_pollset, 1, on_connect, NULL); - GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr1) == 0); + GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6*)addr1) == 0); for (i = 0; i < n; i++) { on_connect_result result; on_connect_result_init(&result); - tcp_connect(&exec_ctx, (struct sockaddr *)addr, - (socklen_t)resolved_addr.len, &result); + tcp_connect(&exec_ctx, (struct sockaddr*)addr, (socklen_t)resolved_addr.len, + &result); GPR_ASSERT(result.port_index == 0); GPR_ASSERT(result.server == s); if (weak_ref.server == NULL) { @@ -274,7 +274,7 @@ static void test_connect(unsigned n) { grpc_tcp_server_unref(&exec_ctx, result.server); on_connect_result_init(&result); - tcp_connect(&exec_ctx, (struct sockaddr *)addr1, + tcp_connect(&exec_ctx, (struct sockaddr*)addr1, (socklen_t)resolved_addr1.len, &result); GPR_ASSERT(result.port_index == 1); GPR_ASSERT(result.server == s); @@ -291,17 +291,17 @@ static void test_connect(unsigned n) { GPR_ASSERT(weak_ref.server == NULL); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset *>(p)); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = static_cast<grpc_pollset *>(gpr_malloc(grpc_pollset_size())); + g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); test_no_op(); @@ -322,6 +322,6 @@ int main(int argc, char **argv) { #else /* GRPC_UV */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_UV */ diff --git a/test/core/iomgr/time_averaged_stats_test.cc b/test/core/iomgr/time_averaged_stats_test.cc index 508e3c5bf8..b932e62d1f 100644 --- a/test/core/iomgr/time_averaged_stats_test.cc +++ b/test/core/iomgr/time_averaged_stats_test.cc @@ -179,7 +179,7 @@ static void some_regress_some_persist_test(void) { EXPECT_DOUBLE_EQ(2.8304, tas.aggregate_total_weight); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); no_regress_no_persist_test_1(); no_regress_no_persist_test_2(); diff --git a/test/core/iomgr/timer_heap_test.cc b/test/core/iomgr/timer_heap_test.cc index 3eb25dd0be..20a383371d 100644 --- a/test/core/iomgr/timer_heap_test.cc +++ b/test/core/iomgr/timer_heap_test.cc @@ -34,9 +34,9 @@ static gpr_atm random_deadline(void) { return rand(); } -static grpc_timer *create_test_elements(size_t num_elements) { - grpc_timer *elems = - static_cast<grpc_timer *>(gpr_malloc(num_elements * sizeof(grpc_timer))); +static grpc_timer* create_test_elements(size_t num_elements) { + grpc_timer* elems = + static_cast<grpc_timer*>(gpr_malloc(num_elements * sizeof(grpc_timer))); size_t i; for (i = 0; i < num_elements; i++) { elems[i].deadline = random_deadline(); @@ -44,7 +44,7 @@ static grpc_timer *create_test_elements(size_t num_elements) { return elems; } -static int contains(grpc_timer_heap *pq, grpc_timer *el) { +static int contains(grpc_timer_heap* pq, grpc_timer* el) { size_t i; for (i = 0; i < pq->timer_count; i++) { if (pq->timers[i] == el) return 1; @@ -52,7 +52,7 @@ static int contains(grpc_timer_heap *pq, grpc_timer *el) { return 0; } -static void check_valid(grpc_timer_heap *pq) { +static void check_valid(grpc_timer_heap* pq) { size_t i; for (i = 0; i < pq->timer_count; ++i) { size_t left_child = 1u + 2u * i; @@ -75,8 +75,8 @@ static void test1(void) { const size_t num_test_elements = 200; const size_t num_test_operations = 10000; size_t i; - grpc_timer *test_elements = create_test_elements(num_test_elements); - uint8_t *inpq = static_cast<uint8_t *>(gpr_malloc(num_test_elements)); + grpc_timer* test_elements = create_test_elements(num_test_elements); + uint8_t* inpq = static_cast<uint8_t*>(gpr_malloc(num_test_elements)); gpr_log(GPR_INFO, "test1"); @@ -103,7 +103,7 @@ static void test1(void) { for (i = 0; i < num_test_operations; ++i) { size_t elem_num = (size_t)rand() % num_test_elements; - grpc_timer *el = &test_elements[elem_num]; + grpc_timer* el = &test_elements[elem_num]; if (!inpq[elem_num]) { /* not in pq */ GPR_ASSERT(!contains(&pq, el)); el->deadline = random_deadline(); @@ -134,10 +134,10 @@ typedef struct { bool inserted; } elem_struct; -static elem_struct *search_elems(elem_struct *elems, size_t count, +static elem_struct* search_elems(elem_struct* elems, size_t count, bool inserted) { - size_t *search_order = - static_cast<size_t *>(gpr_malloc(count * sizeof(*search_order))); + size_t* search_order = + static_cast<size_t*>(gpr_malloc(count * sizeof(*search_order))); for (size_t i = 0; i < count; i++) { search_order[i] = i; } @@ -146,7 +146,7 @@ static elem_struct *search_elems(elem_struct *elems, size_t count, size_t b = (size_t)rand() % count; GPR_SWAP(size_t, search_order[a], search_order[b]); } - elem_struct *out = NULL; + elem_struct* out = NULL; for (size_t i = 0; out == NULL && i < count; i++) { if (elems[search_order[i]].inserted == inserted) { out = &elems[search_order[i]]; @@ -162,8 +162,8 @@ static void test2(void) { grpc_timer_heap pq; static const size_t elems_size = 1000; - elem_struct *elems = - static_cast<elem_struct *>(gpr_malloc(elems_size * sizeof(elem_struct))); + elem_struct* elems = + static_cast<elem_struct*>(gpr_malloc(elems_size * sizeof(elem_struct))); size_t num_inserted = 0; grpc_timer_heap_init(&pq); @@ -173,7 +173,7 @@ static void test2(void) { int r = rand() % 1000; if (r <= 550) { /* 55% of the time we try to add something */ - elem_struct *el = search_elems(elems, GPR_ARRAY_SIZE(elems), false); + elem_struct* el = search_elems(elems, GPR_ARRAY_SIZE(elems), false); if (el != NULL) { el->elem.deadline = random_deadline(); grpc_timer_heap_add(&pq, &el->elem); @@ -183,7 +183,7 @@ static void test2(void) { } } else if (r <= 650) { /* 10% of the time we try to remove something */ - elem_struct *el = search_elems(elems, GPR_ARRAY_SIZE(elems), true); + elem_struct* el = search_elems(elems, GPR_ARRAY_SIZE(elems), true); if (el != NULL) { grpc_timer_heap_remove(&pq, &el->elem); el->inserted = false; @@ -193,7 +193,7 @@ static void test2(void) { } else { /* the remaining times we pop */ if (num_inserted > 0) { - grpc_timer *top = grpc_timer_heap_top(&pq); + grpc_timer* top = grpc_timer_heap_top(&pq); grpc_timer_heap_pop(&pq); for (size_t i = 0; i < elems_size; i++) { if (top == &elems[i].elem) { @@ -207,7 +207,7 @@ static void test2(void) { } if (num_inserted) { - gpr_atm *min_deadline = NULL; + gpr_atm* min_deadline = NULL; for (size_t i = 0; i < elems_size; i++) { if (elems[i].inserted) { if (min_deadline == NULL) { @@ -249,7 +249,7 @@ static void shrink_test(void) { /* Remove elements until the Size is 1/4 the original size. */ while (pq.timer_count > num_elements / 4) { - grpc_timer *const te = pq.timers[pq.timer_count - 1]; + grpc_timer* const te = pq.timers[pq.timer_count - 1]; grpc_timer_heap_remove(&pq, te); gpr_free(te); } @@ -266,7 +266,7 @@ static void shrink_test(void) { expected_size = pq.timer_count; while (pq.timer_count > 0) { const size_t which = (size_t)rand() % pq.timer_count; - grpc_timer *te = pq.timers[which]; + grpc_timer* te = pq.timers[which]; grpc_timer_heap_remove(&pq, te); gpr_free(te); expected_size--; @@ -286,7 +286,7 @@ static void shrink_test(void) { grpc_timer_heap_destroy(&pq); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { int i; grpc_test_init(argc, argv); @@ -302,6 +302,6 @@ int main(int argc, char **argv) { #else /* GRPC_TIMER_USE_GENERIC */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_TIMER_USE_GENERIC */ diff --git a/test/core/iomgr/timer_list_test.cc b/test/core/iomgr/timer_list_test.cc index b07eb50e7f..8783c5c6d7 100644 --- a/test/core/iomgr/timer_list_test.cc +++ b/test/core/iomgr/timer_list_test.cc @@ -36,7 +36,7 @@ extern "C" grpc_tracer_flag grpc_timer_check_trace; static int cb_called[MAX_CB][2]; -static void cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { cb_called[(intptr_t)arg][error == GRPC_ERROR_NONE]++; } @@ -56,16 +56,16 @@ static void add_test(void) { /* 10 ms timers. will expire in the current epoch */ for (i = 0; i < 10; i++) { - grpc_timer_init(&exec_ctx, &timers[i], start + 10, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, - grpc_schedule_on_exec_ctx)); + grpc_timer_init( + &exec_ctx, &timers[i], start + 10, + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx)); } /* 1010 ms timers. will expire in the next epoch */ for (i = 10; i < 20; i++) { - grpc_timer_init(&exec_ctx, &timers[i], start + 1010, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, - grpc_schedule_on_exec_ctx)); + grpc_timer_init( + &exec_ctx, &timers[i], start + 1010, + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx)); } /* collect timers. Only the first batch should be ready. */ @@ -123,19 +123,19 @@ void destruction_test(void) { grpc_timer_init( &exec_ctx, &timers[0], 100, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)0, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)0, grpc_schedule_on_exec_ctx)); grpc_timer_init( &exec_ctx, &timers[1], 3, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)1, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)1, grpc_schedule_on_exec_ctx)); grpc_timer_init( &exec_ctx, &timers[2], 100, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)2, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)2, grpc_schedule_on_exec_ctx)); grpc_timer_init( &exec_ctx, &timers[3], 3, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)3, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)3, grpc_schedule_on_exec_ctx)); grpc_timer_init( &exec_ctx, &timers[4], 1, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)4, grpc_schedule_on_exec_ctx)); exec_ctx.now = 2; GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED); grpc_exec_ctx_finish(&exec_ctx); @@ -152,7 +152,7 @@ void destruction_test(void) { GPR_ASSERT(1 == cb_called[2][0]); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG); add_test(); @@ -162,6 +162,6 @@ int main(int argc, char **argv) { #else /* GRPC_TIMER_USE_GENERIC */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_TIMER_USE_GENERIC */ diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc index 51c7ab8c29..4e8f234a8b 100644 --- a/test/core/iomgr/udp_server_test.cc +++ b/test/core/iomgr/udp_server_test.cc @@ -43,14 +43,14 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x) -static grpc_pollset *g_pollset; -static gpr_mu *g_mu; +static grpc_pollset* g_pollset; +static gpr_mu* g_mu; static int g_number_of_reads = 0; static int g_number_of_writes = 0; static int g_number_of_bytes_read = 0; static int g_number_of_orphan_calls = 0; -static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) { +static void on_read(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) { char read_buffer[512]; ssize_t byte_count; @@ -66,7 +66,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) { gpr_mu_unlock(g_mu); } -static void on_write(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) { +static void on_write(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) { gpr_mu_lock(g_mu); g_number_of_writes++; @@ -75,8 +75,8 @@ static void on_write(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) { gpr_mu_unlock(g_mu); } -static void on_fd_orphaned(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, - grpc_closure *closure, void *user_data) { +static void on_fd_orphaned(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, + grpc_closure* closure, void* user_data) { gpr_log(GPR_INFO, "gRPC FD about to be orphaned: %d", grpc_fd_wrapped_fd(emfd)); g_number_of_orphan_calls++; @@ -89,27 +89,27 @@ struct test_socket_factory { }; typedef struct test_socket_factory test_socket_factory; -static int test_socket_factory_socket(grpc_socket_factory *factory, int domain, +static int test_socket_factory_socket(grpc_socket_factory* factory, int domain, int type, int protocol) { - test_socket_factory *f = (test_socket_factory *)factory; + test_socket_factory* f = (test_socket_factory*)factory; f->number_of_socket_calls++; return socket(domain, type, protocol); } -static int test_socket_factory_bind(grpc_socket_factory *factory, int sockfd, - const grpc_resolved_address *addr) { - test_socket_factory *f = (test_socket_factory *)factory; +static int test_socket_factory_bind(grpc_socket_factory* factory, int sockfd, + const grpc_resolved_address* addr) { + test_socket_factory* f = (test_socket_factory*)factory; f->number_of_bind_calls++; - return bind(sockfd, (struct sockaddr *)addr->addr, (socklen_t)addr->len); + return bind(sockfd, (struct sockaddr*)addr->addr, (socklen_t)addr->len); } -static int test_socket_factory_compare(grpc_socket_factory *a, - grpc_socket_factory *b) { +static int test_socket_factory_compare(grpc_socket_factory* a, + grpc_socket_factory* b) { return GPR_ICMP(a, b); } -static void test_socket_factory_destroy(grpc_socket_factory *factory) { - test_socket_factory *f = (test_socket_factory *)factory; +static void test_socket_factory_destroy(grpc_socket_factory* factory) { + test_socket_factory* f = (test_socket_factory*)factory; gpr_free(f); } @@ -117,8 +117,8 @@ static const grpc_socket_factory_vtable test_socket_factory_vtable = { test_socket_factory_socket, test_socket_factory_bind, test_socket_factory_compare, test_socket_factory_destroy}; -static test_socket_factory *test_socket_factory_create(void) { - test_socket_factory *factory = static_cast<test_socket_factory *>( +static test_socket_factory* test_socket_factory_create(void) { + test_socket_factory* factory = static_cast<test_socket_factory*>( gpr_malloc(sizeof(test_socket_factory))); grpc_socket_factory_init(&factory->base, &test_socket_factory_vtable); factory->number_of_socket_calls = 0; @@ -128,14 +128,14 @@ static test_socket_factory *test_socket_factory_create(void) { static void test_no_op(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_udp_server *s = grpc_udp_server_create(NULL); + grpc_udp_server* s = grpc_udp_server_create(NULL); grpc_udp_server_destroy(&exec_ctx, s, NULL); grpc_exec_ctx_finish(&exec_ctx); } static void test_no_op_with_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_udp_server *s = grpc_udp_server_create(NULL); + grpc_udp_server* s = grpc_udp_server_create(NULL); LOG_TEST("test_no_op_with_start"); grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL); grpc_udp_server_destroy(&exec_ctx, s, NULL); @@ -146,8 +146,8 @@ static void test_no_op_with_port(void) { g_number_of_orphan_calls = 0; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_udp_server *s = grpc_udp_server_create(NULL); + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_udp_server* s = grpc_udp_server_create(NULL); LOG_TEST("test_no_op_with_port"); memset(&resolved_addr, 0, sizeof(resolved_addr)); @@ -167,14 +167,14 @@ static void test_no_op_with_port_and_socket_factory(void) { g_number_of_orphan_calls = 0; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; - test_socket_factory *socket_factory = test_socket_factory_create(); + test_socket_factory* socket_factory = test_socket_factory_create(); grpc_arg socket_factory_arg = grpc_socket_factory_to_arg(&socket_factory->base); - grpc_channel_args *channel_args = + grpc_channel_args* channel_args = grpc_channel_args_copy_and_add(NULL, &socket_factory_arg, 1); - grpc_udp_server *s = grpc_udp_server_create(channel_args); + grpc_udp_server* s = grpc_udp_server_create(channel_args); grpc_channel_args_destroy(&exec_ctx, channel_args); LOG_TEST("test_no_op_with_port_and_socket_factory"); @@ -199,8 +199,8 @@ static void test_no_op_with_port_and_start(void) { g_number_of_orphan_calls = 0; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_udp_server *s = grpc_udp_server_create(NULL); + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_udp_server* s = grpc_udp_server_create(NULL); LOG_TEST("test_no_op_with_port_and_start"); memset(&resolved_addr, 0, sizeof(resolved_addr)); @@ -222,13 +222,13 @@ static void test_no_op_with_port_and_start(void) { static void test_receive(int number_of_clients) { 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 clifd, svrfd; - grpc_udp_server *s = grpc_udp_server_create(NULL); + grpc_udp_server* s = grpc_udp_server_create(NULL); int i; int number_of_reads_before; grpc_millis deadline; - grpc_pollset *pollsets[1]; + grpc_pollset* pollsets[1]; LOG_TEST("test_receive"); gpr_log(GPR_INFO, "clients=%d", number_of_clients); @@ -243,8 +243,8 @@ static void test_receive(int number_of_clients) { svrfd = grpc_udp_server_get_fd(s, 0); GPR_ASSERT(svrfd >= 0); - GPR_ASSERT(getsockname(svrfd, (struct sockaddr *)addr, - (socklen_t *)&resolved_addr.len) == 0); + GPR_ASSERT(getsockname(svrfd, (struct sockaddr*)addr, + (socklen_t*)&resolved_addr.len) == 0); GPR_ASSERT(resolved_addr.len <= sizeof(struct sockaddr_storage)); pollsets[0] = g_pollset; @@ -260,12 +260,12 @@ static void test_receive(int number_of_clients) { /* Create a socket, send a packet to the UDP server. */ clifd = socket(addr->ss_family, SOCK_DGRAM, 0); GPR_ASSERT(clifd >= 0); - GPR_ASSERT(connect(clifd, (struct sockaddr *)addr, + GPR_ASSERT(connect(clifd, (struct sockaddr*)addr, (socklen_t)resolved_addr.len) == 0); GPR_ASSERT(5 == write(clifd, "hello", 5)); while (g_number_of_reads == number_of_reads_before && deadline > grpc_exec_ctx_now(&exec_ctx)) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -291,17 +291,17 @@ static void test_receive(int number_of_clients) { GPR_ASSERT(g_number_of_writes > 0); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset *>(p)); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); test_no_op(); @@ -323,6 +323,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/wakeup_fd_cv_test.cc b/test/core/iomgr/wakeup_fd_cv_test.cc index 0b211274f2..dc1d77a0ab 100644 --- a/test/core/iomgr/wakeup_fd_cv_test.cc +++ b/test/core/iomgr/wakeup_fd_cv_test.cc @@ -32,7 +32,7 @@ #include "src/core/lib/support/env.h" typedef struct poll_args { - struct pollfd *fds; + struct pollfd* fds; nfds_t nfds; int timeout; int result; @@ -57,7 +57,7 @@ void reset_socket_event() { } // Mocks posix poll() function -int mock_poll(struct pollfd *fds, nfds_t nfds, int timeout) { +int mock_poll(struct pollfd* fds, nfds_t nfds, int timeout) { int res = 0; gpr_timespec poll_time; gpr_mu_lock(&poll_mu); @@ -84,8 +84,8 @@ int mock_poll(struct pollfd *fds, nfds_t nfds, int timeout) { return res; } -void background_poll(void *args) { - poll_args *pargs = (poll_args *)args; +void background_poll(void* args) { + poll_args* pargs = (poll_args*)args; pargs->result = grpc_poll_function(pargs->fds, pargs->nfds, pargs->timeout); } @@ -211,7 +211,7 @@ void test_poll_cv_trigger(void) { GPR_ASSERT(pfds[5].revents == 0); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { gpr_setenv("GRPC_POLL_STRATEGY", "poll-cv"); grpc_poll_function = &mock_poll; gpr_mu_init(&poll_mu); @@ -229,6 +229,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/json/fuzzer.cc b/test/core/json/fuzzer.cc index 58c34e51d1..6dafabb95b 100644 --- a/test/core/json/fuzzer.cc +++ b/test/core/json/fuzzer.cc @@ -29,13 +29,13 @@ bool squelch = true; bool leak_check = true; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - char *s; +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + char* s; struct grpc_memory_counters counters; grpc_memory_counters_init(); - s = static_cast<char *>(gpr_malloc(size)); + s = static_cast<char*>(gpr_malloc(size)); memcpy(s, data, size); - grpc_json *x; + grpc_json* x; if ((x = grpc_json_parse_string_with_len(s, size))) { grpc_json_destroy(x); } diff --git a/test/core/json/json_rewrite.cc b/test/core/json/json_rewrite.cc index 27443e3c49..98e76e9772 100644 --- a/test/core/json/json_rewrite.cc +++ b/test/core/json/json_rewrite.cc @@ -26,37 +26,39 @@ #include "src/core/lib/json/json_reader.h" #include "src/core/lib/json/json_writer.h" -typedef struct json_writer_userdata { FILE *out; } json_writer_userdata; +typedef struct json_writer_userdata { + FILE* out; +} json_writer_userdata; typedef struct stacked_container { grpc_json_type type; - struct stacked_container *next; + struct stacked_container* next; } stacked_container; typedef struct json_reader_userdata { - FILE *in; - grpc_json_writer *writer; - char *scratchpad; - char *ptr; + FILE* in; + grpc_json_writer* writer; + char* scratchpad; + char* ptr; size_t free_space; size_t allocated; size_t string_len; - stacked_container *top; + stacked_container* top; } json_reader_userdata; -static void json_writer_output_char(void *userdata, char c) { - json_writer_userdata *state = static_cast<json_writer_userdata *>(userdata); +static void json_writer_output_char(void* userdata, char c) { + json_writer_userdata* state = static_cast<json_writer_userdata*>(userdata); fputc(c, state->out); } -static void json_writer_output_string(void *userdata, const char *str) { - json_writer_userdata *state = static_cast<json_writer_userdata *>(userdata); +static void json_writer_output_string(void* userdata, const char* str) { + json_writer_userdata* state = static_cast<json_writer_userdata*>(userdata); fputs(str, state->out); } -static void json_writer_output_string_with_len(void *userdata, const char *str, +static void json_writer_output_string_with_len(void* userdata, const char* str, size_t len) { - json_writer_userdata *state = static_cast<json_writer_userdata *>(userdata); + json_writer_userdata* state = static_cast<json_writer_userdata*>(userdata); fwrite(str, len, 1, state->out); } @@ -64,30 +66,30 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char, json_writer_output_string, json_writer_output_string_with_len}; -static void check_string(json_reader_userdata *state, size_t needed) { +static void check_string(json_reader_userdata* state, size_t needed) { if (state->free_space >= needed) return; needed -= state->free_space; needed = (needed + 0xffu) & ~0xffu; - state->scratchpad = static_cast<char *>( + state->scratchpad = static_cast<char*>( gpr_realloc(state->scratchpad, state->allocated + needed)); state->free_space += needed; state->allocated += needed; } -static void json_reader_string_clear(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_string_clear(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); state->free_space = state->allocated; state->string_len = 0; } -static void json_reader_string_add_char(void *userdata, uint32_t c) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_string_add_char(void* userdata, uint32_t c) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); check_string(state, 1); GPR_ASSERT(c < 256); state->scratchpad[state->string_len++] = (char)c; } -static void json_reader_string_add_utf32(void *userdata, uint32_t c) { +static void json_reader_string_add_utf32(void* userdata, uint32_t c) { if (c <= 0x7f) { json_reader_string_add_char(userdata, c); } else if (c <= 0x7ff) { @@ -114,19 +116,19 @@ static void json_reader_string_add_utf32(void *userdata, uint32_t c) { } } -static uint32_t json_reader_read_char(void *userdata) { +static uint32_t json_reader_read_char(void* userdata) { int r; - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); r = fgetc(state->in); if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF; return (uint32_t)r; } -static void json_reader_container_begins(void *userdata, grpc_json_type type) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); - stacked_container *container = - static_cast<stacked_container *>(gpr_malloc(sizeof(stacked_container))); +static void json_reader_container_begins(void* userdata, grpc_json_type type) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); + stacked_container* container = + static_cast<stacked_container*>(gpr_malloc(sizeof(stacked_container))); container->type = type; container->next = state->top; @@ -135,9 +137,9 @@ static void json_reader_container_begins(void *userdata, grpc_json_type type) { grpc_json_writer_container_begins(state->writer, type); } -static grpc_json_type json_reader_container_ends(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); - stacked_container *container = state->top; +static grpc_json_type json_reader_container_ends(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); + stacked_container* container = state->top; grpc_json_writer_container_ends(state->writer, container->type); state->top = container->next; @@ -145,22 +147,22 @@ static grpc_json_type json_reader_container_ends(void *userdata) { return state->top ? state->top->type : GRPC_JSON_TOP_LEVEL; } -static void json_reader_set_key(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_key(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); json_reader_string_add_char(userdata, 0); grpc_json_writer_object_key(state->writer, state->scratchpad); } -static void json_reader_set_string(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_string(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); json_reader_string_add_char(userdata, 0); grpc_json_writer_value_string(state->writer, state->scratchpad); } -static int json_reader_set_number(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static int json_reader_set_number(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); grpc_json_writer_value_raw_with_len(state->writer, state->scratchpad, state->string_len); @@ -168,20 +170,20 @@ static int json_reader_set_number(void *userdata) { return 1; } -static void json_reader_set_true(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_true(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); grpc_json_writer_value_raw_with_len(state->writer, "true", 4); } -static void json_reader_set_false(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_false(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); grpc_json_writer_value_raw_with_len(state->writer, "false", 5); } -static void json_reader_set_null(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_null(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); grpc_json_writer_value_raw_with_len(state->writer, "null", 4); } @@ -194,7 +196,7 @@ static grpc_json_reader_vtable reader_vtable = { json_reader_set_number, json_reader_set_true, json_reader_set_false, json_reader_set_null}; -int rewrite(FILE *in, FILE *out, int indent) { +int rewrite(FILE* in, FILE* out, int indent) { grpc_json_writer writer; grpc_json_reader reader; grpc_json_reader_status status; @@ -218,7 +220,7 @@ int rewrite(FILE *in, FILE *out, int indent) { free(reader_user.scratchpad); while (reader_user.top) { - stacked_container *container = reader_user.top; + stacked_container* container = reader_user.top; reader_user.top = container->next; free(container); } @@ -226,9 +228,9 @@ int rewrite(FILE *in, FILE *out, int indent) { return status == GRPC_JSON_DONE; } -int main(int argc, char **argv) { +int main(int argc, char** argv) { int indent = 2; - gpr_cmdline *cl; + gpr_cmdline* cl; cl = gpr_cmdline_create(NULL); gpr_cmdline_add_int(cl, "indent", NULL, &indent); diff --git a/test/core/json/json_rewrite_test.cc b/test/core/json/json_rewrite_test.cc index ba22709a70..47b4f01e8b 100644 --- a/test/core/json/json_rewrite_test.cc +++ b/test/core/json/json_rewrite_test.cc @@ -27,27 +27,29 @@ #include "src/core/lib/json/json_reader.h" #include "src/core/lib/json/json_writer.h" -typedef struct json_writer_userdata { FILE *cmp; } json_writer_userdata; +typedef struct json_writer_userdata { + FILE* cmp; +} json_writer_userdata; typedef struct stacked_container { grpc_json_type type; - struct stacked_container *next; + struct stacked_container* next; } stacked_container; typedef struct json_reader_userdata { - FILE *in; - grpc_json_writer *writer; - char *scratchpad; - char *ptr; + FILE* in; + grpc_json_writer* writer; + char* scratchpad; + char* ptr; size_t free_space; size_t allocated; size_t string_len; - stacked_container *top; + stacked_container* top; int did_eagain; } json_reader_userdata; -static void json_writer_output_char(void *userdata, char c) { - json_writer_userdata *state = static_cast<json_writer_userdata *>(userdata); +static void json_writer_output_char(void* userdata, char c) { + json_writer_userdata* state = static_cast<json_writer_userdata*>(userdata); int cmp = fgetc(state->cmp); /* treat CRLF as LF */ @@ -57,13 +59,13 @@ static void json_writer_output_char(void *userdata, char c) { GPR_ASSERT(cmp == c); } -static void json_writer_output_string(void *userdata, const char *str) { +static void json_writer_output_string(void* userdata, const char* str) { while (*str) { json_writer_output_char(userdata, *str++); } } -static void json_writer_output_string_with_len(void *userdata, const char *str, +static void json_writer_output_string_with_len(void* userdata, const char* str, size_t len) { size_t i; for (i = 0; i < len; i++) { @@ -75,30 +77,30 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char, json_writer_output_string, json_writer_output_string_with_len}; -static void check_string(json_reader_userdata *state, size_t needed) { +static void check_string(json_reader_userdata* state, size_t needed) { if (state->free_space >= needed) return; needed -= state->free_space; needed = (needed + 0xffu) & ~0xffu; - state->scratchpad = static_cast<char *>( + state->scratchpad = static_cast<char*>( gpr_realloc(state->scratchpad, state->allocated + needed)); state->free_space += needed; state->allocated += needed; } -static void json_reader_string_clear(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_string_clear(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); state->free_space = state->allocated; state->string_len = 0; } -static void json_reader_string_add_char(void *userdata, uint32_t c) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_string_add_char(void* userdata, uint32_t c) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); check_string(state, 1); GPR_ASSERT(c <= 256); state->scratchpad[state->string_len++] = (char)c; } -static void json_reader_string_add_utf32(void *userdata, uint32_t c) { +static void json_reader_string_add_utf32(void* userdata, uint32_t c) { if (c <= 0x7f) { json_reader_string_add_char(userdata, c); } else if (c <= 0x7ffu) { @@ -125,9 +127,9 @@ static void json_reader_string_add_utf32(void *userdata, uint32_t c) { } } -static uint32_t json_reader_read_char(void *userdata) { +static uint32_t json_reader_read_char(void* userdata) { int r; - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); if (!state->did_eagain) { state->did_eagain = 1; @@ -141,10 +143,10 @@ static uint32_t json_reader_read_char(void *userdata) { return (uint32_t)r; } -static void json_reader_container_begins(void *userdata, grpc_json_type type) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); - stacked_container *container = - static_cast<stacked_container *>(gpr_malloc(sizeof(stacked_container))); +static void json_reader_container_begins(void* userdata, grpc_json_type type) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); + stacked_container* container = + static_cast<stacked_container*>(gpr_malloc(sizeof(stacked_container))); container->type = type; container->next = state->top; @@ -153,9 +155,9 @@ static void json_reader_container_begins(void *userdata, grpc_json_type type) { grpc_json_writer_container_begins(state->writer, type); } -static grpc_json_type json_reader_container_ends(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); - stacked_container *container = state->top; +static grpc_json_type json_reader_container_ends(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); + stacked_container* container = state->top; grpc_json_writer_container_ends(state->writer, container->type); state->top = container->next; @@ -163,22 +165,22 @@ static grpc_json_type json_reader_container_ends(void *userdata) { return state->top ? state->top->type : GRPC_JSON_TOP_LEVEL; } -static void json_reader_set_key(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_key(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); json_reader_string_add_char(userdata, 0); grpc_json_writer_object_key(state->writer, state->scratchpad); } -static void json_reader_set_string(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_string(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); json_reader_string_add_char(userdata, 0); grpc_json_writer_value_string(state->writer, state->scratchpad); } -static int json_reader_set_number(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static int json_reader_set_number(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); grpc_json_writer_value_raw_with_len(state->writer, state->scratchpad, state->string_len); @@ -186,20 +188,20 @@ static int json_reader_set_number(void *userdata) { return 1; } -static void json_reader_set_true(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_true(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); grpc_json_writer_value_raw_with_len(state->writer, "true", 4); } -static void json_reader_set_false(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_false(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); grpc_json_writer_value_raw_with_len(state->writer, "false", 5); } -static void json_reader_set_null(void *userdata) { - json_reader_userdata *state = static_cast<json_reader_userdata *>(userdata); +static void json_reader_set_null(void* userdata) { + json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata); grpc_json_writer_value_raw_with_len(state->writer, "null", 4); } @@ -212,7 +214,7 @@ static grpc_json_reader_vtable reader_vtable = { json_reader_set_number, json_reader_set_true, json_reader_set_false, json_reader_set_null}; -int rewrite_and_compare(FILE *in, FILE *cmp, int indent) { +int rewrite_and_compare(FILE* in, FILE* cmp, int indent) { grpc_json_writer writer; grpc_json_reader reader; grpc_json_reader_status status; @@ -242,7 +244,7 @@ int rewrite_and_compare(FILE *in, FILE *cmp, int indent) { free(reader_user.scratchpad); while (reader_user.top) { - stacked_container *container = reader_user.top; + stacked_container* container = reader_user.top; reader_user.top = container->next; free(container); } @@ -251,8 +253,8 @@ int rewrite_and_compare(FILE *in, FILE *cmp, int indent) { } typedef struct test_file { - const char *input; - const char *cmp; + const char* input; + const char* cmp; int indent; } test_file; @@ -271,9 +273,9 @@ void test_rewrites() { unsigned i; for (i = 0; i < GPR_ARRAY_SIZE(test_files); i++) { - test_file *test = test_files + i; - FILE *input = fopen(test->input, "rb"); - FILE *cmp = fopen(test->cmp, "rb"); + test_file* test = test_files + i; + FILE* input = fopen(test->input, "rb"); + FILE* cmp = fopen(test->cmp, "rb"); int status; gpr_log(GPR_INFO, "Testing file %s against %s using indent=%i", test->input, test->cmp, test->indent); @@ -284,7 +286,7 @@ void test_rewrites() { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_rewrites(); gpr_log(GPR_INFO, "json_rewrite_test success"); diff --git a/test/core/json/json_stream_error_test.cc b/test/core/json/json_stream_error_test.cc index 379cd5d078..975ccd2b42 100644 --- a/test/core/json/json_stream_error_test.cc +++ b/test/core/json/json_stream_error_test.cc @@ -29,12 +29,12 @@ static int g_string_clear_once = 0; -static void string_clear(void *userdata) { +static void string_clear(void* userdata) { GPR_ASSERT(!g_string_clear_once); g_string_clear_once = 1; } -static uint32_t read_char(void *userdata) { return GRPC_JSON_READ_CHAR_ERROR; } +static uint32_t read_char(void* userdata) { return GRPC_JSON_READ_CHAR_ERROR; } static grpc_json_reader_vtable reader_vtable = { string_clear, NULL, NULL, read_char, NULL, NULL, @@ -49,7 +49,7 @@ static void read_error() { GPR_ASSERT(status == GRPC_JSON_READ_ERROR); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); read_error(); gpr_log(GPR_INFO, "json_stream_error success"); diff --git a/test/core/json/json_test.cc b/test/core/json/json_test.cc index bbc6f7a4e6..9e4d351dd7 100644 --- a/test/core/json/json_test.cc +++ b/test/core/json/json_test.cc @@ -28,8 +28,8 @@ #include "test/core/util/test_config.h" typedef struct testing_pair { - const char *input; - const char *output; + const char* input; + const char* output; } testing_pair; static testing_pair testing_pairs[] = { @@ -52,7 +52,8 @@ static testing_pair testing_pairs[] = { {"{\"\\ud834\\udd1e\":0}", "{\"\\ud834\\udd1e\":0}"}, /* Testing nested empty containers. */ { - " [ [ ] , { } , [ ] ] ", "[[],{},[]]", + " [ [ ] , { } , [ ] ] ", + "[[],{},[]]", }, /* Testing escapes and control chars in key strings. */ {" { \"\\u007f\x7f\\n\\r\\\"\\f\\b\\\\a , b\": 1, \"\": 0 } ", @@ -139,16 +140,16 @@ static void test_pairs() { unsigned i; for (i = 0; i < GPR_ARRAY_SIZE(testing_pairs); i++) { - testing_pair *pair = testing_pairs + i; - char *scratchpad = gpr_strdup(pair->input); - grpc_json *json; + testing_pair* pair = testing_pairs + i; + char* scratchpad = gpr_strdup(pair->input); + grpc_json* json; gpr_log(GPR_INFO, "parsing string %i - should %s", i, pair->output ? "succeed" : "fail"); json = grpc_json_parse_string(scratchpad); if (pair->output) { - char *output; + char* output; GPR_ASSERT(json); output = grpc_json_dump_to_string(json, 0); @@ -168,9 +169,9 @@ static void test_pairs() { } static void test_atypical() { - char *scratchpad = gpr_strdup("[[],[],[]]"); - grpc_json *json = grpc_json_parse_string(scratchpad); - grpc_json *brother; + char* scratchpad = gpr_strdup("[[],[],[]]"); + grpc_json* json = grpc_json_parse_string(scratchpad); + grpc_json* brother; GPR_ASSERT(json); GPR_ASSERT(json->child); @@ -182,7 +183,7 @@ static void test_atypical() { gpr_free(scratchpad); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_pairs(); test_atypical(); diff --git a/test/core/memory_usage/client.cc b/test/core/memory_usage/client.cc index fbf907fe33..74ec4b0738 100644 --- a/test/core/memory_usage/client.cc +++ b/test/core/memory_usage/client.cc @@ -33,15 +33,15 @@ #include "test/core/util/memory_counters.h" #include "test/core/util/test_config.h" -static grpc_channel *channel; -static grpc_completion_queue *cq; +static grpc_channel* channel; +static grpc_completion_queue* cq; static grpc_op metadata_ops[2]; static grpc_op status_ops[2]; static grpc_op snapshot_ops[6]; -static grpc_op *op; +static grpc_op* op; typedef struct { - grpc_call *call; + grpc_call* call; grpc_metadata_array initial_metadata_recv; grpc_status_code status; grpc_slice details; @@ -52,7 +52,7 @@ typedef struct { // calls and 1 extra for the snapshot calls. static fling_call calls[10001]; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } // A call is intentionally divided into two steps. First step is to initiate a // call (i.e send and recv metadata). A call is outstanding after we initated, @@ -114,7 +114,7 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx, grpc_metadata_array_init(&calls[call_idx].initial_metadata_recv); grpc_metadata_array_init(&calls[call_idx].trailing_metadata_recv); - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; memset(snapshot_ops, 0, sizeof(snapshot_ops)); op = snapshot_ops; @@ -144,7 +144,7 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch( calls[call_idx].call, snapshot_ops, - (size_t)(op - snapshot_ops), (void *)0, NULL)); + (size_t)(op - snapshot_ops), (void*)0, NULL)); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_byte_buffer_reader reader; @@ -153,16 +153,16 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx, struct grpc_memory_counters snapshot; snapshot.total_size_absolute = - ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response)) + ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response)) ->total_size_absolute; snapshot.total_allocs_absolute = - ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response)) + ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response)) ->total_allocs_absolute; snapshot.total_size_relative = - ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response)) + ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response)) ->total_size_relative; snapshot.total_allocs_relative = - ((struct grpc_memory_counters *)GRPC_SLICE_START_PTR(response)) + ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response)) ->total_allocs_relative; grpc_metadata_array_destroy(&calls[call_idx].initial_metadata_recv); @@ -178,13 +178,13 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx, return snapshot; } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_memory_counters_init(); grpc_slice slice = grpc_slice_from_copied_string("x"); - char *fake_argv[1]; + char* fake_argv[1]; - const char *target = "localhost:443"; - gpr_cmdline *cl; + const char* target = "localhost:443"; + gpr_cmdline* cl; grpc_event event; grpc_init(); @@ -251,8 +251,9 @@ int main(int argc, char **argv) { do { event = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(10000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(10000, GPR_TIMESPAN)), NULL); } while (event.type != GRPC_QUEUE_TIMEOUT); @@ -301,11 +302,11 @@ int main(int argc, char **argv) { server_calls_end.total_size_relative - after_server_create.total_size_relative); - const char *csv_file = "memory_usage.csv"; - FILE *csv = fopen(csv_file, "w"); + const char* csv_file = "memory_usage.csv"; + FILE* csv = fopen(csv_file, "w"); if (csv) { - char *env_build = gpr_getenv("BUILD_NUMBER"); - char *env_job = gpr_getenv("JOB_NAME"); + char* env_build = gpr_getenv("BUILD_NUMBER"); + char* env_job = gpr_getenv("JOB_NAME"); fprintf(csv, "%f,%zi,%zi,%f,%zi,%s,%s\n", (double)(client_calls_inflight.total_size_relative - client_benchmark_calls_start.total_size_relative) / diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc index 7bf165719b..58e31c9531 100644 --- a/test/core/memory_usage/memory_usage_test.cc +++ b/test/core/memory_usage/memory_usage_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,21 +44,21 @@ int main(int argc, char **argv) { /* start the server */ gpr_asprintf(&args[0], "%s/memory_profile_server%s", root, gpr_subprocess_binary_extension()); - args[1] = const_cast<char *>("--bind"); + args[1] = const_cast<char*>("--bind"); gpr_join_host_port(&args[2], "::", port); - args[3] = const_cast<char *>("--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/memory_profile_client%s", root, gpr_subprocess_binary_extension()); - args[1] = const_cast<char *>("--target"); + args[1] = const_cast<char*>("--target"); gpr_join_host_port(&args[2], "127.0.0.1", port); - args[3] = const_cast<char *>("--warmup=1000"); - args[4] = const_cast<char *>("--benchmark=9000"); - cli = gpr_subprocess_create(5, (const char **)args); + args[3] = const_cast<char*>("--warmup=1000"); + args[4] = const_cast<char*>("--benchmark=9000"); + cli = gpr_subprocess_create(5, (const char**)args); gpr_free(args[0]); gpr_free(args[2]); diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc index 8dee58e274..04e55db30d 100644 --- a/test/core/memory_usage/server.cc +++ b/test/core/memory_usage/server.cc @@ -39,17 +39,17 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static grpc_completion_queue *cq; -static grpc_server *server; +static grpc_completion_queue* cq; +static grpc_server* server; static grpc_op metadata_ops[2]; static grpc_op snapshot_ops[5]; static grpc_op status_op; static int got_sigint = 0; -static grpc_byte_buffer *payload_buffer = NULL; -static grpc_byte_buffer *terminal_buffer = NULL; +static grpc_byte_buffer* payload_buffer = NULL; +static grpc_byte_buffer* terminal_buffer = NULL; static int was_cancelled = 2; -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, @@ -62,7 +62,7 @@ typedef enum { typedef struct { fling_server_tags state; - grpc_call *call; + grpc_call* call; grpc_call_details call_details; grpc_metadata_array request_metadata_recv; grpc_metadata_array initial_metadata_send; @@ -82,33 +82,33 @@ static void request_call_unary(int call_idx) { &calls[call_idx].request_metadata_recv, cq, cq, &calls[call_idx]); } -static void send_initial_metadata_unary(void *tag) { - grpc_metadata_array_init(&(*(fling_call *)tag).initial_metadata_send); +static void send_initial_metadata_unary(void* tag) { + grpc_metadata_array_init(&(*(fling_call*)tag).initial_metadata_send); metadata_ops[0].op = GRPC_OP_SEND_INITIAL_METADATA; metadata_ops[0].data.send_initial_metadata.count = 0; - GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call *)tag).call, + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call*)tag).call, metadata_ops, 1, tag, NULL)); } -static void send_status(void *tag) { +static void send_status(void* tag) { status_op.op = GRPC_OP_SEND_STATUS_FROM_SERVER; status_op.data.send_status_from_server.status = GRPC_STATUS_OK; status_op.data.send_status_from_server.trailing_metadata_count = 0; grpc_slice details = grpc_slice_from_static_string(""); status_op.data.send_status_from_server.status_details = &details; - GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call *)tag).call, + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch((*(fling_call*)tag).call, &status_op, 1, tag, NULL)); } -static void send_snapshot(void *tag, struct grpc_memory_counters *snapshot) { - grpc_op *op; +static void send_snapshot(void* tag, struct grpc_memory_counters* snapshot) { + grpc_op* op; grpc_slice snapshot_slice = grpc_slice_new(snapshot, sizeof(*snapshot), gpr_free); payload_buffer = grpc_raw_byte_buffer_create(&snapshot_slice, 1); - grpc_metadata_array_init(&(*(fling_call *)tag).initial_metadata_send); + grpc_metadata_array_init(&(*(fling_call*)tag).initial_metadata_send); op = snapshot_ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -134,26 +134,26 @@ static void send_snapshot(void *tag, struct grpc_memory_counters *snapshot) { op++; GPR_ASSERT(GRPC_CALL_OK == - grpc_call_start_batch((*(fling_call *)tag).call, snapshot_ops, + grpc_call_start_batch((*(fling_call*)tag).call, snapshot_ops, (size_t)(op - snapshot_ops), tag, NULL)); } /* We have some sort of deadlock, so let's not exit gracefully for now. 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_memory_counters_init(); grpc_event ev; - char *addr_buf = NULL; - gpr_cmdline *cl; - grpc_completion_queue *shutdown_cq; + char* addr_buf = NULL; + gpr_cmdline* cl; + grpc_completion_queue* shutdown_cq; int shutdown_started = 0; int shutdown_finished = 0; int secure = 0; - const char *addr = NULL; + const char* addr = NULL; - char *fake_argv[1]; + char* fake_argv[1]; GPR_ASSERT(argc >= 1); fake_argv[0] = argv[0]; @@ -181,7 +181,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)); @@ -228,10 +228,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); - fling_call *s = static_cast<fling_call *>(ev.tag); + fling_call* s = static_cast<fling_call*>(ev.tag); switch (ev.type) { case GRPC_OP_COMPLETE: switch (s->state) { diff --git a/test/core/nanopb/fuzzer_response.cc b/test/core/nanopb/fuzzer_response.cc index 9a52c3399a..7039c801cb 100644 --- a/test/core/nanopb/fuzzer_response.cc +++ b/test/core/nanopb/fuzzer_response.cc @@ -26,12 +26,12 @@ bool squelch = true; bool leak_check = true; -static void dont_log(gpr_log_func_args *args) {} +static void dont_log(gpr_log_func_args* args) {} -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (squelch) gpr_set_log_function(dont_log); - grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); - grpc_grpclb_initial_response *response; + grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); + grpc_grpclb_initial_response* response; if ((response = grpc_grpclb_initial_response_parse(slice))) { grpc_grpclb_initial_response_destroy(response); } diff --git a/test/core/nanopb/fuzzer_serverlist.cc b/test/core/nanopb/fuzzer_serverlist.cc index 75b0bbeceb..0a6b1767a1 100644 --- a/test/core/nanopb/fuzzer_serverlist.cc +++ b/test/core/nanopb/fuzzer_serverlist.cc @@ -26,12 +26,12 @@ bool squelch = true; bool leak_check = true; -static void dont_log(gpr_log_func_args *args) {} +static void dont_log(gpr_log_func_args* args) {} -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (squelch) gpr_set_log_function(dont_log); - grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); - grpc_grpclb_serverlist *serverlist; + grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); + grpc_grpclb_serverlist* serverlist; if ((serverlist = grpc_grpclb_response_parse_serverlist(slice))) { grpc_grpclb_destroy_serverlist(serverlist); } diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc index 84aebc9584..722652148c 100644 --- a/test/core/network_benchmarks/low_level_ping_pong.cc +++ b/test/core/network_benchmarks/low_level_ping_pong.cc @@ -52,11 +52,11 @@ typedef struct fd_pair { typedef struct thread_args { fd_pair fds; size_t msg_size; - int (*read_bytes)(struct thread_args *args, char *buf); - int (*write_bytes)(struct thread_args *args, char *buf); - int (*setup)(struct thread_args *args); + int (*read_bytes)(struct thread_args* args, char* buf); + int (*write_bytes)(struct thread_args* args, char* buf); + int (*setup)(struct thread_args* args); int epoll_fd; - const char *strategy_name; + const char* strategy_name; } thread_args; /* @@ -67,7 +67,7 @@ typedef struct thread_args { */ /* Basic call to read() */ -static int read_bytes(int fd, char *buf, size_t read_size, int spin) { +static int read_bytes(int fd, char* buf, size_t read_size, int spin) { size_t bytes_read = 0; ssize_t err; do { @@ -89,16 +89,16 @@ static int read_bytes(int fd, char *buf, size_t read_size, int spin) { return 0; } -static int blocking_read_bytes(thread_args *args, char *buf) { +static int blocking_read_bytes(thread_args* args, char* buf) { return read_bytes(args->fds.read_fd, buf, args->msg_size, 0); } -static int spin_read_bytes(thread_args *args, char *buf) { +static int spin_read_bytes(thread_args* args, char* buf) { return read_bytes(args->fds.read_fd, buf, args->msg_size, 1); } /* Call poll() to monitor a non-blocking fd */ -static int poll_read_bytes(int fd, char *buf, size_t read_size, int spin) { +static int poll_read_bytes(int fd, char* buf, size_t read_size, int spin) { struct pollfd pfd; size_t bytes_read = 0; int err; @@ -131,17 +131,17 @@ static int poll_read_bytes(int fd, char *buf, size_t read_size, int spin) { return 0; } -static int poll_read_bytes_blocking(struct thread_args *args, char *buf) { +static int poll_read_bytes_blocking(struct thread_args* args, char* buf) { return poll_read_bytes(args->fds.read_fd, buf, args->msg_size, 0); } -static int poll_read_bytes_spin(struct thread_args *args, char *buf) { +static int poll_read_bytes_spin(struct thread_args* args, char* buf) { return poll_read_bytes(args->fds.read_fd, buf, args->msg_size, 1); } #ifdef __linux__ /* Call epoll_wait() to monitor a non-blocking fd */ -static int epoll_read_bytes(struct thread_args *args, char *buf, int spin) { +static int epoll_read_bytes(struct thread_args* args, char* buf, int spin) { struct epoll_event ev; size_t bytes_read = 0; int err; @@ -174,11 +174,11 @@ static int epoll_read_bytes(struct thread_args *args, char *buf, int spin) { return 0; } -static int epoll_read_bytes_blocking(struct thread_args *args, char *buf) { +static int epoll_read_bytes_blocking(struct thread_args* args, char* buf) { return epoll_read_bytes(args, buf, 0); } -static int epoll_read_bytes_spin(struct thread_args *args, char *buf) { +static int epoll_read_bytes_spin(struct thread_args* args, char* buf) { return epoll_read_bytes(args, buf, 1); } #endif /* __linux__ */ @@ -187,7 +187,7 @@ static int epoll_read_bytes_spin(struct thread_args *args, char *buf) { At this point we only have one strategy, since in the common case these writes go directly out to the kernel. */ -static int blocking_write_bytes(struct thread_args *args, char *buf) { +static int blocking_write_bytes(struct thread_args* args, char* buf) { size_t bytes_written = 0; ssize_t err; size_t write_size = args->msg_size; @@ -214,7 +214,7 @@ static int blocking_write_bytes(struct thread_args *args, char *buf) { These are called at the beginning of the client and server thread, depending on the scenario we're using. */ -static int set_socket_nonblocking(thread_args *args) { +static int set_socket_nonblocking(thread_args* args) { if (!GRPC_LOG_IF_ERROR("Unable to set read socket nonblocking", grpc_set_socket_nonblocking(args->fds.read_fd, 1))) { return -1; @@ -226,11 +226,11 @@ static int set_socket_nonblocking(thread_args *args) { return 0; } -static int do_nothing(thread_args *args) { return 0; } +static int do_nothing(thread_args* args) { return 0; } #ifdef __linux__ /* Special case for epoll, where we need to create the fd ahead of time. */ -static int epoll_setup(thread_args *args) { +static int epoll_setup(thread_args* args) { int epoll_fd; struct epoll_event ev; set_socket_nonblocking(args); @@ -251,8 +251,8 @@ static int epoll_setup(thread_args *args) { } #endif -static void server_thread(thread_args *args) { - char *buf = static_cast<char *>(gpr_malloc(args->msg_size)); +static void server_thread(thread_args* args) { + char* buf = static_cast<char*>(gpr_malloc(args->msg_size)); if (args->setup(args) < 0) { gpr_log(GPR_ERROR, "Setup failed"); } @@ -270,12 +270,12 @@ static void server_thread(thread_args *args) { } } -static void server_thread_wrap(void *arg) { - thread_args *args = static_cast<thread_args *>(arg); +static void server_thread_wrap(void* arg) { + thread_args* args = static_cast<thread_args*>(arg); server_thread(args); } -static void print_histogram(gpr_histogram *histogram) { +static void print_histogram(gpr_histogram* histogram) { /* TODO(klempner): Print more detailed information, such as detailed histogram buckets */ gpr_log(GPR_INFO, "latency (50/95/99/99.9): %f/%f/%f/%f", @@ -290,10 +290,10 @@ static double now(void) { return 1e9 * (double)tv.tv_sec + (double)tv.tv_nsec; } -static void client_thread(thread_args *args) { - char *buf = static_cast<char *>(gpr_malloc(args->msg_size * sizeof(char))); +static void client_thread(thread_args* args) { + char* buf = static_cast<char*>(gpr_malloc(args->msg_size * sizeof(char))); memset(buf, 0, args->msg_size * sizeof(char)); - gpr_histogram *histogram = gpr_histogram_create(0.01, 60e9); + gpr_histogram* histogram = gpr_histogram_create(0.01, 60e9); double start_time; double end_time; double interval; @@ -326,7 +326,7 @@ error: } /* This roughly matches tcp_server's create_listening_socket */ -static int create_listening_socket(struct sockaddr *port, socklen_t len) { +static int create_listening_socket(struct sockaddr* port, socklen_t len) { int fd = socket(port->sa_family, SOCK_STREAM, 0); if (fd < 0) { gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno)); @@ -370,7 +370,7 @@ error: return -1; } -static int connect_client(struct sockaddr *addr, socklen_t len) { +static int connect_client(struct sockaddr* addr, socklen_t len) { int fd = socket(addr->sa_family, SOCK_STREAM, 0); int err; if (fd < 0) { @@ -413,13 +413,13 @@ static int accept_server(int listen_fd) { return fd; } -static int create_sockets_tcp(fd_pair *client_fds, fd_pair *server_fds) { +static int create_sockets_tcp(fd_pair* client_fds, fd_pair* server_fds) { int listen_fd = -1; int client_fd = -1; int server_fd = -1; struct sockaddr_in port; - struct sockaddr *sa_port = (struct sockaddr *)&port; + struct sockaddr* sa_port = (struct sockaddr*)&port; port.sin_family = AF_INET; port.sin_port = 0; @@ -463,7 +463,7 @@ error: return -1; } -static int create_sockets_socketpair(fd_pair *client_fds, fd_pair *server_fds) { +static int create_sockets_socketpair(fd_pair* client_fds, fd_pair* server_fds) { int fds[2]; if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { gpr_log(GPR_ERROR, "socketpair: %s", strerror(errno)); @@ -477,7 +477,7 @@ static int create_sockets_socketpair(fd_pair *client_fds, fd_pair *server_fds) { return 0; } -static int create_sockets_pipe(fd_pair *client_fds, fd_pair *server_fds) { +static int create_sockets_pipe(fd_pair* client_fds, fd_pair* server_fds) { int cfds[2]; int sfds[2]; if (pipe(cfds) < 0) { @@ -497,7 +497,7 @@ static int create_sockets_pipe(fd_pair *client_fds, fd_pair *server_fds) { return 0; } -static const char *read_strategy_usage = +static const char* read_strategy_usage = "Strategy for doing reads, which is one of:\n" " blocking: blocking read calls\n" " same_thread_poll: poll() call on same thread \n" @@ -511,13 +511,13 @@ static const char *read_strategy_usage = #endif ""; -static const char *socket_type_usage = +static const char* socket_type_usage = "Type of socket used, one of:\n" " tcp: fds are endpoints of a TCP connection\n" " socketpair: fds come from socketpair()\n" " pipe: fds come from pipe()\n"; -void print_usage(char *argv0) { +void print_usage(char* argv0) { fprintf(stderr, "%s usage:\n\n", argv0); fprintf(stderr, "%s read_strategy socket_type msg_size\n\n", argv0); fprintf(stderr, "where read_strategy is one of:\n"); @@ -538,9 +538,9 @@ void print_usage(char *argv0) { } typedef struct test_strategy { - const char *name; - int (*read_strategy)(struct thread_args *args, char *buf); - int (*setup)(struct thread_args *args); + const char* name; + int (*read_strategy)(struct thread_args* args, char* buf); + int (*setup)(struct thread_args* args); } test_strategy; static test_strategy test_strategies[] = { @@ -553,10 +553,10 @@ static test_strategy test_strategies[] = { {"spin_read", spin_read_bytes, set_socket_nonblocking}, {"spin_poll", poll_read_bytes_spin, set_socket_nonblocking}}; -static const char *socket_types[] = {"tcp", "socketpair", "pipe"}; +static const char* socket_types[] = {"tcp", "socketpair", "pipe"}; -int create_socket(const char *socket_type, fd_pair *client_fds, - fd_pair *server_fds) { +int create_socket(const char* socket_type, fd_pair* client_fds, + fd_pair* server_fds) { if (strcmp(socket_type, "tcp") == 0) { create_sockets_tcp(client_fds, server_fds); } else if (strcmp(socket_type, "socketpair") == 0) { @@ -570,8 +570,8 @@ int create_socket(const char *socket_type, fd_pair *client_fds, return 0; } -static int run_benchmark(const char *socket_type, thread_args *client_args, - thread_args *server_args) { +static int run_benchmark(const char* socket_type, thread_args* client_args, + thread_args* server_args) { gpr_thd_id tid; int rv = 0; @@ -592,14 +592,14 @@ static int run_all_benchmarks(size_t msg_size) { int error = 0; size_t i; for (i = 0; i < GPR_ARRAY_SIZE(test_strategies); ++i) { - test_strategy *strategy = &test_strategies[i]; + test_strategy* strategy = &test_strategies[i]; size_t j; for (j = 0; j < GPR_ARRAY_SIZE(socket_types); ++j) { - thread_args *client_args = - static_cast<thread_args *>(gpr_malloc(sizeof(thread_args))); - thread_args *server_args = - static_cast<thread_args *>(gpr_malloc(sizeof(thread_args))); - const char *socket_type = socket_types[j]; + thread_args* client_args = + static_cast<thread_args*>(gpr_malloc(sizeof(thread_args))); + thread_args* server_args = + static_cast<thread_args*>(gpr_malloc(sizeof(thread_args))); + const char* socket_type = socket_types[j]; client_args->read_bytes = strategy->read_strategy; client_args->write_bytes = blocking_write_bytes; @@ -620,19 +620,19 @@ static int run_all_benchmarks(size_t msg_size) { return error; } -int main(int argc, char **argv) { - thread_args *client_args = - static_cast<thread_args *>(gpr_malloc(sizeof(thread_args))); - thread_args *server_args = - static_cast<thread_args *>(gpr_malloc(sizeof(thread_args))); +int main(int argc, char** argv) { + thread_args* client_args = + static_cast<thread_args*>(gpr_malloc(sizeof(thread_args))); + thread_args* server_args = + static_cast<thread_args*>(gpr_malloc(sizeof(thread_args))); int msg_size = -1; - const char *read_strategy = NULL; - const char *socket_type = NULL; + const char* read_strategy = NULL; + const char* socket_type = NULL; size_t i; - const test_strategy *strategy = NULL; + const test_strategy* strategy = NULL; int error = 0; - gpr_cmdline *cmdline = + gpr_cmdline* cmdline = gpr_cmdline_create("low_level_ping_pong network benchmarking tool"); gpr_cmdline_add_int(cmdline, "msg_size", "Size of sent messages", &msg_size); diff --git a/test/core/security/auth_context_test.cc b/test/core/security/auth_context_test.cc index 88daf28c99..3ab9190689 100644 --- a/test/core/security/auth_context_test.cc +++ b/test/core/security/auth_context_test.cc @@ -25,7 +25,7 @@ #include <grpc/support/log.h> static void test_empty_context(void) { - grpc_auth_context *ctx = grpc_auth_context_create(NULL); + grpc_auth_context* ctx = grpc_auth_context_create(NULL); grpc_auth_property_iterator it; gpr_log(GPR_INFO, "test_empty_context"); @@ -44,7 +44,7 @@ static void test_empty_context(void) { } static void test_simple_context(void) { - grpc_auth_context *ctx = grpc_auth_context_create(NULL); + grpc_auth_context* ctx = grpc_auth_context_create(NULL); grpc_auth_property_iterator it; size_t i; @@ -61,7 +61,7 @@ static void test_simple_context(void) { strcmp(grpc_auth_context_peer_identity_property_name(ctx), "name") == 0); it = grpc_auth_context_property_iterator(ctx); for (i = 0; i < ctx->properties.count; i++) { - const grpc_auth_property *p = grpc_auth_property_iterator_next(&it); + const grpc_auth_property* p = grpc_auth_property_iterator_next(&it); GPR_ASSERT(p == &ctx->properties.array[i]); } GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL); @@ -82,8 +82,8 @@ static void test_simple_context(void) { } static void test_chained_context(void) { - grpc_auth_context *chained = grpc_auth_context_create(NULL); - grpc_auth_context *ctx = grpc_auth_context_create(chained); + grpc_auth_context* chained = grpc_auth_context_create(NULL); + grpc_auth_context* ctx = grpc_auth_context_create(chained); grpc_auth_property_iterator it; size_t i; @@ -101,11 +101,11 @@ static void test_chained_context(void) { strcmp(grpc_auth_context_peer_identity_property_name(ctx), "name") == 0); it = grpc_auth_context_property_iterator(ctx); for (i = 0; i < ctx->properties.count; i++) { - const grpc_auth_property *p = grpc_auth_property_iterator_next(&it); + const grpc_auth_property* p = grpc_auth_property_iterator_next(&it); GPR_ASSERT(p == &ctx->properties.array[i]); } for (i = 0; i < chained->properties.count; i++) { - const grpc_auth_property *p = grpc_auth_property_iterator_next(&it); + const grpc_auth_property* p = grpc_auth_property_iterator_next(&it); GPR_ASSERT(p == &chained->properties.array[i]); } GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL); @@ -129,7 +129,7 @@ static void test_chained_context(void) { GRPC_AUTH_CONTEXT_UNREF(ctx, "test"); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_empty_context(); test_simple_context(); diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc index 2444dbeae7..95f3615074 100644 --- a/test/core/security/create_jwt.cc +++ b/test/core/security/create_jwt.cc @@ -27,15 +27,15 @@ #include <grpc/support/cmdline.h> #include <grpc/support/log.h> -void create_jwt(const char *json_key_file_path, const char *service_url, - const char *scope) { +void create_jwt(const char* json_key_file_path, const char* service_url, + const char* scope) { grpc_auth_json_key key; - char *jwt; + char* jwt; grpc_slice json_key_data; GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file(json_key_file_path, 1, &json_key_data))); key = grpc_auth_json_key_create_from_string( - (const char *)GRPC_SLICE_START_PTR(json_key_data)); + (const char*)GRPC_SLICE_START_PTR(json_key_data)); grpc_slice_unref(json_key_data); if (!grpc_auth_json_key_is_valid(&key)) { fprintf(stderr, "Could not parse json key.\n"); @@ -53,12 +53,12 @@ void create_jwt(const char *json_key_file_path, const char *service_url, gpr_free(jwt); } -int main(int argc, char **argv) { - const char *scope = NULL; - const char *json_key_file_path = NULL; - const char *service_url = NULL; +int main(int argc, char** argv) { + const char* scope = NULL; + const char* json_key_file_path = NULL; + const char* service_url = NULL; grpc_init(); - gpr_cmdline *cl = gpr_cmdline_create("create_jwt"); + gpr_cmdline* cl = gpr_cmdline_create("create_jwt"); gpr_cmdline_add_string(cl, "json_key", "File path of the json key.", &json_key_file_path); gpr_cmdline_add_string(cl, "scope", diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index dfc071b64a..9b575c4bc5 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -24,6 +24,8 @@ #include <stdlib.h> #include <string.h> +#include <grpc/slice.h> + #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> @@ -35,6 +37,7 @@ #include "src/core/lib/security/credentials/google_default/google_default_credentials.h" #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" #include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h" +#include "src/core/lib/security/transport/auth_filters.h" #include "src/core/lib/support/env.h" #include "src/core/lib/support/string.h" #include "src/core/lib/support/tmpfile.h" @@ -42,10 +45,10 @@ /* -- Mock channel credentials. -- */ -static grpc_channel_credentials *grpc_mock_channel_credentials_create( - const grpc_channel_credentials_vtable *vtable) { - grpc_channel_credentials *c = - static_cast<grpc_channel_credentials *>(gpr_malloc(sizeof(*c))); +static grpc_channel_credentials* grpc_mock_channel_credentials_create( + const grpc_channel_credentials_vtable* vtable) { + grpc_channel_credentials* c = + static_cast<grpc_channel_credentials*>(gpr_malloc(sizeof(*c))); memset(c, 0, sizeof(*c)); c->type = "mock"; c->vtable = vtable; @@ -119,12 +122,12 @@ static const char test_method[] = "ThisIsNotAMethod"; /* -- Utils. -- */ -static char *test_json_key_str(void) { +static char* test_json_key_str(void) { size_t result_len = strlen(test_json_key_str_part1) + strlen(test_json_key_str_part2) + strlen(test_json_key_str_part3); - char *result = static_cast<char *>(gpr_malloc(result_len + 1)); - char *current = result; + char* result = static_cast<char*>(gpr_malloc(result_len + 1)); + char* current = result; strcpy(result, test_json_key_str_part1); current += strlen(test_json_key_str_part1); strcpy(current, test_json_key_str_part2); @@ -133,11 +136,11 @@ static char *test_json_key_str(void) { return result; } -static grpc_httpcli_response http_response(int status, const char *body) { +static grpc_httpcli_response http_response(int status, const char* body) { grpc_httpcli_response response; memset(&response, 0, sizeof(grpc_httpcli_response)); response.status = status; - response.body = gpr_strdup((char *)body); + response.body = gpr_strdup((char*)body); response.body_length = strlen(body); return response; } @@ -158,8 +161,8 @@ static void test_add_to_empty_md_array(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_credentials_mdelem_array md_array; memset(&md_array, 0, sizeof(md_array)); - const char *key = "hello"; - const char *value = "there blah blah blah blah blah blah blah"; + const char* key = "hello"; + const char* value = "there blah blah blah blah blah blah blah"; grpc_mdelem md = grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value)); @@ -175,8 +178,8 @@ static void test_add_abunch_to_md_array(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_credentials_mdelem_array md_array; memset(&md_array, 0, sizeof(md_array)); - const char *key = "hello"; - const char *value = "there blah blah blah blah blah blah blah"; + const char* key = "hello"; + const char* value = "there blah blah blah blah blah blah blah"; grpc_mdelem md = grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value)); @@ -300,22 +303,22 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime( } typedef struct { - const char *key; - const char *value; + const char* key; + const char* value; } expected_md; typedef struct { - grpc_error *expected_error; - const expected_md *expected; + grpc_error* expected_error; + const expected_md* expected; size_t expected_size; grpc_credentials_mdelem_array md_array; grpc_closure on_request_metadata; - grpc_call_credentials *creds; + grpc_call_credentials* creds; grpc_polling_entity pollent; } request_metadata_state; -static void check_metadata(const expected_md *expected, - grpc_credentials_mdelem_array *md_array) { +static void check_metadata(const expected_md* expected, + grpc_credentials_mdelem_array* md_array) { for (size_t i = 0; i < md_array->size; ++i) { size_t j; for (j = 0; j < md_array->size; ++j) { @@ -333,9 +336,9 @@ static void check_metadata(const expected_md *expected, } } -static void check_request_metadata(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - request_metadata_state *state = (request_metadata_state *)arg; +static void check_request_metadata(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + request_metadata_state* state = (request_metadata_state*)arg; gpr_log(GPR_INFO, "expected_error: %s", grpc_error_string(state->expected_error)); gpr_log(GPR_INFO, "actual_error: %s", grpc_error_string(error)); @@ -361,11 +364,11 @@ static void check_request_metadata(grpc_exec_ctx *exec_ctx, void *arg, gpr_free(state); } -static request_metadata_state *make_request_metadata_state( - grpc_error *expected_error, const expected_md *expected, +static request_metadata_state* make_request_metadata_state( + grpc_error* expected_error, const expected_md* expected, size_t expected_size) { - request_metadata_state *state = - static_cast<request_metadata_state *>(gpr_zalloc(sizeof(*state))); + request_metadata_state* state = + static_cast<request_metadata_state*>(gpr_zalloc(sizeof(*state))); state->expected_error = expected_error; state->expected = expected; state->expected_size = expected_size; @@ -376,11 +379,11 @@ static request_metadata_state *make_request_metadata_state( return state; } -static void run_request_metadata_test(grpc_exec_ctx *exec_ctx, - grpc_call_credentials *creds, +static void run_request_metadata_test(grpc_exec_ctx* exec_ctx, + grpc_call_credentials* creds, grpc_auth_metadata_context auth_md_ctx, - request_metadata_state *state) { - grpc_error *error = GRPC_ERROR_NONE; + request_metadata_state* state) { + grpc_error* error = GRPC_ERROR_NONE; if (grpc_call_credentials_get_request_metadata( exec_ctx, creds, &state->pollent, auth_md_ctx, &state->md_array, &state->on_request_metadata, &error)) { @@ -396,9 +399,9 @@ static void test_google_iam_creds(void) { test_google_iam_authorization_token}, {GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, test_google_iam_authority_selector}}; - request_metadata_state *state = + request_metadata_state* state = make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); - grpc_call_credentials *creds = grpc_google_iam_credentials_create( + grpc_call_credentials* creds = grpc_google_iam_credentials_create( test_google_iam_authorization_token, test_google_iam_authority_selector, NULL); grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, @@ -411,9 +414,9 @@ static void test_google_iam_creds(void) { static void test_access_token_creds(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; expected_md emd[] = {{GRPC_AUTHORIZATION_METADATA_KEY, "Bearer blah"}}; - request_metadata_state *state = + request_metadata_state* state = make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); - grpc_call_credentials *creds = + grpc_call_credentials* creds = grpc_access_token_credentials_create("blah", NULL); grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; @@ -424,10 +427,10 @@ static void test_access_token_creds(void) { } static grpc_security_status check_channel_oauth2_create_security_connector( - grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c, - grpc_call_credentials *call_creds, const char *target, - const grpc_channel_args *args, grpc_channel_security_connector **sc, - grpc_channel_args **new_args) { + grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c, + grpc_call_credentials* call_creds, const char* target, + const grpc_channel_args* args, grpc_channel_security_connector** sc, + grpc_channel_args** new_args) { GPR_ASSERT(strcmp(c->type, "mock") == 0); GPR_ASSERT(call_creds != NULL); GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0); @@ -436,14 +439,14 @@ static grpc_security_status check_channel_oauth2_create_security_connector( static void test_channel_oauth2_composite_creds(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_channel_args *new_args; + grpc_channel_args* new_args; grpc_channel_credentials_vtable vtable = { NULL, check_channel_oauth2_create_security_connector, NULL}; - grpc_channel_credentials *channel_creds = + grpc_channel_credentials* channel_creds = grpc_mock_channel_credentials_create(&vtable); - grpc_call_credentials *oauth2_creds = + grpc_call_credentials* oauth2_creds = grpc_access_token_credentials_create("blah", NULL); - grpc_channel_credentials *channel_oauth2_creds = + grpc_channel_credentials* channel_oauth2_creds = grpc_composite_channel_credentials_create(channel_creds, oauth2_creds, NULL); grpc_channel_credentials_release(channel_creds); @@ -463,23 +466,23 @@ static void test_oauth2_google_iam_composite_creds(void) { test_google_iam_authorization_token}, {GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, test_google_iam_authority_selector}}; - request_metadata_state *state = + request_metadata_state* state = make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; - grpc_call_credentials *oauth2_creds = grpc_md_only_test_credentials_create( + grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create( &exec_ctx, "authorization", test_oauth2_bearer_token, 0); - grpc_call_credentials *google_iam_creds = grpc_google_iam_credentials_create( + grpc_call_credentials* google_iam_creds = grpc_google_iam_credentials_create( test_google_iam_authorization_token, test_google_iam_authority_selector, NULL); - grpc_call_credentials *composite_creds = + grpc_call_credentials* composite_creds = grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds, NULL); grpc_call_credentials_unref(&exec_ctx, oauth2_creds); grpc_call_credentials_unref(&exec_ctx, google_iam_creds); GPR_ASSERT( strcmp(composite_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0); - const grpc_call_credentials_array *creds_array = + const grpc_call_credentials_array* creds_array = grpc_composite_call_credentials_get_credentials(composite_creds); GPR_ASSERT(creds_array->num_creds == 2); GPR_ASSERT(strcmp(creds_array->creds_array[0]->type, @@ -493,11 +496,11 @@ static void test_oauth2_google_iam_composite_creds(void) { static grpc_security_status check_channel_oauth2_google_iam_create_security_connector( - grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c, - grpc_call_credentials *call_creds, const char *target, - const grpc_channel_args *args, grpc_channel_security_connector **sc, - grpc_channel_args **new_args) { - const grpc_call_credentials_array *creds_array; + grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c, + grpc_call_credentials* call_creds, const char* target, + const grpc_channel_args* args, grpc_channel_security_connector** sc, + grpc_channel_args** new_args) { + const grpc_call_credentials_array* creds_array; GPR_ASSERT(strcmp(c->type, "mock") == 0); GPR_ASSERT(call_creds != NULL); GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == @@ -512,20 +515,20 @@ check_channel_oauth2_google_iam_create_security_connector( static void test_channel_oauth2_google_iam_composite_creds(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_channel_args *new_args; + grpc_channel_args* new_args; grpc_channel_credentials_vtable vtable = { NULL, check_channel_oauth2_google_iam_create_security_connector, NULL}; - grpc_channel_credentials *channel_creds = + grpc_channel_credentials* channel_creds = grpc_mock_channel_credentials_create(&vtable); - grpc_call_credentials *oauth2_creds = + grpc_call_credentials* oauth2_creds = grpc_access_token_credentials_create("blah", NULL); - grpc_channel_credentials *channel_oauth2_creds = + grpc_channel_credentials* channel_oauth2_creds = grpc_composite_channel_credentials_create(channel_creds, oauth2_creds, NULL); - grpc_call_credentials *google_iam_creds = grpc_google_iam_credentials_create( + grpc_call_credentials* google_iam_creds = grpc_google_iam_credentials_create( test_google_iam_authorization_token, test_google_iam_authority_selector, NULL); - grpc_channel_credentials *channel_oauth2_iam_creds = + grpc_channel_credentials* channel_oauth2_iam_creds = grpc_composite_channel_credentials_create(channel_oauth2_creds, google_iam_creds, NULL); grpc_channel_credentials_release(channel_creds); @@ -542,7 +545,7 @@ static void test_channel_oauth2_google_iam_composite_creds(void) { } static void validate_compute_engine_http_request( - const grpc_httpcli_request *request) { + const grpc_httpcli_request* request) { GPR_ASSERT(request->handshaker != &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0); GPR_ASSERT( @@ -555,9 +558,9 @@ static void validate_compute_engine_http_request( } static int compute_engine_httpcli_get_success_override( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - grpc_millis deadline, grpc_closure *on_done, - grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + grpc_millis deadline, grpc_closure* on_done, + grpc_httpcli_response* response) { validate_compute_engine_http_request(request); *response = http_response(200, valid_oauth2_json_response); GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE); @@ -565,9 +568,9 @@ static int compute_engine_httpcli_get_success_override( } static int compute_engine_httpcli_get_failure_override( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - grpc_millis deadline, grpc_closure *on_done, - grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + grpc_millis deadline, grpc_closure* on_done, + grpc_httpcli_response* response) { validate_compute_engine_http_request(request); *response = http_response(403, "Not Authorized."); GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE); @@ -575,18 +578,18 @@ static int compute_engine_httpcli_get_failure_override( } static int httpcli_post_should_not_be_called( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - const char *body_bytes, size_t body_size, grpc_millis deadline, - grpc_closure *on_done, grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + const char* body_bytes, size_t body_size, grpc_millis deadline, + grpc_closure* on_done, grpc_httpcli_response* response) { GPR_ASSERT("HTTP POST should not be called" == NULL); return 1; } -static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx, - const grpc_httpcli_request *request, +static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx, + const grpc_httpcli_request* request, grpc_millis deadline, - grpc_closure *on_done, - grpc_httpcli_response *response) { + grpc_closure* on_done, + grpc_httpcli_response* response) { GPR_ASSERT("HTTP GET should not be called" == NULL); return 1; } @@ -595,13 +598,13 @@ static void test_compute_engine_creds_success(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; expected_md emd[] = { {"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}}; - grpc_call_credentials *creds = + grpc_call_credentials* creds = grpc_google_compute_engine_credentials_create(NULL); grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; /* First request: http get should be called. */ - request_metadata_state *state = + request_metadata_state* state = make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); grpc_httpcli_set_override(compute_engine_httpcli_get_success_override, httpcli_post_should_not_be_called); @@ -623,13 +626,13 @@ static void test_compute_engine_creds_success(void) { static void test_compute_engine_creds_failure(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - request_metadata_state *state = make_request_metadata_state( + request_metadata_state* state = make_request_metadata_state( GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Error occured when fetching oauth2 token."), NULL, 0); grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; - grpc_call_credentials *creds = + grpc_call_credentials* creds = grpc_google_compute_engine_credentials_create(NULL); grpc_httpcli_set_override(compute_engine_httpcli_get_failure_override, httpcli_post_should_not_be_called); @@ -640,9 +643,9 @@ static void test_compute_engine_creds_failure(void) { } static void validate_refresh_token_http_request( - const grpc_httpcli_request *request, const char *body, size_t body_size) { + const grpc_httpcli_request* request, const char* body, size_t body_size) { /* The content of the assertion is tested extensively in json_token_test. */ - char *expected_body = NULL; + char* expected_body = NULL; GPR_ASSERT(body != NULL); GPR_ASSERT(body_size != 0); gpr_asprintf(&expected_body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING, @@ -663,9 +666,9 @@ static void validate_refresh_token_http_request( } static int refresh_token_httpcli_post_success( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - const char *body, size_t body_size, grpc_millis deadline, - grpc_closure *on_done, grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + const char* body, size_t body_size, grpc_millis deadline, + grpc_closure* on_done, grpc_httpcli_response* response) { validate_refresh_token_http_request(request, body, body_size); *response = http_response(200, valid_oauth2_json_response); GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE); @@ -673,9 +676,9 @@ static int refresh_token_httpcli_post_success( } static int refresh_token_httpcli_post_failure( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - const char *body, size_t body_size, grpc_millis deadline, - grpc_closure *on_done, grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + const char* body, size_t body_size, grpc_millis deadline, + grpc_closure* on_done, grpc_httpcli_response* response) { validate_refresh_token_http_request(request, body, body_size); *response = http_response(403, "Not Authorized."); GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE); @@ -688,11 +691,11 @@ static void test_refresh_token_creds_success(void) { {"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}}; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; - grpc_call_credentials *creds = grpc_google_refresh_token_credentials_create( + grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create( test_refresh_token_str, NULL); /* First request: http get should be called. */ - request_metadata_state *state = + request_metadata_state* state = make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); grpc_httpcli_set_override(httpcli_get_should_not_be_called, refresh_token_httpcli_post_success); @@ -714,13 +717,13 @@ static void test_refresh_token_creds_success(void) { static void test_refresh_token_creds_failure(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - request_metadata_state *state = make_request_metadata_state( + request_metadata_state* state = make_request_metadata_state( GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Error occured when fetching oauth2 token."), NULL, 0); grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; - grpc_call_credentials *creds = grpc_google_refresh_token_credentials_create( + grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create( test_refresh_token_str, NULL); grpc_httpcli_set_override(httpcli_get_should_not_be_called, refresh_token_httpcli_post_failure); @@ -731,7 +734,7 @@ static void test_refresh_token_creds_failure(void) { } static void validate_jwt_encode_and_sign_params( - const grpc_auth_json_key *json_key, const char *scope, + const grpc_auth_json_key* json_key, const char* scope, gpr_timespec token_lifetime) { GPR_ASSERT(grpc_auth_json_key_is_valid(json_key)); GPR_ASSERT(json_key->private_key != NULL); @@ -753,41 +756,41 @@ static void validate_jwt_encode_and_sign_params( GPR_ASSERT(!gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime())); } -static char *encode_and_sign_jwt_success(const grpc_auth_json_key *json_key, - const char *audience, +static char* encode_and_sign_jwt_success(const grpc_auth_json_key* json_key, + const char* audience, gpr_timespec token_lifetime, - const char *scope) { + const char* scope) { validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime); return gpr_strdup(test_signed_jwt); } -static char *encode_and_sign_jwt_failure(const grpc_auth_json_key *json_key, - const char *audience, +static char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key, + const char* audience, gpr_timespec token_lifetime, - const char *scope) { + const char* scope) { validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime); return NULL; } -static char *encode_and_sign_jwt_should_not_be_called( - const grpc_auth_json_key *json_key, const char *audience, - gpr_timespec token_lifetime, const char *scope) { +static char* encode_and_sign_jwt_should_not_be_called( + const grpc_auth_json_key* json_key, const char* audience, + gpr_timespec token_lifetime, const char* scope) { GPR_ASSERT("grpc_jwt_encode_and_sign should not be called" == NULL); return NULL; } -static grpc_service_account_jwt_access_credentials *creds_as_jwt( - grpc_call_credentials *creds) { +static grpc_service_account_jwt_access_credentials* creds_as_jwt( + grpc_call_credentials* creds) { GPR_ASSERT(creds != NULL); GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_JWT) == 0); - return (grpc_service_account_jwt_access_credentials *)creds; + return (grpc_service_account_jwt_access_credentials*)creds; } static void test_jwt_creds_lifetime(void) { - char *json_key_string = test_json_key_str(); + char* json_key_string = test_json_key_str(); // Max lifetime. - grpc_call_credentials *jwt_creds = + grpc_call_credentials* jwt_creds = grpc_service_account_jwt_access_credentials_create( json_key_string, grpc_max_auth_token_lifetime(), NULL); GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime, @@ -816,19 +819,19 @@ static void test_jwt_creds_lifetime(void) { } static void test_jwt_creds_success(void) { - char *json_key_string = test_json_key_str(); + char* json_key_string = test_json_key_str(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; - char *expected_md_value; + char* expected_md_value; gpr_asprintf(&expected_md_value, "Bearer %s", test_signed_jwt); expected_md emd[] = {{"authorization", expected_md_value}}; - grpc_call_credentials *creds = + grpc_call_credentials* creds = grpc_service_account_jwt_access_credentials_create( json_key_string, grpc_max_auth_token_lifetime(), NULL); /* First request: jwt_encode_and_sign should be called. */ - request_metadata_state *state = + request_metadata_state* state = make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success); run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state); @@ -859,13 +862,13 @@ static void test_jwt_creds_success(void) { } static void test_jwt_creds_signing_failure(void) { - char *json_key_string = test_json_key_str(); + char* json_key_string = test_json_key_str(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; - request_metadata_state *state = make_request_metadata_state( + request_metadata_state* state = make_request_metadata_state( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Could not generate JWT."), NULL, 0); - grpc_call_credentials *creds = + grpc_call_credentials* creds = grpc_service_account_jwt_access_credentials_create( json_key_string, grpc_max_auth_token_lifetime(), NULL); @@ -879,10 +882,10 @@ static void test_jwt_creds_signing_failure(void) { } static void set_google_default_creds_env_var_with_file_contents( - const char *file_prefix, const char *contents) { + const char* file_prefix, const char* contents) { size_t contents_len = strlen(contents); - char *creds_file_name; - FILE *creds_file = gpr_tmpfile(file_prefix, &creds_file_name); + char* creds_file_name; + FILE* creds_file = gpr_tmpfile(file_prefix, &creds_file_name); GPR_ASSERT(creds_file_name != NULL); GPR_ASSERT(creds_file != NULL); GPR_ASSERT(fwrite(contents, 1, contents_len, creds_file) == contents_len); @@ -893,17 +896,17 @@ static void set_google_default_creds_env_var_with_file_contents( static void test_google_default_creds_auth_key(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_service_account_jwt_access_credentials *jwt; - grpc_composite_channel_credentials *creds; - char *json_key = test_json_key_str(); + grpc_service_account_jwt_access_credentials* jwt; + grpc_composite_channel_credentials* creds; + char* json_key = test_json_key_str(); grpc_flush_cached_google_default_credentials(); set_google_default_creds_env_var_with_file_contents( "json_key_google_default_creds", json_key); gpr_free(json_key); - creds = (grpc_composite_channel_credentials *) + creds = (grpc_composite_channel_credentials*) grpc_google_default_credentials_create(); GPR_ASSERT(creds != NULL); - jwt = (grpc_service_account_jwt_access_credentials *)creds->call_creds; + jwt = (grpc_service_account_jwt_access_credentials*)creds->call_creds; GPR_ASSERT( strcmp(jwt->key.client_id, "777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") == @@ -915,15 +918,15 @@ static void test_google_default_creds_auth_key(void) { static void test_google_default_creds_refresh_token(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_google_refresh_token_credentials *refresh; - grpc_composite_channel_credentials *creds; + grpc_google_refresh_token_credentials* refresh; + grpc_composite_channel_credentials* creds; grpc_flush_cached_google_default_credentials(); set_google_default_creds_env_var_with_file_contents( "refresh_token_google_default_creds", test_refresh_token_str); - creds = (grpc_composite_channel_credentials *) + creds = (grpc_composite_channel_credentials*) grpc_google_default_credentials_create(); GPR_ASSERT(creds != NULL); - refresh = (grpc_google_refresh_token_credentials *)creds->call_creds; + refresh = (grpc_google_refresh_token_credentials*)creds->call_creds; GPR_ASSERT(strcmp(refresh->refresh_token.client_id, "32555999999.apps.googleusercontent.com") == 0); grpc_channel_credentials_unref(&exec_ctx, &creds->base); @@ -932,12 +935,12 @@ static void test_google_default_creds_refresh_token(void) { } static int default_creds_gce_detection_httpcli_get_success_override( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - grpc_millis deadline, grpc_closure *on_done, - grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + grpc_millis deadline, grpc_closure* on_done, + grpc_httpcli_response* response) { *response = http_response(200, ""); - grpc_http_header *headers = - static_cast<grpc_http_header *>(gpr_malloc(sizeof(*headers) * 1)); + grpc_http_header* headers = + static_cast<grpc_http_header*>(gpr_malloc(sizeof(*headers) * 1)); headers[0].key = gpr_strdup("Metadata-Flavor"); headers[0].value = gpr_strdup("Google"); response->hdr_count = 1; @@ -948,13 +951,13 @@ static int default_creds_gce_detection_httpcli_get_success_override( return 1; } -static char *null_well_known_creds_path_getter(void) { return NULL; } +static char* null_well_known_creds_path_getter(void) { return NULL; } static void test_google_default_creds_gce(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; expected_md emd[] = { {"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}}; - request_metadata_state *state = + request_metadata_state* state = make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd)); grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; @@ -967,8 +970,8 @@ static void test_google_default_creds_gce(void) { grpc_httpcli_set_override( default_creds_gce_detection_httpcli_get_success_override, httpcli_post_should_not_be_called); - grpc_composite_channel_credentials *creds = - (grpc_composite_channel_credentials *) + grpc_composite_channel_credentials* creds = + (grpc_composite_channel_credentials*) grpc_google_default_credentials_create(); /* Verify that the default creds actually embeds a GCE creds. */ @@ -984,7 +987,7 @@ static void test_google_default_creds_gce(void) { GCE detection should not occur anymore either. */ grpc_httpcli_set_override(httpcli_get_should_not_be_called, httpcli_post_should_not_be_called); - grpc_channel_credentials *cached_creds = + grpc_channel_credentials* cached_creds = grpc_google_default_credentials_create(); GPR_ASSERT(cached_creds == &creds->base); @@ -997,9 +1000,9 @@ static void test_google_default_creds_gce(void) { } static int default_creds_gce_detection_httpcli_get_failure_override( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - grpc_millis deadline, grpc_closure *on_done, - grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + grpc_millis deadline, grpc_closure* on_done, + grpc_httpcli_response* response) { /* No magic header. */ GPR_ASSERT(strcmp(request->http.path, "/") == 0); GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0); @@ -1039,18 +1042,18 @@ typedef enum { static const expected_md plugin_md[] = {{"foo", "bar"}, {"hi", "there"}}; static int plugin_get_metadata_success( - void *state, grpc_auth_metadata_context context, - grpc_credentials_plugin_metadata_cb cb, void *user_data, + void* state, grpc_auth_metadata_context context, + grpc_credentials_plugin_metadata_cb cb, void* user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], - size_t *num_creds_md, grpc_status_code *status, - const char **error_details) { + size_t* num_creds_md, grpc_status_code* status, + const char** error_details) { GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0); GPR_ASSERT(strcmp(context.method_name, test_method) == 0); GPR_ASSERT(context.channel_auth_context == NULL); GPR_ASSERT(context.reserved == NULL); GPR_ASSERT(GPR_ARRAY_SIZE(plugin_md) < GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX); - plugin_state *s = (plugin_state *)state; + plugin_state* s = (plugin_state*)state; *s = PLUGIN_GET_METADATA_CALLED_STATE; for (size_t i = 0; i < GPR_ARRAY_SIZE(plugin_md); ++i) { memset(&creds_md[i], 0, sizeof(grpc_metadata)); @@ -1061,27 +1064,27 @@ static int plugin_get_metadata_success( return true; // Synchronous return. } -static const char *plugin_error_details = "Could not get metadata for plugin."; +static const char* plugin_error_details = "Could not get metadata for plugin."; static int plugin_get_metadata_failure( - void *state, grpc_auth_metadata_context context, - grpc_credentials_plugin_metadata_cb cb, void *user_data, + void* state, grpc_auth_metadata_context context, + grpc_credentials_plugin_metadata_cb cb, void* user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], - size_t *num_creds_md, grpc_status_code *status, - const char **error_details) { + size_t* num_creds_md, grpc_status_code* status, + const char** error_details) { GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0); GPR_ASSERT(strcmp(context.method_name, test_method) == 0); GPR_ASSERT(context.channel_auth_context == NULL); GPR_ASSERT(context.reserved == NULL); - plugin_state *s = (plugin_state *)state; + plugin_state* s = (plugin_state*)state; *s = PLUGIN_GET_METADATA_CALLED_STATE; *status = GRPC_STATUS_UNAUTHENTICATED; *error_details = gpr_strdup(plugin_error_details); return true; // Synchronous return. } -static void plugin_destroy(void *state) { - plugin_state *s = (plugin_state *)state; +static void plugin_destroy(void* state) { + plugin_state* s = (plugin_state*)state; *s = PLUGIN_DESTROY_CALLED_STATE; } @@ -1091,14 +1094,14 @@ static void test_metadata_plugin_success(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; - request_metadata_state *md_state = make_request_metadata_state( + request_metadata_state* md_state = make_request_metadata_state( GRPC_ERROR_NONE, plugin_md, GPR_ARRAY_SIZE(plugin_md)); plugin.state = &state; plugin.get_metadata = plugin_get_metadata_success; plugin.destroy = plugin_destroy; - grpc_call_credentials *creds = + grpc_call_credentials* creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL); GPR_ASSERT(state == PLUGIN_INITIAL_STATE); run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state); @@ -1114,11 +1117,11 @@ static void test_metadata_plugin_failure(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL, NULL}; - char *expected_error; + char* expected_error; gpr_asprintf(&expected_error, "Getting metadata from plugin failed with error: %s", plugin_error_details); - request_metadata_state *md_state = make_request_metadata_state( + request_metadata_state* md_state = make_request_metadata_state( GRPC_ERROR_CREATE_FROM_COPIED_STRING(expected_error), NULL, 0); gpr_free(expected_error); @@ -1126,7 +1129,7 @@ static void test_metadata_plugin_failure(void) { plugin.get_metadata = plugin_get_metadata_failure; plugin.destroy = plugin_destroy; - grpc_call_credentials *creds = + grpc_call_credentials* creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL); GPR_ASSERT(state == PLUGIN_INITIAL_STATE); run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state); @@ -1137,8 +1140,8 @@ static void test_metadata_plugin_failure(void) { } static void test_get_well_known_google_credentials_file_path(void) { - char *path; - char *home = gpr_getenv("HOME"); + char* path; + char* home = gpr_getenv("HOME"); path = grpc_get_well_known_google_credentials_file_path(); GPR_ASSERT(path != NULL); gpr_free(path); @@ -1155,18 +1158,18 @@ static void test_get_well_known_google_credentials_file_path(void) { static void test_channel_creds_duplicate_without_call_creds(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_channel_credentials *channel_creds = + grpc_channel_credentials* channel_creds = grpc_fake_transport_security_credentials_create(); - grpc_channel_credentials *dup = + grpc_channel_credentials* dup = grpc_channel_credentials_duplicate_without_call_credentials( channel_creds); GPR_ASSERT(dup == channel_creds); grpc_channel_credentials_unref(&exec_ctx, dup); - grpc_call_credentials *call_creds = + grpc_call_credentials* call_creds = grpc_access_token_credentials_create("blah", NULL); - grpc_channel_credentials *composite_creds = + grpc_channel_credentials* composite_creds = grpc_composite_channel_credentials_create(channel_creds, call_creds, NULL); grpc_call_credentials_unref(&exec_ctx, call_creds); @@ -1181,7 +1184,78 @@ static void test_channel_creds_duplicate_without_call_creds(void) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +typedef struct { + const char* url_scheme; + const char* call_host; + const char* call_method; + const char* desired_service_url; + const char* desired_method_name; +} auth_metadata_context_test_case; + +static void test_auth_metadata_context(void) { + auth_metadata_context_test_case test_cases[] = { + // No service nor method. + {"https", "www.foo.com", "", "https://www.foo.com", ""}, + // No method. + {"https", "www.foo.com", "/Service", "https://www.foo.com/Service", ""}, + // Empty service and method. + {"https", "www.foo.com", "//", "https://www.foo.com/", ""}, + // Empty method. + {"https", "www.foo.com", "/Service/", "https://www.foo.com/Service", ""}, + // Malformed url. + {"https", "www.foo.com:", "/Service/", "https://www.foo.com:/Service", + ""}, + // https, default explicit port. + {"https", "www.foo.com:443", "/Service/FooMethod", + "https://www.foo.com/Service", "FooMethod"}, + // https, default implicit port. + {"https", "www.foo.com", "/Service/FooMethod", + "https://www.foo.com/Service", "FooMethod"}, + // https with ipv6 literal, default explicit port. + {"https", "[1080:0:0:0:8:800:200C:417A]:443", "/Service/FooMethod", + "https://[1080:0:0:0:8:800:200C:417A]/Service", "FooMethod"}, + // https with ipv6 literal, default implicit port. + {"https", "[1080:0:0:0:8:800:200C:443]", "/Service/FooMethod", + "https://[1080:0:0:0:8:800:200C:443]/Service", "FooMethod"}, + // https, custom port. + {"https", "www.foo.com:8888", "/Service/FooMethod", + "https://www.foo.com:8888/Service", "FooMethod"}, + // https with ipv6 literal, custom port. + {"https", "[1080:0:0:0:8:800:200C:417A]:8888", "/Service/FooMethod", + "https://[1080:0:0:0:8:800:200C:417A]:8888/Service", "FooMethod"}, + // custom url scheme, https default port. + {"blah", "www.foo.com:443", "/Service/FooMethod", + "blah://www.foo.com:443/Service", "FooMethod"}}; + for (uint32_t i = 0; i < GPR_ARRAY_SIZE(test_cases); i++) { + const char* url_scheme = test_cases[i].url_scheme; + grpc_slice call_host = + grpc_slice_from_copied_string(test_cases[i].call_host); + grpc_slice call_method = + grpc_slice_from_copied_string(test_cases[i].call_method); + grpc_auth_metadata_context auth_md_context; + memset(&auth_md_context, 0, sizeof(auth_md_context)); + grpc_auth_metadata_context_build(url_scheme, call_host, call_method, NULL, + &auth_md_context); + if (strcmp(auth_md_context.service_url, + test_cases[i].desired_service_url) != 0) { + gpr_log(GPR_ERROR, "Invalid service url, want: %s, got %s.", + test_cases[i].desired_service_url, auth_md_context.service_url); + GPR_ASSERT(false); + } + if (strcmp(auth_md_context.method_name, + test_cases[i].desired_method_name) != 0) { + gpr_log(GPR_ERROR, "Invalid method name, want: %s, got %s.", + test_cases[i].desired_method_name, auth_md_context.method_name); + GPR_ASSERT(false); + } + GPR_ASSERT(auth_md_context.channel_auth_context == NULL); + grpc_slice_unref(call_host); + grpc_slice_unref(call_method); + grpc_auth_metadata_context_reset(&auth_md_context); + } +} + +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_empty_md_array(); @@ -1214,6 +1288,7 @@ int main(int argc, char **argv) { test_metadata_plugin_failure(); test_get_well_known_google_credentials_file_path(); test_channel_creds_duplicate_without_call_creds(); + test_auth_metadata_context(); grpc_shutdown(); return 0; } diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc index 1f1cf11545..fa8036e581 100644 --- a/test/core/security/fetch_oauth2.cc +++ b/test/core/security/fetch_oauth2.cc @@ -31,24 +31,24 @@ #include "src/core/lib/security/credentials/credentials.h" #include "test/core/security/oauth2_utils.h" -static grpc_call_credentials *create_refresh_token_creds( - const char *json_refresh_token_file_path) { +static grpc_call_credentials* create_refresh_token_creds( + const char* json_refresh_token_file_path) { grpc_slice refresh_token; GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file(json_refresh_token_file_path, 1, &refresh_token))); return grpc_google_refresh_token_credentials_create( - (const char *)GRPC_SLICE_START_PTR(refresh_token), NULL); + (const char*)GRPC_SLICE_START_PTR(refresh_token), NULL); } -int main(int argc, char **argv) { - grpc_call_credentials *creds = NULL; - char *json_key_file_path = NULL; - const char *json_refresh_token_file_path = NULL; - char *token = NULL; +int main(int argc, char** argv) { + grpc_call_credentials* creds = NULL; + char* json_key_file_path = NULL; + const char* json_refresh_token_file_path = NULL; + char* token = NULL; int use_gce = 0; - char *scope = NULL; - gpr_cmdline *cl = gpr_cmdline_create("fetch_oauth2"); + char* scope = NULL; + gpr_cmdline* cl = gpr_cmdline_create("fetch_oauth2"); gpr_cmdline_add_string(cl, "json_refresh_token", "File path of the json refresh token.", &json_refresh_token_file_path); diff --git a/test/core/security/json_token_test.cc b/test/core/security/json_token_test.cc index 70661a111b..a06e1d05ce 100644 --- a/test/core/security/json_token_test.cc +++ b/test/core/security/json_token_test.cc @@ -77,12 +77,12 @@ static const char test_scope[] = "myperm1 myperm2"; static const char test_service_url[] = "https://foo.com/foo.v1"; -static char *test_json_key_str(const char *bad_part3) { - const char *part3 = bad_part3 != NULL ? bad_part3 : test_json_key_str_part3; +static char* test_json_key_str(const char* bad_part3) { + const char* part3 = bad_part3 != NULL ? bad_part3 : test_json_key_str_part3; size_t result_len = strlen(test_json_key_str_part1) + strlen(test_json_key_str_part2) + strlen(part3); - char *result = static_cast<char *>(gpr_malloc(result_len + 1)); - char *current = result; + char* result = static_cast<char*>(gpr_malloc(result_len + 1)); + char* current = result; strcpy(result, test_json_key_str_part1); current += strlen(test_json_key_str_part1); strcpy(current, test_json_key_str_part2); @@ -92,7 +92,7 @@ static char *test_json_key_str(const char *bad_part3) { } static void test_parse_json_key_success(void) { - char *json_string = test_json_key_str(NULL); + char* json_string = test_json_key_str(NULL); grpc_auth_json_key json_key = grpc_auth_json_key_create_from_string(json_string); GPR_ASSERT(grpc_auth_json_key_is_valid(&json_key)); @@ -122,7 +122,7 @@ static void test_parse_json_key_failure_bad_json(void) { "com\", \"client_id\": " "\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent." "com\", \"type\": \"service_account\" "; - char *json_string = test_json_key_str(non_closing_part3); + char* json_string = test_json_key_str(non_closing_part3); grpc_auth_json_key json_key = grpc_auth_json_key_create_from_string(json_string); GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key)); @@ -138,7 +138,7 @@ static void test_parse_json_key_failure_no_type(void) { "com\", \"client_id\": " "\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent." "com\" }"; - char *json_string = test_json_key_str(no_type_part3); + char* json_string = test_json_key_str(no_type_part3); grpc_auth_json_key json_key = grpc_auth_json_key_create_from_string(json_string); GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key)); @@ -153,7 +153,7 @@ static void test_parse_json_key_failure_no_client_id(void) { "\"777-abaslkan11hlb6nmim3bpspl31ud@developer.gserviceaccount." "com\", " "\"type\": \"service_account\" }"; - char *json_string = test_json_key_str(no_client_id_part3); + char* json_string = test_json_key_str(no_client_id_part3); grpc_auth_json_key json_key = grpc_auth_json_key_create_from_string(json_string); GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key)); @@ -167,7 +167,7 @@ static void test_parse_json_key_failure_no_client_email(void) { "\"client_id\": " "\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent." "com\", \"type\": \"service_account\" }"; - char *json_string = test_json_key_str(no_client_email_part3); + char* json_string = test_json_key_str(no_client_email_part3); grpc_auth_json_key json_key = grpc_auth_json_key_create_from_string(json_string); GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key)); @@ -182,7 +182,7 @@ static void test_parse_json_key_failure_no_private_key_id(void) { "com\", \"client_id\": " "\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent." "com\", \"type\": \"service_account\" }"; - char *json_string = test_json_key_str(no_private_key_id_part3); + char* json_string = test_json_key_str(no_private_key_id_part3); grpc_auth_json_key json_key = grpc_auth_json_key_create_from_string(json_string); GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key)); @@ -204,20 +204,20 @@ static void test_parse_json_key_failure_no_private_key(void) { grpc_auth_json_key_destruct(&json_key); } -static grpc_json *parse_json_part_from_jwt(const char *str, size_t len, - char **scratchpad) { +static grpc_json* parse_json_part_from_jwt(const char* str, size_t len, + char** scratchpad) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - char *b64; - char *decoded; - grpc_json *json; + char* b64; + char* decoded; + grpc_json* json; grpc_slice slice; - b64 = static_cast<char *>(gpr_malloc(len + 1)); + b64 = static_cast<char*>(gpr_malloc(len + 1)); strncpy(b64, str, len); b64[len] = '\0'; slice = grpc_base64_decode(&exec_ctx, b64, 1); GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice)); - decoded = static_cast<char *>(gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1)); - strncpy(decoded, (const char *)GRPC_SLICE_START_PTR(slice), + decoded = static_cast<char*>(gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1)); + strncpy(decoded, (const char*)GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice)); decoded[GRPC_SLICE_LENGTH(slice)] = '\0'; json = grpc_json_parse_string(decoded); @@ -228,11 +228,11 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len, return json; } -static void check_jwt_header(grpc_json *header) { - grpc_json *ptr; - grpc_json *alg = NULL; - grpc_json *typ = NULL; - grpc_json *kid = NULL; +static void check_jwt_header(grpc_json* header) { + grpc_json* ptr; + grpc_json* alg = NULL; + grpc_json* typ = NULL; + grpc_json* kid = NULL; for (ptr = header->child; ptr; ptr = ptr->next) { if (strcmp(ptr->key, "alg") == 0) { @@ -257,18 +257,18 @@ static void check_jwt_header(grpc_json *header) { 0); } -static void check_jwt_claim(grpc_json *claim, const char *expected_audience, - const char *expected_scope) { +static void check_jwt_claim(grpc_json* claim, const char* expected_audience, + const char* expected_scope) { gpr_timespec expiration = gpr_time_0(GPR_CLOCK_REALTIME); gpr_timespec issue_time = gpr_time_0(GPR_CLOCK_REALTIME); gpr_timespec parsed_lifetime; - grpc_json *iss = NULL; - grpc_json *scope = NULL; - grpc_json *aud = NULL; - grpc_json *exp = NULL; - grpc_json *iat = NULL; - grpc_json *sub = NULL; - grpc_json *ptr; + grpc_json* iss = NULL; + grpc_json* scope = NULL; + grpc_json* aud = NULL; + grpc_json* exp = NULL; + grpc_json* iat = NULL; + grpc_json* sub = NULL; + grpc_json* ptr; for (ptr = claim->child; ptr; ptr = ptr->next) { if (strcmp(ptr->key, "iss") == 0) { @@ -323,13 +323,13 @@ static void check_jwt_claim(grpc_json *claim, const char *expected_audience, GPR_ASSERT(parsed_lifetime.tv_sec == grpc_max_auth_token_lifetime().tv_sec); } -static void check_jwt_signature(const char *b64_signature, RSA *rsa_key, - const char *signed_data, +static void check_jwt_signature(const char* b64_signature, RSA* rsa_key, + const char* signed_data, size_t signed_data_size) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - EVP_MD_CTX *md_ctx = EVP_MD_CTX_create(); - EVP_PKEY *key = EVP_PKEY_new(); + EVP_MD_CTX* md_ctx = EVP_MD_CTX_create(); + EVP_PKEY* key = EVP_PKEY_new(); grpc_slice sig = grpc_base64_decode(&exec_ctx, b64_signature, 1); GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig)); @@ -352,38 +352,38 @@ static void check_jwt_signature(const char *b64_signature, RSA *rsa_key, grpc_exec_ctx_finish(&exec_ctx); } -static char *service_account_creds_jwt_encode_and_sign( - const grpc_auth_json_key *key) { +static char* service_account_creds_jwt_encode_and_sign( + const grpc_auth_json_key* key) { return grpc_jwt_encode_and_sign(key, GRPC_JWT_OAUTH2_AUDIENCE, grpc_max_auth_token_lifetime(), test_scope); } -static char *jwt_creds_jwt_encode_and_sign(const grpc_auth_json_key *key) { +static char* jwt_creds_jwt_encode_and_sign(const grpc_auth_json_key* key) { return grpc_jwt_encode_and_sign(key, test_service_url, grpc_max_auth_token_lifetime(), NULL); } -static void service_account_creds_check_jwt_claim(grpc_json *claim) { +static void service_account_creds_check_jwt_claim(grpc_json* claim) { check_jwt_claim(claim, GRPC_JWT_OAUTH2_AUDIENCE, test_scope); } -static void jwt_creds_check_jwt_claim(grpc_json *claim) { +static void jwt_creds_check_jwt_claim(grpc_json* claim) { check_jwt_claim(claim, test_service_url, NULL); } static void test_jwt_encode_and_sign( - char *(*jwt_encode_and_sign_func)(const grpc_auth_json_key *), - void (*check_jwt_claim_func)(grpc_json *)) { - char *json_string = test_json_key_str(NULL); - grpc_json *parsed_header = NULL; - grpc_json *parsed_claim = NULL; - char *scratchpad; + char* (*jwt_encode_and_sign_func)(const grpc_auth_json_key*), + void (*check_jwt_claim_func)(grpc_json*)) { + char* json_string = test_json_key_str(NULL); + grpc_json* parsed_header = NULL; + grpc_json* parsed_claim = NULL; + char* scratchpad; grpc_auth_json_key json_key = grpc_auth_json_key_create_from_string(json_string); - const char *b64_signature; + const char* b64_signature; size_t offset = 0; - char *jwt = jwt_encode_and_sign_func(&json_key); - const char *dot = strchr(jwt, '.'); + char* jwt = jwt_encode_and_sign_func(&json_key); + const char* dot = strchr(jwt, '.'); GPR_ASSERT(dot != NULL); parsed_header = parse_json_part_from_jwt(jwt, (size_t)(dot - jwt), &scratchpad); @@ -481,7 +481,7 @@ static void test_parse_refresh_token_failure_no_refresh_token(void) { GPR_ASSERT(!grpc_auth_refresh_token_is_valid(&refresh_token)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_parse_json_key_success(); test_parse_json_key_failure_bad_json(); diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc index b0b94ba250..6858b36141 100644 --- a/test/core/security/jwt_verifier_test.cc +++ b/test/core/security/jwt_verifier_test.cc @@ -167,12 +167,12 @@ static const char invalid_claims[] = typedef struct { grpc_jwt_verifier_status expected_status; - const char *expected_issuer; - const char *expected_subject; + const char* expected_issuer; + const char* expected_subject; } verifier_test_config; static void test_jwt_issuer_email_domain(void) { - const char *d = grpc_jwt_issuer_email_domain("https://foo.com"); + const char* d = grpc_jwt_issuer_email_domain("https://foo.com"); GPR_ASSERT(d == NULL); d = grpc_jwt_issuer_email_domain("foo.com"); GPR_ASSERT(d == NULL); @@ -204,10 +204,10 @@ static void test_jwt_issuer_email_domain(void) { } static void test_claims_success(void) { - grpc_jwt_claims *claims; + grpc_jwt_claims* claims; grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint); - grpc_json *json = grpc_json_parse_string_with_len( - (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); + grpc_json* json = grpc_json_parse_string_with_len( + (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); GPR_ASSERT(json != NULL); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; claims = grpc_jwt_claims_from_json(&exec_ctx, json, s); @@ -224,10 +224,10 @@ static void test_claims_success(void) { } static void test_expired_claims_failure(void) { - grpc_jwt_claims *claims; + grpc_jwt_claims* claims; grpc_slice s = grpc_slice_from_copied_string(expired_claims); - grpc_json *json = grpc_json_parse_string_with_len( - (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); + grpc_json* json = grpc_json_parse_string_with_len( + (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); gpr_timespec exp_iat = {100, 0, GPR_CLOCK_REALTIME}; gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME}; gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME}; @@ -252,18 +252,18 @@ static void test_expired_claims_failure(void) { static void test_invalid_claims_failure(void) { grpc_slice s = grpc_slice_from_copied_string(invalid_claims); - grpc_json *json = grpc_json_parse_string_with_len( - (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); + grpc_json* json = grpc_json_parse_string_with_len( + (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(grpc_jwt_claims_from_json(&exec_ctx, json, s) == NULL); grpc_exec_ctx_finish(&exec_ctx); } static void test_bad_audience_claims_failure(void) { - grpc_jwt_claims *claims; + grpc_jwt_claims* claims; grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint); - grpc_json *json = grpc_json_parse_string_with_len( - (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); + grpc_json* json = grpc_json_parse_string_with_len( + (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); GPR_ASSERT(json != NULL); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; claims = grpc_jwt_claims_from_json(&exec_ctx, json, s); @@ -275,10 +275,10 @@ static void test_bad_audience_claims_failure(void) { } static void test_bad_subject_claims_failure(void) { - grpc_jwt_claims *claims; + grpc_jwt_claims* claims; grpc_slice s = grpc_slice_from_copied_string(claims_with_bad_subject); - grpc_json *json = grpc_json_parse_string_with_len( - (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); + grpc_json* json = grpc_json_parse_string_with_len( + (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); GPR_ASSERT(json != NULL); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; claims = grpc_jwt_claims_from_json(&exec_ctx, json, s); @@ -289,11 +289,11 @@ static void test_bad_subject_claims_failure(void) { grpc_exec_ctx_finish(&exec_ctx); } -static char *json_key_str(const char *last_part) { +static char* json_key_str(const char* last_part) { size_t result_len = strlen(json_key_str_part1) + strlen(json_key_str_part2) + strlen(last_part); - char *result = static_cast<char *>(gpr_malloc(result_len + 1)); - char *current = result; + char* result = static_cast<char*>(gpr_malloc(result_len + 1)); + char* current = result; strcpy(result, json_key_str_part1); current += strlen(json_key_str_part1); strcpy(current, json_key_str_part2); @@ -302,18 +302,18 @@ static char *json_key_str(const char *last_part) { return result; } -static char *good_google_email_keys(void) { +static char* good_google_email_keys(void) { size_t result_len = strlen(good_google_email_keys_part1) + strlen(good_google_email_keys_part2); - char *result = static_cast<char *>(gpr_malloc(result_len + 1)); - char *current = result; + char* result = static_cast<char*>(gpr_malloc(result_len + 1)); + char* current = result; strcpy(result, good_google_email_keys_part1); current += strlen(good_google_email_keys_part1); strcpy(current, good_google_email_keys_part2); return result; } -static grpc_httpcli_response http_response(int status, char *body) { +static grpc_httpcli_response http_response(int status, char* body) { grpc_httpcli_response response; memset(&response, 0, sizeof(grpc_httpcli_response)); response.status = status; @@ -323,17 +323,17 @@ static grpc_httpcli_response http_response(int status, char *body) { } static int httpcli_post_should_not_be_called( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - const char *body_bytes, size_t body_size, grpc_millis deadline, - grpc_closure *on_done, grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + const char* body_bytes, size_t body_size, grpc_millis deadline, + grpc_closure* on_done, grpc_httpcli_response* response) { GPR_ASSERT("HTTP POST should not be called" == NULL); return 1; } static int httpcli_get_google_keys_for_email( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - grpc_millis deadline, grpc_closure *on_done, - grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + grpc_millis deadline, grpc_closure* on_done, + grpc_httpcli_response* response) { *response = http_response(200, good_google_email_keys()); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0); @@ -345,21 +345,21 @@ static int httpcli_get_google_keys_for_email( return 1; } -static void on_verification_success(grpc_exec_ctx *exec_ctx, void *user_data, +static void on_verification_success(grpc_exec_ctx* exec_ctx, void* user_data, grpc_jwt_verifier_status status, - grpc_jwt_claims *claims) { + grpc_jwt_claims* claims) { GPR_ASSERT(status == GRPC_JWT_VERIFIER_OK); GPR_ASSERT(claims != NULL); - GPR_ASSERT(user_data == (void *)expected_user_data); + GPR_ASSERT(user_data == (void*)expected_user_data); GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), expected_audience) == 0); grpc_jwt_claims_destroy(exec_ctx, claims); } static void test_jwt_verifier_google_email_issuer_success(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0); - char *jwt = NULL; - char *key_str = json_key_str(json_key_str_part3_for_google_email_issuer); + grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0); + char* jwt = NULL; + char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer); grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str); gpr_free(key_str); GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); @@ -370,7 +370,7 @@ static void test_jwt_verifier_google_email_issuer_success(void) { grpc_auth_json_key_destruct(&key); GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience, - on_verification_success, (void *)expected_user_data); + on_verification_success, (void*)expected_user_data); grpc_jwt_verifier_destroy(&exec_ctx, verifier); grpc_exec_ctx_finish(&exec_ctx); gpr_free(jwt); @@ -378,9 +378,9 @@ static void test_jwt_verifier_google_email_issuer_success(void) { } static int httpcli_get_custom_keys_for_email( - grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - grpc_millis deadline, grpc_closure *on_done, - grpc_httpcli_response *response) { + grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request, + grpc_millis deadline, grpc_closure* on_done, + grpc_httpcli_response* response) { *response = http_response(200, gpr_strdup(good_jwk_set)); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "keys.bar.com") == 0); @@ -391,9 +391,9 @@ static int httpcli_get_custom_keys_for_email( static void test_jwt_verifier_custom_email_issuer_success(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(&custom_mapping, 1); - char *jwt = NULL; - char *key_str = json_key_str(json_key_str_part3_for_custom_email_issuer); + grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(&custom_mapping, 1); + char* jwt = NULL; + char* key_str = json_key_str(json_key_str_part3_for_custom_email_issuer); grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str); gpr_free(key_str); GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); @@ -404,17 +404,17 @@ static void test_jwt_verifier_custom_email_issuer_success(void) { grpc_auth_json_key_destruct(&key); GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience, - on_verification_success, (void *)expected_user_data); + on_verification_success, (void*)expected_user_data); grpc_jwt_verifier_destroy(&exec_ctx, verifier); grpc_exec_ctx_finish(&exec_ctx); gpr_free(jwt); grpc_httpcli_set_override(NULL, NULL); } -static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx, - const grpc_httpcli_request *request, - grpc_millis deadline, grpc_closure *on_done, - grpc_httpcli_response *response) { +static int httpcli_get_jwk_set(grpc_exec_ctx* exec_ctx, + const grpc_httpcli_request* request, + grpc_millis deadline, grpc_closure* on_done, + grpc_httpcli_response* response) { *response = http_response(200, gpr_strdup(good_jwk_set)); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0); @@ -423,11 +423,11 @@ static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx, return 1; } -static int httpcli_get_openid_config(grpc_exec_ctx *exec_ctx, - const grpc_httpcli_request *request, +static int httpcli_get_openid_config(grpc_exec_ctx* exec_ctx, + const grpc_httpcli_request* request, grpc_millis deadline, - grpc_closure *on_done, - grpc_httpcli_response *response) { + grpc_closure* on_done, + grpc_httpcli_response* response) { *response = http_response(200, gpr_strdup(good_openid_config)); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GPR_ASSERT(strcmp(request->host, "accounts.google.com") == 0); @@ -440,9 +440,9 @@ static int httpcli_get_openid_config(grpc_exec_ctx *exec_ctx, static void test_jwt_verifier_url_issuer_success(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0); - char *jwt = NULL; - char *key_str = json_key_str(json_key_str_part3_for_url_issuer); + grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0); + char* jwt = NULL; + char* key_str = json_key_str(json_key_str_part3_for_url_issuer); grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str); gpr_free(key_str); GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); @@ -453,26 +453,26 @@ static void test_jwt_verifier_url_issuer_success(void) { grpc_auth_json_key_destruct(&key); GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience, - on_verification_success, (void *)expected_user_data); + on_verification_success, (void*)expected_user_data); grpc_jwt_verifier_destroy(&exec_ctx, verifier); grpc_exec_ctx_finish(&exec_ctx); gpr_free(jwt); grpc_httpcli_set_override(NULL, NULL); } -static void on_verification_key_retrieval_error(grpc_exec_ctx *exec_ctx, - void *user_data, +static void on_verification_key_retrieval_error(grpc_exec_ctx* exec_ctx, + void* user_data, grpc_jwt_verifier_status status, - grpc_jwt_claims *claims) { + grpc_jwt_claims* claims) { GPR_ASSERT(status == GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR); GPR_ASSERT(claims == NULL); - GPR_ASSERT(user_data == (void *)expected_user_data); + GPR_ASSERT(user_data == (void*)expected_user_data); } -static int httpcli_get_bad_json(grpc_exec_ctx *exec_ctx, - const grpc_httpcli_request *request, - grpc_millis deadline, grpc_closure *on_done, - grpc_httpcli_response *response) { +static int httpcli_get_bad_json(grpc_exec_ctx* exec_ctx, + const grpc_httpcli_request* request, + grpc_millis deadline, grpc_closure* on_done, + grpc_httpcli_response* response) { *response = http_response(200, gpr_strdup("{\"bad\": \"stuff\"}")); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE); @@ -481,9 +481,9 @@ static int httpcli_get_bad_json(grpc_exec_ctx *exec_ctx, static void test_jwt_verifier_url_issuer_bad_config(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0); - char *jwt = NULL; - char *key_str = json_key_str(json_key_str_part3_for_url_issuer); + grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0); + char* jwt = NULL; + char* key_str = json_key_str(json_key_str_part3_for_url_issuer); grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str); gpr_free(key_str); GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); @@ -495,7 +495,7 @@ static void test_jwt_verifier_url_issuer_bad_config(void) { GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience, on_verification_key_retrieval_error, - (void *)expected_user_data); + (void*)expected_user_data); grpc_jwt_verifier_destroy(&exec_ctx, verifier); grpc_exec_ctx_finish(&exec_ctx); gpr_free(jwt); @@ -504,9 +504,9 @@ static void test_jwt_verifier_url_issuer_bad_config(void) { static void test_jwt_verifier_bad_json_key(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0); - char *jwt = NULL; - char *key_str = json_key_str(json_key_str_part3_for_google_email_issuer); + grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0); + char* jwt = NULL; + char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer); grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str); gpr_free(key_str); GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); @@ -518,18 +518,18 @@ static void test_jwt_verifier_bad_json_key(void) { GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience, on_verification_key_retrieval_error, - (void *)expected_user_data); + (void*)expected_user_data); grpc_jwt_verifier_destroy(&exec_ctx, verifier); grpc_exec_ctx_finish(&exec_ctx); gpr_free(jwt); grpc_httpcli_set_override(NULL, NULL); } -static void corrupt_jwt_sig(char *jwt) { +static void corrupt_jwt_sig(char* jwt) { grpc_slice sig; - char *bad_b64_sig; - uint8_t *sig_bytes; - char *last_dot = strrchr(jwt, '.'); + char* bad_b64_sig; + uint8_t* sig_bytes; + char* last_dot = strrchr(jwt, '.'); GPR_ASSERT(last_dot != NULL); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -546,20 +546,20 @@ static void corrupt_jwt_sig(char *jwt) { grpc_slice_unref(sig); } -static void on_verification_bad_signature(grpc_exec_ctx *exec_ctx, - void *user_data, +static void on_verification_bad_signature(grpc_exec_ctx* exec_ctx, + void* user_data, grpc_jwt_verifier_status status, - grpc_jwt_claims *claims) { + grpc_jwt_claims* claims) { GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_SIGNATURE); GPR_ASSERT(claims == NULL); - GPR_ASSERT(user_data == (void *)expected_user_data); + GPR_ASSERT(user_data == (void*)expected_user_data); } static void test_jwt_verifier_bad_signature(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0); - char *jwt = NULL; - char *key_str = json_key_str(json_key_str_part3_for_url_issuer); + grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0); + char* jwt = NULL; + char* key_str = json_key_str(json_key_str_part3_for_url_issuer); grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str); gpr_free(key_str); GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); @@ -572,38 +572,38 @@ static void test_jwt_verifier_bad_signature(void) { GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience, on_verification_bad_signature, - (void *)expected_user_data); + (void*)expected_user_data); gpr_free(jwt); grpc_jwt_verifier_destroy(&exec_ctx, verifier); grpc_exec_ctx_finish(&exec_ctx); grpc_httpcli_set_override(NULL, NULL); } -static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx, - const grpc_httpcli_request *request, +static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx, + const grpc_httpcli_request* request, grpc_millis deadline, - grpc_closure *on_done, - grpc_httpcli_response *response) { + grpc_closure* on_done, + grpc_httpcli_response* response) { GPR_ASSERT(0); return 1; } -static void on_verification_bad_format(grpc_exec_ctx *exec_ctx, void *user_data, +static void on_verification_bad_format(grpc_exec_ctx* exec_ctx, void* user_data, grpc_jwt_verifier_status status, - grpc_jwt_claims *claims) { + grpc_jwt_claims* claims) { GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_FORMAT); GPR_ASSERT(claims == NULL); - GPR_ASSERT(user_data == (void *)expected_user_data); + GPR_ASSERT(user_data == (void*)expected_user_data); } static void test_jwt_verifier_bad_format(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0); + grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0); grpc_httpcli_set_override(httpcli_get_should_not_be_called, httpcli_post_should_not_be_called); grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, "bad jwt", expected_audience, on_verification_bad_format, - (void *)expected_user_data); + (void*)expected_user_data); grpc_jwt_verifier_destroy(&exec_ctx, verifier); grpc_exec_ctx_finish(&exec_ctx); grpc_httpcli_set_override(NULL, NULL); @@ -613,7 +613,7 @@ static void test_jwt_verifier_bad_format(void) { /* bad signature custom provided email*/ /* bad key */ -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_jwt_issuer_email_domain(); diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc index 73d6c5bc7d..fda3d96e18 100644 --- a/test/core/security/oauth2_utils.cc +++ b/test/core/security/oauth2_utils.cc @@ -30,26 +30,26 @@ #include "src/core/lib/security/credentials/credentials.h" typedef struct { - gpr_mu *mu; + gpr_mu* mu; grpc_polling_entity pops; bool is_done; - char *token; + char* token; grpc_credentials_mdelem_array md_array; grpc_closure closure; } oauth2_request; -static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - oauth2_request *request = (oauth2_request *)arg; - char *token = NULL; +static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + oauth2_request* request = (oauth2_request*)arg; + char* token = NULL; grpc_slice token_slice; if (error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Fetching token failed: %s", grpc_error_string(error)); } else { GPR_ASSERT(request->md_array.size == 1); token_slice = GRPC_MDVALUE(request->md_array.md[0]); - token = (char *)gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1); + token = (char*)gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1); memcpy(token, GRPC_SLICE_START_PTR(token_slice), GRPC_SLICE_LENGTH(token_slice)); token[GRPC_SLICE_LENGTH(token_slice)] = '\0'; @@ -65,18 +65,18 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *arg, gpr_mu_unlock(request->mu); } -static void do_nothing(grpc_exec_ctx *exec_ctx, void *unused, - grpc_error *error) {} +static void do_nothing(grpc_exec_ctx* exec_ctx, void* unused, + grpc_error* error) {} -char *grpc_test_fetch_oauth2_token_with_credentials( - grpc_call_credentials *creds) { +char* grpc_test_fetch_oauth2_token_with_credentials( + grpc_call_credentials* creds) { oauth2_request request; memset(&request, 0, sizeof(request)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_closure do_nothing_closure; grpc_auth_metadata_context null_ctx = {"", "", NULL, NULL}; - grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); + grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(pollset, &request.mu); request.pops = grpc_polling_entity_create_from_pollset(pollset); request.is_done = false; @@ -87,7 +87,7 @@ char *grpc_test_fetch_oauth2_token_with_credentials( GRPC_CLOSURE_INIT(&request.closure, on_oauth2_response, &request, grpc_schedule_on_exec_ctx); - grpc_error *error = GRPC_ERROR_NONE; + grpc_error* error = GRPC_ERROR_NONE; if (grpc_call_credentials_get_request_metadata( &exec_ctx, creds, &request.pops, null_ctx, &request.md_array, &request.closure, &error)) { @@ -99,7 +99,7 @@ char *grpc_test_fetch_oauth2_token_with_credentials( gpr_mu_lock(request.mu); while (!request.is_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, diff --git a/test/core/security/oauth2_utils.h b/test/core/security/oauth2_utils.h index 85ef988413..5ad2e398e1 100644 --- a/test/core/security/oauth2_utils.h +++ b/test/core/security/oauth2_utils.h @@ -23,7 +23,7 @@ /* Fetch oauth2 access token with a credentials object. Does not take ownership. Returns NULL on a failure. The caller should call gpr_free on the token. */ -char *grpc_test_fetch_oauth2_token_with_credentials( - grpc_call_credentials *creds); +char* grpc_test_fetch_oauth2_token_with_credentials( + grpc_call_credentials* creds); #endif /* GRPC_TEST_CORE_SECURITY_OAUTH2_UTILS_H */ diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc index 81c992c4d6..a57180b57d 100644 --- a/test/core/security/print_google_default_creds_token.cc +++ b/test/core/security/print_google_default_creds_token.cc @@ -33,7 +33,7 @@ #include "src/core/lib/support/string.h" typedef struct { - gpr_mu *mu; + gpr_mu* mu; grpc_polling_entity pops; bool is_done; @@ -41,13 +41,13 @@ typedef struct { grpc_closure on_request_metadata; } synchronizer; -static void on_metadata_response(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - synchronizer *sync = static_cast<synchronizer *>(arg); +static void on_metadata_response(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + synchronizer* sync = static_cast<synchronizer*>(arg); if (error != GRPC_ERROR_NONE) { fprintf(stderr, "Fetching token failed: %s\n", grpc_error_string(error)); } else { - char *token; + char* token; GPR_ASSERT(sync->md_array.size == 1); token = grpc_slice_to_c_string(GRPC_MDVALUE(sync->md_array.md[0])); printf("\nGot token: %s\n\n", token); @@ -62,16 +62,16 @@ static void on_metadata_response(grpc_exec_ctx *exec_ctx, void *arg, gpr_mu_unlock(sync->mu); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { int result = 0; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; synchronizer sync; - grpc_channel_credentials *creds = NULL; - const char *service_url = "https://test.foo.google.com/Foo"; + grpc_channel_credentials* creds = NULL; + const char* service_url = "https://test.foo.google.com/Foo"; grpc_auth_metadata_context context; - gpr_cmdline *cl = gpr_cmdline_create("print_google_default_creds_token"); - grpc_pollset *pollset = nullptr; - grpc_error *error = nullptr; + gpr_cmdline* cl = gpr_cmdline_create("print_google_default_creds_token"); + grpc_pollset* pollset = nullptr; + grpc_error* error = nullptr; gpr_cmdline_add_string(cl, "service_url", "Service URL for the token request.", &service_url); gpr_cmdline_parse(cl, argc, argv); @@ -88,7 +88,7 @@ int main(int argc, char **argv) { } memset(&sync, 0, sizeof(sync)); - pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); + pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(pollset, &sync.mu); sync.pops = grpc_polling_entity_create_from_pollset(pollset); sync.is_done = false; @@ -97,7 +97,7 @@ int main(int argc, char **argv) { error = GRPC_ERROR_NONE; if (grpc_call_credentials_get_request_metadata( - &exec_ctx, ((grpc_composite_channel_credentials *)creds)->call_creds, + &exec_ctx, ((grpc_composite_channel_credentials*)creds)->call_creds, &sync.pops, context, &sync.md_array, &sync.on_request_metadata, &error)) { // Synchronous response. Invoke callback directly. @@ -107,7 +107,7 @@ int main(int argc, char **argv) { gpr_mu_lock(sync.mu); while (!sync.is_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, diff --git a/test/core/security/secure_endpoint_test.cc b/test/core/security/secure_endpoint_test.cc index 00ff7cf4e8..11d1e5fcf4 100644 --- a/test/core/security/secure_endpoint_test.cc +++ b/test/core/security/secure_endpoint_test.cc @@ -32,28 +32,28 @@ #include "src/core/tsi/fake_transport_security.h" #include "test/core/util/test_config.h" -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( - size_t slice_size, grpc_slice *leftover_slices, size_t leftover_nslices, + size_t slice_size, grpc_slice* leftover_slices, size_t leftover_nslices, bool use_zero_copy_protector) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - tsi_frame_protector *fake_read_protector = + tsi_frame_protector* fake_read_protector = tsi_create_fake_frame_protector(NULL); - tsi_frame_protector *fake_write_protector = + tsi_frame_protector* fake_write_protector = tsi_create_fake_frame_protector(NULL); - tsi_zero_copy_grpc_protector *fake_read_zero_copy_protector = + tsi_zero_copy_grpc_protector* fake_read_zero_copy_protector = use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(NULL) : NULL; - tsi_zero_copy_grpc_protector *fake_write_zero_copy_protector = + tsi_zero_copy_grpc_protector* fake_write_zero_copy_protector = use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(NULL) : NULL; grpc_endpoint_test_fixture f; grpc_endpoint_pair tcp; grpc_arg a[1]; - a[0].key = const_cast<char *>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); a[0].type = GRPC_ARG_INTEGER; a[0].value.integer = (int)slice_size; grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; @@ -71,12 +71,12 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( size_t still_pending_size; size_t total_buffer_size = 8192; size_t buffer_size = total_buffer_size; - uint8_t *encrypted_buffer = (uint8_t *)gpr_malloc(buffer_size); - uint8_t *cur = encrypted_buffer; + uint8_t* encrypted_buffer = (uint8_t*)gpr_malloc(buffer_size); + uint8_t* cur = encrypted_buffer; grpc_slice encrypted_leftover; for (i = 0; i < leftover_nslices; i++) { grpc_slice plain = leftover_slices[i]; - uint8_t *message_bytes = GRPC_SLICE_START_PTR(plain); + uint8_t* message_bytes = GRPC_SLICE_START_PTR(plain); size_t message_size = GRPC_SLICE_LENGTH(plain); while (message_size > 0) { size_t protected_buffer_size_to_send = buffer_size; @@ -104,7 +104,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( buffer_size -= protected_buffer_size_to_send; } while (still_pending_size > 0); encrypted_leftover = grpc_slice_from_copied_buffer( - (const char *)encrypted_buffer, total_buffer_size - buffer_size); + (const char*)encrypted_buffer, total_buffer_size - buffer_size); f.client_ep = grpc_secure_endpoint_create( fake_read_protector, fake_read_zero_copy_protector, tcp.client, &encrypted_leftover, 1); @@ -163,9 +163,9 @@ static grpc_endpoint_test_config configs[] = { clean_up}, }; -static void inc_call_ctr(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - ++*(int *)arg; +static void inc_call_ctr(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + ++*(int*)arg; } static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) { @@ -201,18 +201,18 @@ static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) { clean_up(); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, (grpc_pollset *)p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); + g_pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(g_pollset, &g_mu); grpc_endpoint_tests(configs[0], g_pollset, g_mu); grpc_endpoint_tests(configs[1], g_pollset, g_mu); diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc index eecf0f462b..a0c1e93532 100644 --- a/test/core/security/security_connector_test.cc +++ b/test/core/security/security_connector_test.cc @@ -35,10 +35,10 @@ #include "src/core/tsi/transport_security.h" #include "test/core/util/test_config.h" -static int check_transport_security_type(const grpc_auth_context *ctx) { +static int check_transport_security_type(const grpc_auth_context* ctx) { grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name( ctx, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME); - const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it); + const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it); if (prop == NULL) return 0; if (strncmp(prop->value, GRPC_SSL_TRANSPORT_SECURITY_TYPE, prop->value_length) != 0) { @@ -49,11 +49,11 @@ static int check_transport_security_type(const grpc_auth_context *ctx) { return 1; } -static int check_peer_property(const tsi_peer *peer, - const tsi_peer_property *expected) { +static int check_peer_property(const tsi_peer* peer, + const tsi_peer_property* expected) { size_t i; for (i = 0; i < peer->property_count; i++) { - const tsi_peer_property *prop = &peer->properties[i]; + const tsi_peer_property* prop = &peer->properties[i]; if ((strcmp(prop->name, expected->name) == 0) && (prop->value.length == expected->value.length) && (memcmp(prop->value.data, expected->value.data, @@ -64,12 +64,12 @@ static int check_peer_property(const tsi_peer *peer, return 0; /* Not found... */ } -static int check_ssl_peer_equivalence(const tsi_peer *original, - const tsi_peer *reconstructed) { +static int check_ssl_peer_equivalence(const tsi_peer* original, + const tsi_peer* reconstructed) { /* The reconstructed peer only has CN, SAN and pem cert properties. */ size_t i; for (i = 0; i < original->property_count; i++) { - const tsi_peer_property *prop = &original->properties[i]; + const tsi_peer_property* prop = &original->properties[i]; if ((strcmp(prop->name, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY) == 0) || (strcmp(prop->name, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) || @@ -83,7 +83,7 @@ static int check_ssl_peer_equivalence(const tsi_peer *original, static void test_unauthenticated_ssl_peer(void) { tsi_peer peer; tsi_peer rpeer; - grpc_auth_context *ctx; + grpc_auth_context* ctx; GPR_ASSERT(tsi_construct_peer(1, &peer) == TSI_OK); GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE, @@ -101,12 +101,12 @@ static void test_unauthenticated_ssl_peer(void) { GRPC_AUTH_CONTEXT_UNREF(ctx, "test"); } -static int check_identity(const grpc_auth_context *ctx, - const char *expected_property_name, - const char **expected_identities, +static int check_identity(const grpc_auth_context* ctx, + const char* expected_property_name, + const char** expected_identities, size_t num_identities) { grpc_auth_property_iterator it; - const grpc_auth_property *prop; + const grpc_auth_property* prop; size_t i; GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx)); it = grpc_auth_context_peer_identity(ctx); @@ -131,11 +131,11 @@ static int check_identity(const grpc_auth_context *ctx, return 1; } -static int check_x509_cn(const grpc_auth_context *ctx, - const char *expected_cn) { +static int check_x509_cn(const grpc_auth_context* ctx, + const char* expected_cn) { grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name( ctx, GRPC_X509_CN_PROPERTY_NAME); - const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it); + const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it); if (prop == NULL) { gpr_log(GPR_ERROR, "CN property not found."); return 0; @@ -151,11 +151,11 @@ static int check_x509_cn(const grpc_auth_context *ctx, return 1; } -static int check_x509_pem_cert(const grpc_auth_context *ctx, - const char *expected_pem_cert) { +static int check_x509_pem_cert(const grpc_auth_context* ctx, + const char* expected_pem_cert) { grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name( ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME); - const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it); + const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it); if (prop == NULL) { gpr_log(GPR_ERROR, "Pem certificate property not found."); return 0; @@ -175,9 +175,9 @@ static int check_x509_pem_cert(const grpc_auth_context *ctx, static void test_cn_only_ssl_peer_to_auth_context(void) { tsi_peer peer; tsi_peer rpeer; - grpc_auth_context *ctx; - const char *expected_cn = "cn1"; - const char *expected_pem_cert = "pem_cert1"; + grpc_auth_context* ctx; + const char* expected_cn = "cn1"; + const char* expected_pem_cert = "pem_cert1"; GPR_ASSERT(tsi_construct_peer(3, &peer) == TSI_OK); GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE, @@ -207,10 +207,10 @@ static void test_cn_only_ssl_peer_to_auth_context(void) { static void test_cn_and_one_san_ssl_peer_to_auth_context(void) { tsi_peer peer; tsi_peer rpeer; - grpc_auth_context *ctx; - const char *expected_cn = "cn1"; - const char *expected_san = "san1"; - const char *expected_pem_cert = "pem_cert1"; + grpc_auth_context* ctx; + const char* expected_cn = "cn1"; + const char* expected_san = "san1"; + const char* expected_pem_cert = "pem_cert1"; GPR_ASSERT(tsi_construct_peer(4, &peer) == TSI_OK); GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE, @@ -244,10 +244,10 @@ static void test_cn_and_one_san_ssl_peer_to_auth_context(void) { static void test_cn_and_multiple_sans_ssl_peer_to_auth_context(void) { tsi_peer peer; tsi_peer rpeer; - grpc_auth_context *ctx; - const char *expected_cn = "cn1"; - const char *expected_sans[] = {"san1", "san2", "san3"}; - const char *expected_pem_cert = "pem_cert1"; + grpc_auth_context* ctx; + const char* expected_cn = "cn1"; + const char* expected_sans[] = {"san1", "san2", "san3"}; + const char* expected_pem_cert = "pem_cert1"; size_t i; GPR_ASSERT(tsi_construct_peer(3 + GPR_ARRAY_SIZE(expected_sans), &peer) == TSI_OK); @@ -286,10 +286,10 @@ static void test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context( void) { tsi_peer peer; tsi_peer rpeer; - grpc_auth_context *ctx; - const char *expected_cn = "cn1"; - const char *expected_pem_cert = "pem_cert1"; - const char *expected_sans[] = {"san1", "san2", "san3"}; + grpc_auth_context* ctx; + const char* expected_cn = "cn1"; + const char* expected_pem_cert = "pem_cert1"; + const char* expected_sans[] = {"san1", "san2", "san3"}; size_t i; GPR_ASSERT(tsi_construct_peer(5 + GPR_ARRAY_SIZE(expected_sans), &peer) == TSI_OK); @@ -328,24 +328,24 @@ static void test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context( GRPC_AUTH_CONTEXT_UNREF(ctx, "test"); } -static const char *roots_for_override_api = "roots for override api"; +static const char* roots_for_override_api = "roots for override api"; static grpc_ssl_roots_override_result override_roots_success( - char **pem_root_certs) { + char** pem_root_certs) { *pem_root_certs = gpr_strdup(roots_for_override_api); return GRPC_SSL_ROOTS_OVERRIDE_OK; } static grpc_ssl_roots_override_result override_roots_permanent_failure( - char **pem_root_certs) { + char** pem_root_certs) { return GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY; } static void test_default_ssl_roots(void) { - const char *roots_for_env_var = "roots for env var"; + const char* roots_for_env_var = "roots for env var"; - char *roots_env_var_file_path; - FILE *roots_env_var_file = + char* roots_env_var_file_path; + FILE* roots_env_var_file = gpr_tmpfile("test_roots_for_env_var", &roots_env_var_file_path); fwrite(roots_for_env_var, 1, strlen(roots_for_env_var), roots_env_var_file); fclose(roots_env_var_file); @@ -355,7 +355,7 @@ static void test_default_ssl_roots(void) { gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); grpc_set_ssl_roots_override_callback(override_roots_success); grpc_slice roots = grpc_get_default_ssl_roots_for_testing(); - char *roots_contents = grpc_slice_to_c_string(roots); + char* roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0); gpr_free(roots_contents); @@ -389,7 +389,7 @@ static void test_default_ssl_roots(void) { gpr_free(roots_env_var_file_path); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); diff --git a/test/core/security/ssl_credentials_test.cc b/test/core/security/ssl_credentials_test.cc index 3c838faa60..76ee32b001 100644 --- a/test/core/security/ssl_credentials_test.cc +++ b/test/core/security/ssl_credentials_test.cc @@ -34,13 +34,13 @@ static void test_convert_grpc_to_tsi_cert_pairs() { const size_t num_pairs = 3; { - tsi_ssl_pem_key_cert_pair *tsi_pairs = + tsi_ssl_pem_key_cert_pair* tsi_pairs = grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, 0); GPR_ASSERT(tsi_pairs == NULL); } { - tsi_ssl_pem_key_cert_pair *tsi_pairs = + tsi_ssl_pem_key_cert_pair* tsi_pairs = grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, num_pairs); GPR_ASSERT(tsi_pairs != NULL); @@ -55,7 +55,7 @@ static void test_convert_grpc_to_tsi_cert_pairs() { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc index 8f34e2e420..5c5153b505 100644 --- a/test/core/security/ssl_server_fuzzer.cc +++ b/test/core/security/ssl_server_fuzzer.cc @@ -34,39 +34,39 @@ bool leak_check = false; static void discard_write(grpc_slice slice) {} -static void dont_log(gpr_log_func_args *args) {} +static void dont_log(gpr_log_func_args* args) {} struct handshake_state { bool done_callback_called; }; -static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - grpc_handshaker_args *args = static_cast<grpc_handshaker_args *>(arg); - struct handshake_state *state = - static_cast<struct handshake_state *>(args->user_data); +static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + grpc_handshaker_args* args = static_cast<grpc_handshaker_args*>(arg); + struct handshake_state* state = + static_cast<struct handshake_state*>(args->user_data); GPR_ASSERT(state->done_callback_called == false); state->done_callback_called = true; // The fuzzer should not pass the handshake. GPR_ASSERT(error != GRPC_ERROR_NONE); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { struct grpc_memory_counters counters; if (squelch) gpr_set_log_function(dont_log); if (leak_check) grpc_memory_counters_init(); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("ssl_server_fuzzer"); - grpc_endpoint *mock_endpoint = + grpc_endpoint* mock_endpoint = grpc_mock_endpoint_create(discard_write, resource_quota); grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); grpc_mock_endpoint_put_read( &exec_ctx, mock_endpoint, - grpc_slice_from_copied_buffer((const char *)data, size)); + grpc_slice_from_copied_buffer((const char*)data, size)); // Load key pair and establish server SSL credentials. grpc_ssl_pem_key_cert_pair pem_key_cert_pair; @@ -74,14 +74,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { ca_slice = grpc_slice_from_static_string(test_root_cert); cert_slice = grpc_slice_from_static_string(test_server1_cert); key_slice = grpc_slice_from_static_string(test_server1_key); - const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice); - pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice); - pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice); - grpc_server_credentials *creds = grpc_ssl_server_credentials_create( + const char* ca_cert = (const char*)GRPC_SLICE_START_PTR(ca_slice); + pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice); + pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice); + grpc_server_credentials* creds = grpc_ssl_server_credentials_create( ca_cert, &pem_key_cert_pair, 1, 0, NULL); // Create security connector - grpc_server_security_connector *sc = NULL; + grpc_server_security_connector* sc = NULL; grpc_security_status status = grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc); GPR_ASSERT(status == GRPC_SECURITY_OK); @@ -89,7 +89,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { struct handshake_state state; state.done_callback_called = false; - grpc_handshake_manager *handshake_mgr = grpc_handshake_manager_create(); + grpc_handshake_manager* handshake_mgr = grpc_handshake_manager_create(); grpc_server_security_connector_add_handshakers(&exec_ctx, sc, handshake_mgr); grpc_handshake_manager_do_handshake( &exec_ctx, handshake_mgr, mock_endpoint, NULL /* channel_args */, diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc index c6591cf546..e0e22d16f9 100644 --- a/test/core/security/verify_jwt.cc +++ b/test/core/security/verify_jwt.cc @@ -30,31 +30,31 @@ #include "src/core/lib/security/credentials/jwt/jwt_verifier.h" typedef struct { - grpc_pollset *pollset; - gpr_mu *mu; + grpc_pollset* pollset; + gpr_mu* mu; int is_done; int success; } synchronizer; -static void print_usage_and_exit(gpr_cmdline *cl, const char *argv0) { - char *usage = gpr_cmdline_usage_string(cl, argv0); +static void print_usage_and_exit(gpr_cmdline* cl, const char* argv0) { + char* usage = gpr_cmdline_usage_string(cl, argv0); fprintf(stderr, "%s", usage); gpr_free(usage); gpr_cmdline_destroy(cl); exit(1); } -static void on_jwt_verification_done(grpc_exec_ctx *exec_ctx, void *user_data, +static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data, grpc_jwt_verifier_status status, - grpc_jwt_claims *claims) { - synchronizer *sync = static_cast<synchronizer *>(user_data); + grpc_jwt_claims* claims) { + synchronizer* sync = static_cast<synchronizer*>(user_data); sync->success = (status == GRPC_JWT_VERIFIER_OK); if (sync->success) { - char *claims_str; + char* claims_str; GPR_ASSERT(claims != NULL); claims_str = - grpc_json_dump_to_string((grpc_json *)grpc_jwt_claims_json(claims), 2); + grpc_json_dump_to_string((grpc_json*)grpc_jwt_claims_json(claims), 2); printf("Claims: \n\n%s\n", claims_str); gpr_free(claims_str); grpc_jwt_claims_destroy(exec_ctx, claims); @@ -71,12 +71,12 @@ static void on_jwt_verification_done(grpc_exec_ctx *exec_ctx, void *user_data, gpr_mu_unlock(sync->mu); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { synchronizer sync; - grpc_jwt_verifier *verifier; - gpr_cmdline *cl; - const char *jwt = NULL; - const char *aud = NULL; + grpc_jwt_verifier* verifier; + gpr_cmdline* cl; + const char* jwt = NULL; + const char* aud = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_init(); @@ -92,7 +92,7 @@ int main(int argc, char **argv) { grpc_init(); - sync.pollset = static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + sync.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(sync.pollset, &sync.mu); sync.is_done = 0; @@ -101,7 +101,7 @@ int main(int argc, char **argv) { gpr_mu_lock(sync.mu); while (!sync.is_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (!GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(&exec_ctx, sync.pollset, &worker, GRPC_MILLIS_INF_FUTURE))) diff --git a/test/core/slice/b64_test.cc b/test/core/slice/b64_test.cc index bd375aa6a7..479198f9f9 100644 --- a/test/core/slice/b64_test.cc +++ b/test/core/slice/b64_test.cc @@ -27,8 +27,8 @@ #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" -static int buffers_are_equal(const unsigned char *buf1, - const unsigned char *buf2, size_t size) { +static int buffers_are_equal(const unsigned char* buf1, + const unsigned char* buf2, size_t size) { size_t i; for (i = 0; i < size; i++) { if (buf1[i] != buf2[i]) { @@ -41,13 +41,13 @@ static int buffers_are_equal(const unsigned char *buf1, } static void test_simple_encode_decode_b64(int url_safe, int multiline) { - const char *hello = "hello"; - char *hello_b64 = + const char* hello = "hello"; + char* hello_b64 = grpc_base64_encode(hello, strlen(hello), url_safe, multiline); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_slice hello_slice = grpc_base64_decode(&exec_ctx, hello_b64, url_safe); GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello)); - GPR_ASSERT(strncmp((const char *)GRPC_SLICE_START_PTR(hello_slice), hello, + GPR_ASSERT(strncmp((const char*)GRPC_SLICE_START_PTR(hello_slice), hello, GRPC_SLICE_LENGTH(hello_slice)) == 0); grpc_slice_unref_internal(&exec_ctx, hello_slice); @@ -58,7 +58,7 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) { static void test_full_range_encode_decode_b64(int url_safe, int multiline) { unsigned char orig[256]; size_t i; - char *b64; + char* b64; grpc_slice orig_decoded; for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; @@ -111,7 +111,7 @@ static void test_full_range_encode_decode_b64_urlsafe_multiline(void) { static void test_url_safe_unsafe_mismatch_failure(void) { unsigned char orig[256]; size_t i; - char *b64; + char* b64; grpc_slice orig_decoded; int url_safe = 1; for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; @@ -132,7 +132,7 @@ static void test_url_safe_unsafe_mismatch_failure(void) { } static void test_rfc4648_test_vectors(void) { - char *b64; + char* b64; b64 = grpc_base64_encode("", 0, 0, 0); GPR_ASSERT(strcmp("", b64) == 0); @@ -202,7 +202,7 @@ static void test_unpadded_decode(void) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_simple_encode_decode_b64_no_multiline(); test_simple_encode_decode_b64_multiline(); diff --git a/test/core/slice/percent_decode_fuzzer.cc b/test/core/slice/percent_decode_fuzzer.cc index 2aae335891..3603177c47 100644 --- a/test/core/slice/percent_decode_fuzzer.cc +++ b/test/core/slice/percent_decode_fuzzer.cc @@ -29,10 +29,10 @@ bool squelch = true; bool leak_check = true; -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { struct grpc_memory_counters counters; grpc_memory_counters_init(); - grpc_slice input = grpc_slice_from_copied_buffer((const char *)data, size); + grpc_slice input = grpc_slice_from_copied_buffer((const char*)data, size); grpc_slice output; if (grpc_strict_percent_decode_slice( input, grpc_url_percent_encoding_unreserved_bytes, &output)) { diff --git a/test/core/slice/percent_encode_fuzzer.cc b/test/core/slice/percent_encode_fuzzer.cc index 4813d1218b..c8e3849fc8 100644 --- a/test/core/slice/percent_encode_fuzzer.cc +++ b/test/core/slice/percent_encode_fuzzer.cc @@ -29,10 +29,10 @@ bool squelch = true; bool leak_check = true; -static void test(const uint8_t *data, size_t size, const uint8_t *dict) { +static void test(const uint8_t* data, size_t size, const uint8_t* dict) { struct grpc_memory_counters counters; grpc_memory_counters_init(); - grpc_slice input = grpc_slice_from_copied_buffer((const char *)data, size); + grpc_slice input = grpc_slice_from_copied_buffer((const char*)data, size); grpc_slice output = grpc_percent_encode_slice(input, dict); grpc_slice decoded_output; // encoder must always produce decodable output @@ -51,7 +51,7 @@ static void test(const uint8_t *data, size_t size, const uint8_t *dict) { GPR_ASSERT(counters.total_size_relative == 0); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { test(data, size, grpc_url_percent_encoding_unreserved_bytes); test(data, size, grpc_compatible_percent_encoding_unreserved_bytes); return 0; diff --git a/test/core/slice/percent_encoding_test.cc b/test/core/slice/percent_encoding_test.cc index fcc8d33db3..253240faad 100644 --- a/test/core/slice/percent_encoding_test.cc +++ b/test/core/slice/percent_encoding_test.cc @@ -33,10 +33,10 @@ permissive_unencoded, \ sizeof(permissive_unencoded) - 1, dict) -static void test_vector(const char *raw, size_t raw_length, const char *encoded, - size_t encoded_length, const uint8_t *dict) { - char *raw_msg = gpr_dump(raw, raw_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *encoded_msg = +static void test_vector(const char* raw, size_t raw_length, const char* encoded, + size_t encoded_length, const uint8_t* dict) { + char* raw_msg = gpr_dump(raw, raw_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* encoded_msg = gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", raw_msg, encoded_msg); gpr_free(raw_msg); @@ -52,11 +52,11 @@ static void test_vector(const char *raw, size_t raw_length, const char *encoded, grpc_slice encoded2raw_permissive_slice = grpc_permissive_percent_decode_slice(encoded_slice); - char *raw2encoded_msg = + char* raw2encoded_msg = grpc_dump_slice(raw2encoded_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *encoded2raw_msg = + char* encoded2raw_msg = grpc_dump_slice(encoded2raw_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *encoded2raw_permissive_msg = grpc_dump_slice( + char* encoded2raw_permissive_msg = grpc_dump_slice( encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_DEBUG, "Result:\nraw2encoded = %s\nencoded2raw = %s\nencoded2raw_permissive " @@ -77,15 +77,15 @@ static void test_vector(const char *raw, size_t raw_length, const char *encoded, grpc_slice_unref(encoded_slice); } -static void test_nonconformant_vector(const char *encoded, +static void test_nonconformant_vector(const char* encoded, size_t encoded_length, - const char *permissive_unencoded, + const char* permissive_unencoded, size_t permissive_unencoded_length, - const uint8_t *dict) { - char *permissive_unencoded_msg = + const uint8_t* dict) { + char* permissive_unencoded_msg = gpr_dump(permissive_unencoded, permissive_unencoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *encoded_msg = + char* encoded_msg = gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", permissive_unencoded_msg, encoded_msg); @@ -102,7 +102,7 @@ static void test_nonconformant_vector(const char *encoded, grpc_slice encoded2raw_permissive_slice = grpc_permissive_percent_decode_slice(encoded_slice); - char *encoded2raw_permissive_msg = grpc_dump_slice( + char* encoded2raw_permissive_msg = grpc_dump_slice( encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_DEBUG, "Result:\nencoded2raw_permissive = %s", encoded2raw_permissive_msg); @@ -116,7 +116,7 @@ static void test_nonconformant_vector(const char *encoded, grpc_slice_unref(encoded_slice); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); TEST_VECTOR( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~", diff --git a/test/core/slice/slice_buffer_test.cc b/test/core/slice/slice_buffer_test.cc index 2fba496bd0..338e8079dc 100644 --- a/test/core/slice/slice_buffer_test.cc +++ b/test/core/slice/slice_buffer_test.cc @@ -104,7 +104,7 @@ void test_slice_buffer_move_first() { GPR_ASSERT(dst.length == dst_len); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_slice_buffer_add(); diff --git a/test/core/slice/slice_string_helpers_test.cc b/test/core/slice/slice_string_helpers_test.cc index 8877da73f5..260f8c80d5 100644 --- a/test/core/slice/slice_string_helpers_test.cc +++ b/test/core/slice/slice_string_helpers_test.cc @@ -34,16 +34,16 @@ #define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x) static void expect_slice_dump(grpc_slice slice, uint32_t flags, - const char *result) { - char *got = grpc_dump_slice(slice, flags); + const char* result) { + char* got = grpc_dump_slice(slice, flags); GPR_ASSERT(0 == strcmp(got, result)); gpr_free(got); grpc_slice_unref(slice); } static void test_dump_slice(void) { - static const char *text = "HELLO WORLD!"; - static const char *long_text = + static const char* text = "HELLO WORLD!"; + static const char* long_text = "It was a bright cold day in April, and the clocks were striking " "thirteen. Winston Smith, his chin nuzzled into his breast in an effort " "to escape the vile wind, slipped quickly through the glass doors of " @@ -62,13 +62,13 @@ static void test_dump_slice(void) { } static void test_strsplit(void) { - grpc_slice_buffer *parts; + grpc_slice_buffer* parts; grpc_slice str; LOG_TEST_NAME("test_strsplit"); parts = - static_cast<grpc_slice_buffer *>(gpr_malloc(sizeof(grpc_slice_buffer))); + static_cast<grpc_slice_buffer*>(gpr_malloc(sizeof(grpc_slice_buffer))); grpc_slice_buffer_init(parts); str = grpc_slice_from_copied_string("one, two, three, four"); @@ -128,7 +128,7 @@ static void test_strsplit(void) { gpr_free(parts); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_dump_slice(); test_strsplit(); diff --git a/test/core/slice/slice_test.cc b/test/core/slice/slice_test.cc index ad62344e4d..aec5636376 100644 --- a/test/core/slice/slice_test.cc +++ b/test/core/slice/slice_test.cc @@ -64,7 +64,7 @@ static void test_slice_malloc_returns_something_sensible(void) { } } -static void do_nothing(void *ignored) {} +static void do_nothing(void* ignored) {} static void test_slice_new_returns_something_sensible(void) { uint8_t x; @@ -77,7 +77,7 @@ static void test_slice_new_returns_something_sensible(void) { } /* destroy function that sets a mark to indicate it was called. */ -static void set_mark(void *p) { *((int *)p) = 1; } +static void set_mark(void* p) { *((int*)p) = 1; } static void test_slice_new_with_user_data(void) { int marker = 0; @@ -99,7 +99,7 @@ static void test_slice_new_with_user_data(void) { static int do_nothing_with_len_1_calls = 0; -static void do_nothing_with_len_1(void *ignored, size_t len) { +static void do_nothing_with_len_1(void* ignored, size_t len) { GPR_ASSERT(len == 1); do_nothing_with_len_1_calls++; } @@ -228,7 +228,7 @@ static void test_slice_split_tail_works(size_t length) { } static void test_slice_from_copied_string_works(void) { - static const char *text = "HELLO WORLD!"; + static const char* text = "HELLO WORLD!"; grpc_slice slice; LOG_TEST_NAME("test_slice_from_copied_string_works"); @@ -289,7 +289,7 @@ static void test_static_slice_copy_interning(void) { grpc_shutdown(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { unsigned length; grpc_test_init(argc, argv); test_slice_malloc_returns_something_sensible(); diff --git a/test/core/statistics/census_log_tests.cc b/test/core/statistics/census_log_tests.cc index 229a5e55f9..e6eda5486c 100644 --- a/test/core/statistics/census_log_tests.cc +++ b/test/core/statistics/census_log_tests.cc @@ -16,7 +16,6 @@ * */ -#include "src/core/ext/census/census_log.h" #include <grpc/support/cpu.h> #include <grpc/support/log.h> #include <grpc/support/port_platform.h> @@ -27,26 +26,27 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "src/core/ext/census/census_log.h" #include "test/core/util/test_config.h" /* Fills in 'record' of size 'size'. Each byte in record is filled in with the same value. The value is extracted from 'record' pointer. */ -static void write_record(char *record, size_t size) { +static void write_record(char* record, size_t size) { char data = (uintptr_t)record % 255; memset(record, data, size); } /* Reads fixed size records. Returns the number of records read in 'num_records'. */ -static void read_records(size_t record_size, const char *buffer, - size_t buffer_size, int32_t *num_records) { +static void read_records(size_t record_size, const char* buffer, + size_t buffer_size, int32_t* num_records) { int32_t ix; GPR_ASSERT(buffer_size >= record_size); GPR_ASSERT(buffer_size % record_size == 0); *num_records = buffer_size / record_size; for (ix = 0; ix < *num_records; ++ix) { size_t jx; - const char *record = buffer + (record_size * ix); + const char* record = buffer + (record_size * ix); char data = (uintptr_t)record % 255; for (jx = 0; jx < record_size; ++jx) { GPR_ASSERT(data == record[jx]); @@ -65,13 +65,13 @@ static size_t write_records_to_log(int writer_id, int32_t record_size, for (ix = 0; ix < num_records; ++ix) { int32_t jx; int32_t spin_count = max_spin_count ? rand() % max_spin_count : 0; - char *record; + char* record; if (counter++ == num_records / 10) { printf(" Writer %d: %d out of %d written\n", writer_id, ix, num_records); counter = 0; } - record = (char *)(census_log_start_write(record_size)); + record = (char*)(census_log_start_write(record_size)); if (record == NULL) { return ix; } @@ -86,13 +86,13 @@ static size_t write_records_to_log(int writer_id, int32_t record_size, /* Performs a single read iteration. Returns the number of records read. */ static size_t perform_read_iteration(size_t record_size) { - const void *read_buffer = NULL; + const void* read_buffer = NULL; size_t bytes_available; size_t records_read = 0; census_log_init_reader(); while ((read_buffer = census_log_read_next(&bytes_available))) { int32_t num_records = 0; - read_records(record_size, (const char *)read_buffer, bytes_available, + read_records(record_size, (const char*)read_buffer, bytes_available, &num_records); records_read += num_records; } @@ -162,15 +162,15 @@ typedef struct writer_thread_args { /* Number of records to write. */ int32_t num_records; /* Used to signal when writer is complete */ - gpr_cv *done; - gpr_mu *mu; - int *count; + gpr_cv* done; + gpr_mu* mu; + int* count; } writer_thread_args; /* Writes the given number of records of random size (up to kMaxRecordSize) and random data to the specified log. */ -static void writer_thread(void *arg) { - writer_thread_args *args = (writer_thread_args *)arg; +static void writer_thread(void* arg) { + writer_thread_args* args = (writer_thread_args*)arg; /* Maximum number of times to spin between writes. */ static const int32_t MAX_SPIN_COUNT = 50; int records_written = 0; @@ -207,17 +207,17 @@ typedef struct reader_thread_args { gpr_cv stop; int stop_flag; /* Used to signal when reader has finished */ - gpr_cv *done; - gpr_mu *mu; + gpr_cv* done; + gpr_mu* mu; int running; } reader_thread_args; /* Reads and verifies the specified number of records. Reader can also be stopped via gpr_cv_signal(&args->stop). Sleeps for 'read_interval_in_msec' between read iterations. */ -static void reader_thread(void *arg) { +static void reader_thread(void* arg) { int32_t records_read = 0; - reader_thread_args *args = (reader_thread_args *)arg; + reader_thread_args* args = (reader_thread_args*)arg; int32_t num_iterations = 0; gpr_timespec interval; int counter = 0; @@ -335,7 +335,7 @@ static void setup_test(int circular_log) { void test_invalid_record_size(void) { static const size_t INVALID_SIZE = CENSUS_LOG_MAX_RECORD_SIZE + 1; static const size_t VALID_SIZE = 1; - void *record; + void* record; printf("Starting test: invalid record size\n"); setup_test(0); record = census_log_start_write(INVALID_SIZE); @@ -358,8 +358,8 @@ void test_invalid_record_size(void) { void test_end_write_with_different_size(void) { static const size_t START_WRITE_SIZE = 10; static const size_t END_WRITE_SIZE = 7; - void *record_written; - const void *record_read; + void* record_written; + const void* record_read; size_t bytes_available; printf("Starting test: end write with different size\n"); setup_test(0); @@ -378,8 +378,8 @@ void test_end_write_with_different_size(void) { void test_read_pending_record(void) { static const size_t PR_RECORD_SIZE = 1024; size_t bytes_available; - const void *record_read; - void *record_written; + const void* record_read; + void* record_written; printf("Starting test: read pending record\n"); setup_test(0); /* Start a write. */ @@ -405,9 +405,9 @@ void test_read_beyond_pending_record(void) { uint32_t incomplete_record_size = 10; uint32_t complete_record_size = 20; size_t bytes_available; - void *complete_record; - const void *record_read; - void *incomplete_record; + void* complete_record; + const void* record_read; + void* incomplete_record; printf("Starting test: read beyond pending record\n"); setup_test(0); incomplete_record = census_log_start_write(incomplete_record_size); @@ -442,8 +442,8 @@ void test_read_beyond_pending_record(void) { void test_detached_while_reading(void) { static const size_t DWR_RECORD_SIZE = 10; size_t bytes_available; - const void *record_read; - void *record_written; + const void* record_read; + void* record_written; uint32_t block_read = 0; printf("Starting test: detached while reading\n"); setup_test(0); @@ -556,7 +556,7 @@ void test_performance(void) { setup_test(0); start_time = gpr_now(GPR_CLOCK_REALTIME); while (1) { - void *record = census_log_start_write(write_size); + void* record = census_log_start_write(write_size); if (record == NULL) { break; } diff --git a/test/core/statistics/census_stub_test.cc b/test/core/statistics/census_stub_test.cc index f38d571abd..507ae0a9fa 100644 --- a/test/core/statistics/census_stub_test.cc +++ b/test/core/statistics/census_stub_test.cc @@ -28,7 +28,7 @@ /* Tests census noop stubs in a simulated rpc flow */ void test_census_stubs(void) { census_op_id op_id; - census_rpc_stats *stats = census_rpc_stats_create_empty(); + census_rpc_stats* stats = census_rpc_stats_create_empty(); census_aggregated_rpc_stats data_map = {0, NULL}; /* Initializes census library at server start up time. */ @@ -55,7 +55,7 @@ void test_census_stubs(void) { census_shutdown(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_census_stubs(); return 0; diff --git a/test/core/statistics/hash_table_test.cc b/test/core/statistics/hash_table_test.cc index 72ea0d8066..b660006b8a 100644 --- a/test/core/statistics/hash_table_test.cc +++ b/test/core/statistics/hash_table_test.cc @@ -29,27 +29,27 @@ #include "src/core/lib/support/string.h" #include "test/core/util/test_config.h" -static uint64_t hash64(const void *k) { +static uint64_t hash64(const void* k) { size_t len = strlen(k); - uint64_t higher = gpr_murmur_hash3((const char *)k, len / 2, 0); + uint64_t higher = gpr_murmur_hash3((const char*)k, len / 2, 0); return higher << 32 | - gpr_murmur_hash3((const char *)(k) + len / 2, len - len / 2, 0); + gpr_murmur_hash3((const char*)(k) + len / 2, len - len / 2, 0); } -static int cmp_str_keys(const void *k1, const void *k2) { - return strcmp((const char *)k1, (const char *)k2); +static int cmp_str_keys(const void* k1, const void* k2) { + return strcmp((const char*)k1, (const char*)k2); } -static uint64_t force_collision(const void *k) { +static uint64_t force_collision(const void* k) { return (1997 + hash64(k) % 3); } -static void free_data(void *data) { gpr_free(data); } +static void free_data(void* data) { gpr_free(data); } /* Basic tests that empty hash table can be created and destroyed. */ static void test_create_table(void) { /* Create table with uint64 key type */ - census_ht *ht = NULL; + census_ht* ht = NULL; census_ht_option ht_options = { CENSUS_HT_UINT64, 1999, NULL, NULL, NULL, NULL}; ht = census_ht_create(&ht_options); @@ -69,11 +69,11 @@ static void test_create_table(void) { static void test_table_with_int_key(void) { census_ht_option opt = {CENSUS_HT_UINT64, 7, NULL, NULL, NULL, NULL}; - census_ht *ht = census_ht_create(&opt); + census_ht* ht = census_ht_create(&opt); uint64_t i = 0; uint64_t sum_of_keys = 0; size_t num_elements; - census_ht_kv *elements = NULL; + census_ht_kv* elements = NULL; GPR_ASSERT(ht != NULL); GPR_ASSERT(census_ht_get_size(ht) == 0); elements = census_ht_get_all_elements(ht, &num_elements); @@ -82,15 +82,15 @@ static void test_table_with_int_key(void) { for (i = 0; i < 20; ++i) { census_ht_key key; key.val = i; - census_ht_insert(ht, key, (void *)(intptr_t)i); + census_ht_insert(ht, key, (void*)(intptr_t)i); GPR_ASSERT(census_ht_get_size(ht) == i + 1); } for (i = 0; i < 20; i++) { - uint64_t *val = NULL; + uint64_t* val = NULL; census_ht_key key; key.val = i; - val = static_cast<uint64_t *>(census_ht_find(ht, key)); - GPR_ASSERT(val == (void *)(intptr_t)i); + val = static_cast<uint64_t*>(census_ht_find(ht, key)); + GPR_ASSERT(val == (void*)(intptr_t)i); } elements = census_ht_get_all_elements(ht, &num_elements); GPR_ASSERT(elements != NULL); @@ -107,27 +107,27 @@ static void test_table_with_int_key(void) { static void test_value_and_key_deleter(void) { census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64, &cmp_str_keys, &free_data, &free_data}; - census_ht *ht = census_ht_create(&opt); + census_ht* ht = census_ht_create(&opt); census_ht_key key; - char *val = NULL; - char *val2 = NULL; + char* val = NULL; + char* val2 = NULL; key.ptr = gpr_malloc(100); - val = static_cast<char *>(gpr_malloc(10)); + val = static_cast<char*>(gpr_malloc(10)); strcpy(val, "value"); strcpy(key.ptr, "some string as a key"); GPR_ASSERT(ht != NULL); GPR_ASSERT(census_ht_get_size(ht) == 0); census_ht_insert(ht, key, val); GPR_ASSERT(census_ht_get_size(ht) == 1); - val = static_cast<char *>(census_ht_find(ht, key)); + val = static_cast<char*>(census_ht_find(ht, key)); GPR_ASSERT(val != NULL); GPR_ASSERT(strcmp(val, "value") == 0); /* Insert same key different value, old value is overwritten. */ - val2 = static_cast<char *>(gpr_malloc(10)); + val2 = static_cast<char*>(gpr_malloc(10)); strcpy(val2, "v2"); census_ht_insert(ht, key, val2); GPR_ASSERT(census_ht_get_size(ht) == 1); - val2 = static_cast<char *>(census_ht_find(ht, key)); + val2 = static_cast<char*>(census_ht_find(ht, key)); GPR_ASSERT(val2 != NULL); GPR_ASSERT(strcmp(val2, "v2") == 0); census_ht_destroy(ht); @@ -136,14 +136,14 @@ static void test_value_and_key_deleter(void) { /* Test simple insert and erase operations. */ static void test_simple_add_and_erase(void) { census_ht_option opt = {CENSUS_HT_UINT64, 7, NULL, NULL, NULL, NULL}; - census_ht *ht = census_ht_create(&opt); + census_ht* ht = census_ht_create(&opt); GPR_ASSERT(ht != NULL); GPR_ASSERT(census_ht_get_size(ht) == 0); { census_ht_key key; int val = 3; key.val = 2; - census_ht_insert(ht, key, (void *)&val); + census_ht_insert(ht, key, (void*)&val); GPR_ASSERT(census_ht_get_size(ht) == 1); census_ht_erase(ht, key); GPR_ASSERT(census_ht_get_size(ht) == 0); @@ -151,11 +151,11 @@ static void test_simple_add_and_erase(void) { census_ht_erase(ht, key); GPR_ASSERT(census_ht_get_size(ht) == 0); /* Erasing a non-existant key from a table should be noop. */ - census_ht_insert(ht, key, (void *)&val); + census_ht_insert(ht, key, (void*)&val); key.val = 3; - census_ht_insert(ht, key, (void *)&val); + census_ht_insert(ht, key, (void*)&val); key.val = 9; - census_ht_insert(ht, key, (void *)&val); + census_ht_insert(ht, key, (void*)&val); GPR_ASSERT(census_ht_get_size(ht) == 3); key.val = 1; census_ht_erase(ht, key); @@ -172,7 +172,7 @@ static void test_simple_add_and_erase(void) { static void test_insertion_and_deletion_with_high_collision_rate(void) { census_ht_option opt = {CENSUS_HT_POINTER, 13, &force_collision, &cmp_str_keys, NULL, NULL}; - census_ht *ht = census_ht_create(&opt); + census_ht* ht = census_ht_create(&opt); char key_str[1000][GPR_LTOA_MIN_BUFSIZE]; uint64_t val = 0; unsigned i = 0; @@ -180,7 +180,7 @@ static void test_insertion_and_deletion_with_high_collision_rate(void) { census_ht_key key; key.ptr = key_str[i]; gpr_ltoa(i, key_str[i]); - census_ht_insert(ht, key, (void *)(&val)); + census_ht_insert(ht, key, (void*)(&val)); gpr_log(GPR_INFO, "%d\n", i); GPR_ASSERT(census_ht_get_size(ht) == (i + 1)); } @@ -196,8 +196,8 @@ static void test_insertion_and_deletion_with_high_collision_rate(void) { static void test_table_with_string_key(void) { census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64, &cmp_str_keys, NULL, NULL}; - census_ht *ht = census_ht_create(&opt); - const char *keys[] = { + census_ht* ht = census_ht_create(&opt); + const char* keys[] = { "k1", "a", "000", "apple", "banana_a_long_long_long_banana", "%$", "111", "foo", "b"}; const int vals[] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; @@ -206,39 +206,39 @@ static void test_table_with_string_key(void) { GPR_ASSERT(census_ht_get_size(ht) == 0); for (i = 0; i < 9; i++) { census_ht_key key; - key.ptr = (void *)(keys[i]); - census_ht_insert(ht, key, (void *)(vals + i)); + key.ptr = (void*)(keys[i]); + census_ht_insert(ht, key, (void*)(vals + i)); } GPR_ASSERT(census_ht_get_size(ht) == 9); for (i = 0; i < 9; i++) { census_ht_key key; - int *val_ptr; - key.ptr = (void *)(keys[i]); - val_ptr = static_cast<int *>(census_ht_find(ht, key)); + int* val_ptr; + key.ptr = (void*)(keys[i]); + val_ptr = static_cast<int*>(census_ht_find(ht, key)); GPR_ASSERT(*val_ptr == vals[i]); } { /* inserts duplicate keys */ census_ht_key key; - int *val_ptr = NULL; - key.ptr = (void *)(keys[2]); - census_ht_insert(ht, key, (void *)(vals + 8)); + int* val_ptr = NULL; + key.ptr = (void*)(keys[2]); + census_ht_insert(ht, key, (void*)(vals + 8)); /* expect value to be over written by new insertion */ GPR_ASSERT(census_ht_get_size(ht) == 9); - val_ptr = static_cast<int *>(census_ht_find(ht, key)); + val_ptr = static_cast<int*>(census_ht_find(ht, key)); GPR_ASSERT(*val_ptr == vals[8]); } for (i = 0; i < 9; i++) { census_ht_key key; - int *val_ptr; + int* val_ptr; uint32_t expected_tbl_sz = 9 - i; GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz); - key.ptr = (void *)(keys[i]); - val_ptr = static_cast<int *>(census_ht_find(ht, key)); + key.ptr = (void*)(keys[i]); + val_ptr = static_cast<int*>(census_ht_find(ht, key)); GPR_ASSERT(val_ptr != NULL); census_ht_erase(ht, key); GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz - 1); - val_ptr = static_cast<int *>(census_ht_find(ht, key)); + val_ptr = static_cast<int*>(census_ht_find(ht, key)); GPR_ASSERT(val_ptr == NULL); } census_ht_destroy(ht); @@ -246,34 +246,34 @@ static void test_table_with_string_key(void) { static void test_insertion_with_same_key(void) { census_ht_option opt = {CENSUS_HT_UINT64, 11, NULL, NULL, NULL, NULL}; - census_ht *ht = census_ht_create(&opt); + census_ht* ht = census_ht_create(&opt); census_ht_key key; const char vals[] = {'a', 'b', 'c'}; - char *val_ptr; + char* val_ptr; key.val = 3; - census_ht_insert(ht, key, (void *)&(vals[0])); + census_ht_insert(ht, key, (void*)&(vals[0])); GPR_ASSERT(census_ht_get_size(ht) == 1); - val_ptr = (char *)census_ht_find(ht, key); + val_ptr = (char*)census_ht_find(ht, key); GPR_ASSERT(val_ptr != NULL); GPR_ASSERT(*val_ptr == 'a'); key.val = 4; - val_ptr = (char *)census_ht_find(ht, key); + val_ptr = (char*)census_ht_find(ht, key); GPR_ASSERT(val_ptr == NULL); key.val = 3; - census_ht_insert(ht, key, (void *)&(vals[1])); + census_ht_insert(ht, key, (void*)&(vals[1])); GPR_ASSERT(census_ht_get_size(ht) == 1); - val_ptr = (char *)census_ht_find(ht, key); + val_ptr = (char*)census_ht_find(ht, key); GPR_ASSERT(val_ptr != NULL); GPR_ASSERT(*val_ptr == 'b'); - census_ht_insert(ht, key, (void *)&(vals[2])); + census_ht_insert(ht, key, (void*)&(vals[2])); GPR_ASSERT(census_ht_get_size(ht) == 1); - val_ptr = (char *)census_ht_find(ht, key); + val_ptr = (char*)census_ht_find(ht, key); GPR_ASSERT(val_ptr != NULL); GPR_ASSERT(*val_ptr == 'c'); census_ht_destroy(ht); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_create_table(); test_simple_add_and_erase(); diff --git a/test/core/statistics/multiple_writers_circular_buffer_test.cc b/test/core/statistics/multiple_writers_circular_buffer_test.cc index 8abd76c3d1..6d3411289e 100644 --- a/test/core/statistics/multiple_writers_circular_buffer_test.cc +++ b/test/core/statistics/multiple_writers_circular_buffer_test.cc @@ -23,7 +23,7 @@ #include <grpc/support/time.h> #include "test/core/util/test_config.h" -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); test_multiple_writers_circular_log(); diff --git a/test/core/statistics/multiple_writers_test.cc b/test/core/statistics/multiple_writers_test.cc index de800e0d8a..47410ab105 100644 --- a/test/core/statistics/multiple_writers_test.cc +++ b/test/core/statistics/multiple_writers_test.cc @@ -23,7 +23,7 @@ #include <grpc/support/time.h> #include "test/core/util/test_config.h" -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); test_multiple_writers(); diff --git a/test/core/statistics/performance_test.cc b/test/core/statistics/performance_test.cc index 6104acb612..9d4fd6ef90 100644 --- a/test/core/statistics/performance_test.cc +++ b/test/core/statistics/performance_test.cc @@ -23,7 +23,7 @@ #include <grpc/support/time.h> #include "test/core/util/test_config.h" -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); test_performance(); diff --git a/test/core/statistics/quick_test.cc b/test/core/statistics/quick_test.cc index 1e044b6b59..91ecdde818 100644 --- a/test/core/statistics/quick_test.cc +++ b/test/core/statistics/quick_test.cc @@ -23,7 +23,7 @@ #include <grpc/support/time.h> #include "test/core/util/test_config.h" -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); test_invalid_record_size(); diff --git a/test/core/statistics/rpc_stats_test.cc b/test/core/statistics/rpc_stats_test.cc index 01ac5a19ab..aead5cfdca 100644 --- a/test/core/statistics/rpc_stats_test.cc +++ b/test/core/statistics/rpc_stats_test.cc @@ -39,7 +39,7 @@ static void test_init_shutdown(void) { } static void test_create_and_destroy(void) { - census_rpc_stats *stats = NULL; + census_rpc_stats* stats = NULL; census_aggregated_rpc_stats agg_stats = {0, NULL}; stats = census_rpc_stats_create_empty(); @@ -54,7 +54,7 @@ static void test_create_and_destroy(void) { GPR_ASSERT(agg_stats.num_entries == 0); GPR_ASSERT(agg_stats.stats == NULL); agg_stats.num_entries = 1; - agg_stats.stats = (census_per_method_rpc_stats *)gpr_malloc( + agg_stats.stats = (census_per_method_rpc_stats*)gpr_malloc( sizeof(census_per_method_rpc_stats)); agg_stats.stats[0].method = gpr_strdup("foo"); census_aggregated_rpc_stats_set_empty(&agg_stats); @@ -172,7 +172,7 @@ static void test_record_stats_with_trace_store_uninitialized(void) { census_stats_store_shutdown(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_init_shutdown(); test_create_and_destroy(); diff --git a/test/core/statistics/small_log_test.cc b/test/core/statistics/small_log_test.cc index 4bcc35c37e..fb8dfc9988 100644 --- a/test/core/statistics/small_log_test.cc +++ b/test/core/statistics/small_log_test.cc @@ -23,7 +23,7 @@ #include <grpc/support/time.h> #include "test/core/util/test_config.h" -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); test_small_log(); diff --git a/test/core/statistics/trace_test.cc b/test/core/statistics/trace_test.cc index 63da9f71d3..ecbfed09ee 100644 --- a/test/core/statistics/trace_test.cc +++ b/test/core/statistics/trace_test.cc @@ -28,7 +28,6 @@ #include <grpc/support/useful.h> #include "src/core/ext/census/census_interface.h" #include "src/core/ext/census/census_tracing.h" -#include "src/core/ext/census/census_tracing.h" #include "test/core/util/test_config.h" /* Ensure all possible state transitions are called without causing problem */ @@ -70,7 +69,7 @@ static void test_get_trace_method_name(void) { census_add_method_tag(id, write_name); census_internal_lock_trace_store(); { - const char *read_name = + const char* read_name = census_get_trace_method_name(census_get_trace_obj_locked(id)); GPR_ASSERT(strcmp(read_name, write_name) == 0); } @@ -84,12 +83,12 @@ typedef struct thd_arg { gpr_mu mu; } thd_arg; -static void mimic_trace_op_sequences(void *arg) { +static void mimic_trace_op_sequences(void* arg) { census_op_id id; - const char *method_name = "service_foo/method_bar"; + const char* method_name = "service_foo/method_bar"; int i = 0; const int num_iter = 200; - thd_arg *args = (thd_arg *)arg; + thd_arg* args = (thd_arg*)arg; GPR_ASSERT(args != NULL); gpr_log(GPR_INFO, "Start trace op sequence thread."); for (i = 0; i < num_iter; i++) { @@ -140,7 +139,7 @@ static void test_add_method_tag_to_unknown_op_id(void) { static void test_trace_print(void) { census_op_id id; int i; - const char *annotation_txt[4] = {"abc", "", "$%^ *()_"}; + const char* annotation_txt[4] = {"abc", "", "$%^ *()_"}; char long_txt[CENSUS_MAX_ANNOTATION_LENGTH + 10]; memset(long_txt, 'a', GPR_ARRAY_SIZE(long_txt)); @@ -166,8 +165,8 @@ static int ids_equal(census_op_id id1, census_op_id id2) { static void test_get_active_ops(void) { census_op_id id_1, id_2, id_3; - census_trace_obj **active_ops; - const char *annotation_txt[] = {"annotation 1", "a2"}; + census_trace_obj** active_ops; + const char* annotation_txt[] = {"annotation 1", "a2"}; int i = 0; int n = 0; @@ -227,7 +226,7 @@ static void test_get_active_ops(void) { census_tracing_shutdown(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_init_shutdown(); test_start_op_generates_locally_unique_ids(); diff --git a/test/core/statistics/window_stats_test.cc b/test/core/statistics/window_stats_test.cc index 91eafd5724..b17c61a47b 100644 --- a/test/core/statistics/window_stats_test.cc +++ b/test/core/statistics/window_stats_test.cc @@ -27,16 +27,16 @@ typedef struct test_stat { int value2; } test_stat; -void add_test_stat(void *base, const void *addme) { - test_stat *b = (test_stat *)base; - const test_stat *a = (const test_stat *)addme; +void add_test_stat(void* base, const void* addme) { + test_stat* b = (test_stat*)base; + const test_stat* a = (const test_stat*)addme; b->value1 += a->value1; b->value2 += a->value2; } -void add_proportion_test_stat(double p, void *base, const void *addme) { - test_stat *b = (test_stat *)base; - const test_stat *a = (const test_stat *)addme; +void add_proportion_test_stat(double p, void* base, const void* addme) { + test_stat* b = (test_stat*)base; + const test_stat* a = (const test_stat*)addme; b->value1 += p * a->value1; b->value2 += p * a->value2 + 0.5; /* +0.5 is poor mans (no c99) round() */ } @@ -62,7 +62,7 @@ void empty_test(void) { census_window_stats_sums result; const gpr_timespec zero = {0, 0, GPR_CLOCK_MONOTONIC}; test_stat sum; - struct census_window_stats *stats = + struct census_window_stats* stats = census_window_stats_create(1, &kMinInterval, 5, &kMyStatInfo); GPR_ASSERT(stats != NULL); result.statistic = ∑ @@ -80,7 +80,7 @@ void one_interval_test(void) { census_window_stats_sums result; test_stat sum; /* granularity == 5 so width of internal windows should be 12s */ - struct census_window_stats *stats = + struct census_window_stats* stats = census_window_stats_create(1, &kMinInterval, 5, &kMyStatInfo); GPR_ASSERT(stats != NULL); /* phase 1: insert a single value at t=0s, and check that various measurement @@ -190,7 +190,7 @@ void many_interval_test(void) { census_window_stats_sums result[4]; test_stat sums[4]; int i; - struct census_window_stats *stats; + struct census_window_stats* stats; intervals[0] = kMilliSecInterval; intervals[1] = kSecInterval; intervals[2] = kMinInterval; @@ -250,7 +250,7 @@ void rolling_time_test(void) { test_stat sum; int i; gpr_timespec increment = {0, 0, GPR_CLOCK_MONOTONIC}; - struct census_window_stats *stats = + struct census_window_stats* stats = census_window_stats_create(1, &kMinInterval, 7, &kMyStatInfo); GPR_ASSERT(stats != NULL); srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); @@ -277,7 +277,7 @@ void infinite_interval_test(void) { const int count = 100000; gpr_timespec increment = {0, 0, GPR_CLOCK_MONOTONIC}; gpr_timespec temp = gpr_inf_future(GPR_CLOCK_REALTIME); - struct census_window_stats *stats = census_window_stats_create( + struct census_window_stats* stats = census_window_stats_create( 1, &gpr_inf_future(GPR_CLOCK_REALTIME), 10, &kMyStatInfo); srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); for (i = 0; i < count; i++) { @@ -293,7 +293,7 @@ void infinite_interval_test(void) { census_window_stats_destroy(stats); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { grpc_test_init(argc, argv); empty_test(); one_interval_test(); diff --git a/test/core/support/alloc_test.cc b/test/core/support/alloc_test.cc index ef9785a275..ee590366b9 100644 --- a/test/core/support/alloc_test.cc +++ b/test/core/support/alloc_test.cc @@ -20,36 +20,34 @@ #include <grpc/support/log.h> #include "test/core/util/test_config.h" -static void *fake_malloc(size_t size) { return (void *)size; } +static void* fake_malloc(size_t size) { return (void*)size; } -static void *fake_realloc(void *addr, size_t size) { return (void *)size; } +static void* fake_realloc(void* addr, size_t size) { return (void*)size; } -static void fake_free(void *addr) { - *((intptr_t *)addr) = (intptr_t)0xdeadd00d; -} +static void fake_free(void* addr) { *((intptr_t*)addr) = (intptr_t)0xdeadd00d; } static void test_custom_allocs() { const gpr_allocation_functions default_fns = gpr_get_allocation_functions(); intptr_t addr_to_free = 0; - char *i; + char* i; gpr_allocation_functions fns = {fake_malloc, NULL, fake_realloc, fake_free}; gpr_set_allocation_functions(fns); - GPR_ASSERT((void *)(size_t)0xdeadbeef == gpr_malloc(0xdeadbeef)); - GPR_ASSERT((void *)(size_t)0xcafed00d == gpr_realloc(0, 0xcafed00d)); + GPR_ASSERT((void*)(size_t)0xdeadbeef == gpr_malloc(0xdeadbeef)); + GPR_ASSERT((void*)(size_t)0xcafed00d == gpr_realloc(0, 0xcafed00d)); gpr_free(&addr_to_free); GPR_ASSERT(addr_to_free == (intptr_t)0xdeadd00d); /* Restore and check we don't get funky values and that we don't leak */ gpr_set_allocation_functions(default_fns); - GPR_ASSERT((void *)sizeof(*i) != - (i = static_cast<char *>(gpr_malloc(sizeof(*i))))); - GPR_ASSERT((void *)2 != (i = static_cast<char *>(gpr_realloc(i, 2)))); + GPR_ASSERT((void*)sizeof(*i) != + (i = static_cast<char*>(gpr_malloc(sizeof(*i))))); + GPR_ASSERT((void*)2 != (i = static_cast<char*>(gpr_realloc(i, 2)))); gpr_free(i); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_custom_allocs(); return 0; diff --git a/test/core/support/arena_test.cc b/test/core/support/arena_test.cc index 021bd18f5e..6c666af096 100644 --- a/test/core/support/arena_test.cc +++ b/test/core/support/arena_test.cc @@ -32,10 +32,10 @@ static void test_noop(void) { gpr_arena_destroy(gpr_arena_create(1)); } -static void test(const char *name, size_t init_size, const size_t *allocs, +static void test(const char* name, size_t init_size, const size_t* allocs, size_t nallocs) { gpr_strvec v; - char *s; + char* s; gpr_strvec_init(&v); gpr_asprintf(&s, "test '%s': %" PRIdPTR " <- {", name, init_size); gpr_strvec_add(&v, s); @@ -49,8 +49,8 @@ static void test(const char *name, size_t init_size, const size_t *allocs, gpr_log(GPR_INFO, "%s", s); gpr_free(s); - gpr_arena *a = gpr_arena_create(init_size); - void **ps = static_cast<void **>(gpr_zalloc(sizeof(*ps) * nallocs)); + gpr_arena* a = gpr_arena_create(init_size); + void** ps = static_cast<void**>(gpr_zalloc(sizeof(*ps) * nallocs)); for (size_t i = 0; i < nallocs; i++) { ps[i] = gpr_arena_alloc(a, allocs[i]); // ensure no duplicate results @@ -71,20 +71,20 @@ static void test(const char *name, size_t init_size, const size_t *allocs, #define CONCURRENT_TEST_THREADS 100 size_t concurrent_test_iterations() { - if (sizeof(void *) < 8) return 1000; + if (sizeof(void*) < 8) return 1000; return 100000; } typedef struct { gpr_event ev_start; - gpr_arena *arena; + gpr_arena* arena; } concurrent_test_args; -static void concurrent_test_body(void *arg) { - concurrent_test_args *a = static_cast<concurrent_test_args *>(arg); +static void concurrent_test_body(void* arg) { + concurrent_test_args* a = static_cast<concurrent_test_args*>(arg); gpr_event_wait(&a->ev_start, gpr_inf_future(GPR_CLOCK_REALTIME)); for (size_t i = 0; i < concurrent_test_iterations(); i++) { - *(char *)gpr_arena_alloc(a->arena, 1) = (char)i; + *(char*)gpr_arena_alloc(a->arena, 1) = (char)i; } } @@ -103,7 +103,7 @@ static void concurrent_test(void) { gpr_thd_new(&thds[i], concurrent_test_body, &args, &opt); } - gpr_event_set(&args.ev_start, (void *)1); + gpr_event_set(&args.ev_start, (void*)1); for (int i = 0; i < CONCURRENT_TEST_THREADS; i++) { gpr_thd_join(thds[i]); @@ -112,7 +112,7 @@ static void concurrent_test(void) { gpr_arena_destroy(args.arena); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { grpc_test_init(argc, argv); test_noop(); diff --git a/test/core/support/avl_test.cc b/test/core/support/avl_test.cc index 474e773225..cd3a852e9d 100644 --- a/test/core/support/avl_test.cc +++ b/test/core/support/avl_test.cc @@ -27,36 +27,36 @@ #include "test/core/util/test_config.h" -static int *box(int x) { - int *b = static_cast<int *>(gpr_malloc(sizeof(*b))); +static int* box(int x) { + int* b = static_cast<int*>(gpr_malloc(sizeof(*b))); *b = x; return b; } -static long int_compare(void *int1, void *int2, void *unused) { - return (*(int *)int1) - (*(int *)int2); +static long int_compare(void* int1, void* int2, void* unused) { + return (*(int*)int1) - (*(int*)int2); } -static void *int_copy(void *p, void *unused) { return box(*(int *)p); } +static void* int_copy(void* p, void* unused) { return box(*(int*)p); } -static void destroy(void *p, void *unused) { gpr_free(p); } +static void destroy(void* p, void* unused) { gpr_free(p); } static const gpr_avl_vtable int_int_vtable = {destroy, int_copy, int_compare, destroy, int_copy}; static void check_get(gpr_avl avl, int key, int value) { - int *k = box(key); - GPR_ASSERT(*(int *)gpr_avl_get(avl, k, NULL) == value); + int* k = box(key); + GPR_ASSERT(*(int*)gpr_avl_get(avl, k, NULL) == value); gpr_free(k); } static void check_negget(gpr_avl avl, int key) { - int *k = box(key); + int* k = box(key); GPR_ASSERT(gpr_avl_get(avl, k, NULL) == NULL); gpr_free(k); } static gpr_avl remove_int(gpr_avl avl, int key) { - int *k = box(key); + int* k = box(key); avl = gpr_avl_remove(avl, k, NULL); gpr_free(k); return avl; @@ -83,9 +83,9 @@ static void test_ll(void) { avl = gpr_avl_add(avl, box(5), box(1), NULL); avl = gpr_avl_add(avl, box(4), box(2), NULL); avl = gpr_avl_add(avl, box(3), box(3), NULL); - GPR_ASSERT(*(int *)avl.root->key == 4); - GPR_ASSERT(*(int *)avl.root->left->key == 3); - GPR_ASSERT(*(int *)avl.root->right->key == 5); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); gpr_avl_unref(avl, NULL); } @@ -96,9 +96,9 @@ static void test_lr(void) { avl = gpr_avl_add(avl, box(5), box(1), NULL); avl = gpr_avl_add(avl, box(3), box(2), NULL); avl = gpr_avl_add(avl, box(4), box(3), NULL); - GPR_ASSERT(*(int *)avl.root->key == 4); - GPR_ASSERT(*(int *)avl.root->left->key == 3); - GPR_ASSERT(*(int *)avl.root->right->key == 5); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); gpr_avl_unref(avl, NULL); } @@ -109,9 +109,9 @@ static void test_rr(void) { avl = gpr_avl_add(avl, box(3), box(1), NULL); avl = gpr_avl_add(avl, box(4), box(2), NULL); avl = gpr_avl_add(avl, box(5), box(3), NULL); - GPR_ASSERT(*(int *)avl.root->key == 4); - GPR_ASSERT(*(int *)avl.root->left->key == 3); - GPR_ASSERT(*(int *)avl.root->right->key == 5); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); gpr_avl_unref(avl, NULL); } @@ -122,9 +122,9 @@ static void test_rl(void) { avl = gpr_avl_add(avl, box(3), box(1), NULL); avl = gpr_avl_add(avl, box(5), box(2), NULL); avl = gpr_avl_add(avl, box(4), box(3), NULL); - GPR_ASSERT(*(int *)avl.root->key == 4); - GPR_ASSERT(*(int *)avl.root->left->key == 3); - GPR_ASSERT(*(int *)avl.root->right->key == 5); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); gpr_avl_unref(avl, NULL); } @@ -137,11 +137,11 @@ static void test_unbalanced(void) { avl = gpr_avl_add(avl, box(3), box(3), NULL); avl = gpr_avl_add(avl, box(2), box(4), NULL); avl = gpr_avl_add(avl, box(1), box(5), NULL); - GPR_ASSERT(*(int *)avl.root->key == 4); - GPR_ASSERT(*(int *)avl.root->left->key == 2); - GPR_ASSERT(*(int *)avl.root->left->left->key == 1); - GPR_ASSERT(*(int *)avl.root->left->right->key == 3); - GPR_ASSERT(*(int *)avl.root->right->key == 5); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 2); + GPR_ASSERT(*(int*)avl.root->left->left->key == 1); + GPR_ASSERT(*(int*)avl.root->left->right->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); gpr_avl_unref(avl, NULL); } @@ -3639,7 +3639,7 @@ static void test_stress(int amount_of_stress) { gpr_avl_unref(avl, NULL); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { grpc_test_init(argc, argv); test_get(); diff --git a/test/core/support/cmdline_test.cc b/test/core/support/cmdline_test.cc index a3740d4881..5afaa2a60a 100644 --- a/test/core/support/cmdline_test.cc +++ b/test/core/support/cmdline_test.cc @@ -29,9 +29,9 @@ static void test_simple_int(void) { int x = 1; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("-foo"), - const_cast<char *>("3")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("-foo"), + const_cast<char*>("3")}; LOG_TEST(); @@ -45,8 +45,8 @@ static void test_simple_int(void) { static void test_eq_int(void) { int x = 1; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("-foo=3")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("-foo=3")}; LOG_TEST(); @@ -60,9 +60,9 @@ static void test_eq_int(void) { static void test_2dash_int(void) { int x = 1; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--foo"), - const_cast<char *>("3")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--foo"), + const_cast<char*>("3")}; LOG_TEST(); @@ -76,8 +76,8 @@ static void test_2dash_int(void) { static void test_2dash_eq_int(void) { int x = 1; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--foo=3")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=3")}; LOG_TEST(); @@ -90,10 +90,10 @@ static void test_2dash_eq_int(void) { } static void test_simple_string(void) { - const char *x = NULL; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("-foo"), - const_cast<char *>("3")}; + const char* x = NULL; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("-foo"), + const_cast<char*>("3")}; LOG_TEST(); @@ -106,9 +106,9 @@ static void test_simple_string(void) { } static void test_eq_string(void) { - const char *x = NULL; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("-foo=3")}; + const char* x = NULL; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("-foo=3")}; LOG_TEST(); @@ -121,10 +121,10 @@ static void test_eq_string(void) { } static void test_2dash_string(void) { - const char *x = NULL; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--foo"), - const_cast<char *>("3")}; + const char* x = NULL; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--foo"), + const_cast<char*>("3")}; LOG_TEST(); @@ -137,9 +137,9 @@ static void test_2dash_string(void) { } static void test_2dash_eq_string(void) { - const char *x = NULL; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--foo=3")}; + const char* x = NULL; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=3")}; LOG_TEST(); @@ -153,8 +153,8 @@ static void test_2dash_eq_string(void) { static void test_flag_on(void) { int x = 2; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--foo")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--foo")}; LOG_TEST(); @@ -168,8 +168,8 @@ static void test_flag_on(void) { static void test_flag_no(void) { int x = 2; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--no-foo")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--no-foo")}; LOG_TEST(); @@ -183,8 +183,8 @@ static void test_flag_no(void) { static void test_flag_val_1(void) { int x = 2; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--foo=1")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=1")}; LOG_TEST(); @@ -198,8 +198,8 @@ static void test_flag_val_1(void) { static void test_flag_val_0(void) { int x = 2; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--foo=0")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=0")}; LOG_TEST(); @@ -213,8 +213,8 @@ static void test_flag_val_0(void) { static void test_flag_val_true(void) { int x = 2; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--foo=true")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=true")}; LOG_TEST(); @@ -228,8 +228,8 @@ static void test_flag_val_true(void) { static void test_flag_val_false(void) { int x = 2; - gpr_cmdline *cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--foo=false")}; + gpr_cmdline* cl; + char* args[] = {(char*)__FILE__, const_cast<char*>("--foo=false")}; LOG_TEST(); @@ -242,14 +242,14 @@ static void test_flag_val_false(void) { } static void test_many(void) { - const char *str = NULL; + const char* str = NULL; int x = 0; int flag = 2; - gpr_cmdline *cl; + gpr_cmdline* cl; - char *args[] = {(char *)__FILE__, const_cast<char *>("--str"), - const_cast<char *>("hello"), const_cast<char *>("-x=4"), - const_cast<char *>("-no-flag")}; + char* args[] = {(char*)__FILE__, const_cast<char*>("--str"), + const_cast<char*>("hello"), const_cast<char*>("-x=4"), + const_cast<char*>("-no-flag")}; LOG_TEST(); @@ -264,8 +264,8 @@ static void test_many(void) { gpr_cmdline_destroy(cl); } -static void extra_arg_cb(void *user_data, const char *arg) { - int *count = static_cast<int *>(user_data); +static void extra_arg_cb(void* user_data, const char* arg) { + int* count = static_cast<int*>(user_data); GPR_ASSERT(arg != NULL); GPR_ASSERT(strlen(arg) == 1); GPR_ASSERT(arg[0] == 'a' + *count); @@ -273,10 +273,10 @@ static void extra_arg_cb(void *user_data, const char *arg) { } static void test_extra(void) { - gpr_cmdline *cl; + gpr_cmdline* cl; int count = 0; - char *args[] = {(char *)__FILE__, const_cast<char *>("a"), - const_cast<char *>("b"), const_cast<char *>("c")}; + char* args[] = {(char*)__FILE__, const_cast<char*>("a"), + const_cast<char*>("b"), const_cast<char*>("c")}; LOG_TEST(); @@ -289,11 +289,11 @@ static void test_extra(void) { } static void test_extra_dashdash(void) { - gpr_cmdline *cl; + gpr_cmdline* cl; int count = 0; - char *args[] = {(char *)__FILE__, const_cast<char *>("--"), - const_cast<char *>("a"), const_cast<char *>("b"), - const_cast<char *>("c")}; + char* args[] = {(char*)__FILE__, const_cast<char*>("--"), + const_cast<char*>("a"), const_cast<char*>("b"), + const_cast<char*>("c")}; LOG_TEST(); @@ -306,10 +306,10 @@ static void test_extra_dashdash(void) { } static void test_usage(void) { - gpr_cmdline *cl; - char *usage; + gpr_cmdline* cl; + char* usage; - const char *str = NULL; + const char* str = NULL; int x = 0; int flag = 2; @@ -338,13 +338,13 @@ static void test_usage(void) { } static void test_help(void) { - gpr_cmdline *cl; + gpr_cmdline* cl; - const char *str = NULL; + const char* str = NULL; int x = 0; int flag = 2; - char *help[] = {(char *)__FILE__, const_cast<char *>("-h")}; + char* help[] = {(char*)__FILE__, const_cast<char*>("-h")}; LOG_TEST(); @@ -362,13 +362,13 @@ static void test_help(void) { } static void test_badargs1(void) { - gpr_cmdline *cl; + gpr_cmdline* cl; - const char *str = NULL; + const char* str = NULL; int x = 0; int flag = 2; - char *bad_arg_name[] = {(char *)__FILE__, const_cast<char *>("--y")}; + char* bad_arg_name[] = {(char*)__FILE__, const_cast<char*>("--y")}; LOG_TEST(); @@ -387,14 +387,14 @@ static void test_badargs1(void) { } static void test_badargs2(void) { - gpr_cmdline *cl; + gpr_cmdline* cl; - const char *str = NULL; + const char* str = NULL; int x = 0; int flag = 2; - char *bad_int_value[] = {(char *)__FILE__, const_cast<char *>("--x"), - const_cast<char *>("henry")}; + char* bad_int_value[] = {(char*)__FILE__, const_cast<char*>("--x"), + const_cast<char*>("henry")}; LOG_TEST(); @@ -413,14 +413,13 @@ static void test_badargs2(void) { } static void test_badargs3(void) { - gpr_cmdline *cl; + gpr_cmdline* cl; - const char *str = NULL; + const char* str = NULL; int x = 0; int flag = 2; - char *bad_bool_value[] = {(char *)__FILE__, - const_cast<char *>("--flag=henry")}; + char* bad_bool_value[] = {(char*)__FILE__, const_cast<char*>("--flag=henry")}; LOG_TEST(); @@ -439,13 +438,13 @@ static void test_badargs3(void) { } static void test_badargs4(void) { - gpr_cmdline *cl; + gpr_cmdline* cl; - const char *str = NULL; + const char* str = NULL; int x = 0; int flag = 2; - char *bad_bool_value[] = {(char *)__FILE__, const_cast<char *>("--no-str")}; + char* bad_bool_value[] = {(char*)__FILE__, const_cast<char*>("--no-str")}; LOG_TEST(); @@ -463,7 +462,7 @@ static void test_badargs4(void) { gpr_cmdline_destroy(cl); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_simple_int(); test_eq_int(); diff --git a/test/core/support/cpu_test.cc b/test/core/support/cpu_test.cc index 7eaf65b110..a76531ead9 100644 --- a/test/core/support/cpu_test.cc +++ b/test/core/support/cpu_test.cc @@ -57,12 +57,12 @@ struct cpu_test { uint32_t ncores; int is_done; gpr_cv done_cv; - int *used; /* is this core used? */ + int* used; /* is this core used? */ unsigned r; /* random number */ }; -static void worker_thread(void *arg) { - struct cpu_test *ct = (struct cpu_test *)arg; +static void worker_thread(void* arg) { + struct cpu_test* ct = (struct cpu_test*)arg; uint32_t cpu; unsigned r = 12345678; unsigned i, j; @@ -104,7 +104,7 @@ static void cpu_test(void) { ct.ncores = gpr_cpu_num_cores(); GPR_ASSERT(ct.ncores > 0); ct.nthreads = (int)ct.ncores * 3; - ct.used = static_cast<int *>(gpr_malloc(ct.ncores * sizeof(int))); + ct.used = static_cast<int*>(gpr_malloc(ct.ncores * sizeof(int))); memset(ct.used, 0, ct.ncores * sizeof(int)); gpr_mu_init(&ct.mu); gpr_cv_init(&ct.done_cv); @@ -128,7 +128,7 @@ static void cpu_test(void) { gpr_free(ct.used); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { grpc_test_init(argc, argv); cpu_test(); return 0; diff --git a/test/core/support/env_test.cc b/test/core/support/env_test.cc index 661a546720..54009536b4 100644 --- a/test/core/support/env_test.cc +++ b/test/core/support/env_test.cc @@ -29,9 +29,9 @@ #define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x) static void test_setenv_getenv(void) { - const char *name = "FOO"; - const char *value = "BAR"; - char *retrieved_value; + const char* name = "FOO"; + const char* value = "BAR"; + char* retrieved_value; LOG_TEST_NAME("test_setenv_getenv"); @@ -42,7 +42,7 @@ static void test_setenv_getenv(void) { gpr_free(retrieved_value); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_setenv_getenv(); return 0; diff --git a/test/core/support/histogram_test.cc b/test/core/support/histogram_test.cc index 0ee5d5cdd1..86b7d599e6 100644 --- a/test/core/support/histogram_test.cc +++ b/test/core/support/histogram_test.cc @@ -25,7 +25,7 @@ static void test_no_op(void) { gpr_histogram_destroy(gpr_histogram_create(0.01, 60e9)); } -static void expect_percentile(gpr_histogram *h, double percentile, +static void expect_percentile(gpr_histogram* h, double percentile, double min_expect, double max_expect) { double got = gpr_histogram_percentile(h, percentile); gpr_log(GPR_INFO, "@%f%%, expect %f <= %f <= %f", percentile, min_expect, got, @@ -35,7 +35,7 @@ static void expect_percentile(gpr_histogram *h, double percentile, } static void test_simple(void) { - gpr_histogram *h; + gpr_histogram* h; LOG_TEST("test_simple"); @@ -52,7 +52,7 @@ static void test_simple(void) { } static void test_percentile(void) { - gpr_histogram *h; + gpr_histogram* h; double last; double i; double cur; diff --git a/test/core/support/host_port_test.cc b/test/core/support/host_port_test.cc index 2ff3bcf68e..42dd56524f 100644 --- a/test/core/support/host_port_test.cc +++ b/test/core/support/host_port_test.cc @@ -23,9 +23,9 @@ #include <grpc/support/log.h> #include "test/core/util/test_config.h" -static void join_host_port_expect(const char *host, int port, - const char *expected) { - char *buf; +static void join_host_port_expect(const char* host, int port, + const char* expected) { + char* buf; int len; len = gpr_join_host_port(&buf, host, port); GPR_ASSERT(len >= 0); @@ -48,7 +48,7 @@ static void test_join_host_port_garbage(void) { join_host_port_expect("::]", 107, "[::]]:107"); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_join_host_port(); diff --git a/test/core/support/log_test.cc b/test/core/support/log_test.cc index c221ff6783..9602bbb090 100644 --- a/test/core/support/log_test.cc +++ b/test/core/support/log_test.cc @@ -26,17 +26,17 @@ static bool log_func_reached = false; -static void test_callback(gpr_log_func_args *args) { +static void test_callback(gpr_log_func_args* args) { GPR_ASSERT(0 == strcmp(__FILE__, args->file)); GPR_ASSERT(args->severity == GPR_LOG_SEVERITY_INFO); GPR_ASSERT(0 == strcmp(args->message, "hello 1 2 3")); } -static void test_should_log(gpr_log_func_args *args) { +static void test_should_log(gpr_log_func_args* args) { log_func_reached = true; } -static void test_should_not_log(gpr_log_func_args *args) { GPR_ASSERT(false); } +static void test_should_not_log(gpr_log_func_args* args) { GPR_ASSERT(false); } #define test_log_function_reached(SEVERITY) \ gpr_set_log_function(test_should_log); \ @@ -52,7 +52,7 @@ static void test_should_not_log(gpr_log_func_args *args) { GPR_ASSERT(false); } gpr_log_message(SEVERITY, "hello 1 2 3"); \ gpr_log(SEVERITY, "hello %d %d %d", 1, 2, 3); -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); /* test logging at various verbosity levels */ gpr_log(GPR_DEBUG, "%s", "hello world"); diff --git a/test/core/support/mpscq_test.cc b/test/core/support/mpscq_test.cc index a4fa6a3e34..d5b7bf21c1 100644 --- a/test/core/support/mpscq_test.cc +++ b/test/core/support/mpscq_test.cc @@ -30,11 +30,11 @@ typedef struct test_node { gpr_mpscq_node node; size_t i; - size_t *ctr; + size_t* ctr; } test_node; -static test_node *new_node(size_t i, size_t *ctr) { - test_node *n = static_cast<test_node *>(gpr_malloc(sizeof(test_node))); +static test_node* new_node(size_t i, size_t* ctr) { + test_node* n = static_cast<test_node*>(gpr_malloc(sizeof(test_node))); n->i = i; n->ctr = ctr; return n; @@ -48,7 +48,7 @@ static void test_serial(void) { gpr_mpscq_push(&q, &new_node(i, NULL)->node); } for (size_t i = 0; i < 10000000; i++) { - test_node *n = (test_node *)gpr_mpscq_pop(&q); + test_node* n = (test_node*)gpr_mpscq_pop(&q); GPR_ASSERT(n); GPR_ASSERT(n->i == i); gpr_free(n); @@ -57,14 +57,14 @@ static void test_serial(void) { typedef struct { size_t ctr; - gpr_mpscq *q; - gpr_event *start; + gpr_mpscq* q; + gpr_event* start; } thd_args; #define THREAD_ITERATIONS 10000 -static void test_thread(void *args) { - thd_args *a = static_cast<thd_args *>(args); +static void test_thread(void* args) { + thd_args* a = static_cast<thd_args*>(args); gpr_event_wait(a->start, gpr_inf_future(GPR_CLOCK_REALTIME)); for (size_t i = 1; i <= THREAD_ITERATIONS; i++) { gpr_mpscq_push(a->q, &new_node(i, &a->ctr)->node); @@ -89,13 +89,13 @@ static void test_mt(void) { } size_t num_done = 0; size_t spins = 0; - gpr_event_set(&start, (void *)1); + gpr_event_set(&start, (void*)1); while (num_done != GPR_ARRAY_SIZE(thds)) { - gpr_mpscq_node *n; + gpr_mpscq_node* n; while ((n = gpr_mpscq_pop(&q)) == NULL) { spins++; } - test_node *tn = (test_node *)n; + test_node* tn = (test_node*)n; GPR_ASSERT(*tn->ctr == tn->i - 1); *tn->ctr = tn->i; if (tn->i == THREAD_ITERATIONS) num_done++; @@ -109,17 +109,17 @@ static void test_mt(void) { } typedef struct { - thd_args *ta; + thd_args* ta; size_t num_thds; gpr_mu mu; size_t num_done; size_t spins; - gpr_mpscq *q; - gpr_event *start; + gpr_mpscq* q; + gpr_event* start; } pull_args; -static void pull_thread(void *arg) { - pull_args *pa = static_cast<pull_args *>(arg); +static void pull_thread(void* arg) { + pull_args* pa = static_cast<pull_args*>(arg); gpr_event_wait(pa->start, gpr_inf_future(GPR_CLOCK_REALTIME)); for (;;) { @@ -128,11 +128,11 @@ static void pull_thread(void *arg) { gpr_mu_unlock(&pa->mu); return; } - gpr_mpscq_node *n; + gpr_mpscq_node* n; while ((n = gpr_mpscq_pop(pa->q)) == NULL) { pa->spins++; } - test_node *tn = (test_node *)n; + test_node* tn = (test_node*)n; GPR_ASSERT(*tn->ctr == tn->i - 1); *tn->ctr = tn->i; if (tn->i == THREAD_ITERATIONS) pa->num_done++; @@ -171,7 +171,7 @@ static void test_mt_multipop(void) { gpr_thd_options_set_joinable(&options); GPR_ASSERT(gpr_thd_new(&pull_thds[i], pull_thread, &pa, &options)); } - gpr_event_set(&start, (void *)1); + gpr_event_set(&start, (void*)1); for (size_t i = 0; i < GPR_ARRAY_SIZE(pull_thds); i++) { gpr_thd_join(pull_thds[i]); } @@ -182,7 +182,7 @@ static void test_mt_multipop(void) { gpr_mpscq_destroy(&q); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_serial(); test_mt(); diff --git a/test/core/support/murmur_hash_test.cc b/test/core/support/murmur_hash_test.cc index 5677515d04..461c728951 100644 --- a/test/core/support/murmur_hash_test.cc +++ b/test/core/support/murmur_hash_test.cc @@ -23,7 +23,7 @@ #include <string.h> -typedef uint32_t (*hash_func)(const void *key, size_t len, uint32_t seed); +typedef uint32_t (*hash_func)(const void* key, size_t len, uint32_t seed); /* From smhasher: This should hopefully be a thorough and uambiguous test of whether a hash @@ -63,7 +63,7 @@ static void verification_test(hash_func hash, uint32_t expected) { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); /* basic tests to verify that things don't crash */ gpr_murmur_hash3("", 0, 0); diff --git a/test/core/support/spinlock_test.cc b/test/core/support/spinlock_test.cc index 8c8c8cedfa..3639802cd7 100644 --- a/test/core/support/spinlock_test.cc +++ b/test/core/support/spinlock_test.cc @@ -32,7 +32,7 @@ /* Tests for gpr_spinlock. */ struct test { int thread_count; /* number of threads */ - gpr_thd_id *threads; + gpr_thd_id* threads; int64_t iterations; /* number of iterations per thread */ int64_t counter; @@ -42,10 +42,10 @@ struct test { }; /* Return pointer to a new struct test. */ -static struct test *test_new(int threads, int64_t iterations, int incr_step) { - struct test *m = static_cast<struct test *>(gpr_malloc(sizeof(*m))); +static struct test* test_new(int threads, int64_t iterations, int incr_step) { + struct test* m = static_cast<struct test*>(gpr_malloc(sizeof(*m))); m->thread_count = threads; - m->threads = static_cast<gpr_thd_id *>( + m->threads = static_cast<gpr_thd_id*>( gpr_malloc(sizeof(*m->threads) * (size_t)threads)); m->iterations = iterations; m->counter = 0; @@ -56,13 +56,13 @@ static struct test *test_new(int threads, int64_t iterations, int incr_step) { } /* Return pointer to a new struct test. */ -static void test_destroy(struct test *m) { +static void test_destroy(struct test* m) { gpr_free(m->threads); gpr_free(m); } /* Create m->threads threads, each running (*body)(m) */ -static void test_create_threads(struct test *m, void (*body)(void *arg)) { +static void test_create_threads(struct test* m, void (*body)(void* arg)) { int i; for (i = 0; i != m->thread_count; i++) { gpr_thd_options opt = gpr_thd_options_default(); @@ -72,7 +72,7 @@ static void test_create_threads(struct test *m, void (*body)(void *arg)) { } /* Wait until all threads report done. */ -static void test_wait(struct test *m) { +static void test_wait(struct test* m) { int i; for (i = 0; i != m->thread_count; i++) { gpr_thd_join(m->threads[i]); @@ -85,10 +85,10 @@ static void test_wait(struct test *m) { incr_step controls by how much m->refcount should be incremented/decremented (if at all) each time in the tests. */ -static void test(const char *name, void (*body)(void *m), int timeout_s, +static void test(const char* name, void (*body)(void* m), int timeout_s, int incr_step) { int64_t iterations = 1024; - struct test *m; + struct test* m; gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec time_taken; gpr_timespec deadline = gpr_time_add( @@ -113,8 +113,8 @@ static void test(const char *name, void (*body)(void *m), int timeout_s, } /* Increment m->counter on each iteration; then mark thread as done. */ -static void inc(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void inc(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; for (i = 0; i != m->iterations; i++) { gpr_spinlock_lock(&m->mu); @@ -125,8 +125,8 @@ static void inc(void *v /*=m*/) { /* Increment m->counter under lock acquired with trylock, m->iterations times; then mark thread as done. */ -static void inctry(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void inctry(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; for (i = 0; i != m->iterations;) { if (gpr_spinlock_trylock(&m->mu)) { @@ -139,7 +139,7 @@ static void inctry(void *v /*=m*/) { /* ------------------------------------------------- */ -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { grpc_test_init(argc, argv); test("spinlock", &inc, 1, 1); test("spinlock try", &inctry, 1, 1); diff --git a/test/core/support/stack_lockfree_test.cc b/test/core/support/stack_lockfree_test.cc index 4b1f60ce01..e6d0c9b795 100644 --- a/test/core/support/stack_lockfree_test.cc +++ b/test/core/support/stack_lockfree_test.cc @@ -32,7 +32,7 @@ #define MAX_THREADS 32 static void test_serial_sized(size_t size) { - gpr_stack_lockfree *stack = gpr_stack_lockfree_create(size); + gpr_stack_lockfree* stack = gpr_stack_lockfree_create(size); size_t i; size_t j; @@ -67,15 +67,15 @@ static void test_serial() { } struct test_arg { - gpr_stack_lockfree *stack; + gpr_stack_lockfree* stack; int stack_size; int nthreads; int rank; int sum; }; -static void test_mt_body(void *v) { - struct test_arg *arg = (struct test_arg *)v; +static void test_mt_body(void* v) { + struct test_arg* arg = (struct test_arg*)v; int lo, hi; int i; int res; @@ -93,7 +93,7 @@ static void test_mt_body(void *v) { } static void test_mt_sized(size_t size, int nth) { - gpr_stack_lockfree *stack; + gpr_stack_lockfree* stack; struct test_arg args[MAX_THREADS]; gpr_thd_id thds[MAX_THREADS]; int sum; @@ -132,7 +132,7 @@ static void test_mt() { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_serial(); test_mt(); diff --git a/test/core/support/string_test.cc b/test/core/support/string_test.cc index bee2139477..4bae158a15 100644 --- a/test/core/support/string_test.cc +++ b/test/core/support/string_test.cc @@ -32,8 +32,8 @@ #define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x) static void test_strdup(void) { - static const char *src1 = "hello world"; - char *dst1; + static const char* src1 = "hello world"; + char* dst1; LOG_TEST_NAME("test_strdup"); @@ -44,9 +44,9 @@ static void test_strdup(void) { GPR_ASSERT(NULL == gpr_strdup(NULL)); } -static void expect_dump(const char *buf, size_t len, uint32_t flags, - const char *result) { - char *got = gpr_dump(buf, len, flags); +static void expect_dump(const char* buf, size_t len, uint32_t flags, + const char* result) { + char* got = gpr_dump(buf, len, flags); GPR_ASSERT(0 == strcmp(got, result)); gpr_free(got); } @@ -61,12 +61,12 @@ static void test_dump(void) { expect_dump("ab", 2, GPR_DUMP_HEX | GPR_DUMP_ASCII, "61 62 'ab'"); } -static void test_pu32_fail(const char *s) { +static void test_pu32_fail(const char* s) { uint32_t out; GPR_ASSERT(!gpr_parse_bytes_to_uint32(s, strlen(s), &out)); } -static void test_pu32_succeed(const char *s, uint32_t want) { +static void test_pu32_succeed(const char* s, uint32_t want) { uint32_t out; GPR_ASSERT(gpr_parse_bytes_to_uint32(s, strlen(s), &out)); GPR_ASSERT(out == want); @@ -107,7 +107,7 @@ static void test_parse_uint32(void) { } static void test_asprintf(void) { - char *buf; + char* buf; int i, j; LOG_TEST_NAME("test_asprintf"); @@ -132,9 +132,9 @@ static void test_asprintf(void) { } static void test_strjoin(void) { - const char *parts[4] = {"one", "two", "three", "four"}; + const char* parts[4] = {"one", "two", "three", "four"}; size_t joined_len; - char *joined; + char* joined; LOG_TEST_NAME("test_strjoin"); @@ -152,9 +152,9 @@ static void test_strjoin(void) { } static void test_strjoin_sep(void) { - const char *parts[4] = {"one", "two", "three", "four"}; + const char* parts[4] = {"one", "two", "three", "four"}; size_t joined_len; - char *joined; + char* joined; LOG_TEST_NAME("test_strjoin_sep"); @@ -179,7 +179,7 @@ static void test_strjoin_sep(void) { } static void test_ltoa() { - char *str; + char* str; char buf[GPR_LTOA_MIN_BUFSIZE]; LOG_TEST_NAME("test_ltoa"); @@ -226,7 +226,7 @@ static void test_int64toa() { } static void test_leftpad() { - char *padded; + char* padded; LOG_TEST_NAME("test_leftpad"); @@ -274,9 +274,9 @@ static void test_memrchr(void) { GPR_ASSERT(NULL == gpr_memrchr(NULL, 'a', 0)); GPR_ASSERT(NULL == gpr_memrchr("", 'a', 0)); GPR_ASSERT(NULL == gpr_memrchr("hello", 'b', 5)); - GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'h', 5), "hello")); - GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'o', 5), "o")); - GPR_ASSERT(0 == strcmp((const char *)gpr_memrchr("hello", 'l', 5), "lo")); + GPR_ASSERT(0 == strcmp((const char*)gpr_memrchr("hello", 'h', 5), "hello")); + GPR_ASSERT(0 == strcmp((const char*)gpr_memrchr("hello", 'o', 5), "o")); + GPR_ASSERT(0 == strcmp((const char*)gpr_memrchr("hello", 'l', 5), "lo")); } static void test_is_true(void) { @@ -294,7 +294,7 @@ static void test_is_true(void) { GPR_ASSERT(false == gpr_is_true("0")); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_strdup(); test_dump(); diff --git a/test/core/support/sync_test.cc b/test/core/support/sync_test.cc index c005a2bbb1..416e94d06d 100644 --- a/test/core/support/sync_test.cc +++ b/test/core/support/sync_test.cc @@ -47,7 +47,7 @@ typedef struct queue { } queue; /* Initialize *q. */ -void queue_init(queue *q) { +void queue_init(queue* q) { gpr_mu_init(&q->mu); gpr_cv_init(&q->non_empty); gpr_cv_init(&q->non_full); @@ -56,14 +56,14 @@ void queue_init(queue *q) { } /* Free storage associated with *q. */ -void queue_destroy(queue *q) { +void queue_destroy(queue* q) { gpr_mu_destroy(&q->mu); gpr_cv_destroy(&q->non_empty); gpr_cv_destroy(&q->non_full); } /* Wait until there is room in *q, then append x to *q. */ -void queue_append(queue *q, int x) { +void queue_append(queue* q, int x) { gpr_mu_lock(&q->mu); /* To wait for a predicate without a deadline, loop on the negation of the predicate, and use gpr_cv_wait(..., gpr_inf_future(GPR_CLOCK_REALTIME)) @@ -87,7 +87,7 @@ void queue_append(queue *q, int x) { /* If it can be done without blocking, append x to *q and return non-zero. Otherwise return 0. */ -int queue_try_append(queue *q, int x) { +int queue_try_append(queue* q, int x) { int result = 0; if (gpr_mu_trylock(&q->mu)) { if (q->length != N) { @@ -106,7 +106,7 @@ int queue_try_append(queue *q, int x) { /* Wait until the *q is non-empty or deadline abs_deadline passes. If the queue is non-empty, remove its head entry, place it in *head, and return non-zero. Otherwise return 0. */ -int queue_remove(queue *q, int *head, gpr_timespec abs_deadline) { +int queue_remove(queue* q, int* head, gpr_timespec abs_deadline) { int result = 0; gpr_mu_lock(&q->mu); /* To wait for a predicate with a deadline, loop on the negation of the @@ -156,8 +156,8 @@ struct test { }; /* Return pointer to a new struct test. */ -static struct test *test_new(int threads, int64_t iterations, int incr_step) { - struct test *m = static_cast<struct test *>(gpr_malloc(sizeof(*m))); +static struct test* test_new(int threads, int64_t iterations, int incr_step) { + struct test* m = static_cast<struct test*>(gpr_malloc(sizeof(*m))); m->threads = threads; m->iterations = iterations; m->counter = 0; @@ -176,7 +176,7 @@ static struct test *test_new(int threads, int64_t iterations, int incr_step) { } /* Return pointer to a new struct test. */ -static void test_destroy(struct test *m) { +static void test_destroy(struct test* m) { gpr_mu_destroy(&m->mu); gpr_cv_destroy(&m->cv); gpr_cv_destroy(&m->done_cv); @@ -185,7 +185,7 @@ static void test_destroy(struct test *m) { } /* Create m->threads threads, each running (*body)(m) */ -static void test_create_threads(struct test *m, void (*body)(void *arg)) { +static void test_create_threads(struct test* m, void (*body)(void* arg)) { gpr_thd_id id; int i; for (i = 0; i != m->threads; i++) { @@ -194,7 +194,7 @@ static void test_create_threads(struct test *m, void (*body)(void *arg)) { } /* Wait until all threads report done. */ -static void test_wait(struct test *m) { +static void test_wait(struct test* m) { gpr_mu_lock(&m->mu); while (m->done != 0) { gpr_cv_wait(&m->done_cv, &m->mu, gpr_inf_future(GPR_CLOCK_REALTIME)); @@ -203,7 +203,7 @@ static void test_wait(struct test *m) { } /* Get an integer thread id in the raneg 0..threads-1 */ -static int thread_id(struct test *m) { +static int thread_id(struct test* m) { int id; gpr_mu_lock(&m->mu); id = m->thread_count++; @@ -213,7 +213,7 @@ static int thread_id(struct test *m) { /* Indicate that a thread is done, by decrementing m->done and signalling done_cv if m->done==0. */ -static void mark_thread_done(struct test *m) { +static void mark_thread_done(struct test* m) { gpr_mu_lock(&m->mu); GPR_ASSERT(m->done != 0); m->done--; @@ -229,10 +229,10 @@ static void mark_thread_done(struct test *m) { incr_step controls by how much m->refcount should be incremented/decremented (if at all) each time in the tests. */ -static void test(const char *name, void (*body)(void *m), - void (*extra)(void *m), int timeout_s, int incr_step) { +static void test(const char* name, void (*body)(void* m), + void (*extra)(void* m), int timeout_s, int incr_step) { int64_t iterations = 1024; - struct test *m; + struct test* m; gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec time_taken; gpr_timespec deadline = gpr_time_add( @@ -262,8 +262,8 @@ static void test(const char *name, void (*body)(void *m), } /* Increment m->counter on each iteration; then mark thread as done. */ -static void inc(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void inc(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; for (i = 0; i != m->iterations; i++) { gpr_mu_lock(&m->mu); @@ -275,8 +275,8 @@ static void inc(void *v /*=m*/) { /* Increment m->counter under lock acquired with trylock, m->iterations times; then mark thread as done. */ -static void inctry(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void inctry(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; for (i = 0; i != m->iterations;) { if (gpr_mu_trylock(&m->mu)) { @@ -290,8 +290,8 @@ static void inctry(void *v /*=m*/) { /* Increment counter only when (m->counter%m->threads)==m->thread_id; then mark thread as done. */ -static void inc_by_turns(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void inc_by_turns(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; int id = thread_id(m); for (i = 0; i != m->iterations; i++) { @@ -308,8 +308,8 @@ static void inc_by_turns(void *v /*=m*/) { /* Wait a millisecond and increment counter on each iteration; then mark thread as done. */ -static void inc_with_1ms_delay(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void inc_with_1ms_delay(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; for (i = 0; i != m->iterations; i++) { gpr_timespec deadline; @@ -326,8 +326,8 @@ static void inc_with_1ms_delay(void *v /*=m*/) { /* Wait a millisecond and increment counter on each iteration, using an event for timing; then mark thread as done. */ -static void inc_with_1ms_delay_event(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void inc_with_1ms_delay_event(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; for (i = 0; i != m->iterations; i++) { gpr_timespec deadline; @@ -344,8 +344,8 @@ static void inc_with_1ms_delay_event(void *v /*=m*/) { /* Produce m->iterations elements on queue m->q, then mark thread as done. Even threads use queue_append(), and odd threads use queue_try_append() until it succeeds. */ -static void many_producers(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void many_producers(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; int x = thread_id(m); if ((x & 1) == 0) { @@ -364,8 +364,8 @@ static void many_producers(void *v /*=m*/) { /* Consume elements from m->q until m->threads*m->iterations are seen, wait an extra second to confirm that no more elements are arriving, then mark thread as done. */ -static void consumer(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void consumer(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t n = m->iterations * m->threads; int64_t i; int value; @@ -384,8 +384,8 @@ static void consumer(void *v /*=m*/) { /* Increment m->stats_counter m->iterations times, transfer counter value to m->counter, then mark thread as done. */ -static void statsinc(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void statsinc(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; for (i = 0; i != m->iterations; i++) { gpr_stats_inc(&m->stats_counter, 1); @@ -399,8 +399,8 @@ static void statsinc(void *v /*=m*/) { /* Increment m->refcount by m->incr_step for m->iterations times. Decrement m->thread_refcount once, and if it reaches zero, set m->event to (void*)1; then mark thread as done. */ -static void refinc(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void refinc(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t i; for (i = 0; i != m->iterations; i++) { if (m->incr_step == 1) { @@ -410,7 +410,7 @@ static void refinc(void *v /*=m*/) { } } if (gpr_unref(&m->thread_refcount)) { - gpr_event_set(&m->event, (void *)1); + gpr_event_set(&m->event, (void*)1); } mark_thread_done(m); } @@ -418,13 +418,13 @@ static void refinc(void *v /*=m*/) { /* Wait until m->event is set to (void *)1, then decrement m->refcount by 1 (m->threads * m->iterations * m->incr_step) times, and ensure that the last decrement caused the counter to reach zero, then mark thread as done. */ -static void refcheck(void *v /*=m*/) { - struct test *m = static_cast<struct test *>(v); +static void refcheck(void* v /*=m*/) { + struct test* m = static_cast<struct test*>(v); int64_t n = m->iterations * m->threads * m->incr_step; int64_t i; GPR_ASSERT(gpr_event_wait(&m->event, gpr_inf_future(GPR_CLOCK_REALTIME)) == - (void *)1); - GPR_ASSERT(gpr_event_get(&m->event) == (void *)1); + (void*)1); + GPR_ASSERT(gpr_event_get(&m->event) == (void*)1); for (i = 1; i != n; i++) { GPR_ASSERT(!gpr_unref(&m->refcount)); m->counter++; @@ -436,7 +436,7 @@ static void refcheck(void *v /*=m*/) { /* ------------------------------------------------- */ -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { grpc_test_init(argc, argv); test("mutex", &inc, NULL, 1, 1); test("mutex try", &inctry, NULL, 1, 1); diff --git a/test/core/support/thd_test.cc b/test/core/support/thd_test.cc index e6b4ea405b..f70a3b4fe2 100644 --- a/test/core/support/thd_test.cc +++ b/test/core/support/thd_test.cc @@ -36,8 +36,8 @@ struct test { }; /* A Thread body. Decrement t->n, and if is becomes zero, set t->done. */ -static void thd_body(void *v) { - struct test *t = static_cast<struct test *>(v); +static void thd_body(void* v) { + struct test* t = static_cast<struct test*>(v); gpr_mu_lock(&t->mu); t->n--; if (t->n == 0) { @@ -47,7 +47,7 @@ static void thd_body(void *v) { gpr_mu_unlock(&t->mu); } -static void thd_body_joinable(void *v) {} +static void thd_body_joinable(void* v) {} /* Test thread options work as expected */ static void test_options(void) { @@ -93,7 +93,7 @@ static void test(void) { /* ------------------------------------------------- */ -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { grpc_test_init(argc, argv); test_options(); test(); diff --git a/test/core/support/time_test.cc b/test/core/support/time_test.cc index 74b5ef6114..608169274f 100644 --- a/test/core/support/time_test.cc +++ b/test/core/support/time_test.cc @@ -28,15 +28,15 @@ #include <string.h> #include "test/core/util/test_config.h" -static void to_fp(void *arg, const char *buf, size_t len) { - fwrite(buf, 1, len, (FILE *)arg); +static void to_fp(void* arg, const char* buf, size_t len) { + fwrite(buf, 1, len, (FILE*)arg); } /* Convert gpr_intmax x to ascii base b (2..16), and write with (*writer)(arg, ...), zero padding to "chars" digits). */ static void i_to_s(intmax_t x, int base, int chars, - void (*writer)(void *arg, const char *buf, size_t len), - void *arg) { + void (*writer)(void* arg, const char* buf, size_t len), + void* arg) { char buf[64]; char fmt[32]; GPR_ASSERT(base == 16 || base == 10); @@ -47,8 +47,8 @@ static void i_to_s(intmax_t x, int base, int chars, /* Convert ts to ascii, and write with (*writer)(arg, ...). */ static void ts_to_s(gpr_timespec t, - void (*writer)(void *arg, const char *buf, size_t len), - void *arg) { + void (*writer)(void* arg, const char* buf, size_t len), + void* arg) { if (t.tv_sec < 0 && t.tv_nsec != 0) { t.tv_sec++; t.tv_nsec = GPR_NS_PER_SEC - t.tv_nsec; @@ -241,7 +241,7 @@ static void test_cmp_extreme(void) { GPR_ASSERT(gpr_time_cmp(t1, t2) == 0); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { grpc_test_init(argc, argv); test_values(); diff --git a/test/core/support/tls_test.cc b/test/core/support/tls_test.cc index 5529d5cf59..b1b4737432 100644 --- a/test/core/support/tls_test.cc +++ b/test/core/support/tls_test.cc @@ -30,7 +30,7 @@ GPR_TLS_DECL(test_var); -static void thd_body(void *arg) { +static void thd_body(void* arg) { intptr_t i; GPR_ASSERT(gpr_tls_get(&test_var) == 0); @@ -44,7 +44,7 @@ static void thd_body(void *arg) { /* ------------------------------------------------- */ -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { gpr_thd_options opt = gpr_thd_options_default(); int i; gpr_thd_id threads[NUM_THREADS]; diff --git a/test/core/support/useful_test.cc b/test/core/support/useful_test.cc index 2f84f485fc..2f86010d77 100644 --- a/test/core/support/useful_test.cc +++ b/test/core/support/useful_test.cc @@ -21,7 +21,7 @@ #include <grpc/support/useful.h> #include "test/core/util/test_config.h" -int main(int argc, char **argv) { +int main(int argc, char** argv) { int four[4]; int five[5]; uint32_t bitset = 0; diff --git a/test/core/surface/alarm_test.cc b/test/core/surface/alarm_test.cc index 4fd7cb93c6..88b0b31478 100644 --- a/test/core/surface/alarm_test.cc +++ 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.cc b/test/core/surface/byte_buffer_reader_test.cc index a6b4c86abc..e5d2d7c78d 100644 --- a/test/core/surface/byte_buffer_reader_test.cc +++ 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.cc b/test/core/surface/channel_create_test.cc index a6884750e7..4627c57438 100644 --- a/test/core/surface/channel_create_test.cc +++ 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.cc b/test/core/surface/completion_queue_test.cc index e4e4c9f1b2..277ffde553 100644 --- a/test/core/surface/completion_queue_test.cc +++ 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.cc b/test/core/surface/completion_queue_threading_test.cc index abe119789f..043c5c1617 100644 --- a/test/core/surface/completion_queue_threading_test.cc +++ 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 = static_cast<struct thread_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,69 +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 = static_cast<test_thread_options *>(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, - static_cast<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 = static_cast<test_thread_options *>(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); @@ -200,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"); @@ -210,11 +210,11 @@ static void consumer_thread(void *arg) { } static void test_threading(size_t producers, size_t consumers) { - test_thread_options *options = static_cast<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; @@ -242,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++) { @@ -252,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 */ @@ -281,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.cc b/test/core/surface/concurrent_connectivity_test.cc index 303180c0d1..6f6a71e6f5 100644 --- a/test/core/surface/concurrent_connectivity_test.cc +++ 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, static_cast<grpc_pollset *>(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 = static_cast<grpc_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.cc b/test/core/surface/init_test.cc index b835a2a884..5749bc8b36 100644 --- a/test/core/surface/init_test.cc +++ 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.cc b/test/core/surface/invalid_channel_args_test.cc index e6099d4fca..6a58a32e3c 100644 --- a/test/core/surface/invalid_channel_args_test.cc +++ 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 = const_cast<char *>(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 = const_cast<char *>(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 = const_cast<char *>(GRPC_ARG_DEFAULT_AUTHORITY); - client_arg[0].value.string = const_cast<char *>("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 = const_cast<char *>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG); - client_arg[1].value.string = const_cast<char *>("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.cc b/test/core/surface/lame_client_test.cc index 6d563d2f1f..c374adc08d 100644 --- a/test/core/surface/lame_client_test.cc +++ 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 = static_cast<grpc_connectivity_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.cc b/test/core/surface/num_external_connectivity_watchers_test.cc index f5f09b38e2..89dc364fb8 100644 --- a/test/core/surface/num_external_connectivity_watchers_test.cc +++ 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,24 +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, - const_cast<char *>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), - {const_cast<char *>("foo.test.google.fr")}}; - grpc_channel_args *new_client_args = + 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; @@ -186,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.cc b/test/core/surface/secure_channel_create_test.cc index ccb58ee793..f3163c1d80 100644 --- a/test/core/surface/secure_channel_create_test.cc +++ 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 = const_cast<char *>(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.cc b/test/core/surface/sequential_connectivity_test.cc index 6596a3a0ce..9ffbc82667 100644 --- a/test/core/surface/sequential_connectivity_test.cc +++ 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 = static_cast<server_thread_args *>(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,37 +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, - const_cast<char *>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), - {const_cast<char *>("foo.test.google.fr")}}; - grpc_channel_args *new_client_args = + 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; @@ -163,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.cc b/test/core/surface/server_chttp2_test.cc index ecd5314b83..b0ffb1de3c 100644 --- a/test/core/surface/server_chttp2_test.cc +++ 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 = const_cast<char *>(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.cc b/test/core/surface/server_test.cc index 08b8dca4d7..240969a121 100644 --- a/test/core/surface/server_test.cc +++ 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 = const_cast<char *>(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)); } diff --git a/test/core/transport/bdp_estimator_test.cc b/test/core/transport/bdp_estimator_test.cc index 2c4fc4588b..2a6fa95162 100644 --- a/test/core/transport/bdp_estimator_test.cc +++ b/test/core/transport/bdp_estimator_test.cc @@ -55,7 +55,7 @@ TEST(BdpEstimatorTest, EstimateBdpNoSamples) { } namespace { -void AddSamples(BdpEstimator *estimator, int64_t *samples, size_t n) { +void AddSamples(BdpEstimator* estimator, int64_t* samples, size_t n) { estimator->AddIncomingBytes(1234567); inc_time(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -71,7 +71,7 @@ void AddSamples(BdpEstimator *estimator, int64_t *samples, size_t n) { grpc_exec_ctx_finish(&exec_ctx); } -void AddSample(BdpEstimator *estimator, int64_t sample) { +void AddSample(BdpEstimator* estimator, int64_t sample) { AddSamples(estimator, &sample, 1); } } // namespace @@ -137,7 +137,7 @@ INSTANTIATE_TEST_CASE_P(TooManyNames, BdpEstimatorRandomTest, } // namespace testing } // namespace grpc_core -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); gpr_now_impl = grpc_core::testing::fake_gpr_now; grpc_init(); diff --git a/test/core/transport/byte_stream_test.cc b/test/core/transport/byte_stream_test.cc index a0c5f961cf..e62a697284 100644 --- a/test/core/transport/byte_stream_test.cc +++ b/test/core/transport/byte_stream_test.cc @@ -30,8 +30,8 @@ // grpc_slice_buffer_stream tests // -static void not_called_closure(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void not_called_closure(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { GPR_ASSERT(false); } @@ -60,7 +60,7 @@ static void test_slice_buffer_stream_basic(void) { GPR_ASSERT( grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure)); grpc_slice output; - grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output); + grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(grpc_slice_eq(input[i], output)); grpc_slice_unref_internal(&exec_ctx, output); @@ -95,12 +95,12 @@ static void test_slice_buffer_stream_shutdown(void) { GPR_ASSERT( grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure)); grpc_slice output; - grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output); + grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(grpc_slice_eq(input[0], output)); grpc_slice_unref_internal(&exec_ctx, output); // Now shutdown. - grpc_error *shutdown_error = + grpc_error* shutdown_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("shutdown error"); grpc_byte_stream_shutdown(&exec_ctx, &stream.base, GRPC_ERROR_REF(shutdown_error)); @@ -150,7 +150,7 @@ static void test_caching_byte_stream_basic(void) { GPR_ASSERT( grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure)); grpc_slice output; - grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output); + grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(grpc_slice_eq(input[i], output)); grpc_slice_unref_internal(&exec_ctx, output); @@ -189,7 +189,7 @@ static void test_caching_byte_stream_reset(void) { GPR_ASSERT( grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure)); grpc_slice output; - grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output); + grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(grpc_slice_eq(input[0], output)); grpc_slice_unref_internal(&exec_ctx, output); @@ -240,7 +240,7 @@ static void test_caching_byte_stream_shared_cache(void) { GPR_ASSERT( grpc_byte_stream_next(&exec_ctx, &stream1.base, ~(size_t)0, &closure)); grpc_slice output; - grpc_error *error = grpc_byte_stream_pull(&exec_ctx, &stream1.base, &output); + grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream1.base, &output); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(grpc_slice_eq(input[0], output)); grpc_slice_unref_internal(&exec_ctx, output); @@ -268,7 +268,7 @@ static void test_caching_byte_stream_shared_cache(void) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_slice_buffer_stream_basic(); test_slice_buffer_stream_shutdown(); diff --git a/test/core/transport/chttp2/alpn_test.cc b/test/core/transport/chttp2/alpn_test.cc index 72c30c40eb..a43377393e 100644 --- a/test/core/transport/chttp2/alpn_test.cc +++ b/test/core/transport/chttp2/alpn_test.cc @@ -33,7 +33,7 @@ static void test_alpn_failure(void) { // First index in ALPN supported version list of a given protocol. Returns a // value one beyond the last valid element index if not found. -static size_t alpn_version_index(const char *version, size_t size) { +static size_t alpn_version_index(const char* version, size_t size) { size_t i; for (i = 0; i < grpc_chttp2_num_alpn_versions(); ++i) { if (!strncmp(version, grpc_chttp2_get_alpn_version_index(i), size)) { @@ -48,7 +48,7 @@ static void test_alpn_grpc_before_h2(void) { GPR_ASSERT(alpn_version_index("grpc-exp", 8) < alpn_version_index("h2", 2)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_alpn_success(); test_alpn_failure(); diff --git a/test/core/transport/chttp2/bin_decoder_test.cc b/test/core/transport/chttp2/bin_decoder_test.cc index a09aadb18d..a29ec8a13f 100644 --- a/test/core/transport/chttp2/bin_decoder_test.cc +++ b/test/core/transport/chttp2/bin_decoder_test.cc @@ -29,11 +29,11 @@ static int all_ok = 1; -static void expect_slice_eq(grpc_exec_ctx *exec_ctx, grpc_slice expected, - grpc_slice slice, const char *debug, int line) { +static void expect_slice_eq(grpc_exec_ctx* exec_ctx, grpc_slice expected, + grpc_slice slice, const char* debug, int line) { if (!grpc_slice_eq(slice, expected)) { - char *hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs, he); gpr_free(hs); @@ -44,22 +44,22 @@ static void expect_slice_eq(grpc_exec_ctx *exec_ctx, grpc_slice expected, grpc_slice_unref_internal(exec_ctx, slice); } -static grpc_slice base64_encode(grpc_exec_ctx *exec_ctx, const char *s) { +static grpc_slice base64_encode(grpc_exec_ctx* exec_ctx, const char* s) { grpc_slice ss = grpc_slice_from_copied_string(s); grpc_slice out = grpc_chttp2_base64_encode(ss); grpc_slice_unref_internal(exec_ctx, ss); return out; } -static grpc_slice base64_decode(grpc_exec_ctx *exec_ctx, const char *s) { +static grpc_slice base64_decode(grpc_exec_ctx* exec_ctx, const char* s) { grpc_slice ss = grpc_slice_from_copied_string(s); grpc_slice out = grpc_chttp2_base64_decode(exec_ctx, ss); grpc_slice_unref_internal(exec_ctx, ss); return out; } -static grpc_slice base64_decode_with_length(grpc_exec_ctx *exec_ctx, - const char *s, +static grpc_slice base64_decode_with_length(grpc_exec_ctx* exec_ctx, + const char* s, size_t output_length) { grpc_slice ss = grpc_slice_from_copied_string(s); grpc_slice out = @@ -78,7 +78,7 @@ static grpc_slice base64_decode_with_length(grpc_exec_ctx *exec_ctx, grpc_chttp2_base64_decode_with_length( \ exec_ctx, base64_encode(exec_ctx, s), strlen(s))); -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; /* ENCODE_AND_DECODE tests grpc_chttp2_base64_decode_with_length(), which diff --git a/test/core/transport/chttp2/bin_encoder_test.cc b/test/core/transport/chttp2/bin_encoder_test.cc index d073f74d27..78b8808c41 100644 --- a/test/core/transport/chttp2/bin_encoder_test.cc +++ b/test/core/transport/chttp2/bin_encoder_test.cc @@ -32,10 +32,10 @@ static int all_ok = 1; static void expect_slice_eq(grpc_slice expected, grpc_slice slice, - const char *debug, int line) { + const char* debug, int line) { if (!grpc_slice_eq(slice, expected)) { - char *hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs, he); gpr_free(hs); @@ -46,14 +46,14 @@ static void expect_slice_eq(grpc_slice expected, grpc_slice slice, grpc_slice_unref(slice); } -static grpc_slice B64(const char *s) { +static grpc_slice B64(const char* s) { grpc_slice ss = grpc_slice_from_copied_string(s); grpc_slice out = grpc_chttp2_base64_encode(ss); grpc_slice_unref(ss); return out; } -static grpc_slice HUFF(const char *s) { +static grpc_slice HUFF(const char* s) { grpc_slice ss = grpc_slice_from_copied_string(s); grpc_slice out = grpc_chttp2_huffman_compress(ss); grpc_slice_unref(ss); @@ -65,15 +65,15 @@ static grpc_slice HUFF(const char *s) { grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \ #slice, __LINE__); -static void expect_combined_equiv(const char *s, size_t len, int line) { +static void expect_combined_equiv(const char* s, size_t len, int line) { grpc_slice input = grpc_slice_from_copied_buffer(s, len); grpc_slice base64 = grpc_chttp2_base64_encode(input); grpc_slice expect = grpc_chttp2_huffman_compress(base64); grpc_slice got = grpc_chttp2_base64_encode_and_huffman_compress(input); if (!grpc_slice_eq(expect, got)) { - char *t = grpc_dump_slice(input, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *e = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *g = grpc_dump_slice(got, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* t = grpc_dump_slice(input, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* e = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* g = grpc_dump_slice(got, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "FAILED:%d:\ntest: %s\ngot: %s\nwant: %s", line, t, g, e); gpr_free(t); @@ -90,7 +90,7 @@ static void expect_combined_equiv(const char *s, size_t len, int line) { #define EXPECT_COMBINED_EQUIV(x) \ expect_combined_equiv(x, sizeof(x) - 1, __LINE__) -static void expect_binary_header(const char *hdr, int binary) { +static void expect_binary_header(const char* hdr, int binary) { if (grpc_is_binary_header(grpc_slice_from_static_string(hdr)) != binary) { gpr_log(GPR_ERROR, "FAILED: expected header '%s' to be %s", hdr, binary ? "binary" : "not binary"); @@ -98,7 +98,7 @@ static void expect_binary_header(const char *hdr, int binary) { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { /* Base64 test vectors from RFC 4648, with padding removed */ /* BASE64("") = "" */ EXPECT_SLICE_EQ("", B64("")); diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc index f950f8a63c..a7e44abc2b 100644 --- a/test/core/transport/chttp2/hpack_encoder_test.cc +++ b/test/core/transport/chttp2/hpack_encoder_test.cc @@ -39,7 +39,7 @@ grpc_chttp2_hpack_compressor g_compressor; int g_failure = 0; -void **to_delete = NULL; +void** to_delete = NULL; size_t num_to_delete = 0; size_t cap_to_delete = 0; @@ -51,23 +51,23 @@ typedef struct { /* verify that the output generated by encoding the stream matches the hexstring passed in */ -static void verify(grpc_exec_ctx *exec_ctx, const verify_params params, - const char *expected, size_t nheaders, ...) { +static void verify(grpc_exec_ctx* exec_ctx, const verify_params params, + const char* expected, size_t nheaders, ...) { grpc_slice_buffer output; grpc_slice merged; grpc_slice expect = parse_hexstring(expected); size_t i; va_list l; - grpc_linked_mdelem *e = - static_cast<grpc_linked_mdelem *>(gpr_malloc(sizeof(*e) * nheaders)); + grpc_linked_mdelem* e = + static_cast<grpc_linked_mdelem*>(gpr_malloc(sizeof(*e) * nheaders)); grpc_metadata_batch b; grpc_metadata_batch_init(&b); va_start(l, nheaders); for (i = 0; i < nheaders; i++) { - char *key = va_arg(l, char *); - char *value = va_arg(l, char *); + char* key = va_arg(l, char*); + char* value = va_arg(l, char*); if (i) { e[i - 1].next = &e[i]; e[i].prev = &e[i - 1]; @@ -90,7 +90,7 @@ static void verify(grpc_exec_ctx *exec_ctx, const verify_params params, if (cap_to_delete == num_to_delete) { cap_to_delete = GPR_MAX(2 * cap_to_delete, 1000); - to_delete = static_cast<void **>( + to_delete = static_cast<void**>( gpr_realloc(to_delete, sizeof(*to_delete) * cap_to_delete)); } to_delete[num_to_delete++] = e; @@ -113,8 +113,8 @@ static void verify(grpc_exec_ctx *exec_ctx, const verify_params params, grpc_metadata_batch_destroy(exec_ctx, &b); if (!grpc_slice_eq(merged, expect)) { - char *expect_str = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *got_str = grpc_dump_slice(merged, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* expect_str = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char* got_str = grpc_dump_slice(merged, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "mismatched output for %s", expected); gpr_log(GPR_ERROR, "EXPECT: %s", expect_str); gpr_log(GPR_ERROR, "GOT: %s", got_str); @@ -127,11 +127,13 @@ static void verify(grpc_exec_ctx *exec_ctx, const verify_params params, grpc_slice_unref_internal(exec_ctx, expect); } -static void test_basic_headers(grpc_exec_ctx *exec_ctx) { +static void test_basic_headers(grpc_exec_ctx* exec_ctx) { int i; verify_params params = { - false, false, false, + false, + false, + false, }; verify(exec_ctx, params, "000005 0104 deadbeef 40 0161 0161", 1, "a", "a"); verify(exec_ctx, params, "000001 0104 deadbeef be", 1, "a", "a"); @@ -153,7 +155,7 @@ static void test_basic_headers(grpc_exec_ctx *exec_ctx) { verify(exec_ctx, params, "000004 0104 deadbeef 0f 2f 0176", 1, "a", "v"); } -static void encode_int_to_str(int i, char *p) { +static void encode_int_to_str(int i, char* p) { p[0] = (char)('a' + i % 26); i /= 26; GPR_ASSERT(i < 26); @@ -161,13 +163,15 @@ static void encode_int_to_str(int i, char *p) { p[2] = 0; } -static void test_decode_table_overflow(grpc_exec_ctx *exec_ctx) { +static void test_decode_table_overflow(grpc_exec_ctx* exec_ctx) { int i; char key[3], value[3]; - char *expect; + char* expect; verify_params params = { - false, false, false, + false, + false, + false, }; for (i = 0; i < 114; i++) { @@ -201,9 +205,9 @@ static void test_decode_table_overflow(grpc_exec_ctx *exec_ctx) { "ba"); } -static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx, - const char *key, - const char *value, +static void verify_table_size_change_match_elem_size(grpc_exec_ctx* exec_ctx, + const char* key, + const char* value, bool use_true_binary) { grpc_slice_buffer output; grpc_mdelem elem = grpc_mdelem_from_slices( @@ -211,8 +215,8 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(value))); size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, use_true_binary); size_t initial_table_size = g_compressor.table_size; - grpc_linked_mdelem *e = - static_cast<grpc_linked_mdelem *>(gpr_malloc(sizeof(*e))); + grpc_linked_mdelem* e = + static_cast<grpc_linked_mdelem*>(gpr_malloc(sizeof(*e))); grpc_metadata_batch b; grpc_metadata_batch_init(&b); e[0].md = elem; @@ -240,7 +244,7 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx, gpr_free(e); } -static void test_encode_header_size(grpc_exec_ctx *exec_ctx) { +static void test_encode_header_size(grpc_exec_ctx* exec_ctx) { verify_table_size_change_match_elem_size(exec_ctx, "hello", "world", false); verify_table_size_change_match_elem_size(exec_ctx, "hello-bin", "world", false); @@ -248,7 +252,7 @@ static void test_encode_header_size(grpc_exec_ctx *exec_ctx) { "I_am_true_binary_value", true); } -static void test_interned_key_indexed(grpc_exec_ctx *exec_ctx) { +static void test_interned_key_indexed(grpc_exec_ctx* exec_ctx) { int i; verify_params params = {false, false, true}; verify(exec_ctx, params, "000009 0104 deadbeef 40 0161 0162 0f2f 0163", 2, @@ -259,7 +263,7 @@ static void test_interned_key_indexed(grpc_exec_ctx *exec_ctx) { } } -static void run_test(void (*test)(grpc_exec_ctx *exec_ctx), const char *name) { +static void run_test(void (*test)(grpc_exec_ctx* exec_ctx), const char* name) { gpr_log(GPR_INFO, "RUN TEST: %s", name); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_chttp2_hpack_compressor_init(&g_compressor); @@ -268,7 +272,7 @@ static void run_test(void (*test)(grpc_exec_ctx *exec_ctx), const char *name) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; grpc_test_only_set_slice_hash_seed(0); grpc_test_init(argc, argv); diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc index bad7491162..942f25e0b7 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc @@ -29,12 +29,12 @@ bool squelch = true; bool leak_check = true; -static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem md) { +static void onhdr(grpc_exec_ctx* exec_ctx, void* ud, grpc_mdelem md) { GRPC_MDELEM_UNREF(exec_ctx, md); } -static void dont_log(gpr_log_func_args *args) {} +static void dont_log(gpr_log_func_args* args) {} -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_test_only_set_slice_hash_seed(0); if (squelch) gpr_set_log_function(dont_log); grpc_init(); diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc index 27b4a1c2c0..434b46eb2e 100644 --- a/test/core/transport/chttp2/hpack_parser_test.cc +++ b/test/core/transport/chttp2/hpack_parser_test.cc @@ -28,25 +28,27 @@ #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" -typedef struct { va_list args; } test_checker; +typedef struct { + va_list args; +} test_checker; -static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem md) { +static void onhdr(grpc_exec_ctx* exec_ctx, void* ud, grpc_mdelem md) { const char *ekey, *evalue; - test_checker *chk = static_cast<test_checker *>(ud); - ekey = va_arg(chk->args, char *); + test_checker* chk = static_cast<test_checker*>(ud); + ekey = va_arg(chk->args, char*); GPR_ASSERT(ekey); - evalue = va_arg(chk->args, char *); + evalue = va_arg(chk->args, char*); GPR_ASSERT(evalue); GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(md), ekey) == 0); GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(md), evalue) == 0); GRPC_MDELEM_UNREF(exec_ctx, md); } -static void test_vector(grpc_chttp2_hpack_parser *parser, - grpc_slice_split_mode mode, const char *hexstring, +static void test_vector(grpc_chttp2_hpack_parser* parser, + grpc_slice_split_mode mode, const char* hexstring, ... /* char *key, char *value */) { grpc_slice input = parse_hexstring(hexstring); - grpc_slice *slices; + grpc_slice* slices; size_t nslices; size_t i; test_checker chk; @@ -71,7 +73,7 @@ static void test_vector(grpc_chttp2_hpack_parser *parser, } gpr_free(slices); - GPR_ASSERT(NULL == va_arg(chk.args, char *)); + GPR_ASSERT(NULL == va_arg(chk.args, char*)); va_end(chk.args); } @@ -206,7 +208,7 @@ static void test_vectors(grpc_slice_split_mode mode) { 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_vectors(GRPC_SLICE_SPLIT_MERGE_ALL); diff --git a/test/core/transport/chttp2/hpack_table_test.cc b/test/core/transport/chttp2/hpack_table_test.cc index 430ece33c7..ff7c2de538 100644 --- a/test/core/transport/chttp2/hpack_table_test.cc +++ b/test/core/transport/chttp2/hpack_table_test.cc @@ -31,13 +31,13 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) -static void assert_str(const grpc_chttp2_hptbl *tbl, grpc_slice mdstr, - const char *str) { +static void assert_str(const grpc_chttp2_hptbl* tbl, grpc_slice mdstr, + const char* str) { GPR_ASSERT(grpc_slice_str_cmp(mdstr, str) == 0); } -static void assert_index(const grpc_chttp2_hptbl *tbl, uint32_t idx, - const char *key, const char *value) { +static void assert_index(const grpc_chttp2_hptbl* tbl, uint32_t idx, + const char* key, const char* value) { grpc_mdelem md = grpc_chttp2_hptbl_lookup(tbl, idx); assert_str(tbl, GRPC_MDKEY(md), key); assert_str(tbl, GRPC_MDVALUE(md), value); @@ -119,8 +119,8 @@ static void test_static_lookup(void) { static void test_many_additions(void) { grpc_chttp2_hptbl tbl; int i; - char *key; - char *value; + char* key; + char* value; LOG_TEST("test_many_additions"); @@ -152,9 +152,9 @@ static void test_many_additions(void) { grpc_exec_ctx_finish(&exec_ctx); } -static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl *tbl, - const char *key, - const char *value) { +static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl* tbl, + const char* key, + const char* value) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_mdelem md = grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key), @@ -274,7 +274,7 @@ static void test_find(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_static_lookup(); diff --git a/test/core/transport/chttp2/stream_map_test.cc b/test/core/transport/chttp2/stream_map_test.cc index 7df7b1b2a6..23a7b3f4c2 100644 --- a/test/core/transport/chttp2/stream_map_test.cc +++ b/test/core/transport/chttp2/stream_map_test.cc @@ -51,10 +51,10 @@ static void test_double_deletion(void) { grpc_chttp2_stream_map_init(&map, 8); GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map)); - grpc_chttp2_stream_map_add(&map, 1, (void *)1); - GPR_ASSERT((void *)1 == grpc_chttp2_stream_map_find(&map, 1)); + grpc_chttp2_stream_map_add(&map, 1, (void*)1); + GPR_ASSERT((void*)1 == grpc_chttp2_stream_map_find(&map, 1)); GPR_ASSERT(1 == grpc_chttp2_stream_map_size(&map)); - GPR_ASSERT((void *)1 == grpc_chttp2_stream_map_delete(&map, 1)); + GPR_ASSERT((void*)1 == grpc_chttp2_stream_map_delete(&map, 1)); GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 1)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_delete(&map, 1)); @@ -78,7 +78,7 @@ static void test_basic_add_find(uint32_t n) { grpc_chttp2_stream_map_init(&map, 8); GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map)); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i); + grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i); } GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0)); @@ -91,14 +91,14 @@ static void test_basic_add_find(uint32_t n) { } /* verify that for_each gets the right values during test_delete_evens_XXX */ -static void verify_for_each(void *user_data, uint32_t stream_id, void *ptr) { - uint32_t *for_each_check = static_cast<uint32_t *>(user_data); +static void verify_for_each(void* user_data, uint32_t stream_id, void* ptr) { + uint32_t* for_each_check = static_cast<uint32_t*>(user_data); GPR_ASSERT(ptr); GPR_ASSERT(*for_each_check == stream_id); *for_each_check += 2; } -static void check_delete_evens(grpc_chttp2_stream_map *map, uint32_t n) { +static void check_delete_evens(grpc_chttp2_stream_map* map, uint32_t n) { uint32_t for_each_check = 1; uint32_t i; size_t got; @@ -133,12 +133,11 @@ static void test_delete_evens_sweep(uint32_t n) { grpc_chttp2_stream_map_init(&map, 8); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i); + grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i); } for (i = 1; i <= n; i++) { if ((i & 1) == 0) { - GPR_ASSERT((void *)(uintptr_t)i == - grpc_chttp2_stream_map_delete(&map, i)); + GPR_ASSERT((void*)(uintptr_t)i == grpc_chttp2_stream_map_delete(&map, i)); } } check_delete_evens(&map, n); @@ -156,7 +155,7 @@ static void test_delete_evens_incremental(uint32_t n) { grpc_chttp2_stream_map_init(&map, 8); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i); + grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i); if ((i & 1) == 0) { grpc_chttp2_stream_map_delete(&map, i); } @@ -178,10 +177,10 @@ static void test_periodic_compaction(uint32_t n) { grpc_chttp2_stream_map_init(&map, 16); GPR_ASSERT(map.capacity == 16); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i); + grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i); if (i > 8) { del = i - 8; - GPR_ASSERT((void *)(uintptr_t)del == + GPR_ASSERT((void*)(uintptr_t)del == grpc_chttp2_stream_map_delete(&map, del)); } } @@ -189,7 +188,7 @@ static void test_periodic_compaction(uint32_t n) { grpc_chttp2_stream_map_destroy(&map); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { uint32_t n = 1; uint32_t prev = 1; uint32_t tmp; diff --git a/test/core/transport/chttp2/varint_test.cc b/test/core/transport/chttp2/varint_test.cc index 0986a2cde6..413b461b3a 100644 --- a/test/core/transport/chttp2/varint_test.cc +++ b/test/core/transport/chttp2/varint_test.cc @@ -24,7 +24,7 @@ #include "test/core/util/test_config.h" static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or, - const char *expect_bytes, size_t expect_length) { + const char* expect_bytes, size_t expect_length) { uint32_t nbytes = GRPC_CHTTP2_VARINT_LENGTH(value, prefix_bits); grpc_slice expect = grpc_slice_from_copied_buffer(expect_bytes, expect_length); @@ -42,7 +42,7 @@ static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or, #define TEST_VARINT(value, prefix_bits, prefix_or, expect) \ test_varint(value, prefix_bits, prefix_or, expect, sizeof(expect) - 1) -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); TEST_VARINT(0, 1, 0, "\x00"); TEST_VARINT(128, 1, 0, "\x7f\x01"); diff --git a/test/core/transport/connectivity_state_test.cc b/test/core/transport/connectivity_state_test.cc index 4ef8683107..8cd7b30b66 100644 --- a/test/core/transport/connectivity_state_test.cc +++ b/test/core/transport/connectivity_state_test.cc @@ -24,18 +24,18 @@ #include "test/core/util/test_config.h" -#define THE_ARG ((void *)(size_t)0xcafebabe) +#define THE_ARG ((void*)(size_t)0xcafebabe) int g_counter; -static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(arg == THE_ARG); g_counter++; } -static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { GPR_ASSERT(error != GRPC_ERROR_NONE); GPR_ASSERT(arg == THE_ARG); g_counter++; @@ -59,7 +59,7 @@ static void test_connectivity_state_name(void) { static void test_check(void) { grpc_connectivity_state_tracker tracker; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_error *error; + grpc_error* error; gpr_log(GPR_DEBUG, "test_check"); grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx"); GPR_ASSERT(grpc_connectivity_state_get(&tracker, &error) == @@ -72,7 +72,7 @@ static void test_check(void) { static void test_subscribe_then_unsubscribe(void) { grpc_connectivity_state_tracker tracker; - grpc_closure *closure = + grpc_closure* closure = GRPC_CLOSURE_CREATE(must_fail, THE_ARG, grpc_schedule_on_exec_ctx); grpc_connectivity_state state = GRPC_CHANNEL_IDLE; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -96,7 +96,7 @@ static void test_subscribe_then_unsubscribe(void) { static void test_subscribe_then_destroy(void) { grpc_connectivity_state_tracker tracker; - grpc_closure *closure = + grpc_closure* closure = GRPC_CLOSURE_CREATE(must_succeed, THE_ARG, grpc_schedule_on_exec_ctx); grpc_connectivity_state state = GRPC_CHANNEL_IDLE; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -116,7 +116,7 @@ static void test_subscribe_then_destroy(void) { static void test_subscribe_with_failure_then_destroy(void) { grpc_connectivity_state_tracker tracker; - grpc_closure *closure = + grpc_closure* closure = GRPC_CLOSURE_CREATE(must_fail, THE_ARG, grpc_schedule_on_exec_ctx); grpc_connectivity_state state = GRPC_CHANNEL_SHUTDOWN; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -134,7 +134,7 @@ static void test_subscribe_with_failure_then_destroy(void) { GPR_ASSERT(g_counter == 1); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_connectivity_state_trace.value = 1; test_connectivity_state_name(); diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc index e043078560..b60a9619fb 100644 --- a/test/core/transport/metadata_test.cc +++ b/test/core/transport/metadata_test.cc @@ -114,8 +114,8 @@ static void test_create_many_ephemeral_metadata(bool intern_keys, static void test_create_many_persistant_metadata(void) { char buffer[GPR_LTOA_MIN_BUFSIZE]; long i; - grpc_mdelem *created = - static_cast<grpc_mdelem *>(gpr_malloc(sizeof(grpc_mdelem) * MANY)); + grpc_mdelem* created = + static_cast<grpc_mdelem*>(gpr_malloc(sizeof(grpc_mdelem) * MANY)); grpc_mdelem md; gpr_log(GPR_INFO, "test_create_many_persistant_metadata"); @@ -225,11 +225,11 @@ static void test_identity_laws(bool intern_keys, bool intern_values) { static void test_things_stick_around(void) { size_t i, j; - char *buffer; + char* buffer; size_t nstrs = 1000; - grpc_slice *strs = - static_cast<grpc_slice *>(gpr_malloc(sizeof(grpc_slice) * nstrs)); - size_t *shuf = static_cast<size_t *>(gpr_malloc(sizeof(size_t) * nstrs)); + grpc_slice* strs = + static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice) * nstrs)); + size_t* shuf = static_cast<size_t*>(gpr_malloc(sizeof(size_t) * nstrs)); grpc_slice test; gpr_log(GPR_INFO, "test_things_stick_around"); @@ -276,16 +276,16 @@ static void test_things_stick_around(void) { } static void test_user_data_works(void) { - int *ud1; - int *ud2; + int* ud1; + int* ud2; grpc_mdelem md; gpr_log(GPR_INFO, "test_user_data_works"); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - ud1 = static_cast<int *>(gpr_malloc(sizeof(int))); + ud1 = static_cast<int*>(gpr_malloc(sizeof(int))); *ud1 = 1; - ud2 = static_cast<int *>(gpr_malloc(sizeof(int))); + ud2 = static_cast<int*>(gpr_malloc(sizeof(int))); *ud2 = 2; md = grpc_mdelem_from_slices( &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")), @@ -298,8 +298,8 @@ static void test_user_data_works(void) { grpc_shutdown(); } -static void verify_ascii_header_size(grpc_exec_ctx *exec_ctx, const char *key, - const char *value, bool intern_key, +static void verify_ascii_header_size(grpc_exec_ctx* exec_ctx, const char* key, + const char* value, bool intern_key, bool intern_value) { grpc_mdelem elem = grpc_mdelem_from_slices( exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key), @@ -310,8 +310,8 @@ static void verify_ascii_header_size(grpc_exec_ctx *exec_ctx, const char *key, GRPC_MDELEM_UNREF(exec_ctx, elem); } -static void verify_binary_header_size(grpc_exec_ctx *exec_ctx, const char *key, - const uint8_t *value, size_t value_len, +static void verify_binary_header_size(grpc_exec_ctx* exec_ctx, const char* key, + const uint8_t* value, size_t value_len, bool intern_key, bool intern_value) { grpc_mdelem elem = grpc_mdelem_from_slices( exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key), @@ -320,7 +320,7 @@ static void verify_binary_header_size(grpc_exec_ctx *exec_ctx, const char *key, GPR_ASSERT(grpc_is_binary_header(GRPC_MDKEY(elem))); size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false); grpc_slice value_slice = - grpc_slice_from_copied_buffer((const char *)value, value_len); + grpc_slice_from_copied_buffer((const char*)value, value_len); grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice); size_t expected_size = 32 + strlen(key) + GRPC_SLICE_LENGTH(base64_encoded); GPR_ASSERT(expected_size == elem_size); @@ -384,7 +384,7 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) { grpc_shutdown(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_no_op(); for (int k = 0; k <= 1; k++) { diff --git a/test/core/transport/status_conversion_test.cc b/test/core/transport/status_conversion_test.cc index 02dad86693..7af5d12cb7 100644 --- a/test/core/transport/status_conversion_test.cc +++ b/test/core/transport/status_conversion_test.cc @@ -34,7 +34,7 @@ #define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \ GPR_ASSERT(grpc_http2_status_to_grpc_status(a) == (b)) -int main(int argc, char **argv) { +int main(int argc, char** argv) { int i; grpc_test_init(argc, argv); diff --git a/test/core/transport/stream_owned_slice_test.cc b/test/core/transport/stream_owned_slice_test.cc index 774ad4e72e..0b592a0496 100644 --- a/test/core/transport/stream_owned_slice_test.cc +++ b/test/core/transport/stream_owned_slice_test.cc @@ -22,9 +22,9 @@ #include <grpc/support/log.h> -static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} +static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); uint8_t buffer[] = "abc123"; diff --git a/test/core/transport/timeout_encoding_test.cc b/test/core/transport/timeout_encoding_test.cc index 30357faed3..0930bc836d 100644 --- a/test/core/transport/timeout_encoding_test.cc +++ b/test/core/transport/timeout_encoding_test.cc @@ -31,7 +31,7 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) -static void assert_encodes_as(grpc_millis ts, const char *s) { +static void assert_encodes_as(grpc_millis ts, const char* s) { char buffer[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE]; grpc_http2_encode_timeout(ts, buffer); gpr_log(GPR_INFO, "check '%s' == '%s'", buffer, s); @@ -63,7 +63,7 @@ void test_encoding(void) { assert_encodes_as(10 * 60 * 60 * GPR_MS_PER_SEC, "10H"); } -static void assert_decodes_as(const char *buffer, grpc_millis expected) { +static void assert_decodes_as(const char* buffer, grpc_millis expected) { grpc_millis got; uint32_t hash = gpr_murmur_hash3(buffer, strlen(buffer), 0); gpr_log(GPR_INFO, "check decoding '%s' (hash=0x%x)", buffer, hash); @@ -81,7 +81,7 @@ void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) { 1234567, 12345678, 123456789, 98765432, 9876543, 987654, 98765, 9876, 987, 98, 9}; unsigned i; - char *input; + char* input; for (i = 0; i < GPR_ARRAY_SIZE(test_vals); i++) { gpr_asprintf(&input, "%ld%c", test_vals[i], ext); assert_decodes_as(input, answer(test_vals[i])); @@ -133,7 +133,7 @@ void test_decoding(void) { assert_decodes_as("9999999999S", GRPC_MILLIS_INF_FUTURE); } -static void assert_decoding_fails(const char *s) { +static void assert_decoding_fails(const char* s) { grpc_millis x; GPR_ASSERT(0 == grpc_http2_decode_timeout(grpc_slice_from_static_string(s), &x)); @@ -152,7 +152,7 @@ void test_decoding_fails(void) { assert_decoding_fails("-1u"); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_encoding(); test_decoding(); diff --git a/test/core/tsi/fake_transport_security_test.cc b/test/core/tsi/fake_transport_security_test.cc index 6561028860..32b0f898af 100644 --- a/test/core/tsi/fake_transport_security_test.cc +++ b/test/core/tsi/fake_transport_security_test.cc @@ -33,18 +33,18 @@ typedef struct fake_tsi_test_fixture { tsi_test_fixture base; } fake_tsi_test_fixture; -static void fake_test_setup_handshakers(tsi_test_fixture *fixture) { +static void fake_test_setup_handshakers(tsi_test_fixture* fixture) { fixture->client_handshaker = tsi_create_fake_handshaker(true /* is_client. */); fixture->server_handshaker = tsi_create_fake_handshaker(false /* is_client. */); } -static void validate_handshaker_peers(tsi_handshaker_result *result) { +static void validate_handshaker_peers(tsi_handshaker_result* result) { GPR_ASSERT(result != NULL); tsi_peer peer; GPR_ASSERT(tsi_handshaker_result_extract_peer(result, &peer) == TSI_OK); - const tsi_peer_property *property = + const tsi_peer_property* property = tsi_peer_get_property_by_name(&peer, TSI_CERTIFICATE_TYPE_PEER_PROPERTY); GPR_ASSERT(property != NULL); GPR_ASSERT(memcmp(property->value.data, TSI_FAKE_CERTIFICATE_TYPE, @@ -52,47 +52,47 @@ static void validate_handshaker_peers(tsi_handshaker_result *result) { tsi_peer_destruct(&peer); } -static void fake_test_check_handshaker_peers(tsi_test_fixture *fixture) { +static void fake_test_check_handshaker_peers(tsi_test_fixture* fixture) { validate_handshaker_peers(fixture->client_result); validate_handshaker_peers(fixture->server_result); } -static void fake_test_destruct(tsi_test_fixture *fixture) {} +static void fake_test_destruct(tsi_test_fixture* fixture) {} static const struct tsi_test_fixture_vtable vtable = { fake_test_setup_handshakers, fake_test_check_handshaker_peers, fake_test_destruct}; -static tsi_test_fixture *fake_tsi_test_fixture_create() { - fake_tsi_test_fixture *fake_fixture = - static_cast<fake_tsi_test_fixture *>(gpr_zalloc(sizeof(*fake_fixture))); +static tsi_test_fixture* fake_tsi_test_fixture_create() { + fake_tsi_test_fixture* fake_fixture = + static_cast<fake_tsi_test_fixture*>(gpr_zalloc(sizeof(*fake_fixture))); tsi_test_fixture_init(&fake_fixture->base); fake_fixture->base.vtable = &vtable; return &fake_fixture->base; } void fake_tsi_test_do_handshake_tiny_handshake_buffer() { - tsi_test_fixture *fixture = fake_tsi_test_fixture_create(); + tsi_test_fixture* fixture = fake_tsi_test_fixture_create(); fixture->handshake_buffer_size = TSI_TEST_TINY_HANDSHAKE_BUFFER_SIZE; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void fake_tsi_test_do_handshake_small_handshake_buffer() { - tsi_test_fixture *fixture = fake_tsi_test_fixture_create(); + tsi_test_fixture* fixture = fake_tsi_test_fixture_create(); fixture->handshake_buffer_size = TSI_TEST_SMALL_HANDSHAKE_BUFFER_SIZE; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void fake_tsi_test_do_handshake() { - tsi_test_fixture *fixture = fake_tsi_test_fixture_create(); + tsi_test_fixture* fixture = fake_tsi_test_fixture_create(); tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void fake_tsi_test_do_round_trip_for_all_configs() { - unsigned int *bit_array = static_cast<unsigned int *>( + unsigned int* bit_array = static_cast<unsigned int*>( gpr_zalloc(sizeof(unsigned int) * TSI_TEST_NUM_OF_ARGUMENTS)); const unsigned int mask = 1U << (TSI_TEST_NUM_OF_ARGUMENTS - 1); for (unsigned int val = 0; val < TSI_TEST_NUM_OF_COMBINATIONS; val++) { @@ -101,8 +101,8 @@ void fake_tsi_test_do_round_trip_for_all_configs() { bit_array[ind] = (v & mask) ? 1 : 0; v <<= 1; } - tsi_test_fixture *fixture = fake_tsi_test_fixture_create(); - fake_tsi_test_fixture *fake_fixture = (fake_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = fake_tsi_test_fixture_create(); + fake_tsi_test_fixture* fake_fixture = (fake_tsi_test_fixture*)fixture; tsi_test_frame_protector_config_destroy(fake_fixture->base.config); fake_fixture->base.config = tsi_test_frame_protector_config_create( bit_array[0], bit_array[1], bit_array[2], bit_array[3], bit_array[4], @@ -121,9 +121,9 @@ void fake_tsi_test_do_round_trip_odd_buffer_size() { for (size_t ind3 = 0; ind3 < size; ind3++) { for (size_t ind4 = 0; ind4 < size; ind4++) { for (size_t ind5 = 0; ind5 < size; ind5++) { - tsi_test_fixture *fixture = fake_tsi_test_fixture_create(); - fake_tsi_test_fixture *fake_fixture = - (fake_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = fake_tsi_test_fixture_create(); + fake_tsi_test_fixture* fake_fixture = + (fake_tsi_test_fixture*)fixture; tsi_test_frame_protector_config_set_buffer_size( fake_fixture->base.config, odd_sizes[ind1], odd_sizes[ind2], odd_sizes[ind3], odd_sizes[ind4], odd_sizes[ind5]); @@ -136,7 +136,7 @@ void fake_tsi_test_do_round_trip_odd_buffer_size() { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); fake_tsi_test_do_handshake_tiny_handshake_buffer(); diff --git a/test/core/tsi/ssl_transport_security_test.cc b/test/core/tsi/ssl_transport_security_test.cc index 27b2049dd8..0903ce8625 100644 --- a/test/core/tsi/ssl_transport_security_test.cc +++ b/test/core/tsi/ssl_transport_security_test.cc @@ -52,8 +52,8 @@ typedef enum AlpnMode { typedef struct ssl_alpn_lib { AlpnMode alpn_mode; - char **server_alpn_protocols; - char **client_alpn_protocols; + char** server_alpn_protocols; + char** client_alpn_protocols; uint16_t num_server_alpn_protocols; uint16_t num_client_alpn_protocols; } ssl_alpn_lib; @@ -61,9 +61,9 @@ typedef struct ssl_alpn_lib { typedef struct ssl_key_cert_lib { bool use_bad_server_cert; bool use_bad_client_cert; - char *root_cert; - tsi_ssl_pem_key_cert_pair *server_pem_key_cert_pairs; - tsi_ssl_pem_key_cert_pair *bad_server_pem_key_cert_pairs; + char* root_cert; + tsi_ssl_pem_key_cert_pair* server_pem_key_cert_pairs; + tsi_ssl_pem_key_cert_pair* bad_server_pem_key_cert_pairs; tsi_ssl_pem_key_cert_pair client_pem_key_cert_pair; tsi_ssl_pem_key_cert_pair bad_client_pem_key_cert_pair; uint16_t server_num_key_cert_pairs; @@ -72,29 +72,29 @@ typedef struct ssl_key_cert_lib { typedef struct ssl_tsi_test_fixture { tsi_test_fixture base; - ssl_key_cert_lib *key_cert_lib; - ssl_alpn_lib *alpn_lib; + ssl_key_cert_lib* key_cert_lib; + ssl_alpn_lib* alpn_lib; bool force_client_auth; - char *server_name_indication; - tsi_ssl_server_handshaker_factory *server_handshaker_factory; - tsi_ssl_client_handshaker_factory *client_handshaker_factory; + char* server_name_indication; + tsi_ssl_server_handshaker_factory* server_handshaker_factory; + tsi_ssl_client_handshaker_factory* client_handshaker_factory; } ssl_tsi_test_fixture; -static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) { - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; +static void ssl_test_setup_handshakers(tsi_test_fixture* fixture) { + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; GPR_ASSERT(ssl_fixture != NULL); GPR_ASSERT(ssl_fixture->key_cert_lib != NULL); GPR_ASSERT(ssl_fixture->alpn_lib != NULL); - ssl_key_cert_lib *key_cert_lib = ssl_fixture->key_cert_lib; - ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib; + ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib; + ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; /* Create client handshaker factory. */ - tsi_ssl_pem_key_cert_pair *client_key_cert_pair = NULL; + tsi_ssl_pem_key_cert_pair* client_key_cert_pair = NULL; if (ssl_fixture->force_client_auth) { client_key_cert_pair = key_cert_lib->use_bad_client_cert ? &key_cert_lib->bad_client_pem_key_cert_pair : &key_cert_lib->client_pem_key_cert_pair; } - char **client_alpn_protocols = NULL; + char** client_alpn_protocols = NULL; uint16_t num_client_alpn_protocols = 0; if (alpn_lib->alpn_mode == ALPN_CLIENT_NO_SERVER || alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK || @@ -104,11 +104,10 @@ static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) { } GPR_ASSERT(tsi_create_ssl_client_handshaker_factory( client_key_cert_pair, key_cert_lib->root_cert, NULL, - (const char **)client_alpn_protocols, - num_client_alpn_protocols, + (const char**)client_alpn_protocols, num_client_alpn_protocols, &ssl_fixture->client_handshaker_factory) == TSI_OK); /* Create server handshaker factory. */ - char **server_alpn_protocols = NULL; + char** server_alpn_protocols = NULL; uint16_t num_server_alpn_protocols = 0; if (alpn_lib->alpn_mode == ALPN_SERVER_NO_CLIENT || alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK || @@ -127,18 +126,17 @@ static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) { ? key_cert_lib->bad_server_num_key_cert_pairs : key_cert_lib->server_num_key_cert_pairs, key_cert_lib->root_cert, ssl_fixture->force_client_auth, NULL, - (const char **)server_alpn_protocols, - num_server_alpn_protocols, + (const char**)server_alpn_protocols, num_server_alpn_protocols, &ssl_fixture->server_handshaker_factory) == TSI_OK); /* Create server and client handshakers. */ - tsi_handshaker *client_handshaker = NULL; + tsi_handshaker* client_handshaker = NULL; GPR_ASSERT(tsi_ssl_client_handshaker_factory_create_handshaker( ssl_fixture->client_handshaker_factory, ssl_fixture->server_name_indication, &client_handshaker) == TSI_OK); ssl_fixture->base.client_handshaker = tsi_create_adapter_handshaker(client_handshaker); - tsi_handshaker *server_handshaker = NULL; + tsi_handshaker* server_handshaker = NULL; GPR_ASSERT(tsi_ssl_server_handshaker_factory_create_handshaker( ssl_fixture->server_handshaker_factory, &server_handshaker) == TSI_OK); @@ -146,40 +144,40 @@ static void ssl_test_setup_handshakers(tsi_test_fixture *fixture) { tsi_create_adapter_handshaker(server_handshaker); } -static void check_alpn(ssl_tsi_test_fixture *ssl_fixture, - const tsi_peer *peer) { +static void check_alpn(ssl_tsi_test_fixture* ssl_fixture, + const tsi_peer* peer) { GPR_ASSERT(ssl_fixture != NULL); GPR_ASSERT(ssl_fixture->alpn_lib != NULL); - ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib; - const tsi_peer_property *alpn_property = + ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; + const tsi_peer_property* alpn_property = tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL); if (alpn_lib->alpn_mode != ALPN_CLIENT_SERVER_OK) { GPR_ASSERT(alpn_property == NULL); } else { GPR_ASSERT(alpn_property != NULL); - const char *expected_match = "baz"; + const char* expected_match = "baz"; GPR_ASSERT(memcmp(alpn_property->value.data, expected_match, alpn_property->value.length) == 0); } } -static const tsi_peer_property * -check_basic_authenticated_peer_and_get_common_name(const tsi_peer *peer) { - const tsi_peer_property *cert_type_property = +static const tsi_peer_property* +check_basic_authenticated_peer_and_get_common_name(const tsi_peer* peer) { + const tsi_peer_property* cert_type_property = tsi_peer_get_property_by_name(peer, TSI_CERTIFICATE_TYPE_PEER_PROPERTY); GPR_ASSERT(cert_type_property != NULL); GPR_ASSERT(memcmp(cert_type_property->value.data, TSI_X509_CERTIFICATE_TYPE, cert_type_property->value.length) == 0); - const tsi_peer_property *property = tsi_peer_get_property_by_name( + const tsi_peer_property* property = tsi_peer_get_property_by_name( peer, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY); GPR_ASSERT(property != NULL); return property; } -void check_server0_peer(tsi_peer *peer) { - const tsi_peer_property *property = +void check_server0_peer(tsi_peer* peer) { + const tsi_peer_property* property = check_basic_authenticated_peer_and_get_common_name(peer); - const char *expected_match = "*.test.google.com.au"; + const char* expected_match = "*.test.google.com.au"; GPR_ASSERT(memcmp(property->value.data, expected_match, property->value.length) == 0); GPR_ASSERT(tsi_peer_get_property_by_name( @@ -194,9 +192,9 @@ void check_server0_peer(tsi_peer *peer) { tsi_peer_destruct(peer); } -static bool check_subject_alt_name(tsi_peer *peer, const char *name) { +static bool check_subject_alt_name(tsi_peer* peer, const char* name) { for (size_t i = 0; i < peer->property_count; i++) { - const tsi_peer_property *prop = &peer->properties[i]; + const tsi_peer_property* prop = &peer->properties[i]; if (strcmp(prop->name, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) { if (memcmp(prop->value.data, name, prop->value.length) == 0) { @@ -207,10 +205,10 @@ static bool check_subject_alt_name(tsi_peer *peer, const char *name) { return false; } -void check_server1_peer(tsi_peer *peer) { - const tsi_peer_property *property = +void check_server1_peer(tsi_peer* peer) { + const tsi_peer_property* property = check_basic_authenticated_peer_and_get_common_name(peer); - const char *expected_match = "*.test.google.com"; + const char* expected_match = "*.test.google.com"; GPR_ASSERT(memcmp(property->value.data, expected_match, property->value.length) == 0); GPR_ASSERT(check_subject_alt_name(peer, "*.test.google.fr") == 1); @@ -226,29 +224,29 @@ void check_server1_peer(tsi_peer *peer) { tsi_peer_destruct(peer); } -static void check_client_peer(ssl_tsi_test_fixture *ssl_fixture, - tsi_peer *peer) { +static void check_client_peer(ssl_tsi_test_fixture* ssl_fixture, + tsi_peer* peer) { GPR_ASSERT(ssl_fixture != NULL); GPR_ASSERT(ssl_fixture->alpn_lib != NULL); - ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib; + ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; if (!ssl_fixture->force_client_auth) { GPR_ASSERT(peer->property_count == (alpn_lib->alpn_mode == ALPN_CLIENT_SERVER_OK ? 1 : 0)); } else { - const tsi_peer_property *property = + const tsi_peer_property* property = check_basic_authenticated_peer_and_get_common_name(peer); - const char *expected_match = "testclient"; + const char* expected_match = "testclient"; GPR_ASSERT(memcmp(property->value.data, expected_match, property->value.length) == 0); } tsi_peer_destruct(peer); } -static void ssl_test_check_handshaker_peers(tsi_test_fixture *fixture) { - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; +static void ssl_test_check_handshaker_peers(tsi_test_fixture* fixture) { + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; GPR_ASSERT(ssl_fixture != NULL); GPR_ASSERT(ssl_fixture->key_cert_lib != NULL); - ssl_key_cert_lib *key_cert_lib = ssl_fixture->key_cert_lib; + ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib; tsi_peer peer; bool expect_success = !(key_cert_lib->use_bad_server_cert || @@ -277,17 +275,17 @@ static void ssl_test_check_handshaker_peers(tsi_test_fixture *fixture) { } static void ssl_test_pem_key_cert_pair_destroy(tsi_ssl_pem_key_cert_pair kp) { - gpr_free((void *)kp.private_key); - gpr_free((void *)kp.cert_chain); + gpr_free((void*)kp.private_key); + gpr_free((void*)kp.cert_chain); } -static void ssl_test_destruct(tsi_test_fixture *fixture) { - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; +static void ssl_test_destruct(tsi_test_fixture* fixture) { + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; if (ssl_fixture == NULL) { return; } /* Destroy ssl_alpn_lib. */ - ssl_alpn_lib *alpn_lib = ssl_fixture->alpn_lib; + ssl_alpn_lib* alpn_lib = ssl_fixture->alpn_lib; for (size_t i = 0; i < alpn_lib->num_server_alpn_protocols; i++) { gpr_free(alpn_lib->server_alpn_protocols[i]); } @@ -298,7 +296,7 @@ static void ssl_test_destruct(tsi_test_fixture *fixture) { gpr_free(alpn_lib->client_alpn_protocols); gpr_free(alpn_lib); /* Destroy ssl_key_cert_lib. */ - ssl_key_cert_lib *key_cert_lib = ssl_fixture->key_cert_lib; + ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib; for (size_t i = 0; i < key_cert_lib->server_num_key_cert_pairs; i++) { ssl_test_pem_key_cert_pair_destroy( key_cert_lib->server_pem_key_cert_pairs[i]); @@ -325,28 +323,28 @@ static const struct tsi_test_fixture_vtable vtable = { ssl_test_setup_handshakers, ssl_test_check_handshaker_peers, ssl_test_destruct}; -static char *load_file(const char *dir_path, const char *file_name) { - char *file_path = static_cast<char *>( +static char* load_file(const char* dir_path, const char* file_name) { + char* file_path = static_cast<char*>( gpr_zalloc(sizeof(char) * (strlen(dir_path) + strlen(file_name) + 1))); memcpy(file_path, dir_path, strlen(dir_path)); memcpy(file_path + strlen(dir_path), file_name, strlen(file_name)); grpc_slice slice; GPR_ASSERT(grpc_load_file(file_path, 1, &slice) == GRPC_ERROR_NONE); - char *data = grpc_slice_to_c_string(slice); + char* data = grpc_slice_to_c_string(slice); grpc_slice_unref(slice); gpr_free(file_path); return data; } -static tsi_test_fixture *ssl_tsi_test_fixture_create() { - ssl_tsi_test_fixture *ssl_fixture = - static_cast<ssl_tsi_test_fixture *>(gpr_zalloc(sizeof(*ssl_fixture))); +static tsi_test_fixture* ssl_tsi_test_fixture_create() { + ssl_tsi_test_fixture* ssl_fixture = + static_cast<ssl_tsi_test_fixture*>(gpr_zalloc(sizeof(*ssl_fixture))); tsi_test_fixture_init(&ssl_fixture->base); ssl_fixture->base.test_unused_bytes = false; ssl_fixture->base.vtable = &vtable; /* Create ssl_key_cert_lib. */ - ssl_key_cert_lib *key_cert_lib = - static_cast<ssl_key_cert_lib *>(gpr_zalloc(sizeof(*key_cert_lib))); + ssl_key_cert_lib* key_cert_lib = + static_cast<ssl_key_cert_lib*>(gpr_zalloc(sizeof(*key_cert_lib))); key_cert_lib->use_bad_server_cert = false; key_cert_lib->use_bad_client_cert = false; key_cert_lib->server_num_key_cert_pairs = @@ -354,11 +352,11 @@ static tsi_test_fixture *ssl_tsi_test_fixture_create() { key_cert_lib->bad_server_num_key_cert_pairs = SSL_TSI_TEST_BAD_SERVER_KEY_CERT_PAIRS_NUM; key_cert_lib->server_pem_key_cert_pairs = - static_cast<tsi_ssl_pem_key_cert_pair *>( + static_cast<tsi_ssl_pem_key_cert_pair*>( gpr_malloc(sizeof(tsi_ssl_pem_key_cert_pair) * key_cert_lib->server_num_key_cert_pairs)); key_cert_lib->bad_server_pem_key_cert_pairs = - static_cast<tsi_ssl_pem_key_cert_pair *>( + static_cast<tsi_ssl_pem_key_cert_pair*>( gpr_malloc(sizeof(tsi_ssl_pem_key_cert_pair) * key_cert_lib->bad_server_num_key_cert_pairs)); key_cert_lib->server_pem_key_cert_pairs[0].private_key = @@ -384,12 +382,12 @@ static tsi_test_fixture *ssl_tsi_test_fixture_create() { key_cert_lib->root_cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "ca.pem"); ssl_fixture->key_cert_lib = key_cert_lib; /* Create ssl_alpn_lib. */ - ssl_alpn_lib *alpn_lib = - static_cast<ssl_alpn_lib *>(gpr_zalloc(sizeof(*alpn_lib))); + ssl_alpn_lib* alpn_lib = + static_cast<ssl_alpn_lib*>(gpr_zalloc(sizeof(*alpn_lib))); alpn_lib->server_alpn_protocols = - static_cast<char **>(gpr_zalloc(sizeof(char *) * SSL_TSI_TEST_ALPN_NUM)); + static_cast<char**>(gpr_zalloc(sizeof(char*) * SSL_TSI_TEST_ALPN_NUM)); alpn_lib->client_alpn_protocols = - static_cast<char **>(gpr_zalloc(sizeof(char *) * SSL_TSI_TEST_ALPN_NUM)); + static_cast<char**>(gpr_zalloc(sizeof(char*) * SSL_TSI_TEST_ALPN_NUM)); alpn_lib->server_alpn_protocols[0] = gpr_strdup(SSL_TSI_TEST_ALPN1); alpn_lib->server_alpn_protocols[1] = gpr_strdup(SSL_TSI_TEST_ALPN3); alpn_lib->client_alpn_protocols[0] = gpr_strdup(SSL_TSI_TEST_ALPN2); @@ -405,28 +403,28 @@ static tsi_test_fixture *ssl_tsi_test_fixture_create() { } void ssl_tsi_test_do_handshake_tiny_handshake_buffer() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); fixture->handshake_buffer_size = TSI_TEST_TINY_HANDSHAKE_BUFFER_SIZE; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_small_handshake_buffer() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); fixture->handshake_buffer_size = TSI_TEST_SMALL_HANDSHAKE_BUFFER_SIZE; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_with_client_authentication() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->force_client_auth = true; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); @@ -434,35 +432,35 @@ void ssl_tsi_test_do_handshake_with_client_authentication() { void ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain() { /* server1 cert contains "waterzooi.test.google.be" in SAN. */ - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->server_name_indication = - const_cast<char *>("waterzooi.test.google.be"); + const_cast<char*>("waterzooi.test.google.be"); tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain() { /* server1 cert contains "*.test.google.fr" in SAN. */ - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->server_name_indication = - const_cast<char *>("juju.test.google.fr"); + const_cast<char*>("juju.test.google.fr"); tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_with_bad_server_cert() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->key_cert_lib->use_bad_server_cert = true; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_with_bad_client_cert() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->key_cert_lib->use_bad_client_cert = true; ssl_fixture->force_client_auth = true; tsi_test_do_handshake(fixture); @@ -470,39 +468,39 @@ void ssl_tsi_test_do_handshake_with_bad_client_cert() { } void ssl_tsi_test_do_handshake_alpn_client_no_server() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_NO_SERVER; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_alpn_server_no_client() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->alpn_lib->alpn_mode = ALPN_SERVER_NO_CLIENT; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_alpn_client_server_mismatch() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_SERVER_MISMATCH; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_handshake_alpn_client_server_ok() { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_SERVER_OK; tsi_test_do_handshake(fixture); tsi_test_fixture_destroy(fixture); } void ssl_tsi_test_do_round_trip_for_all_configs() { - unsigned int *bit_array = static_cast<unsigned int *>( + unsigned int* bit_array = static_cast<unsigned int*>( gpr_zalloc(sizeof(unsigned int) * TSI_TEST_NUM_OF_ARGUMENTS)); const unsigned int mask = 1U << (TSI_TEST_NUM_OF_ARGUMENTS - 1); for (unsigned int val = 0; val < TSI_TEST_NUM_OF_COMBINATIONS; val++) { @@ -511,8 +509,8 @@ void ssl_tsi_test_do_round_trip_for_all_configs() { bit_array[ind] = (v & mask) ? 1 : 0; v <<= 1; } - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; tsi_test_frame_protector_config_destroy(ssl_fixture->base.config); ssl_fixture->base.config = tsi_test_frame_protector_config_create( bit_array[0], bit_array[1], bit_array[2], bit_array[3], bit_array[4], @@ -531,8 +529,8 @@ void ssl_tsi_test_do_round_trip_odd_buffer_size() { for (size_t ind3 = 0; ind3 < size; ind3++) { for (size_t ind4 = 0; ind4 < size; ind4++) { for (size_t ind5 = 0; ind5 < size; ind5++) { - tsi_test_fixture *fixture = ssl_tsi_test_fixture_create(); - ssl_tsi_test_fixture *ssl_fixture = (ssl_tsi_test_fixture *)fixture; + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture; tsi_test_frame_protector_config_set_buffer_size( ssl_fixture->base.config, odd_sizes[ind1], odd_sizes[ind2], odd_sizes[ind3], odd_sizes[ind4], odd_sizes[ind5]); @@ -545,11 +543,11 @@ void ssl_tsi_test_do_round_trip_odd_buffer_size() { } } -static const tsi_ssl_handshaker_factory_vtable *original_vtable; +static const tsi_ssl_handshaker_factory_vtable* original_vtable; static bool handshaker_factory_destructor_called; static void ssl_tsi_test_handshaker_factory_destructor( - tsi_ssl_handshaker_factory *factory) { + tsi_ssl_handshaker_factory* factory) { GPR_ASSERT(factory != NULL); handshaker_factory_destructor_called = true; if (original_vtable != NULL && original_vtable->destroy != NULL) { @@ -562,20 +560,20 @@ static tsi_ssl_handshaker_factory_vtable test_handshaker_factory_vtable = { void test_tsi_ssl_client_handshaker_factory_refcounting() { int i; - const char *cert_chain = + const char* cert_chain = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "client.pem"); - tsi_ssl_client_handshaker_factory *client_handshaker_factory; + tsi_ssl_client_handshaker_factory* client_handshaker_factory; GPR_ASSERT(tsi_create_ssl_client_handshaker_factory( NULL, cert_chain, NULL, NULL, 0, &client_handshaker_factory) == TSI_OK); handshaker_factory_destructor_called = false; original_vtable = tsi_ssl_handshaker_factory_swap_vtable( - (tsi_ssl_handshaker_factory *)client_handshaker_factory, + (tsi_ssl_handshaker_factory*)client_handshaker_factory, &test_handshaker_factory_vtable); - tsi_handshaker *handshaker[3]; + tsi_handshaker* handshaker[3]; for (i = 0; i < 3; ++i) { GPR_ASSERT(tsi_ssl_client_handshaker_factory_create_handshaker( @@ -595,14 +593,14 @@ void test_tsi_ssl_client_handshaker_factory_refcounting() { tsi_handshaker_destroy(handshaker[2]); GPR_ASSERT(handshaker_factory_destructor_called); - gpr_free((void *)cert_chain); + gpr_free((void*)cert_chain); } void test_tsi_ssl_server_handshaker_factory_refcounting() { int i; - tsi_ssl_server_handshaker_factory *server_handshaker_factory; - tsi_handshaker *handshaker[3]; - const char *cert_chain = + tsi_ssl_server_handshaker_factory* server_handshaker_factory; + tsi_handshaker* handshaker[3]; + const char* cert_chain = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "server0.pem"); tsi_ssl_pem_key_cert_pair cert_pair; @@ -616,7 +614,7 @@ void test_tsi_ssl_server_handshaker_factory_refcounting() { handshaker_factory_destructor_called = false; original_vtable = tsi_ssl_handshaker_factory_swap_vtable( - (tsi_ssl_handshaker_factory *)server_handshaker_factory, + (tsi_ssl_handshaker_factory*)server_handshaker_factory, &test_handshaker_factory_vtable); for (i = 0; i < 3; ++i) { @@ -642,9 +640,9 @@ void test_tsi_ssl_server_handshaker_factory_refcounting() { /* Attempting to create a handshaker factory with invalid parameters should fail * but not crash. */ void test_tsi_ssl_client_handshaker_factory_bad_params() { - const char *cert_chain = "This is not a valid PEM file."; + const char* cert_chain = "This is not a valid PEM file."; - tsi_ssl_client_handshaker_factory *client_handshaker_factory; + tsi_ssl_client_handshaker_factory* client_handshaker_factory; GPR_ASSERT(tsi_create_ssl_client_handshaker_factory( NULL, cert_chain, NULL, NULL, 0, &client_handshaker_factory) == TSI_INVALID_ARGUMENT); @@ -657,7 +655,7 @@ void ssl_tsi_test_handshaker_factory_internals() { test_tsi_ssl_client_handshaker_factory_bad_params(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); ssl_tsi_test_do_handshake_tiny_handshake_buffer(); diff --git a/test/core/tsi/transport_security_test.cc b/test/core/tsi/transport_security_test.cc index c1be1e952d..39adf2fab6 100644 --- a/test/core/tsi/transport_security_test.cc +++ b/test/core/tsi/transport_security_test.cc @@ -37,17 +37,17 @@ typedef struct { int expected; /* Host name to match. */ - const char *host_name; + const char* host_name; /* Common name (CN). */ - const char *common_name; + const char* common_name; /* Comma separated list of certificate names to match against. Any occurrence of '#' will be replaced with a null character before processing. */ - const char *dns_names; + const char* dns_names; /* Comma separated list of IP SANs to match aggainst */ - const char *ip_names; + const char* ip_names; } cert_name_test_entry; /* Largely inspired from: @@ -189,26 +189,26 @@ const cert_name_test_entry cert_name_test_entries[] = { }; typedef struct name_list { - const char *name; - struct name_list *next; + const char* name; + struct name_list* next; } name_list; typedef struct { size_t name_count; - char *buffer; - name_list *names; + char* buffer; + name_list* names; } parsed_names; -name_list *name_list_add(const char *n) { - name_list *result = static_cast<name_list *>(gpr_malloc(sizeof(name_list))); +name_list* name_list_add(const char* n) { + name_list* result = static_cast<name_list*>(gpr_malloc(sizeof(name_list))); result->name = n; result->next = NULL; return result; } -static parsed_names parse_names(const char *names_str) { +static parsed_names parse_names(const char* names_str) { parsed_names result; - name_list *current_nl; + name_list* current_nl; size_t i; memset(&result, 0, sizeof(parsed_names)); if (names_str == 0) return result; @@ -228,18 +228,18 @@ static parsed_names parse_names(const char *names_str) { return result; } -static void destruct_parsed_names(parsed_names *pdn) { - name_list *nl = pdn->names; +static void destruct_parsed_names(parsed_names* pdn) { + name_list* nl = pdn->names; if (pdn->buffer != NULL) gpr_free(pdn->buffer); while (nl != NULL) { - name_list *to_be_free = nl; + name_list* to_be_free = nl; nl = nl->next; gpr_free(to_be_free); } } -static char *processed_name(const char *name) { - char *result = gpr_strdup(name); +static char* processed_name(const char* name) { + char* result = gpr_strdup(name); size_t i; for (i = 0; i < strlen(result); i++) { if (result[i] == '#') { @@ -250,10 +250,10 @@ static char *processed_name(const char *name) { } static tsi_peer peer_from_cert_name_test_entry( - const cert_name_test_entry *entry) { + const cert_name_test_entry* entry) { size_t i; tsi_peer peer; - name_list *nl; + name_list* nl; parsed_names dns_entries = parse_names(entry->dns_names); parsed_names ip_entries = parse_names(entry->ip_names); nl = dns_entries.names; @@ -265,7 +265,7 @@ static tsi_peer peer_from_cert_name_test_entry( &peer.properties[0]) == TSI_OK); i = 1; while (nl != NULL) { - char *processed = processed_name(nl->name); + char* processed = processed_name(nl->name); GPR_ASSERT(tsi_construct_string_peer_property( TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed, strlen(nl->name), &peer.properties[i++]) == TSI_OK); @@ -275,7 +275,7 @@ static tsi_peer peer_from_cert_name_test_entry( nl = ip_entries.names; while (nl != NULL) { - char *processed = processed_name(nl->name); + char* processed = processed_name(nl->name); GPR_ASSERT(tsi_construct_string_peer_property( TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed, strlen(nl->name), &peer.properties[i++]) == TSI_OK); @@ -287,8 +287,8 @@ static tsi_peer peer_from_cert_name_test_entry( return peer; } -char *cert_name_test_entry_to_string(const cert_name_test_entry *entry) { - char *s; +char* cert_name_test_entry_to_string(const cert_name_test_entry* entry) { + char* s; gpr_asprintf(&s, "{ success = %s, host_name = %s, common_name = %s, dns_names = " "%s, ip_names = %s}", @@ -302,11 +302,11 @@ char *cert_name_test_entry_to_string(const cert_name_test_entry *entry) { static void test_peer_matches_name(void) { size_t i = 0; for (i = 0; i < GPR_ARRAY_SIZE(cert_name_test_entries); i++) { - const cert_name_test_entry *entry = &cert_name_test_entries[i]; + const cert_name_test_entry* entry = &cert_name_test_entries[i]; tsi_peer peer = peer_from_cert_name_test_entry(entry); int result = tsi_ssl_peer_matches_name(&peer, entry->host_name); if (result != entry->expected) { - char *entry_str = cert_name_test_entry_to_string(entry); + char* entry_str = cert_name_test_entry_to_string(entry); gpr_log(GPR_ERROR, "%s", entry_str); gpr_free(entry_str); GPR_ASSERT(0); /* Unexpected result. */ @@ -317,7 +317,7 @@ static void test_peer_matches_name(void) { typedef struct { tsi_result res; - const char *str; + const char* str; } tsi_result_string_pair; static void test_result_strings(void) { @@ -366,16 +366,16 @@ static void test_handshaker_invalid_args(void) { } static void test_handshaker_invalid_state(void) { - tsi_handshaker *h = tsi_create_fake_handshaker(0); + tsi_handshaker* h = tsi_create_fake_handshaker(0); tsi_peer peer; - tsi_frame_protector *p; + tsi_frame_protector* p; GPR_ASSERT(tsi_handshaker_extract_peer(h, &peer) == TSI_FAILED_PRECONDITION); GPR_ASSERT(tsi_handshaker_create_frame_protector(h, NULL, &p) == TSI_FAILED_PRECONDITION); tsi_handshaker_destroy(h); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_peer_matches_name(); test_result_strings(); diff --git a/test/core/tsi/transport_security_test_lib.cc b/test/core/tsi/transport_security_test_lib.cc index b98ab9ba05..af8316873e 100644 --- a/test/core/tsi/transport_security_test_lib.cc +++ b/test/core/tsi/transport_security_test_lib.cc @@ -27,14 +27,14 @@ #include "src/core/lib/security/transport/tsi_error.h" #include "test/core/tsi/transport_security_test_lib.h" -static void notification_signal(tsi_test_fixture *fixture) { +static void notification_signal(tsi_test_fixture* fixture) { gpr_mu_lock(&fixture->mu); fixture->notified = true; gpr_cv_signal(&fixture->cv); gpr_mu_unlock(&fixture->mu); } -static void notification_wait(tsi_test_fixture *fixture) { +static void notification_wait(tsi_test_fixture* fixture) { gpr_mu_lock(&fixture->mu); while (!fixture->notified) { gpr_cv_wait(&fixture->cv, &fixture->mu, gpr_inf_future(GPR_CLOCK_REALTIME)); @@ -44,53 +44,53 @@ static void notification_wait(tsi_test_fixture *fixture) { } typedef struct handshaker_args { - tsi_test_fixture *fixture; - unsigned char *handshake_buffer; + tsi_test_fixture* fixture; + unsigned char* handshake_buffer; size_t handshake_buffer_size; bool is_client; bool transferred_data; bool appended_unused_bytes; - grpc_error *error; + grpc_error* error; } handshaker_args; -static handshaker_args *handshaker_args_create(tsi_test_fixture *fixture, +static handshaker_args* handshaker_args_create(tsi_test_fixture* fixture, bool is_client) { GPR_ASSERT(fixture != NULL); GPR_ASSERT(fixture->config != NULL); - handshaker_args *args = - static_cast<handshaker_args *>(gpr_zalloc(sizeof(*args))); + handshaker_args* args = + static_cast<handshaker_args*>(gpr_zalloc(sizeof(*args))); args->fixture = fixture; args->handshake_buffer_size = fixture->handshake_buffer_size; args->handshake_buffer = - static_cast<unsigned char *>(gpr_zalloc(args->handshake_buffer_size)); + static_cast<unsigned char*>(gpr_zalloc(args->handshake_buffer_size)); args->is_client = is_client; args->error = GRPC_ERROR_NONE; return args; } -static void handshaker_args_destroy(handshaker_args *args) { +static void handshaker_args_destroy(handshaker_args* args) { gpr_free(args->handshake_buffer); GRPC_ERROR_UNREF(args->error); gpr_free(args); } -static void do_handshaker_next(handshaker_args *args); +static void do_handshaker_next(handshaker_args* args); -static void setup_handshakers(tsi_test_fixture *fixture) { +static void setup_handshakers(tsi_test_fixture* fixture) { GPR_ASSERT(fixture != NULL); GPR_ASSERT(fixture->vtable != NULL); GPR_ASSERT(fixture->vtable->setup_handshakers != NULL); fixture->vtable->setup_handshakers(fixture); } -static void check_unused_bytes(tsi_test_fixture *fixture) { - tsi_handshaker_result *result_with_unused_bytes = +static void check_unused_bytes(tsi_test_fixture* fixture) { + tsi_handshaker_result* result_with_unused_bytes = fixture->has_client_finished_first ? fixture->server_result : fixture->client_result; - tsi_handshaker_result *result_without_unused_bytes = + tsi_handshaker_result* result_without_unused_bytes = fixture->has_client_finished_first ? fixture->client_result : fixture->server_result; - const unsigned char *bytes = NULL; + const unsigned char* bytes = NULL; size_t bytes_size = 0; GPR_ASSERT(tsi_handshaker_result_get_unused_bytes( result_with_unused_bytes, &bytes, &bytes_size) == TSI_OK); @@ -102,7 +102,7 @@ static void check_unused_bytes(tsi_test_fixture *fixture) { GPR_ASSERT(bytes == NULL); } -static void check_handshake_results(tsi_test_fixture *fixture) { +static void check_handshake_results(tsi_test_fixture* fixture) { GPR_ASSERT(fixture != NULL); GPR_ASSERT(fixture->vtable != NULL); GPR_ASSERT(fixture->vtable->check_handshaker_peers != NULL); @@ -120,15 +120,15 @@ static void check_handshake_results(tsi_test_fixture *fixture) { } } -static void send_bytes_to_peer(tsi_test_fixture *fixture, - const unsigned char *buf, size_t buf_size, +static void send_bytes_to_peer(tsi_test_fixture* fixture, + const unsigned char* buf, size_t buf_size, bool is_client) { GPR_ASSERT(fixture != NULL); GPR_ASSERT(buf != NULL); - uint8_t *channel = + uint8_t* channel = is_client ? fixture->server_channel : fixture->client_channel; GPR_ASSERT(channel != NULL); - size_t *bytes_written = is_client ? &fixture->bytes_written_to_server_channel + size_t* bytes_written = is_client ? &fixture->bytes_written_to_server_channel : &fixture->bytes_written_to_client_channel; GPR_ASSERT(bytes_written != NULL); GPR_ASSERT(*bytes_written + buf_size <= TSI_TEST_DEFAULT_CHANNEL_SIZE); @@ -137,13 +137,13 @@ static void send_bytes_to_peer(tsi_test_fixture *fixture, *bytes_written += buf_size; } -static void maybe_append_unused_bytes(handshaker_args *args) { +static void maybe_append_unused_bytes(handshaker_args* args) { GPR_ASSERT(args != NULL); GPR_ASSERT(args->fixture != NULL); - tsi_test_fixture *fixture = args->fixture; + tsi_test_fixture* fixture = args->fixture; if (fixture->test_unused_bytes && !args->appended_unused_bytes) { args->appended_unused_bytes = true; - send_bytes_to_peer(fixture, (const unsigned char *)TSI_TEST_UNUSED_BYTES, + send_bytes_to_peer(fixture, (const unsigned char*)TSI_TEST_UNUSED_BYTES, strlen(TSI_TEST_UNUSED_BYTES), args->is_client); if (fixture->client_result != NULL && fixture->server_result == NULL) { fixture->has_client_finished_first = true; @@ -151,18 +151,18 @@ static void maybe_append_unused_bytes(handshaker_args *args) { } } -static void receive_bytes_from_peer(tsi_test_fixture *fixture, - unsigned char **buf, size_t *buf_size, +static void receive_bytes_from_peer(tsi_test_fixture* fixture, + unsigned char** buf, size_t* buf_size, bool is_client) { GPR_ASSERT(fixture != NULL); GPR_ASSERT(*buf != NULL); GPR_ASSERT(buf_size != NULL); - uint8_t *channel = + uint8_t* channel = is_client ? fixture->client_channel : fixture->server_channel; GPR_ASSERT(channel != NULL); - size_t *bytes_read = is_client ? &fixture->bytes_read_from_client_channel + size_t* bytes_read = is_client ? &fixture->bytes_read_from_client_channel : &fixture->bytes_read_from_server_channel; - size_t *bytes_written = is_client ? &fixture->bytes_written_to_client_channel + size_t* bytes_written = is_client ? &fixture->bytes_written_to_client_channel : &fixture->bytes_written_to_server_channel; GPR_ASSERT(bytes_read != NULL); GPR_ASSERT(bytes_written != NULL); @@ -175,22 +175,22 @@ static void receive_bytes_from_peer(tsi_test_fixture *fixture, *bytes_read += to_read; } -static void send_message_to_peer(tsi_test_fixture *fixture, - tsi_frame_protector *protector, +static void send_message_to_peer(tsi_test_fixture* fixture, + tsi_frame_protector* protector, bool is_client) { /* Initialization. */ GPR_ASSERT(fixture != NULL); GPR_ASSERT(fixture->config != NULL); GPR_ASSERT(protector != NULL); - tsi_test_frame_protector_config *config = fixture->config; - unsigned char *protected_buffer = - static_cast<unsigned char *>(gpr_zalloc(config->protected_buffer_size)); + tsi_test_frame_protector_config* config = fixture->config; + unsigned char* protected_buffer = + static_cast<unsigned char*>(gpr_zalloc(config->protected_buffer_size)); size_t message_size = is_client ? config->client_message_size : config->server_message_size; - uint8_t *message = + uint8_t* message = is_client ? config->client_message : config->server_message; GPR_ASSERT(message != NULL); - const unsigned char *message_bytes = (const unsigned char *)message; + const unsigned char* message_bytes = (const unsigned char*)message; tsi_result result = TSI_OK; /* Do protect and send protected data to peer. */ while (message_size > 0 && result == TSI_OK) { @@ -225,25 +225,25 @@ static void send_message_to_peer(tsi_test_fixture *fixture, gpr_free(protected_buffer); } -static void receive_message_from_peer(tsi_test_fixture *fixture, - tsi_frame_protector *protector, - unsigned char *message, - size_t *bytes_received, bool is_client) { +static void receive_message_from_peer(tsi_test_fixture* fixture, + tsi_frame_protector* protector, + unsigned char* message, + size_t* bytes_received, bool is_client) { /* Initialization. */ GPR_ASSERT(fixture != NULL); GPR_ASSERT(protector != NULL); GPR_ASSERT(message != NULL); GPR_ASSERT(bytes_received != NULL); GPR_ASSERT(fixture->config != NULL); - tsi_test_frame_protector_config *config = fixture->config; + tsi_test_frame_protector_config* config = fixture->config; size_t read_offset = 0; size_t message_offset = 0; size_t read_from_peer_size = 0; tsi_result result = TSI_OK; bool done = false; - unsigned char *read_buffer = static_cast<unsigned char *>( + unsigned char* read_buffer = static_cast<unsigned char*>( gpr_zalloc(config->read_buffer_allocated_size)); - unsigned char *message_buffer = static_cast<unsigned char *>( + unsigned char* message_buffer = static_cast<unsigned char*>( gpr_zalloc(config->message_buffer_allocated_size)); /* Do unprotect on data received from peer. */ while (!done && result == TSI_OK) { @@ -282,15 +282,15 @@ static void receive_message_from_peer(tsi_test_fixture *fixture, gpr_free(message_buffer); } -grpc_error *on_handshake_next_done(tsi_result result, void *user_data, - const unsigned char *bytes_to_send, +grpc_error* on_handshake_next_done(tsi_result result, void* user_data, + const unsigned char* bytes_to_send, size_t bytes_to_send_size, - tsi_handshaker_result *handshaker_result) { - handshaker_args *args = (handshaker_args *)user_data; + tsi_handshaker_result* handshaker_result) { + handshaker_args* args = (handshaker_args*)user_data; GPR_ASSERT(args != NULL); GPR_ASSERT(args->fixture != NULL); - tsi_test_fixture *fixture = args->fixture; - grpc_error *error = GRPC_ERROR_NONE; + tsi_test_fixture* fixture = args->fixture; + grpc_error* error = GRPC_ERROR_NONE; /* Read more data if we need to. */ if (result == TSI_INCOMPLETE_DATA) { GPR_ASSERT(bytes_to_send_size == 0); @@ -304,7 +304,7 @@ grpc_error *on_handshake_next_done(tsi_result result, void *user_data, } /* Update handshaker result. */ if (handshaker_result != NULL) { - tsi_handshaker_result **result_to_write = + tsi_handshaker_result** result_to_write = args->is_client ? &fixture->client_result : &fixture->server_result; GPR_ASSERT(*result_to_write == NULL); *result_to_write = handshaker_result; @@ -323,17 +323,17 @@ grpc_error *on_handshake_next_done(tsi_result result, void *user_data, } static void on_handshake_next_done_wrapper( - tsi_result result, void *user_data, const unsigned char *bytes_to_send, - size_t bytes_to_send_size, tsi_handshaker_result *handshaker_result) { - handshaker_args *args = (handshaker_args *)user_data; + tsi_result result, void* user_data, const unsigned char* bytes_to_send, + size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) { + handshaker_args* args = (handshaker_args*)user_data; args->error = on_handshake_next_done(result, user_data, bytes_to_send, bytes_to_send_size, handshaker_result); } -static bool is_handshake_finished_properly(handshaker_args *args) { +static bool is_handshake_finished_properly(handshaker_args* args) { GPR_ASSERT(args != NULL); GPR_ASSERT(args->fixture != NULL); - tsi_test_fixture *fixture = args->fixture; + tsi_test_fixture* fixture = args->fixture; if ((args->is_client && fixture->client_result != NULL) || (!args->is_client && fixture->server_result != NULL)) { return true; @@ -341,18 +341,18 @@ static bool is_handshake_finished_properly(handshaker_args *args) { return false; } -static void do_handshaker_next(handshaker_args *args) { +static void do_handshaker_next(handshaker_args* args) { /* Initialization. */ GPR_ASSERT(args != NULL); GPR_ASSERT(args->fixture != NULL); - tsi_test_fixture *fixture = args->fixture; - tsi_handshaker *handshaker = + tsi_test_fixture* fixture = args->fixture; + tsi_handshaker* handshaker = args->is_client ? fixture->client_handshaker : fixture->server_handshaker; if (is_handshake_finished_properly(args)) { return; } - tsi_handshaker_result *handshaker_result = NULL; - unsigned char *bytes_to_send = NULL; + tsi_handshaker_result* handshaker_result = NULL; + unsigned char* bytes_to_send = NULL; size_t bytes_to_send_size = 0; tsi_result result = TSI_OK; /* Receive data from peer, if available. */ @@ -365,7 +365,7 @@ static void do_handshaker_next(handshaker_args *args) { } /* Peform handshaker next. */ result = tsi_handshaker_next(handshaker, args->handshake_buffer, buf_size, - (const unsigned char **)&bytes_to_send, + (const unsigned char**)&bytes_to_send, &bytes_to_send_size, &handshaker_result, &on_handshake_next_done_wrapper, args); if (result != TSI_ASYNC) { @@ -379,12 +379,12 @@ static void do_handshaker_next(handshaker_args *args) { notification_wait(fixture); } -void tsi_test_do_handshake(tsi_test_fixture *fixture) { +void tsi_test_do_handshake(tsi_test_fixture* fixture) { /* Initializaiton. */ setup_handshakers(fixture); - handshaker_args *client_args = + handshaker_args* client_args = handshaker_args_create(fixture, true /* is_client */); - handshaker_args *server_args = + handshaker_args* server_args = handshaker_args_create(fixture, false /* is_client */); /* Do handshake. */ do { @@ -407,13 +407,13 @@ void tsi_test_do_handshake(tsi_test_fixture *fixture) { handshaker_args_destroy(server_args); } -void tsi_test_do_round_trip(tsi_test_fixture *fixture) { +void tsi_test_do_round_trip(tsi_test_fixture* fixture) { /* Initialization. */ GPR_ASSERT(fixture != NULL); GPR_ASSERT(fixture->config != NULL); - tsi_test_frame_protector_config *config = fixture->config; - tsi_frame_protector *client_frame_protector = NULL; - tsi_frame_protector *server_frame_protector = NULL; + tsi_test_frame_protector_config* config = fixture->config; + tsi_frame_protector* client_frame_protector = NULL; + tsi_frame_protector* server_frame_protector = NULL; /* Perform handshake. */ tsi_test_do_handshake(fixture); /* Create frame protectors.*/ @@ -435,8 +435,8 @@ void tsi_test_do_round_trip(tsi_test_fixture *fixture) { &server_frame_protector) == TSI_OK); /* Client sends a message to server. */ send_message_to_peer(fixture, client_frame_protector, true /* is_client */); - unsigned char *server_received_message = - static_cast<unsigned char *>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE)); + unsigned char* server_received_message = + static_cast<unsigned char*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE)); size_t server_received_message_size = 0; receive_message_from_peer( fixture, server_frame_protector, server_received_message, @@ -446,8 +446,8 @@ void tsi_test_do_round_trip(tsi_test_fixture *fixture) { server_received_message_size) == 0); /* Server sends a message to client. */ send_message_to_peer(fixture, server_frame_protector, false /* is_client */); - unsigned char *client_received_message = - static_cast<unsigned char *>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE)); + unsigned char* client_received_message = + static_cast<unsigned char*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE)); size_t client_received_message_size = 0; receive_message_from_peer( fixture, client_frame_protector, client_received_message, @@ -462,18 +462,18 @@ void tsi_test_do_round_trip(tsi_test_fixture *fixture) { gpr_free(client_received_message); } -static unsigned char *generate_random_message(size_t size) { +static unsigned char* generate_random_message(size_t size) { size_t i; unsigned char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; - unsigned char *output = - static_cast<unsigned char *>(gpr_zalloc(sizeof(unsigned char) * size)); + unsigned char* output = + static_cast<unsigned char*>(gpr_zalloc(sizeof(unsigned char) * size)); for (i = 0; i < size - 1; ++i) { output[i] = chars[rand() % (int)(sizeof(chars) - 1)]; } return output; } -tsi_test_frame_protector_config *tsi_test_frame_protector_config_create( +tsi_test_frame_protector_config* tsi_test_frame_protector_config_create( bool use_default_read_buffer_allocated_size, bool use_default_message_buffer_allocated_size, bool use_default_protected_buffer_size, bool use_default_client_message, @@ -481,8 +481,8 @@ tsi_test_frame_protector_config *tsi_test_frame_protector_config_create( bool use_default_client_max_output_protected_frame_size, bool use_default_server_max_output_protected_frame_size, bool use_default_handshake_buffer_size) { - tsi_test_frame_protector_config *config = - static_cast<tsi_test_frame_protector_config *>( + tsi_test_frame_protector_config* config = + static_cast<tsi_test_frame_protector_config*>( gpr_zalloc(sizeof(*config))); /* Set the value for read_buffer_allocated_size. */ config->read_buffer_allocated_size = @@ -532,7 +532,7 @@ tsi_test_frame_protector_config *tsi_test_frame_protector_config_create( } void tsi_test_frame_protector_config_set_buffer_size( - tsi_test_frame_protector_config *config, size_t read_buffer_allocated_size, + tsi_test_frame_protector_config* config, size_t read_buffer_allocated_size, size_t message_buffer_allocated_size, size_t protected_buffer_size, size_t client_max_output_protected_frame_size, size_t server_max_output_protected_frame_size) { @@ -547,21 +547,21 @@ void tsi_test_frame_protector_config_set_buffer_size( } void tsi_test_frame_protector_config_destroy( - tsi_test_frame_protector_config *config) { + tsi_test_frame_protector_config* config) { GPR_ASSERT(config != NULL); gpr_free(config->client_message); gpr_free(config->server_message); gpr_free(config); } -void tsi_test_fixture_init(tsi_test_fixture *fixture) { +void tsi_test_fixture_init(tsi_test_fixture* fixture) { fixture->config = tsi_test_frame_protector_config_create( true, true, true, true, true, true, true, true); fixture->handshake_buffer_size = TSI_TEST_DEFAULT_BUFFER_SIZE; fixture->client_channel = - static_cast<uint8_t *>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE)); + static_cast<uint8_t*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE)); fixture->server_channel = - static_cast<uint8_t *>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE)); + static_cast<uint8_t*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE)); fixture->bytes_written_to_client_channel = 0; fixture->bytes_written_to_server_channel = 0; fixture->bytes_read_from_client_channel = 0; @@ -573,7 +573,7 @@ void tsi_test_fixture_init(tsi_test_fixture *fixture) { fixture->notified = false; } -void tsi_test_fixture_destroy(tsi_test_fixture *fixture) { +void tsi_test_fixture_destroy(tsi_test_fixture* fixture) { GPR_ASSERT(fixture != NULL); tsi_test_frame_protector_config_destroy(fixture->config); tsi_handshaker_destroy(fixture->client_handshaker); diff --git a/test/core/tsi/transport_security_test_lib.h b/test/core/tsi/transport_security_test_lib.h index 49a7a59c58..9b07448cc5 100644 --- a/test/core/tsi/transport_security_test_lib.h +++ b/test/core/tsi/transport_security_test_lib.h @@ -55,29 +55,29 @@ typedef struct tsi_test_frame_protector_config tsi_test_frame_protector_config; /* V-table for tsi_test_fixture operations that are implemented differently in different TSI implementations. */ typedef struct tsi_test_fixture_vtable { - void (*setup_handshakers)(tsi_test_fixture *fixture); - void (*check_handshaker_peers)(tsi_test_fixture *fixture); - void (*destruct)(tsi_test_fixture *fixture); + void (*setup_handshakers)(tsi_test_fixture* fixture); + void (*check_handshaker_peers)(tsi_test_fixture* fixture); + void (*destruct)(tsi_test_fixture* fixture); } tsi_test_fixture_vtable; struct tsi_test_fixture { - const tsi_test_fixture_vtable *vtable; + const tsi_test_fixture_vtable* vtable; /* client/server TSI handshaker used to perform TSI handshakes, and will get instantiated during the call to setup_handshakers. */ - tsi_handshaker *client_handshaker; - tsi_handshaker *server_handshaker; + tsi_handshaker* client_handshaker; + tsi_handshaker* server_handshaker; /* client/server TSI handshaker results used to store the result of TSI handshake. If the handshake fails, the result will store NULL upon finishing the handshake. */ - tsi_handshaker_result *client_result; - tsi_handshaker_result *server_result; + tsi_handshaker_result* client_result; + tsi_handshaker_result* server_result; /* size of buffer used to store data received from the peer. */ size_t handshake_buffer_size; /* simulated channels between client and server. If the server (client) wants to send data to the client (server), he will write data to client_channel (server_channel), which will be read by client (server). */ - uint8_t *client_channel; - uint8_t *server_channel; + uint8_t* client_channel; + uint8_t* server_channel; /* size of data written to the client/server channel. */ size_t bytes_written_to_client_channel; size_t bytes_written_to_server_channel; @@ -85,7 +85,7 @@ struct tsi_test_fixture { size_t bytes_read_from_client_channel; size_t bytes_read_from_server_channel; /* tsi_test_frame_protector_config instance */ - tsi_test_frame_protector_config *config; + tsi_test_frame_protector_config* config; /* a flag indicating if client has finished TSI handshake first (i.e., before server). The flag should be referred if and only if TSI handshake finishes @@ -117,8 +117,8 @@ struct tsi_test_frame_protector_config { size_t client_max_output_protected_frame_size; size_t server_max_output_protected_frame_size; /* pointer that points to client/server message to be protected. */ - uint8_t *client_message; - uint8_t *server_message; + uint8_t* client_message; + uint8_t* server_message; /* size of client/server message. */ size_t client_message_size; size_t server_message_size; @@ -129,7 +129,7 @@ struct tsi_test_frame_protector_config { corresponding parameter with a default value or not. If it's false, it will be set with a specific value which is usually much smaller than the default. Both values are defined with #define directive. */ -tsi_test_frame_protector_config *tsi_test_frame_protector_config_create( +tsi_test_frame_protector_config* tsi_test_frame_protector_config_create( bool use_default_read_buffer_allocated_size, bool use_default_message_buffer_allocated_size, bool use_default_protected_buffer_size, bool use_default_client_message, @@ -141,34 +141,34 @@ tsi_test_frame_protector_config *tsi_test_frame_protector_config_create( /* This method sets different buffer and frame sizes of a tsi_test_frame_protector_config instance with user provided values. */ void tsi_test_frame_protector_config_set_buffer_size( - tsi_test_frame_protector_config *config, size_t read_buffer_allocated_size, + tsi_test_frame_protector_config* config, size_t read_buffer_allocated_size, size_t message_buffer_allocated_size, size_t protected_buffer_size, size_t client_max_output_protected_frame_size, size_t server_max_output_protected_frame_size); /* This method destroys a tsi_test_frame_protector_config instance. */ void tsi_test_frame_protector_config_destroy( - tsi_test_frame_protector_config *config); + tsi_test_frame_protector_config* config); /* This method initializes members of tsi_test_fixture instance. Note that the struct instance should be allocated before making this call. */ -void tsi_test_fixture_init(tsi_test_fixture *fixture); +void tsi_test_fixture_init(tsi_test_fixture* fixture); /* This method destroys a tsi_test_fixture instance. Note that the fixture intance must be dynamically allocated and will be freed by this function. */ -void tsi_test_fixture_destroy(tsi_test_fixture *fixture); +void tsi_test_fixture_destroy(tsi_test_fixture* fixture); /* This method performs a full TSI handshake between a client and a server. Note that the test library will implement the new TSI handshaker API to perform handshakes. */ -void tsi_test_do_handshake(tsi_test_fixture *fixture); +void tsi_test_do_handshake(tsi_test_fixture* fixture); /* This method performs a round trip test between the client and the server. That is, the client sends a protected message to a server who receives the message, and unprotects it. The same operation is triggered again with the client and server switching its role. */ -void tsi_test_do_round_trip(tsi_test_fixture *fixture); +void tsi_test_do_round_trip(tsi_test_fixture* fixture); #endif // GRPC_TEST_CORE_TSI_TRANSPORT_SECURITY_TEST_LIB_H_ diff --git a/test/core/util/debugger_macros.cc b/test/core/util/debugger_macros.cc index ebe74f1fd6..d344c3fb74 100644 --- a/test/core/util/debugger_macros.cc +++ b/test/core/util/debugger_macros.cc @@ -31,12 +31,12 @@ void grpc_summon_debugger_macros() {} -grpc_stream *grpc_transport_stream_from_call(grpc_call *call) { - grpc_call_stack *cs = grpc_call_get_call_stack(call); +grpc_stream* grpc_transport_stream_from_call(grpc_call* call) { + grpc_call_stack* cs = grpc_call_get_call_stack(call); for (;;) { - grpc_call_element *el = grpc_call_stack_element(cs, cs->count - 1); + grpc_call_element* el = grpc_call_stack_element(cs, cs->count - 1); if (el->filter == &grpc_client_channel_filter) { - grpc_subchannel_call *scc = grpc_client_channel_get_subchannel_call(el); + grpc_subchannel_call* scc = grpc_client_channel_get_subchannel_call(el); if (scc == NULL) { fprintf(stderr, "No subchannel-call"); return NULL; @@ -51,6 +51,6 @@ grpc_stream *grpc_transport_stream_from_call(grpc_call *call) { } } -grpc_chttp2_stream *grpc_chttp2_stream_from_call(grpc_call *call) { - return (grpc_chttp2_stream *)grpc_transport_stream_from_call(call); +grpc_chttp2_stream* grpc_chttp2_stream_from_call(grpc_call* call) { + return (grpc_chttp2_stream*)grpc_transport_stream_from_call(call); } diff --git a/test/core/util/grpc_profiler.cc b/test/core/util/grpc_profiler.cc index 47b0270e29..88f233598b 100644 --- a/test/core/util/grpc_profiler.cc +++ b/test/core/util/grpc_profiler.cc @@ -21,13 +21,13 @@ #if GRPC_HAVE_PERFTOOLS #include <gperftools/profiler.h> -void grpc_profiler_start(const char *filename) { ProfilerStart(filename); } +void grpc_profiler_start(const char* filename) { ProfilerStart(filename); } void grpc_profiler_stop() { ProfilerStop(); } #else #include <grpc/support/log.h> -void grpc_profiler_start(const char *filename) { +void grpc_profiler_start(const char* filename) { static int printed_warning = 0; if (!printed_warning) { gpr_log(GPR_DEBUG, diff --git a/test/core/util/grpc_profiler.h b/test/core/util/grpc_profiler.h index f3d0eaa962..f9ddd2242e 100644 --- a/test/core/util/grpc_profiler.h +++ b/test/core/util/grpc_profiler.h @@ -19,7 +19,7 @@ #ifndef GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H #define GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H -void grpc_profiler_start(const char *filename); +void grpc_profiler_start(const char* filename); void grpc_profiler_stop(); #endif /* GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H */ diff --git a/test/core/util/memory_counters.cc b/test/core/util/memory_counters.cc index 9fb3ffe095..ff85a63803 100644 --- a/test/core/util/memory_counters.cc +++ b/test/core/util/memory_counters.cc @@ -27,9 +27,9 @@ static struct grpc_memory_counters g_memory_counters; static gpr_allocation_functions g_old_allocs; -static void *guard_malloc(size_t size); -static void *guard_realloc(void *vptr, size_t size); -static void guard_free(void *vptr); +static void* guard_malloc(size_t size); +static void* guard_realloc(void* vptr, size_t size); +static void guard_free(void* vptr); #ifdef GPR_LOW_LEVEL_COUNTERS /* hide these from the microbenchmark atomic stats */ @@ -41,20 +41,20 @@ static void guard_free(void *vptr); #define NO_BARRIER_LOAD(x) gpr_atm_no_barrier_load(x) #endif -static void *guard_malloc(size_t size) { - size_t *ptr; +static void* guard_malloc(size_t size) { + size_t* ptr; if (!size) return NULL; NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)size); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_relative, (gpr_atm)1); - ptr = (size_t *)g_old_allocs.malloc_fn(size + sizeof(size)); + ptr = (size_t*)g_old_allocs.malloc_fn(size + sizeof(size)); *ptr++ = size; return ptr; } -static void *guard_realloc(void *vptr, size_t size) { - size_t *ptr = (size_t *)vptr; +static void* guard_realloc(void* vptr, size_t size) { + size_t* ptr = (size_t*)vptr; if (vptr == NULL) { return guard_malloc(size); } @@ -67,13 +67,13 @@ static void *guard_realloc(void *vptr, size_t size) { NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -(gpr_atm)*ptr); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1); - ptr = (size_t *)g_old_allocs.realloc_fn(ptr, size + sizeof(size)); + ptr = (size_t*)g_old_allocs.realloc_fn(ptr, size + sizeof(size)); *ptr++ = size; return ptr; } -static void guard_free(void *vptr) { - size_t *ptr = (size_t *)vptr; +static void guard_free(void* vptr) { + size_t* ptr = (size_t*)vptr; if (!vptr) return; --ptr; NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -(gpr_atm)*ptr); diff --git a/test/core/util/mock_endpoint.cc b/test/core/util/mock_endpoint.cc index 7cae5c045e..a467dcdc18 100644 --- a/test/core/util/mock_endpoint.cc +++ b/test/core/util/mock_endpoint.cc @@ -35,14 +35,14 @@ typedef struct grpc_mock_endpoint { gpr_mu mu; void (*on_write)(grpc_slice slice); grpc_slice_buffer read_buffer; - grpc_slice_buffer *on_read_out; - grpc_closure *on_read; - grpc_resource_user *resource_user; + grpc_slice_buffer* on_read_out; + grpc_closure* on_read; + grpc_resource_user* resource_user; } grpc_mock_endpoint; -static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; gpr_mu_lock(&m->mu); if (m->read_buffer.count > 0) { grpc_slice_buffer_swap(&m->read_buffer, slices); @@ -54,28 +54,28 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_mu_unlock(&m->mu); } -static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; for (size_t i = 0; i < slices->count; i++) { m->on_write(slices->slices[i]); } GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE); } -static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset *pollset) {} +static void me_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset* pollset) {} -static void me_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset_set *pollset) {} +static void me_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset_set* pollset) {} -static void me_delete_from_pollset_set(grpc_exec_ctx *exec_ctx, - grpc_endpoint *ep, - grpc_pollset_set *pollset) {} +static void me_delete_from_pollset_set(grpc_exec_ctx* exec_ctx, + grpc_endpoint* ep, + grpc_pollset_set* pollset) {} -static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_error *why) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_error* why) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; gpr_mu_lock(&m->mu); if (m->on_read) { GRPC_CLOSURE_SCHED(exec_ctx, m->on_read, @@ -88,23 +88,23 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, GRPC_ERROR_UNREF(why); } -static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static void me_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; grpc_slice_buffer_destroy(&m->read_buffer); grpc_resource_user_unref(exec_ctx, m->resource_user); gpr_free(m); } -static char *me_get_peer(grpc_endpoint *ep) { +static char* me_get_peer(grpc_endpoint* ep) { return gpr_strdup("fake:mock_endpoint"); } -static grpc_resource_user *me_get_resource_user(grpc_endpoint *ep) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; return m->resource_user; } -static int me_get_fd(grpc_endpoint *ep) { return -1; } +static int me_get_fd(grpc_endpoint* ep) { return -1; } static const grpc_endpoint_vtable vtable = { me_read, @@ -119,11 +119,11 @@ static const grpc_endpoint_vtable vtable = { me_get_fd, }; -grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), - grpc_resource_quota *resource_quota) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)gpr_malloc(sizeof(*m)); +grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), + grpc_resource_quota* resource_quota) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)gpr_malloc(sizeof(*m)); m->base.vtable = &vtable; - char *name; + char* name; gpr_asprintf(&name, "mock_endpoint_%" PRIxPTR, (intptr_t)m); m->resource_user = grpc_resource_user_create(resource_quota, name); gpr_free(name); @@ -134,9 +134,9 @@ grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), return &m->base; } -void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, +void grpc_mock_endpoint_put_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, grpc_slice slice) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; gpr_mu_lock(&m->mu); if (m->on_read != NULL) { grpc_slice_buffer_add(m->on_read_out, slice); diff --git a/test/core/util/mock_endpoint.h b/test/core/util/mock_endpoint.h index 73b08dca31..ccabaf7c3b 100644 --- a/test/core/util/mock_endpoint.h +++ b/test/core/util/mock_endpoint.h @@ -21,10 +21,10 @@ #include "src/core/lib/iomgr/endpoint.h" -grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), - grpc_resource_quota *resource_quota); -void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx, - grpc_endpoint *mock_endpoint, +grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), + grpc_resource_quota* resource_quota); +void grpc_mock_endpoint_put_read(grpc_exec_ctx* exec_ctx, + grpc_endpoint* mock_endpoint, grpc_slice slice); #endif diff --git a/test/core/util/one_corpus_entry_fuzzer.cc b/test/core/util/one_corpus_entry_fuzzer.cc index aebc1bfc29..c0b67da1e2 100644 --- a/test/core/util/one_corpus_entry_fuzzer.cc +++ b/test/core/util/one_corpus_entry_fuzzer.cc @@ -21,12 +21,12 @@ #include <grpc/support/log.h> #include "src/core/lib/iomgr/load_file.h" -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); extern bool squelch; extern bool leak_check; -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_slice buffer; squelch = false; leak_check = false; diff --git a/test/core/util/parse_hexstring.cc b/test/core/util/parse_hexstring.cc index 346b871b67..6dee0f163a 100644 --- a/test/core/util/parse_hexstring.cc +++ b/test/core/util/parse_hexstring.cc @@ -19,10 +19,10 @@ #include "test/core/util/parse_hexstring.h" #include <grpc/support/log.h> -grpc_slice parse_hexstring(const char *hexstring) { +grpc_slice parse_hexstring(const char* hexstring) { size_t nibbles = 0; - const char *p = 0; - uint8_t *out; + const char* p = 0; + uint8_t* out; uint8_t temp; grpc_slice slice; diff --git a/test/core/util/parse_hexstring.h b/test/core/util/parse_hexstring.h index deab747dd1..b7d54c1711 100644 --- a/test/core/util/parse_hexstring.h +++ b/test/core/util/parse_hexstring.h @@ -21,6 +21,6 @@ #include <grpc/slice.h> -grpc_slice parse_hexstring(const char *hexstring); +grpc_slice parse_hexstring(const char* hexstring); #endif /* GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H */ diff --git a/test/core/util/passthru_endpoint.cc b/test/core/util/passthru_endpoint.cc index ed39255294..acce902010 100644 --- a/test/core/util/passthru_endpoint.cc +++ b/test/core/util/passthru_endpoint.cc @@ -37,17 +37,17 @@ typedef struct passthru_endpoint passthru_endpoint; typedef struct { grpc_endpoint base; - passthru_endpoint *parent; + passthru_endpoint* parent; grpc_slice_buffer read_buffer; - grpc_slice_buffer *on_read_out; - grpc_closure *on_read; - grpc_resource_user *resource_user; + grpc_slice_buffer* on_read_out; + grpc_closure* on_read; + grpc_resource_user* resource_user; } half; struct passthru_endpoint { gpr_mu mu; int halves; - grpc_passthru_endpoint_stats *stats; + grpc_passthru_endpoint_stats* stats; grpc_passthru_endpoint_stats dummy_stats; // used if constructor stats == NULL bool shutdown; @@ -55,9 +55,9 @@ struct passthru_endpoint { half server; }; -static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - half *m = (half *)ep; +static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + half* m = (half*)ep; gpr_mu_lock(&m->parent->mu); if (m->parent->shutdown) { GRPC_CLOSURE_SCHED( @@ -72,16 +72,16 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_mu_unlock(&m->parent->mu); } -static half *other_half(half *h) { +static half* other_half(half* h) { if (h == &h->parent->client) return &h->parent->server; return &h->parent->client; } -static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - half *m = other_half((half *)ep); +static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + half* m = other_half((half*)ep); gpr_mu_lock(&m->parent->mu); - grpc_error *error = GRPC_ERROR_NONE; + grpc_error* error = GRPC_ERROR_NONE; gpr_atm_no_barrier_fetch_add(&m->parent->stats->num_writes, (gpr_atm)1); if (m->parent->shutdown) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown"); @@ -101,19 +101,19 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, GRPC_CLOSURE_SCHED(exec_ctx, cb, error); } -static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset *pollset) {} +static void me_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset* pollset) {} -static void me_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset_set *pollset) {} +static void me_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset_set* pollset) {} -static void me_delete_from_pollset_set(grpc_exec_ctx *exec_ctx, - grpc_endpoint *ep, - grpc_pollset_set *pollset) {} +static void me_delete_from_pollset_set(grpc_exec_ctx* exec_ctx, + grpc_endpoint* ep, + grpc_pollset_set* pollset) {} -static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_error *why) { - half *m = (half *)ep; +static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_error* why) { + half* m = (half*)ep; gpr_mu_lock(&m->parent->mu); m->parent->shutdown = true; if (m->on_read) { @@ -134,8 +134,8 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, GRPC_ERROR_UNREF(why); } -static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { - passthru_endpoint *p = ((half *)ep)->parent; +static void me_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) { + passthru_endpoint* p = ((half*)ep)->parent; gpr_mu_lock(&p->mu); if (0 == --p->halves) { gpr_mu_unlock(&p->mu); @@ -150,16 +150,16 @@ static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { } } -static char *me_get_peer(grpc_endpoint *ep) { - passthru_endpoint *p = ((half *)ep)->parent; - return ((half *)ep) == &p->client ? gpr_strdup("fake:mock_client_endpoint") - : gpr_strdup("fake:mock_server_endpoint"); +static char* me_get_peer(grpc_endpoint* ep) { + passthru_endpoint* p = ((half*)ep)->parent; + return ((half*)ep) == &p->client ? gpr_strdup("fake:mock_client_endpoint") + : gpr_strdup("fake:mock_server_endpoint"); } -static int me_get_fd(grpc_endpoint *ep) { return -1; } +static int me_get_fd(grpc_endpoint* ep) { return -1; } -static grpc_resource_user *me_get_resource_user(grpc_endpoint *ep) { - half *m = (half *)ep; +static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) { + half* m = (half*)ep; return m->resource_user; } @@ -176,25 +176,25 @@ static const grpc_endpoint_vtable vtable = { me_get_fd, }; -static void half_init(half *m, passthru_endpoint *parent, - grpc_resource_quota *resource_quota, - const char *half_name) { +static void half_init(half* m, passthru_endpoint* parent, + grpc_resource_quota* resource_quota, + const char* half_name) { m->base.vtable = &vtable; m->parent = parent; grpc_slice_buffer_init(&m->read_buffer); m->on_read = NULL; - char *name; + char* name; gpr_asprintf(&name, "passthru_endpoint_%s_%" PRIxPTR, half_name, (intptr_t)parent); m->resource_user = grpc_resource_user_create(resource_quota, name); gpr_free(name); } -void grpc_passthru_endpoint_create(grpc_endpoint **client, - grpc_endpoint **server, - grpc_resource_quota *resource_quota, - grpc_passthru_endpoint_stats *stats) { - passthru_endpoint *m = (passthru_endpoint *)gpr_malloc(sizeof(*m)); +void grpc_passthru_endpoint_create(grpc_endpoint** client, + grpc_endpoint** server, + grpc_resource_quota* resource_quota, + grpc_passthru_endpoint_stats* stats) { + passthru_endpoint* m = (passthru_endpoint*)gpr_malloc(sizeof(*m)); m->halves = 2; m->shutdown = 0; m->stats = stats == NULL ? &m->dummy_stats : stats; diff --git a/test/core/util/passthru_endpoint.h b/test/core/util/passthru_endpoint.h index 23d21c6061..bddd8ea6a2 100644 --- a/test/core/util/passthru_endpoint.h +++ b/test/core/util/passthru_endpoint.h @@ -23,11 +23,13 @@ #include "src/core/lib/iomgr/endpoint.h" -typedef struct { gpr_atm num_writes; } grpc_passthru_endpoint_stats; +typedef struct { + gpr_atm num_writes; +} grpc_passthru_endpoint_stats; -void grpc_passthru_endpoint_create(grpc_endpoint **client, - grpc_endpoint **server, - grpc_resource_quota *resource_quota, - grpc_passthru_endpoint_stats *stats); +void grpc_passthru_endpoint_create(grpc_endpoint** client, + grpc_endpoint** server, + grpc_resource_quota* resource_quota, + grpc_passthru_endpoint_stats* stats); #endif diff --git a/test/core/util/port.cc b/test/core/util/port.cc index 61f2e5018f..c5bebe08e7 100644 --- a/test/core/util/port.cc +++ b/test/core/util/port.cc @@ -36,7 +36,7 @@ #include "src/core/lib/iomgr/sockaddr_utils.h" #include "test/core/util/port_server_client.h" -static int *chosen_ports = NULL; +static int* chosen_ports = NULL; static size_t num_chosen_ports = 0; static int free_chosen_port(int port) { @@ -76,7 +76,7 @@ static void chose_port(int port) { } num_chosen_ports++; chosen_ports = - (int *)gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports); + (int*)gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports); chosen_ports[num_chosen_ports - 1] = port; } diff --git a/test/core/util/port_server_client.cc b/test/core/util/port_server_client.cc index 2c7301d058..927bc91d38 100644 --- a/test/core/util/port_server_client.cc +++ b/test/core/util/port_server_client.cc @@ -35,21 +35,21 @@ #include "src/core/lib/http/httpcli.h" typedef struct freereq { - gpr_mu *mu; + gpr_mu* mu; grpc_polling_entity pops; int done; } freereq; -static void destroy_pops_and_shutdown(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset *pollset = grpc_polling_entity_pollset((grpc_polling_entity *)p); +static void destroy_pops_and_shutdown(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset* pollset = grpc_polling_entity_pollset((grpc_polling_entity*)p); grpc_pollset_destroy(exec_ctx, pollset); gpr_free(pollset); } -static void freed_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - freereq *pr = (freereq *)arg; +static void freed_port_from_server(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + freereq* pr = (freereq*)arg; gpr_mu_lock(pr->mu); pr->done = 1; GRPC_LOG_IF_ERROR( @@ -64,9 +64,9 @@ void grpc_free_port_using_server(int port) { grpc_httpcli_request req; grpc_httpcli_response rsp; freereq pr; - char *path; + char* path; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_closure *shutdown_closure; + grpc_closure* shutdown_closure; grpc_init(); @@ -74,18 +74,18 @@ void grpc_free_port_using_server(int port) { memset(&req, 0, sizeof(req)); memset(&rsp, 0, sizeof(rsp)); - grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); + grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(pollset, &pr.mu); pr.pops = grpc_polling_entity_create_from_pollset(pollset); shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops, grpc_schedule_on_exec_ctx); - req.host = const_cast<char *>(GRPC_PORT_SERVER_ADDRESS); + req.host = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS); gpr_asprintf(&path, "/drop/%d", port); req.http.path = path; grpc_httpcli_context_init(&context); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("port_server_client/free"); grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req, grpc_exec_ctx_now(&exec_ctx) + 30 * GPR_MS_PER_SEC, @@ -96,7 +96,7 @@ void grpc_free_port_using_server(int port) { grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(pr.mu); while (!pr.done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), @@ -118,26 +118,26 @@ void grpc_free_port_using_server(int port) { } typedef struct portreq { - gpr_mu *mu; + gpr_mu* mu; grpc_polling_entity pops; int port; int retries; - char *server; - grpc_httpcli_context *ctx; + char* server; + grpc_httpcli_context* ctx; grpc_httpcli_response response; } portreq; -static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { size_t i; int port = 0; - portreq *pr = (portreq *)arg; + portreq* pr = (portreq*)arg; int failed = 0; - grpc_httpcli_response *response = &pr->response; + grpc_httpcli_response* response = &pr->response; if (error != GRPC_ERROR_NONE) { failed = 1; - const char *msg = grpc_error_string(error); + const char* msg = grpc_error_string(error); gpr_log(GPR_DEBUG, "failed port pick from server: retrying [%s]", msg); } else if (response->status != 200) { @@ -167,10 +167,10 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, GPR_TIMESPAN))); pr->retries++; req.host = pr->server; - req.http.path = const_cast<char *>("/get"); + req.http.path = const_cast<char*>("/get"); grpc_http_response_destroy(&pr->response); memset(&pr->response, 0, sizeof(pr->response)); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("port_server_client/pick_retry"); grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, resource_quota, &req, grpc_exec_ctx_now(exec_ctx) + 30 * GPR_MS_PER_SEC, @@ -201,26 +201,26 @@ int grpc_pick_port_using_server(void) { grpc_httpcli_request req; portreq pr; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_closure *shutdown_closure; + grpc_closure* shutdown_closure; grpc_init(); memset(&pr, 0, sizeof(pr)); memset(&req, 0, sizeof(req)); - grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); + grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(pollset, &pr.mu); pr.pops = grpc_polling_entity_create_from_pollset(pollset); shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops, grpc_schedule_on_exec_ctx); pr.port = -1; - pr.server = const_cast<char *>(GRPC_PORT_SERVER_ADDRESS); + pr.server = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS); pr.ctx = &context; - req.host = const_cast<char *>(GRPC_PORT_SERVER_ADDRESS); - req.http.path = const_cast<char *>("/get"); + req.host = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS); + req.http.path = const_cast<char*>("/get"); grpc_httpcli_context_init(&context); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("port_server_client/pick"); grpc_httpcli_get( &exec_ctx, &context, &pr.pops, resource_quota, &req, @@ -231,7 +231,7 @@ int grpc_pick_port_using_server(void) { grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(pr.mu); while (pr.port == -1) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc index 883c02e51c..c7c0595d7f 100644 --- a/test/core/util/reconnect_server.cc +++ b/test/core/util/reconnect_server.cc @@ -31,11 +31,11 @@ #include "test/core/util/port.h" #include "test/core/util/test_tcp_server.h" -static void pretty_print_backoffs(reconnect_server *server) { +static void pretty_print_backoffs(reconnect_server* server) { gpr_timespec diff; int i = 1; double expected_backoff = 1000.0, backoff; - timestamp_list *head = server->head; + timestamp_list* head = server->head; gpr_log(GPR_INFO, "reconnect server: new connection"); for (head = server->head; head && head->next; head = head->next, i++) { diff = gpr_time_sub(head->next->timestamp, head->timestamp); @@ -55,15 +55,15 @@ static void pretty_print_backoffs(reconnect_server *server) { } } -static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, - grpc_pollset *accepting_pollset, - grpc_tcp_server_acceptor *acceptor) { +static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp, + grpc_pollset* accepting_pollset, + grpc_tcp_server_acceptor* acceptor) { gpr_free(acceptor); - char *peer; - char *last_colon; - reconnect_server *server = (reconnect_server *)arg; + char* peer; + char* last_colon; + reconnect_server* server = (reconnect_server*)arg; gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); - timestamp_list *new_tail; + timestamp_list* new_tail; peer = grpc_endpoint_get_peer(tcp); grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected")); @@ -82,7 +82,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, gpr_free(peer); } } - new_tail = static_cast<timestamp_list *>(gpr_malloc(sizeof(timestamp_list))); + new_tail = static_cast<timestamp_list*>(gpr_malloc(sizeof(timestamp_list))); new_tail->timestamp = now; new_tail->next = NULL; if (server->tail == NULL) { @@ -95,7 +95,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, pretty_print_backoffs(server); } -void reconnect_server_init(reconnect_server *server) { +void reconnect_server_init(reconnect_server* server) { test_tcp_server_init(&server->tcp_server, on_connect, server); server->head = NULL; server->tail = NULL; @@ -103,16 +103,16 @@ void reconnect_server_init(reconnect_server *server) { server->max_reconnect_backoff_ms = 0; } -void reconnect_server_start(reconnect_server *server, int port) { +void reconnect_server_start(reconnect_server* server, int port) { test_tcp_server_start(&server->tcp_server, port); } -void reconnect_server_poll(reconnect_server *server, int seconds) { +void reconnect_server_poll(reconnect_server* server, int seconds) { test_tcp_server_poll(&server->tcp_server, seconds); } -void reconnect_server_clear_timestamps(reconnect_server *server) { - timestamp_list *new_head = server->head; +void reconnect_server_clear_timestamps(reconnect_server* server) { + timestamp_list* new_head = server->head; while (server->head) { new_head = server->head->next; gpr_free(server->head); @@ -123,7 +123,7 @@ void reconnect_server_clear_timestamps(reconnect_server *server) { server->peer = NULL; } -void reconnect_server_destroy(reconnect_server *server) { +void reconnect_server_destroy(reconnect_server* server) { reconnect_server_clear_timestamps(server); test_tcp_server_destroy(&server->tcp_server); } diff --git a/test/core/util/reconnect_server.h b/test/core/util/reconnect_server.h index de9150a6a7..d15abe529d 100644 --- a/test/core/util/reconnect_server.h +++ b/test/core/util/reconnect_server.h @@ -25,21 +25,21 @@ typedef struct timestamp_list { gpr_timespec timestamp; - struct timestamp_list *next; + struct timestamp_list* next; } timestamp_list; typedef struct reconnect_server { test_tcp_server tcp_server; - timestamp_list *head; - timestamp_list *tail; - char *peer; + timestamp_list* head; + timestamp_list* tail; + char* peer; int max_reconnect_backoff_ms; } reconnect_server; -void reconnect_server_init(reconnect_server *server); -void reconnect_server_start(reconnect_server *server, int port); -void reconnect_server_poll(reconnect_server *server, int seconds); -void reconnect_server_destroy(reconnect_server *server); -void reconnect_server_clear_timestamps(reconnect_server *server); +void reconnect_server_init(reconnect_server* server); +void reconnect_server_start(reconnect_server* server, int port); +void reconnect_server_poll(reconnect_server* server, int seconds); +void reconnect_server_destroy(reconnect_server* server); +void reconnect_server_clear_timestamps(reconnect_server* server); #endif /* GRPC_TEST_CORE_UTIL_RECONNECT_SERVER_H */ diff --git a/test/core/util/slice_splitter.cc b/test/core/util/slice_splitter.cc index 6fcef9acce..e25e1d862a 100644 --- a/test/core/util/slice_splitter.cc +++ b/test/core/util/slice_splitter.cc @@ -23,7 +23,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/useful.h> -const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode) { +const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode) { switch (mode) { case GRPC_SLICE_SPLIT_IDENTITY: return "identity"; @@ -35,9 +35,9 @@ const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode) { return "error"; } -void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, - size_t src_slice_count, grpc_slice **dst_slices, - size_t *dst_slice_count) { +void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices, + size_t src_slice_count, grpc_slice** dst_slices, + size_t* dst_slice_count) { size_t i, j; size_t length; @@ -45,7 +45,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, case GRPC_SLICE_SPLIT_IDENTITY: *dst_slice_count = src_slice_count; *dst_slices = - (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * src_slice_count); + (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * src_slice_count); for (i = 0; i < src_slice_count; i++) { (*dst_slices)[i] = src_slices[i]; grpc_slice_ref((*dst_slices)[i]); @@ -57,7 +57,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, for (i = 0; i < src_slice_count; i++) { length += GRPC_SLICE_LENGTH(src_slices[i]); } - *dst_slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice)); + *dst_slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice)); **dst_slices = grpc_slice_malloc(length); length = 0; for (i = 0; i < src_slice_count; i++) { @@ -73,7 +73,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, length += GRPC_SLICE_LENGTH(src_slices[i]); } *dst_slice_count = length; - *dst_slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * length); + *dst_slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * length); length = 0; for (i = 0; i < src_slice_count; i++) { for (j = 0; j < GRPC_SLICE_LENGTH(src_slices[i]); j++) { @@ -86,9 +86,9 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, } void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, - grpc_slice *src_slices, size_t src_slice_count, - grpc_slice_buffer *dst) { - grpc_slice *slices; + grpc_slice* src_slices, size_t src_slice_count, + grpc_slice_buffer* dst) { + grpc_slice* slices; size_t nslices; size_t i; grpc_split_slices(mode, src_slices, src_slice_count, &slices, &nslices); @@ -99,13 +99,13 @@ void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, gpr_free(slices); } -void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer *src, - grpc_slice_buffer *dst) { +void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src, + grpc_slice_buffer* dst) { grpc_split_slices_to_buffer(mode, src->slices, src->count, dst); } -grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices) { - uint8_t *out = NULL; +grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices) { + uint8_t* out = NULL; size_t length = 0; size_t capacity = 0; size_t i; @@ -113,7 +113,7 @@ grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices) { for (i = 0; i < nslices; i++) { if (GRPC_SLICE_LENGTH(slices[i]) + length > capacity) { capacity = GPR_MAX(capacity * 2, GRPC_SLICE_LENGTH(slices[i]) + length); - out = (uint8_t *)gpr_realloc(out, capacity); + out = (uint8_t*)gpr_realloc(out, capacity); } memcpy(out + length, GRPC_SLICE_START_PTR(slices[i]), GRPC_SLICE_LENGTH(slices[i])); diff --git a/test/core/util/slice_splitter.h b/test/core/util/slice_splitter.h index 713eca93d2..65b9f6f7df 100644 --- a/test/core/util/slice_splitter.h +++ b/test/core/util/slice_splitter.h @@ -36,18 +36,18 @@ typedef enum { /* allocates *dst_slices; caller must unref all slices in dst_slices then free it */ -void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, - size_t src_slice_count, grpc_slice **dst_slices, - size_t *dst_slice_count); +void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices, + size_t src_slice_count, grpc_slice** dst_slices, + size_t* dst_slice_count); void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, - grpc_slice *src_slices, size_t src_slice_count, - grpc_slice_buffer *dst); -void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer *src, - grpc_slice_buffer *dst); + grpc_slice* src_slices, size_t src_slice_count, + grpc_slice_buffer* dst); +void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src, + grpc_slice_buffer* dst); -grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices); +grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices); -const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode); +const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode); #endif /* GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H */ diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index a673d6b97a..3106fb01ea 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -59,7 +59,7 @@ static unsigned seed(void) { return (unsigned)_getpid(); } static void print_current_stack() { typedef USHORT(WINAPI * CaptureStackBackTraceType)( - __in ULONG, __in ULONG, __out PVOID *, __out_opt PULONG); + __in ULONG, __in ULONG, __out PVOID*, __out_opt PULONG); CaptureStackBackTraceType func = (CaptureStackBackTraceType)(GetProcAddress( LoadLibrary(_T("kernel32.dll")), "RtlCaptureStackBackTrace")); @@ -71,15 +71,15 @@ static void print_current_stack() { // than 63. #define MAX_CALLERS 62 - void *callers_stack[MAX_CALLERS]; + void* callers_stack[MAX_CALLERS]; unsigned short frames; - SYMBOL_INFOW *symbol; + SYMBOL_INFOW* symbol; HANDLE process; process = GetCurrentProcess(); SymInitialize(process, NULL, TRUE); frames = (func)(0, MAX_CALLERS, callers_stack, NULL); symbol = - (SYMBOL_INFOW *)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1); + (SYMBOL_INFOW*)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1); symbol->MaxNameLen = 255; symbol->SizeOfStruct = sizeof(SYMBOL_INFOW); @@ -133,8 +133,8 @@ static void print_stack_from_context(CONTEXT c) { HANDLE process = GetCurrentProcess(); HANDLE thread = GetCurrentThread(); - SYMBOL_INFOW *symbol = - (SYMBOL_INFOW *)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1); + SYMBOL_INFOW* symbol = + (SYMBOL_INFOW*)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1); symbol->MaxNameLen = 255; symbol->SizeOfStruct = sizeof(SYMBOL_INFOW); @@ -151,7 +151,7 @@ static void print_stack_from_context(CONTEXT c) { free(symbol); } -static LONG crash_handler(struct _EXCEPTION_POINTERS *ex_info) { +static LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) { fprintf(stderr, "Exception handler called, dumping information\n"); bool try_to_print_stack = true; PEXCEPTION_RECORD exrec = ex_info->ExceptionRecord; @@ -202,7 +202,7 @@ static void install_crash_handler() { #define SIGNAL_NAMES_LENGTH 32 -static const char *const signal_names[] = { +static const char* const signal_names[] = { NULL, "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT", "SIGCHLD", @@ -215,7 +215,7 @@ static char g_alt_stack[GPR_MAX(MINSIGSTKSZ, 65536)]; #define MAX_FRAMES 32 /* signal safe output */ -static void output_string(const char *string) { +static void output_string(const char* string) { size_t len = strlen(string); ssize_t r; @@ -230,8 +230,8 @@ static void output_num(long num) { output_string(buf); } -static void crash_handler(int signum, siginfo_t *info, void *data) { - void *addrlist[MAX_FRAMES + 1]; +static void crash_handler(int signum, siginfo_t* info, void* data) { + void* addrlist[MAX_FRAMES + 1]; int addrlen; output_string("\n\n\n*******************************\nCaught signal "); @@ -376,10 +376,10 @@ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms) { GPR_TIMESPAN)); } -void grpc_test_init(int argc, char **argv) { +void grpc_test_init(int argc, char** argv) { install_crash_handler(); { /* poll-cv poll strategy runs much more slowly than anything else */ - char *s = gpr_getenv("GRPC_POLL_STRATEGY"); + char* s = gpr_getenv("GRPC_POLL_STRATEGY"); if (s != NULL && 0 == strcmp(s, "poll-cv")) { g_poller_slowdown_factor = 5; } diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 9761f464f5..4383fbfce8 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -41,7 +41,7 @@ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms); #define GRPC_TEST_PICK_PORT #endif -void grpc_test_init(int argc, char **argv); +void grpc_test_init(int argc, char** argv); #ifdef __cplusplus } diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index e2d1562aca..925209d255 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -33,29 +33,28 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static void on_server_destroyed(grpc_exec_ctx *exec_ctx, void *data, - grpc_error *error) { - test_tcp_server *server = static_cast<test_tcp_server *>(data); +static void on_server_destroyed(grpc_exec_ctx* exec_ctx, void* data, + grpc_error* error) { + test_tcp_server* server = static_cast<test_tcp_server*>(data); server->shutdown = 1; } -void test_tcp_server_init(test_tcp_server *server, - grpc_tcp_server_cb on_connect, void *user_data) { +void test_tcp_server_init(test_tcp_server* server, + grpc_tcp_server_cb on_connect, void* user_data) { grpc_init(); server->tcp_server = NULL; GRPC_CLOSURE_INIT(&server->shutdown_complete, on_server_destroyed, server, grpc_schedule_on_exec_ctx); server->shutdown = 0; - server->pollset = - static_cast<grpc_pollset *>(gpr_zalloc(grpc_pollset_size())); + server->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(server->pollset, &server->mu); server->on_connect = on_connect; server->cb_data = user_data; } -void test_tcp_server_start(test_tcp_server *server, int port) { +void test_tcp_server_start(test_tcp_server* server, int port) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; int port_added; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -63,7 +62,7 @@ void test_tcp_server_start(test_tcp_server *server, int port) { addr->sin_port = htons((uint16_t)port); memset(&addr->sin_addr, 0, sizeof(addr->sin_addr)); - grpc_error *error = grpc_tcp_server_create( + grpc_error* error = grpc_tcp_server_create( &exec_ctx, &server->shutdown_complete, NULL, &server->tcp_server); GPR_ASSERT(error == GRPC_ERROR_NONE); error = @@ -78,8 +77,8 @@ void test_tcp_server_start(test_tcp_server *server, int port) { grpc_exec_ctx_finish(&exec_ctx); } -void test_tcp_server_poll(test_tcp_server *server, int seconds) { - grpc_pollset_worker *worker = NULL; +void test_tcp_server_poll(test_tcp_server* server, int seconds) { + grpc_pollset_worker* worker = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = grpc_timespec_to_millis_round_up( grpc_timeout_seconds_to_deadline(seconds)); @@ -91,13 +90,13 @@ void test_tcp_server_poll(test_tcp_server *server, int seconds) { grpc_exec_ctx_finish(&exec_ctx); } -static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} -static void finish_pollset(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset *>(arg)); +static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} +static void finish_pollset(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(arg)); } -void test_tcp_server_destroy(test_tcp_server *server) { +void test_tcp_server_destroy(test_tcp_server* server) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_timespec shutdown_deadline; grpc_closure do_nothing_cb; diff --git a/test/core/util/test_tcp_server.h b/test/core/util/test_tcp_server.h index bd62992a09..58140388da 100644 --- a/test/core/util/test_tcp_server.h +++ b/test/core/util/test_tcp_server.h @@ -23,19 +23,19 @@ #include "src/core/lib/iomgr/tcp_server.h" typedef struct test_tcp_server { - grpc_tcp_server *tcp_server; + grpc_tcp_server* tcp_server; grpc_closure shutdown_complete; int shutdown; - gpr_mu *mu; - grpc_pollset *pollset; + gpr_mu* mu; + grpc_pollset* pollset; grpc_tcp_server_cb on_connect; - void *cb_data; + void* cb_data; } test_tcp_server; -void test_tcp_server_init(test_tcp_server *server, - grpc_tcp_server_cb on_connect, void *user_data); -void test_tcp_server_start(test_tcp_server *server, int port); -void test_tcp_server_poll(test_tcp_server *server, int seconds); -void test_tcp_server_destroy(test_tcp_server *server); +void test_tcp_server_init(test_tcp_server* server, + grpc_tcp_server_cb on_connect, void* user_data); +void test_tcp_server_start(test_tcp_server* server, int port); +void test_tcp_server_poll(test_tcp_server* server, int seconds); +void test_tcp_server_destroy(test_tcp_server* server); #endif /* GRPC_TEST_CORE_UTIL_TEST_TCP_SERVER_H */ diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc index d761f72297..c8b54b481d 100644 --- a/test/core/util/trickle_endpoint.cc +++ b/test/core/util/trickle_endpoint.cc @@ -34,25 +34,25 @@ typedef struct { grpc_endpoint base; double bytes_per_second; - grpc_endpoint *wrapped; + grpc_endpoint* wrapped; gpr_timespec last_write; gpr_mu mu; grpc_slice_buffer write_buffer; grpc_slice_buffer writing_buffer; - grpc_error *error; + grpc_error* error; bool writing; - grpc_closure *write_cb; + grpc_closure* write_cb; } trickle_endpoint; -static void te_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_read(exec_ctx, te->wrapped, slices, cb); } -static void maybe_call_write_cb_locked(grpc_exec_ctx *exec_ctx, - trickle_endpoint *te) { +static void maybe_call_write_cb_locked(grpc_exec_ctx* exec_ctx, + trickle_endpoint* te) { if (te->write_cb != NULL && (te->error != GRPC_ERROR_NONE || te->write_buffer.length <= WRITE_BUFFER_SIZE)) { GRPC_CLOSURE_SCHED(exec_ctx, te->write_cb, GRPC_ERROR_REF(te->error)); @@ -60,9 +60,9 @@ static void maybe_call_write_cb_locked(grpc_exec_ctx *exec_ctx, } } -static void te_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + trickle_endpoint* te = (trickle_endpoint*)ep; gpr_mu_lock(&te->mu); GPR_ASSERT(te->write_cb == NULL); if (te->write_buffer.length == 0) { @@ -77,28 +77,28 @@ static void te_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_mu_unlock(&te->mu); } -static void te_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset *pollset) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset* pollset) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_add_to_pollset(exec_ctx, te->wrapped, pollset); } -static void te_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset_set *pollset_set) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset_set* pollset_set) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_add_to_pollset_set(exec_ctx, te->wrapped, pollset_set); } -static void te_delete_from_pollset_set(grpc_exec_ctx *exec_ctx, - grpc_endpoint *ep, - grpc_pollset_set *pollset_set) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_delete_from_pollset_set(grpc_exec_ctx* exec_ctx, + grpc_endpoint* ep, + grpc_pollset_set* pollset_set) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_delete_from_pollset_set(exec_ctx, te->wrapped, pollset_set); } -static void te_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_error *why) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_error* why) { + trickle_endpoint* te = (trickle_endpoint*)ep; gpr_mu_lock(&te->mu); if (te->error == GRPC_ERROR_NONE) { te->error = GRPC_ERROR_REF(why); @@ -108,8 +108,8 @@ static void te_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, grpc_endpoint_shutdown(exec_ctx, te->wrapped, why); } -static void te_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_destroy(exec_ctx, te->wrapped); gpr_mu_destroy(&te->mu); grpc_slice_buffer_destroy_internal(exec_ctx, &te->write_buffer); @@ -118,24 +118,24 @@ static void te_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { gpr_free(te); } -static grpc_resource_user *te_get_resource_user(grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static grpc_resource_user* te_get_resource_user(grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; return grpc_endpoint_get_resource_user(te->wrapped); } -static char *te_get_peer(grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static char* te_get_peer(grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; return grpc_endpoint_get_peer(te->wrapped); } -static int te_get_fd(grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static int te_get_fd(grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; return grpc_endpoint_get_fd(te->wrapped); } -static void te_finish_write(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - trickle_endpoint *te = (trickle_endpoint *)arg; +static void te_finish_write(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + trickle_endpoint* te = (trickle_endpoint*)arg; gpr_mu_lock(&te->mu); te->writing = false; grpc_slice_buffer_reset_and_unref(&te->writing_buffer); @@ -153,9 +153,9 @@ static const grpc_endpoint_vtable vtable = {te_read, te_get_peer, te_get_fd}; -grpc_endpoint *grpc_trickle_endpoint_create(grpc_endpoint *wrap, +grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap, double bytes_per_second) { - trickle_endpoint *te = (trickle_endpoint *)gpr_malloc(sizeof(*te)); + trickle_endpoint* te = (trickle_endpoint*)gpr_malloc(sizeof(*te)); te->base.vtable = &vtable; te->wrapped = wrap; te->bytes_per_second = bytes_per_second; @@ -172,9 +172,9 @@ static double ts2dbl(gpr_timespec s) { return (double)s.tv_sec + 1e-9 * (double)s.tv_nsec; } -size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx, - grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx, + grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; gpr_mu_lock(&te->mu); if (!te->writing && te->write_buffer.length > 0) { gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); @@ -198,8 +198,8 @@ size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx, return backlog; } -size_t grpc_trickle_get_backlog(grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +size_t grpc_trickle_get_backlog(grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; gpr_mu_lock(&te->mu); size_t backlog = te->write_buffer.length; gpr_mu_unlock(&te->mu); diff --git a/test/core/util/trickle_endpoint.h b/test/core/util/trickle_endpoint.h index 78f1eeeda2..11c113bda8 100644 --- a/test/core/util/trickle_endpoint.h +++ b/test/core/util/trickle_endpoint.h @@ -21,13 +21,13 @@ #include "src/core/lib/iomgr/endpoint.h" -grpc_endpoint *grpc_trickle_endpoint_create(grpc_endpoint *wrap, +grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap, double bytes_per_second); /* Allow up to \a bytes through the endpoint. Returns the new backlog. */ -size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx, - grpc_endpoint *endpoint); +size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx, + grpc_endpoint* endpoint); -size_t grpc_trickle_get_backlog(grpc_endpoint *endpoint); +size_t grpc_trickle_get_backlog(grpc_endpoint* endpoint); #endif diff --git a/test/cpp/codegen/BUILD b/test/cpp/codegen/BUILD index 8de46be816..6cc81e3398 100644 --- a/test/cpp/codegen/BUILD +++ b/test/cpp/codegen/BUILD @@ -51,6 +51,7 @@ grpc_cc_test( ], external_deps = [ "gtest", + "protobuf", ], ) diff --git a/test/cpp/codegen/golden_file_test.cc b/test/cpp/codegen/golden_file_test.cc index 5df1b8a16b..14880982b5 100644 --- a/test/cpp/codegen/golden_file_test.cc +++ b/test/cpp/codegen/golden_file_test.cc @@ -58,7 +58,7 @@ TEST(GoldenMockFileTest, TestGeneratedMockFile) { kMockGoldenFilePath); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); ::google::ParseCommandLineFlags(&argc, &argv, true); if (FLAGS_generated_file_path.empty()) { diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc index 6f27ddd1e0..d6ed2e5aa2 100644 --- a/test/cpp/common/channel_arguments_test.cc +++ b/test/cpp/common/channel_arguments_test.cc @@ -70,7 +70,7 @@ grpc_socket_mutator_vtable test_mutator_vtable = { TestSocketMutator::TestSocketMutator() { grpc_socket_mutator_init(this, &test_mutator_vtable); } -} +} // namespace class ChannelArgumentsTest : public ::testing::Test { protected: diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index cf1cc7e486..5b6e9aa312 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -458,6 +458,7 @@ TEST_P(AsyncEnd2endTest, SequentialRpcs) { } TEST_P(AsyncEnd2endTest, ReconnectChannel) { + // GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS is set to 100ms in main() if (GetParam().inproc) { return; } @@ -2012,9 +2013,9 @@ INSTANTIATE_TEST_CASE_P(AsyncEnd2endServerTryCancel, } // namespace grpc int main(int argc, char** argv) { - // Change the backup poll interval from 5s to 200ms to speed up the + // Change the backup poll interval from 5s to 100ms to speed up the // ReconnectChannel test - gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "200"); + gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "100"); grpc_test_init(argc, argv); gpr_tls_init(&g_is_async_end2end_test); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index 4d2304feca..f34b27511b 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -56,7 +56,8 @@ class CrashTest : public ::testing::Test { addr_stream << "localhost:" << port; auto addr = addr_stream.str(); server_.reset(new SubProcess({ - g_root + "/client_crash_test_server", "--address=" + addr, + g_root + "/client_crash_test_server", + "--address=" + addr, })); GPR_ASSERT(server_); return grpc::testing::EchoTestService::NewStub( diff --git a/test/cpp/end2end/client_crash_test_server.cc b/test/cpp/end2end/client_crash_test_server.cc index 01dcd40f9a..887504d308 100644 --- a/test/cpp/end2end/client_crash_test_server.cc +++ b/test/cpp/end2end/client_crash_test_server.cc @@ -68,8 +68,8 @@ void RunServer() { std::cout << "Server listening on " << FLAGS_address << std::endl; server->Wait(); } -} -} +} // namespace testing +} // namespace grpc int main(int argc, char** argv) { ParseCommandLineFlags(&argc, &argv, true); diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 9450182302..7f7ed14802 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -321,8 +321,9 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { TEST_F(GenericEnd2endTest, Deadline) { ResetStub(); - SendRpc(1, true, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(10, GPR_TIMESPAN))); + SendRpc(1, true, + gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_seconds(10, GPR_TIMESPAN))); } } // namespace diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 499e4ef36c..c15ab88da1 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -73,9 +73,9 @@ using std::chrono::system_clock; -using grpc::lb::v1::LoadBalancer; using grpc::lb::v1::LoadBalanceRequest; using grpc::lb::v1::LoadBalanceResponse; +using grpc::lb::v1::LoadBalancer; namespace grpc { namespace testing { @@ -659,8 +659,9 @@ TEST_F(SingleBalancerTest, Fallback) { // Send non-empty serverlist only after kServerlistDelayMs. ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends( - GetBackendPorts(kNumBackendInResolution /* start_index */), {}), + 0, + BalancerServiceImpl::BuildResponseForBackends( + GetBackendPorts(kNumBackendInResolution /* start_index */), {}), kServerlistDelayMs); // Wait until all the fallback backends are reachable. @@ -725,10 +726,11 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { // Send non-empty serverlist only after kServerlistDelayMs. ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends( - GetBackendPorts(kNumBackendInResolution + - kNumBackendInResolutionUpdate /* start_index */), - {}), + 0, + BalancerServiceImpl::BuildResponseForBackends( + GetBackendPorts(kNumBackendInResolution + + kNumBackendInResolutionUpdate /* start_index */), + {}), kServerlistDelayMs); // Wait until all the fallback backends are reachable. @@ -1069,10 +1071,11 @@ TEST_F(SingleBalancerTest, Drop) { num_of_drop_by_load_balancing_addresses; const int num_total_addresses = num_backends_ + num_of_drop_addresses; ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends( - GetBackendPorts(), - {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, - {"load_balancing", num_of_drop_by_load_balancing_addresses}}), + 0, + BalancerServiceImpl::BuildResponseForBackends( + GetBackendPorts(), + {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, + {"load_balancing", num_of_drop_by_load_balancing_addresses}}), 0); // Wait until all backends are ready. WaitForAllBackends(); @@ -1108,9 +1111,10 @@ TEST_F(SingleBalancerTest, DropAllFirst) { const int num_of_drop_by_rate_limiting_addresses = 1; const int num_of_drop_by_load_balancing_addresses = 1; ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends( - {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, - {"load_balancing", num_of_drop_by_load_balancing_addresses}}), + 0, + BalancerServiceImpl::BuildResponseForBackends( + {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, + {"load_balancing", num_of_drop_by_load_balancing_addresses}}), 0); const Status status = SendRpc(); EXPECT_FALSE(status.ok()); @@ -1124,9 +1128,10 @@ TEST_F(SingleBalancerTest, DropAll) { const int num_of_drop_by_rate_limiting_addresses = 1; const int num_of_drop_by_load_balancing_addresses = 1; ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends( - {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, - {"load_balancing", num_of_drop_by_load_balancing_addresses}}), + 0, + BalancerServiceImpl::BuildResponseForBackends( + {}, {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, + {"load_balancing", num_of_drop_by_load_balancing_addresses}}), 1000); // First call succeeds. @@ -1188,10 +1193,11 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) { num_of_drop_by_load_balancing_addresses; const int num_total_addresses = num_backends_ + num_of_drop_addresses; ScheduleResponseForBalancer( - 0, BalancerServiceImpl::BuildResponseForBackends( - GetBackendPorts(), - {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, - {"load_balancing", num_of_drop_by_load_balancing_addresses}}), + 0, + BalancerServiceImpl::BuildResponseForBackends( + GetBackendPorts(), + {{"rate_limiting", num_of_drop_by_rate_limiting_addresses}, + {"load_balancing", num_of_drop_by_load_balancing_addresses}}), 0); // Wait until all backends are ready. int num_warmup_ok = 0; diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 0b63c25055..61f4111e3b 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -44,19 +44,19 @@ #include <iostream> using namespace std; +using ::testing::AtLeast; +using ::testing::DoAll; +using ::testing::Invoke; +using ::testing::Return; +using ::testing::SaveArg; +using ::testing::SetArgPointee; +using ::testing::WithArg; +using ::testing::_; using grpc::testing::EchoRequest; using grpc::testing::EchoResponse; using grpc::testing::EchoTestService; using grpc::testing::MockClientReaderWriter; using std::chrono::system_clock; -using ::testing::AtLeast; -using ::testing::SetArgPointee; -using ::testing::SaveArg; -using ::testing::_; -using ::testing::Return; -using ::testing::Invoke; -using ::testing::WithArg; -using ::testing::DoAll; namespace grpc { namespace testing { diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index a4b364417d..a7647344c0 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -87,19 +87,19 @@ namespace grpc { namespace { typedef struct client_fixture { - grpc_channel *client; - char *server_uri; - grpc_completion_queue *cq; + grpc_channel* client; + char* server_uri; + grpc_completion_queue* cq; } client_fixture; typedef struct server_fixture { - grpc_server *server; - grpc_call *server_call; - grpc_completion_queue *cq; - char *servers_hostport; - const char *balancer_name; + grpc_server* server; + grpc_call* server_call; + grpc_completion_queue* cq; + char* servers_hostport; + const char* balancer_name; int port; - const char *lb_token_prefix; + const char* lb_token_prefix; gpr_thd_id tid; int num_calls_serviced; } server_fixture; @@ -111,12 +111,12 @@ typedef struct test_fixture { int lb_server_update_delay_ms; } test_fixture; -static void *tag(intptr_t t) { return (void *)t; } +static void* tag(intptr_t t) { return (void*)t; } static grpc_slice build_response_payload_slice( - const char *host, int *ports, size_t nports, + const char* host, int* ports, size_t nports, int64_t expiration_interval_secs, int32_t expiration_interval_nanos, - const char *token_prefix) { + const char* token_prefix) { // server_list { // servers { // ip_address: <in_addr/6 bytes of an IP> @@ -126,10 +126,10 @@ static grpc_slice build_response_payload_slice( // ... // } grpc::lb::v1::LoadBalanceResponse response; - auto *serverlist = response.mutable_server_list(); + auto* serverlist = response.mutable_server_list(); if (expiration_interval_secs > 0 || expiration_interval_nanos > 0) { - auto *expiration_interval = serverlist->mutable_expiration_interval(); + auto* expiration_interval = serverlist->mutable_expiration_interval(); if (expiration_interval_secs > 0) { expiration_interval->set_seconds(expiration_interval_secs); } @@ -138,12 +138,12 @@ static grpc_slice build_response_payload_slice( } } for (size_t i = 0; i < nports; i++) { - auto *server = serverlist->add_servers(); + auto* server = serverlist->add_servers(); // TODO(dgq): test ipv6 struct in_addr ip4; GPR_ASSERT(inet_pton(AF_INET, host, &ip4) == 1); server->set_ip_address( - string(reinterpret_cast<const char *>(&ip4), sizeof(ip4))); + string(reinterpret_cast<const char*>(&ip4), sizeof(ip4))); server->set_port(ports[i]); // Missing tokens are acceptable. Test that path. if (strlen(token_prefix) > 0) { @@ -151,11 +151,11 @@ static grpc_slice build_response_payload_slice( server->set_load_balance_token(token_data); } } - const string &enc_resp = response.SerializeAsString(); + const string& enc_resp = response.SerializeAsString(); return grpc_slice_from_copied_buffer(enc_resp.data(), enc_resp.size()); } -static void drain_cq(grpc_completion_queue *cq) { +static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5), @@ -168,18 +168,18 @@ static void sleep_ms(int delay_ms) { gpr_time_from_millis(delay_ms, GPR_TIMESPAN))); } -static void start_lb_server(server_fixture *sf, int *ports, size_t nports, +static void start_lb_server(server_fixture* sf, int* ports, size_t nports, int update_delay_ms) { - grpc_call *s; - cq_verifier *cqv = cq_verifier_create(sf->cq); + grpc_call* s; + cq_verifier* cqv = cq_verifier_create(sf->cq); grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array request_metadata_recv; grpc_call_details call_details; grpc_call_error error; int was_cancelled = 2; - grpc_byte_buffer *request_payload_recv; - grpc_byte_buffer *response_payload; + grpc_byte_buffer* request_payload_recv; + grpc_byte_buffer* response_payload; memset(ops, 0, sizeof(ops)); grpc_metadata_array_init(&request_metadata_recv); @@ -303,17 +303,17 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, grpc_call_details_destroy(&call_details); } -static void start_backend_server(server_fixture *sf) { - grpc_call *s; - cq_verifier *cqv; +static void start_backend_server(server_fixture* sf) { + grpc_call* s; + cq_verifier* cqv; grpc_op ops[6]; - grpc_op *op; + grpc_op* op; grpc_metadata_array request_metadata_recv; grpc_call_details call_details; grpc_call_error error; int was_cancelled; - grpc_byte_buffer *request_payload_recv; - grpc_byte_buffer *response_payload; + grpc_byte_buffer* request_payload_recv; + grpc_byte_buffer* response_payload; grpc_event ev; while (true) { @@ -339,8 +339,9 @@ static void start_backend_server(server_fixture *sf) { } GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); const string expected_token = - strlen(sf->lb_token_prefix) == 0 ? "" : sf->lb_token_prefix + - std::to_string(sf->port); + strlen(sf->lb_token_prefix) == 0 + ? "" + : sf->lb_token_prefix + std::to_string(sf->port); GPR_ASSERT(contains_metadata(&request_metadata_recv, "lb-token", expected_token.c_str())); @@ -449,18 +450,18 @@ static void start_backend_server(server_fixture *sf) { } } -static void perform_request(client_fixture *cf) { - grpc_call *c; - cq_verifier *cqv = cq_verifier_create(cf->cq); +static void perform_request(client_fixture* cf) { + grpc_call* c; + cq_verifier* cqv = cq_verifier_create(cf->cq); 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; - grpc_byte_buffer *request_payload; - grpc_byte_buffer *response_payload_recv; + grpc_byte_buffer* request_payload; + grpc_byte_buffer* response_payload_recv; int i; memset(ops, 0, sizeof(ops)); @@ -474,7 +475,7 @@ static void perform_request(client_fixture *cf) { NULL); gpr_log(GPR_INFO, "Call 0x%" PRIxPTR " created", (intptr_t)c); GPR_ASSERT(c); - char *peer; + char* peer; grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -555,21 +556,21 @@ static void perform_request(client_fixture *cf) { } #define BALANCERS_NAME "lb.name" -static void setup_client(const server_fixture *lb_server, - const server_fixture *backends, client_fixture *cf) { +static void setup_client(const server_fixture* lb_server, + const server_fixture* backends, client_fixture* cf) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - char *expected_target_names = NULL; - const char *backends_name = lb_server->servers_hostport; + char* expected_target_names = NULL; + const char* backends_name = lb_server->servers_hostport; gpr_asprintf(&expected_target_names, "%s;%s", backends_name, BALANCERS_NAME); - grpc_fake_resolver_response_generator *response_generator = + grpc_fake_resolver_response_generator* response_generator = grpc_fake_resolver_response_generator_create(); - grpc_lb_addresses *addresses = grpc_lb_addresses_create(1, NULL); - char *lb_uri_str; + grpc_lb_addresses* addresses = grpc_lb_addresses_create(1, NULL); + char* lb_uri_str; gpr_asprintf(&lb_uri_str, "ipv4:%s", lb_server->servers_hostport); - grpc_uri *lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true); + grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true); GPR_ASSERT(lb_uri != NULL); grpc_lb_addresses_set_address_from_uri(addresses, 0, lb_uri, true, lb_server->balancer_name, NULL); @@ -579,7 +580,7 @@ static void setup_client(const server_fixture *lb_server, gpr_asprintf(&cf->server_uri, "fake:///%s", lb_server->servers_hostport); const grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); - grpc_channel_args *fake_result = + grpc_channel_args* fake_result = grpc_channel_args_copy_and_add(NULL, &fake_addresses, 1); grpc_lb_addresses_destroy(&exec_ctx, addresses); @@ -587,12 +588,12 @@ static void setup_client(const server_fixture *lb_server, grpc_fake_transport_expected_targets_arg(expected_target_names), grpc_fake_resolver_response_generator_arg(response_generator)}; - grpc_channel_args *args = + grpc_channel_args* args = grpc_channel_args_copy_and_add(NULL, new_args, GPR_ARRAY_SIZE(new_args)); gpr_free(expected_target_names); cf->cq = grpc_completion_queue_create_for_next(NULL); - grpc_channel_credentials *fake_creds = + grpc_channel_credentials* fake_creds = grpc_fake_transport_security_credentials_create(); cf->client = grpc_secure_channel_create(fake_creds, cf->server_uri, args, NULL); @@ -605,7 +606,7 @@ static void setup_client(const server_fixture *lb_server, grpc_exec_ctx_finish(&exec_ctx); } -static void teardown_client(client_fixture *cf) { +static void teardown_client(client_fixture* cf) { grpc_completion_queue_shutdown(cf->cq); drain_cq(cf->cq); grpc_completion_queue_destroy(cf->cq); @@ -615,13 +616,13 @@ static void teardown_client(client_fixture *cf) { gpr_free(cf->server_uri); } -static void setup_server(const char *host, server_fixture *sf) { +static void setup_server(const char* host, server_fixture* sf) { int assigned_port; sf->cq = grpc_completion_queue_create_for_next(NULL); - const char *colon_idx = strchr(host, ':'); + const char* colon_idx = strchr(host, ':'); if (colon_idx) { - const char *port_str = colon_idx + 1; + const char* port_str = colon_idx + 1; sf->port = atoi(port_str); sf->servers_hostport = gpr_strdup(host); } else { @@ -629,7 +630,7 @@ static void setup_server(const char *host, server_fixture *sf) { gpr_join_host_port(&sf->servers_hostport, host, sf->port); } - grpc_server_credentials *server_creds = + grpc_server_credentials* server_creds = grpc_fake_transport_security_server_credentials_create(); sf->server = grpc_server_create(NULL, NULL); @@ -641,12 +642,12 @@ static void setup_server(const char *host, server_fixture *sf) { grpc_server_start(sf->server); } -static void teardown_server(server_fixture *sf) { +static void teardown_server(server_fixture* sf) { if (!sf->server) return; gpr_log(GPR_INFO, "Server[%s] shutting down", sf->servers_hostport); - grpc_completion_queue *shutdown_cq = + grpc_completion_queue* shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_server_shutdown_and_notify(sf->server, shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), @@ -666,13 +667,13 @@ static void teardown_server(server_fixture *sf) { gpr_free(sf->servers_hostport); } -static void fork_backend_server(void *arg) { - server_fixture *sf = static_cast<server_fixture *>(arg); +static void fork_backend_server(void* arg) { + server_fixture* sf = static_cast<server_fixture*>(arg); start_backend_server(sf); } -static void fork_lb_server(void *arg) { - test_fixture *tf = static_cast<test_fixture *>(arg); +static void fork_lb_server(void* arg) { + test_fixture* tf = static_cast<test_fixture*>(arg); int ports[NUM_BACKENDS]; for (int i = 0; i < NUM_BACKENDS; i++) { ports[i] = tf->lb_backends[i].port; @@ -710,7 +711,7 @@ static test_fixture setup_test_fixture(int lb_server_update_delay_ms) { return tf; } -static void teardown_test_fixture(test_fixture *tf) { +static void teardown_test_fixture(test_fixture* tf) { teardown_client(&tf->client); for (int i = 0; i < NUM_BACKENDS; ++i) { teardown_server(&tf->lb_backends[i]); @@ -787,7 +788,7 @@ TEST(GrpclbTest, InvalidAddressInServerlist) {} } // namespace } // namespace grpc -int main(int argc, char **argv) { +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); grpc_test_init(argc, argv); // Make the backup poller poll very frequently in order to pick up diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index 4149724b1e..a24cdc7d2d 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -51,8 +51,9 @@ using grpc::ServerCredentials; using grpc::ServerReader; using grpc::ServerReaderWriter; using grpc::ServerWriter; -using grpc::WriteOptions; using grpc::SslServerCredentialsOptions; +using grpc::Status; +using grpc::WriteOptions; using grpc::testing::InteropServerContextInspector; using grpc::testing::Payload; using grpc::testing::SimpleRequest; @@ -62,7 +63,6 @@ using grpc::testing::StreamingInputCallResponse; using grpc::testing::StreamingOutputCallRequest; using grpc::testing::StreamingOutputCallResponse; using grpc::testing::TestService; -using grpc::Status; const char kEchoInitialMetadataKey[] = "x-grpc-test-echo-initial"; const char kEchoTrailingBinMetadataKey[] = "x-grpc-test-echo-trailing-bin"; diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc index 50af8fcc8a..5e257e1b38 100644 --- a/test/cpp/interop/reconnect_interop_server.cc +++ b/test/cpp/interop/reconnect_interop_server.cc @@ -53,9 +53,9 @@ using grpc::ServerWriter; using grpc::SslServerCredentialsOptions; using grpc::Status; using grpc::testing::Empty; -using grpc::testing::ReconnectService; using grpc::testing::ReconnectInfo; using grpc::testing::ReconnectParams; +using grpc::testing::ReconnectService; static bool got_sigint = false; diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index c6d3600be8..991fc88ad2 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -106,13 +106,13 @@ DEFINE_bool(use_test_ca, false, "False to use SSL roots for google"); DEFINE_string(server_host_override, "foo.test.google.fr", "Override the server host which is sent in HTTP header"); -using grpc::testing::kTestCaseList; using grpc::testing::MetricsService; using grpc::testing::MetricsServiceImpl; using grpc::testing::StressTestInteropClient; using grpc::testing::TestCaseType; using grpc::testing::UNKNOWN_TEST; using grpc::testing::WeightedRandomTestSelector; +using grpc::testing::kTestCaseList; static int log_level = GPR_LOG_SEVERITY_DEBUG; diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index a53565bb09..ec5c1275d1 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -47,9 +47,9 @@ #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/cpp/microbenchmarks/helpers.h" -auto &force_library_initialization = Library::get(); +auto& force_library_initialization = Library::get(); -void BM_Zalloc(benchmark::State &state) { +void BM_Zalloc(benchmark::State& state) { // speed of light for call creation is zalloc, so benchmark a few interesting // sizes TrackCounters track_counters; @@ -78,13 +78,13 @@ BENCHMARK(BM_Zalloc) class BaseChannelFixture { public: - BaseChannelFixture(grpc_channel *channel) : channel_(channel) {} + BaseChannelFixture(grpc_channel* channel) : channel_(channel) {} ~BaseChannelFixture() { grpc_channel_destroy(channel_); } - grpc_channel *channel() const { return channel_; } + grpc_channel* channel() const { return channel_; } private: - grpc_channel *const channel_; + grpc_channel* const channel_; }; class InsecureChannel : public BaseChannelFixture { @@ -102,12 +102,12 @@ class LameChannel : public BaseChannelFixture { }; template <class Fixture> -static void BM_CallCreateDestroy(benchmark::State &state) { +static void BM_CallCreateDestroy(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; - grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - void *method_hdl = + void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); while (state.KeepRunning()) { grpc_call_unref(grpc_channel_create_registered_call( @@ -124,11 +124,11 @@ BENCHMARK_TEMPLATE(BM_CallCreateDestroy, LameChannel); //////////////////////////////////////////////////////////////////////////////// // Benchmarks isolating individual filters -static void *tag(int i) { - return reinterpret_cast<void *>(static_cast<intptr_t>(i)); +static void* tag(int i) { + return reinterpret_cast<void*>(static_cast<intptr_t>(i)); } -static void BM_LameChannelCallCreateCpp(benchmark::State &state) { +static void BM_LameChannelCallCreateCpp(benchmark::State& state) { TrackCounters track_counters; auto stub = grpc::testing::EchoTestService::NewStub(grpc::CreateChannelInternal( @@ -143,7 +143,7 @@ static void BM_LameChannelCallCreateCpp(benchmark::State &state) { grpc::ClientContext cli_ctx; auto reader = stub->AsyncEcho(&cli_ctx, send_request, &cq); reader->Finish(&recv_response, &recv_status, tag(0)); - void *t; + void* t; bool ok; GPR_ASSERT(cq.Next(&t, &ok)); GPR_ASSERT(ok); @@ -152,16 +152,16 @@ static void BM_LameChannelCallCreateCpp(benchmark::State &state) { } BENCHMARK(BM_LameChannelCallCreateCpp); -static void do_nothing(void *ignored) {} +static void do_nothing(void* ignored) {} -static void BM_LameChannelCallCreateCore(benchmark::State &state) { +static void BM_LameChannelCallCreateCore(benchmark::State& state) { TrackCounters track_counters; - grpc_channel *channel; - grpc_completion_queue *cq; + grpc_channel* channel; + grpc_completion_queue* cq; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_status_code status; grpc_slice details; grpc::testing::EchoRequest send_request; @@ -171,22 +171,22 @@ static void BM_LameChannelCallCreateCore(benchmark::State &state) { channel = grpc_lame_client_channel_create( "localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah"); cq = grpc_completion_queue_create_for_next(NULL); - void *rc = grpc_channel_register_call( + void* rc = grpc_channel_register_call( channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL); while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - grpc_call *call = grpc_channel_create_registered_call( + grpc_call* call = grpc_channel_create_registered_call( channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); - grpc_byte_buffer *request_payload_send = + grpc_byte_buffer* request_payload_send = grpc_raw_byte_buffer_create(&send_request_slice, 1); // Fill in call ops grpc_op ops[6]; memset(ops, 0, sizeof(ops)); - grpc_op *op = ops; + grpc_op* op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op++; @@ -210,7 +210,7 @@ static void BM_LameChannelCallCreateCore(benchmark::State &state) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), - (void *)1, NULL)); + (void*)1, NULL)); grpc_event ev = grpc_completion_queue_next( cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN); @@ -228,14 +228,14 @@ static void BM_LameChannelCallCreateCore(benchmark::State &state) { } BENCHMARK(BM_LameChannelCallCreateCore); -static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) { +static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { TrackCounters track_counters; - grpc_channel *channel; - grpc_completion_queue *cq; + grpc_channel* channel; + grpc_completion_queue* cq; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; - grpc_byte_buffer *response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = NULL; grpc_status_code status; grpc_slice details; grpc::testing::EchoRequest send_request; @@ -245,22 +245,22 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) { channel = grpc_lame_client_channel_create( "localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah"); cq = grpc_completion_queue_create_for_next(NULL); - void *rc = grpc_channel_register_call( + void* rc = grpc_channel_register_call( channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL); while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - grpc_call *call = grpc_channel_create_registered_call( + grpc_call* call = grpc_channel_create_registered_call( channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); - grpc_byte_buffer *request_payload_send = + grpc_byte_buffer* request_payload_send = grpc_raw_byte_buffer_create(&send_request_slice, 1); // Fill in call ops grpc_op ops[3]; memset(ops, 0, sizeof(ops)); - grpc_op *op = ops; + grpc_op* op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op++; @@ -271,7 +271,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) { op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), - (void *)0, NULL)); + (void*)0, NULL)); memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_INITIAL_METADATA; @@ -289,7 +289,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), - (void *)1, NULL)); + (void*)1, NULL)); grpc_event ev = grpc_completion_queue_next( cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN); @@ -311,31 +311,31 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) { } BENCHMARK(BM_LameChannelCallCreateCoreSeparateBatch); -static void FilterDestroy(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void FilterDestroy(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { gpr_free(arg); } -static void DoNothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} +static void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} class FakeClientChannelFactory : public grpc_client_channel_factory { public: FakeClientChannelFactory() { vtable = &vtable_; } private: - static void NoRef(grpc_client_channel_factory *factory) {} - static void NoUnref(grpc_exec_ctx *exec_ctx, - grpc_client_channel_factory *factory) {} - static grpc_subchannel *CreateSubchannel(grpc_exec_ctx *exec_ctx, - grpc_client_channel_factory *factory, - const grpc_subchannel_args *args) { + static void NoRef(grpc_client_channel_factory* factory) {} + static void NoUnref(grpc_exec_ctx* exec_ctx, + grpc_client_channel_factory* factory) {} + static grpc_subchannel* CreateSubchannel(grpc_exec_ctx* exec_ctx, + grpc_client_channel_factory* factory, + const grpc_subchannel_args* args) { return nullptr; } - static grpc_channel *CreateClientChannel(grpc_exec_ctx *exec_ctx, - grpc_client_channel_factory *factory, - const char *target, + static grpc_channel* CreateClientChannel(grpc_exec_ctx* exec_ctx, + grpc_client_channel_factory* factory, + const char* target, grpc_client_channel_type type, - const grpc_channel_args *args) { + const grpc_channel_args* args) { return nullptr; } @@ -345,11 +345,11 @@ class FakeClientChannelFactory : public grpc_client_channel_factory { const grpc_client_channel_factory_vtable FakeClientChannelFactory::vtable_ = { NoRef, NoUnref, CreateSubchannel, CreateClientChannel}; -static grpc_arg StringArg(const char *key, const char *value) { +static grpc_arg StringArg(const char* key, const char* value) { grpc_arg a; a.type = GRPC_ARG_STRING; - a.key = const_cast<char *>(key); - a.value.string = const_cast<char *>(value); + a.key = const_cast<char*>(key); + a.value.string = const_cast<char*>(value); return a; } @@ -358,45 +358,45 @@ enum FixtureFlags : uint32_t { REQUIRES_TRANSPORT = 2, }; -template <const grpc_channel_filter *kFilter, uint32_t kFlags> +template <const grpc_channel_filter* kFilter, uint32_t kFlags> struct Fixture { - const grpc_channel_filter *filter = kFilter; + const grpc_channel_filter* filter = kFilter; const uint32_t flags = kFlags; }; namespace dummy_filter { -static void StartTransportStreamOp(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_transport_stream_op_batch *op) {} +static void StartTransportStreamOp(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + grpc_transport_stream_op_batch* op) {} -static void StartTransportOp(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_transport_op *op) {} +static void StartTransportOp(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, + grpc_transport_op* op) {} -static grpc_error *InitCallElem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { +static grpc_error* InitCallElem(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_element_args* args) { return GRPC_ERROR_NONE; } -static void SetPollsetOrPollsetSet(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_polling_entity *pollent) {} +static void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + grpc_polling_entity* pollent) {} -static void DestroyCallElem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *then_sched_closure) {} +static void DestroyCallElem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* then_sched_closure) {} -grpc_error *InitChannelElem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, - grpc_channel_element_args *args) { +grpc_error* InitChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, + grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } -void DestroyChannelElem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem) {} +void DestroyChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem) {} -void GetChannelInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, - const grpc_channel_info *channel_info) {} +void GetChannelInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, + const grpc_channel_info* channel_info) {} static const grpc_channel_filter dummy_filter = {StartTransportStreamOp, StartTransportOp, @@ -419,42 +419,42 @@ namespace dummy_transport { size_t sizeof_stream; /* = sizeof(transport stream) */ /* name of this transport implementation */ -const char *name; +const char* name; /* implementation of grpc_transport_init_stream */ -int InitStream(grpc_exec_ctx *exec_ctx, grpc_transport *self, - grpc_stream *stream, grpc_stream_refcount *refcount, - const void *server_data, gpr_arena *arena) { +int InitStream(grpc_exec_ctx* exec_ctx, grpc_transport* self, + grpc_stream* stream, grpc_stream_refcount* refcount, + const void* server_data, gpr_arena* arena) { return 0; } /* implementation of grpc_transport_set_pollset */ -void SetPollset(grpc_exec_ctx *exec_ctx, grpc_transport *self, - grpc_stream *stream, grpc_pollset *pollset) {} +void SetPollset(grpc_exec_ctx* exec_ctx, grpc_transport* self, + grpc_stream* stream, grpc_pollset* pollset) {} /* implementation of grpc_transport_set_pollset */ -void SetPollsetSet(grpc_exec_ctx *exec_ctx, grpc_transport *self, - grpc_stream *stream, grpc_pollset_set *pollset_set) {} +void SetPollsetSet(grpc_exec_ctx* exec_ctx, grpc_transport* self, + grpc_stream* stream, grpc_pollset_set* pollset_set) {} /* implementation of grpc_transport_perform_stream_op */ -void PerformStreamOp(grpc_exec_ctx *exec_ctx, grpc_transport *self, - grpc_stream *stream, grpc_transport_stream_op_batch *op) { +void PerformStreamOp(grpc_exec_ctx* exec_ctx, grpc_transport* self, + grpc_stream* stream, grpc_transport_stream_op_batch* op) { GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_NONE); } /* implementation of grpc_transport_perform_op */ -void PerformOp(grpc_exec_ctx *exec_ctx, grpc_transport *self, - grpc_transport_op *op) {} +void PerformOp(grpc_exec_ctx* exec_ctx, grpc_transport* self, + grpc_transport_op* op) {} /* implementation of grpc_transport_destroy_stream */ -void DestroyStream(grpc_exec_ctx *exec_ctx, grpc_transport *self, - grpc_stream *stream, grpc_closure *then_sched_closure) {} +void DestroyStream(grpc_exec_ctx* exec_ctx, grpc_transport* self, + grpc_stream* stream, grpc_closure* then_sched_closure) {} /* implementation of grpc_transport_destroy */ -void Destroy(grpc_exec_ctx *exec_ctx, grpc_transport *self) {} +void Destroy(grpc_exec_ctx* exec_ctx, grpc_transport* self) {} /* implementation of grpc_transport_get_endpoint */ -grpc_endpoint *GetEndpoint(grpc_exec_ctx *exec_ctx, grpc_transport *self) { +grpc_endpoint* GetEndpoint(grpc_exec_ctx* exec_ctx, grpc_transport* self) { return nullptr; } @@ -472,8 +472,8 @@ class NoOp { public: class Op { public: - Op(grpc_exec_ctx *exec_ctx, NoOp *p, grpc_call_stack *s) {} - void Finish(grpc_exec_ctx *exec_ctx) {} + Op(grpc_exec_ctx* exec_ctx, NoOp* p, grpc_call_stack* s) {} + void Finish(grpc_exec_ctx* exec_ctx) {} }; }; @@ -489,11 +489,11 @@ class SendEmptyMetadata { class Op { public: - Op(grpc_exec_ctx *exec_ctx, SendEmptyMetadata *p, grpc_call_stack *s) { + Op(grpc_exec_ctx* exec_ctx, SendEmptyMetadata* p, grpc_call_stack* s) { grpc_metadata_batch_init(&batch_); p->op_payload_.send_initial_metadata.send_initial_metadata = &batch_; } - void Finish(grpc_exec_ctx *exec_ctx) { + void Finish(grpc_exec_ctx* exec_ctx) { grpc_metadata_batch_destroy(exec_ctx, &batch_); } @@ -514,7 +514,7 @@ class SendEmptyMetadata { // Fixture<> template to specify this), and TestOp defines some unit of work to // perform on said filter. template <class Fixture, class TestOp> -static void BM_IsolatedFilter(benchmark::State &state) { +static void BM_IsolatedFilter(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; std::ostringstream label; @@ -527,7 +527,7 @@ static void BM_IsolatedFilter(benchmark::State &state) { grpc_channel_args channel_args = {args.size(), &args[0]}; - std::vector<const grpc_channel_filter *> filters; + std::vector<const grpc_channel_filter*> filters; if (fixture.filter != nullptr) { filters.push_back(fixture.filter); } @@ -539,8 +539,8 @@ static void BM_IsolatedFilter(benchmark::State &state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; size_t channel_size = grpc_channel_stack_size( filters.size() == 0 ? NULL : &filters[0], filters.size()); - grpc_channel_stack *channel_stack = - static_cast<grpc_channel_stack *>(gpr_zalloc(channel_size)); + grpc_channel_stack* channel_stack = + static_cast<grpc_channel_stack*>(gpr_zalloc(channel_size)); GPR_ASSERT(GRPC_LOG_IF_ERROR( "channel_stack_init", grpc_channel_stack_init(&exec_ctx, 1, FilterDestroy, channel_stack, @@ -550,8 +550,8 @@ static void BM_IsolatedFilter(benchmark::State &state) { : nullptr, "CHANNEL", channel_stack))); grpc_exec_ctx_flush(&exec_ctx); - grpc_call_stack *call_stack = static_cast<grpc_call_stack *>( - gpr_zalloc(channel_stack->call_stack_size)); + grpc_call_stack* call_stack = + static_cast<grpc_call_stack*>(gpr_zalloc(channel_stack->call_stack_size)); grpc_millis deadline = GRPC_MILLIS_INF_FUTURE; gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); grpc_slice method = grpc_slice_from_static_string("/foo/bar"); @@ -628,12 +628,14 @@ BENCHMARK_TEMPLATE(BM_IsolatedFilter, LoadReportingFilter, SendEmptyMetadata); namespace isolated_call_filter { -typedef struct { grpc_call_combiner *call_combiner; } call_data; +typedef struct { + grpc_call_combiner* call_combiner; +} call_data; -static void StartTransportStreamOp(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_transport_stream_op_batch *op) { - call_data *calld = static_cast<call_data *>(elem->call_data); +static void StartTransportStreamOp(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + grpc_transport_stream_op_batch* op) { + call_data* calld = static_cast<call_data*>(elem->call_data); if (op->recv_initial_metadata) { GRPC_CALL_COMBINER_START( exec_ctx, calld->call_combiner, @@ -648,42 +650,42 @@ static void StartTransportStreamOp(grpc_exec_ctx *exec_ctx, GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_NONE); } -static void StartTransportOp(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_transport_op *op) { +static void StartTransportOp(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); } GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE); } -static grpc_error *InitCallElem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { - call_data *calld = static_cast<call_data *>(elem->call_data); +static grpc_error* InitCallElem(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_element_args* args) { + call_data* calld = static_cast<call_data*>(elem->call_data); calld->call_combiner = args->call_combiner; return GRPC_ERROR_NONE; } -static void SetPollsetOrPollsetSet(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_polling_entity *pollent) {} +static void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + grpc_polling_entity* pollent) {} -static void DestroyCallElem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *then_sched_closure) { +static void DestroyCallElem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* then_sched_closure) { GRPC_CLOSURE_SCHED(exec_ctx, then_sched_closure, GRPC_ERROR_NONE); } -grpc_error *InitChannelElem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, - grpc_channel_element_args *args) { +grpc_error* InitChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, + grpc_channel_element_args* args) { return GRPC_ERROR_NONE; } -void DestroyChannelElem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem) {} +void DestroyChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem) {} -void GetChannelInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, - const grpc_channel_info *channel_info) {} +void GetChannelInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, + const grpc_channel_info* channel_info) {} static const grpc_channel_filter isolated_call_filter = { StartTransportStreamOp, @@ -702,7 +704,7 @@ static const grpc_channel_filter isolated_call_filter = { class IsolatedCallFixture : public TrackCounters { public: IsolatedCallFixture() { - grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create(); + grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); grpc_channel_stack_builder_set_name(builder, "dummy"); grpc_channel_stack_builder_set_target(builder, "dummy_target"); GPR_ASSERT(grpc_channel_stack_builder_append_filter( @@ -716,24 +718,24 @@ class IsolatedCallFixture : public TrackCounters { cq_ = grpc_completion_queue_create_for_next(NULL); } - void Finish(benchmark::State &state) { + void Finish(benchmark::State& state) { grpc_completion_queue_destroy(cq_); grpc_channel_destroy(channel_); TrackCounters::Finish(state); } - grpc_channel *channel() const { return channel_; } - grpc_completion_queue *cq() const { return cq_; } + grpc_channel* channel() const { return channel_; } + grpc_completion_queue* cq() const { return cq_; } private: - grpc_completion_queue *cq_; - grpc_channel *channel_; + grpc_completion_queue* cq_; + grpc_channel* channel_; }; -static void BM_IsolatedCall_NoOp(benchmark::State &state) { +static void BM_IsolatedCall_NoOp(benchmark::State& state) { IsolatedCallFixture fixture; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - void *method_hdl = + void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); @@ -745,14 +747,14 @@ static void BM_IsolatedCall_NoOp(benchmark::State &state) { } BENCHMARK(BM_IsolatedCall_NoOp); -static void BM_IsolatedCall_Unary(benchmark::State &state) { +static void BM_IsolatedCall_Unary(benchmark::State& state) { IsolatedCallFixture fixture; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - void *method_hdl = + void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); grpc_slice slice = grpc_slice_from_static_string("hello world"); - grpc_byte_buffer *send_message = grpc_raw_byte_buffer_create(&slice, 1); - grpc_byte_buffer *recv_message = NULL; + grpc_byte_buffer* send_message = grpc_raw_byte_buffer_create(&slice, 1); + grpc_byte_buffer* recv_message = NULL; grpc_status_code status_code; grpc_slice status_details = grpc_empty_slice(); grpc_metadata_array recv_initial_metadata; @@ -776,7 +778,7 @@ static void BM_IsolatedCall_Unary(benchmark::State &state) { ops[5].data.recv_status_on_client.trailing_metadata = &recv_trailing_metadata; while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - grpc_call *call = grpc_channel_create_registered_call( + grpc_call* call = grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), method_hdl, deadline, NULL); grpc_call_start_batch(call, ops, 6, tag(1), NULL); @@ -791,13 +793,13 @@ static void BM_IsolatedCall_Unary(benchmark::State &state) { } BENCHMARK(BM_IsolatedCall_Unary); -static void BM_IsolatedCall_StreamingSend(benchmark::State &state) { +static void BM_IsolatedCall_StreamingSend(benchmark::State& state) { IsolatedCallFixture fixture; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - void *method_hdl = + void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); grpc_slice slice = grpc_slice_from_static_string("hello world"); - grpc_byte_buffer *send_message = grpc_raw_byte_buffer_create(&slice, 1); + grpc_byte_buffer* send_message = grpc_raw_byte_buffer_create(&slice, 1); grpc_metadata_array recv_initial_metadata; grpc_metadata_array_init(&recv_initial_metadata); grpc_metadata_array recv_trailing_metadata; @@ -808,7 +810,7 @@ static void BM_IsolatedCall_StreamingSend(benchmark::State &state) { ops[1].op = GRPC_OP_RECV_INITIAL_METADATA; ops[1].data.recv_initial_metadata.recv_initial_metadata = &recv_initial_metadata; - grpc_call *call = grpc_channel_create_registered_call( + grpc_call* call = grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), method_hdl, deadline, NULL); grpc_call_start_batch(call, ops, 2, tag(1), NULL); diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 930081341b..45f5382fde 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -33,11 +33,11 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "third_party/benchmark/include/benchmark/benchmark.h" -auto &force_library_initialization = Library::get(); +auto& force_library_initialization = Library::get(); static grpc_slice MakeSlice(std::vector<uint8_t> bytes) { grpc_slice s = grpc_slice_malloc(bytes.size()); - uint8_t *p = GRPC_SLICE_START_PTR(s); + uint8_t* p = GRPC_SLICE_START_PTR(s); for (auto b : bytes) { *p++ = b; } @@ -48,7 +48,7 @@ static grpc_slice MakeSlice(std::vector<uint8_t> bytes) { // HPACK encoder // -static void BM_HpackEncoderInitDestroy(benchmark::State &state) { +static void BM_HpackEncoderInitDestroy(benchmark::State& state) { TrackCounters track_counters; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_chttp2_hpack_compressor c; @@ -62,7 +62,7 @@ static void BM_HpackEncoderInitDestroy(benchmark::State &state) { } BENCHMARK(BM_HpackEncoderInitDestroy); -static void BM_HpackEncoderEncodeDeadline(benchmark::State &state) { +static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) { TrackCounters track_counters; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis saved_now = grpc_exec_ctx_now(&exec_ctx); @@ -95,17 +95,19 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State &state) { grpc_exec_ctx_finish(&exec_ctx); std::ostringstream label; - label << "framing_bytes/iter:" << (static_cast<double>(stats.framing_bytes) / - static_cast<double>(state.iterations())) - << " header_bytes/iter:" << (static_cast<double>(stats.header_bytes) / - static_cast<double>(state.iterations())); + label << "framing_bytes/iter:" + << (static_cast<double>(stats.framing_bytes) / + static_cast<double>(state.iterations())) + << " header_bytes/iter:" + << (static_cast<double>(stats.header_bytes) / + static_cast<double>(state.iterations())); track_counters.AddLabel(label.str()); track_counters.Finish(state); } BENCHMARK(BM_HpackEncoderEncodeDeadline); template <class Fixture> -static void BM_HpackEncoderEncodeHeader(benchmark::State &state) { +static void BM_HpackEncoderEncodeHeader(benchmark::State& state) { TrackCounters track_counters; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; static bool logged_representative_output = false; @@ -138,7 +140,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State &state) { if (!logged_representative_output && state.iterations() > 3) { logged_representative_output = true; for (size_t i = 0; i < outbuf.count; i++) { - char *s = grpc_dump_slice(outbuf.slices[i], GPR_DUMP_HEX); + char* s = grpc_dump_slice(outbuf.slices[i], GPR_DUMP_HEX); gpr_log(GPR_DEBUG, "%" PRIdPTR ": %s", i, s); gpr_free(s); } @@ -152,10 +154,12 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State &state) { grpc_exec_ctx_finish(&exec_ctx); std::ostringstream label; - label << "framing_bytes/iter:" << (static_cast<double>(stats.framing_bytes) / - static_cast<double>(state.iterations())) - << " header_bytes/iter:" << (static_cast<double>(stats.header_bytes) / - static_cast<double>(state.iterations())); + label << "framing_bytes/iter:" + << (static_cast<double>(stats.framing_bytes) / + static_cast<double>(state.iterations())) + << " header_bytes/iter:" + << (static_cast<double>(stats.header_bytes) / + static_cast<double>(state.iterations())); track_counters.AddLabel(label.str()); track_counters.Finish(state); } @@ -165,7 +169,7 @@ namespace hpack_encoder_fixtures { class EmptyBatch { public: static constexpr bool kEnableTrueBinary = false; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return {}; } }; @@ -173,7 +177,7 @@ class EmptyBatch { class SingleStaticElem { public: static constexpr bool kEnableTrueBinary = false; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return {GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE}; } }; @@ -181,7 +185,7 @@ class SingleStaticElem { class SingleInternedElem { public: static constexpr bool kEnableTrueBinary = false; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return {grpc_mdelem_from_slices( exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")), grpc_slice_intern(grpc_slice_from_static_string("def")))}; @@ -192,7 +196,7 @@ template <int kLength, bool kTrueBinary> class SingleInternedBinaryElem { public: static constexpr bool kEnableTrueBinary = kTrueBinary; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { grpc_slice bytes = MakeBytes(); std::vector<grpc_mdelem> out = {grpc_mdelem_from_slices( exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc-bin")), @@ -214,7 +218,7 @@ class SingleInternedBinaryElem { class SingleInternedKeyElem { public: static constexpr bool kEnableTrueBinary = false; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return {grpc_mdelem_from_slices( exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")), grpc_slice_from_static_string("def"))}; @@ -224,7 +228,7 @@ class SingleInternedKeyElem { class SingleNonInternedElem { public: static constexpr bool kEnableTrueBinary = false; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return {grpc_mdelem_from_slices(exec_ctx, grpc_slice_from_static_string("abc"), grpc_slice_from_static_string("def"))}; @@ -235,7 +239,7 @@ template <int kLength, bool kTrueBinary> class SingleNonInternedBinaryElem { public: static constexpr bool kEnableTrueBinary = kTrueBinary; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return {grpc_mdelem_from_slices( exec_ctx, grpc_slice_from_static_string("abc-bin"), MakeBytes())}; } @@ -253,9 +257,10 @@ class SingleNonInternedBinaryElem { class RepresentativeClientInitialMetadata { public: static constexpr bool kEnableTrueBinary = true; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return { - GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_METHOD_POST, + GRPC_MDELEM_SCHEME_HTTP, + GRPC_MDELEM_METHOD_POST, grpc_mdelem_from_slices( exec_ctx, GRPC_MDSTR_PATH, grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))), @@ -278,9 +283,10 @@ class RepresentativeClientInitialMetadata { class MoreRepresentativeClientInitialMetadata { public: static constexpr bool kEnableTrueBinary = true; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return { - GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_METHOD_POST, + GRPC_MDELEM_SCHEME_HTTP, + GRPC_MDELEM_METHOD_POST, grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_PATH, grpc_slice_intern(grpc_slice_from_static_string( "/grpc.test.FooService/BarMethod"))), @@ -314,7 +320,7 @@ class MoreRepresentativeClientInitialMetadata { class RepresentativeServerInitialMetadata { public: static constexpr bool kEnableTrueBinary = true; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return {GRPC_MDELEM_STATUS_200, GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC, GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP}; @@ -324,7 +330,7 @@ class RepresentativeServerInitialMetadata { class RepresentativeServerTrailingMetadata { public: static constexpr bool kEnableTrueBinary = true; - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return {GRPC_MDELEM_GRPC_STATUS_0}; } }; @@ -423,7 +429,7 @@ BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, // HPACK parser // -static void BM_HpackParserInitDestroy(benchmark::State &state) { +static void BM_HpackParserInitDestroy(benchmark::State& state) { TrackCounters track_counters; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_chttp2_hpack_parser p; @@ -437,13 +443,13 @@ static void BM_HpackParserInitDestroy(benchmark::State &state) { } BENCHMARK(BM_HpackParserInitDestroy); -static void UnrefHeader(grpc_exec_ctx *exec_ctx, void *user_data, +static void UnrefHeader(grpc_exec_ctx* exec_ctx, void* user_data, grpc_mdelem md) { GRPC_MDELEM_UNREF(exec_ctx, md); } -template <class Fixture, void (*OnHeader)(grpc_exec_ctx *, void *, grpc_mdelem)> -static void BM_HpackParserParseHeader(benchmark::State &state) { +template <class Fixture, void (*OnHeader)(grpc_exec_ctx*, void*, grpc_mdelem)> +static void BM_HpackParserParseHeader(benchmark::State& state) { TrackCounters track_counters; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; std::vector<grpc_slice> init_slices = Fixture::GetInitSlices(); @@ -760,20 +766,20 @@ class RepresentativeServerTrailingMetadata { } }; -static void free_timeout(void *p) { gpr_free(p); } +static void free_timeout(void* p) { gpr_free(p); } // New implementation. -static void OnHeaderNew(grpc_exec_ctx *exec_ctx, void *user_data, +static void OnHeaderNew(grpc_exec_ctx* exec_ctx, void* user_data, grpc_mdelem md) { if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) { - grpc_millis *cached_timeout = - static_cast<grpc_millis *>(grpc_mdelem_get_user_data(md, free_timeout)); + grpc_millis* cached_timeout = + static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout)); grpc_millis timeout; if (cached_timeout != NULL) { timeout = *cached_timeout; } else { if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) { - char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); + char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val); gpr_free(val); timeout = GRPC_MILLIS_INF_FUTURE; @@ -781,7 +787,7 @@ static void OnHeaderNew(grpc_exec_ctx *exec_ctx, void *user_data, if (GRPC_MDELEM_IS_INTERNED(md)) { /* not already parsed: parse it now, and store the * result away */ - cached_timeout = (grpc_millis *)gpr_malloc(sizeof(grpc_millis)); + cached_timeout = (grpc_millis*)gpr_malloc(sizeof(grpc_millis)); *cached_timeout = timeout; grpc_mdelem_set_user_data(md, free_timeout, cached_timeout); } diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index e9f537faa4..154cc91778 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -35,7 +35,7 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "third_party/benchmark/include/benchmark/benchmark.h" -auto &force_library_initialization = Library::get(); +auto& force_library_initialization = Library::get(); //////////////////////////////////////////////////////////////////////////////// // Helper classes @@ -58,7 +58,7 @@ class DummyEndpoint : public grpc_endpoint { ru_ = grpc_resource_user_create(Library::get().rq(), "dummy_endpoint"); } - void PushInput(grpc_exec_ctx *exec_ctx, grpc_slice slice) { + void PushInput(grpc_exec_ctx* exec_ctx, grpc_slice slice) { if (read_cb_ == nullptr) { GPR_ASSERT(!have_slice_); buffered_slice_ = slice; @@ -71,14 +71,14 @@ class DummyEndpoint : public grpc_endpoint { } private: - grpc_resource_user *ru_; - grpc_closure *read_cb_ = nullptr; - grpc_slice_buffer *slices_ = nullptr; + grpc_resource_user* ru_; + grpc_closure* read_cb_ = nullptr; + grpc_slice_buffer* slices_ = nullptr; bool have_slice_ = false; grpc_slice buffered_slice_; - void QueueRead(grpc_exec_ctx *exec_ctx, grpc_slice_buffer *slices, - grpc_closure *cb) { + void QueueRead(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* slices, + grpc_closure* cb) { GPR_ASSERT(read_cb_ == nullptr); if (have_slice_) { have_slice_ = false; @@ -90,51 +90,50 @@ class DummyEndpoint : public grpc_endpoint { slices_ = slices; } - static void read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - static_cast<DummyEndpoint *>(ep)->QueueRead(exec_ctx, slices, cb); + static void read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + static_cast<DummyEndpoint*>(ep)->QueueRead(exec_ctx, slices, cb); } - static void write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { + static void write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE); } - static grpc_workqueue *get_workqueue(grpc_endpoint *ep) { return NULL; } + static grpc_workqueue* get_workqueue(grpc_endpoint* ep) { return NULL; } - static void add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset *pollset) {} + static void add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset* pollset) {} - static void add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset_set *pollset) {} + static void add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset_set* pollset) {} - static void delete_from_pollset_set(grpc_exec_ctx *exec_ctx, - grpc_endpoint *ep, - grpc_pollset_set *pollset) {} + static void delete_from_pollset_set(grpc_exec_ctx* exec_ctx, + grpc_endpoint* ep, + grpc_pollset_set* pollset) {} - static void shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_error *why) { - grpc_resource_user_shutdown(exec_ctx, - static_cast<DummyEndpoint *>(ep)->ru_); - GRPC_CLOSURE_SCHED(exec_ctx, static_cast<DummyEndpoint *>(ep)->read_cb_, + static void shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_error* why) { + grpc_resource_user_shutdown(exec_ctx, static_cast<DummyEndpoint*>(ep)->ru_); + GRPC_CLOSURE_SCHED(exec_ctx, static_cast<DummyEndpoint*>(ep)->read_cb_, why); } - static void destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { - grpc_resource_user_unref(exec_ctx, static_cast<DummyEndpoint *>(ep)->ru_); - delete static_cast<DummyEndpoint *>(ep); + static void destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) { + grpc_resource_user_unref(exec_ctx, static_cast<DummyEndpoint*>(ep)->ru_); + delete static_cast<DummyEndpoint*>(ep); } - static grpc_resource_user *get_resource_user(grpc_endpoint *ep) { - return static_cast<DummyEndpoint *>(ep)->ru_; + static grpc_resource_user* get_resource_user(grpc_endpoint* ep) { + return static_cast<DummyEndpoint*>(ep)->ru_; } - static char *get_peer(grpc_endpoint *ep) { return gpr_strdup("test"); } - static int get_fd(grpc_endpoint *ep) { return 0; } + static char* get_peer(grpc_endpoint* ep) { return gpr_strdup("test"); } + static int get_fd(grpc_endpoint* ep) { return 0; } }; class Fixture { public: - Fixture(const grpc::ChannelArguments &args, bool client) { + Fixture(const grpc::ChannelArguments& args, bool client) { grpc_channel_args c_args = args.c_channel_args(); ep_ = new DummyEndpoint; t_ = grpc_create_chttp2_transport(exec_ctx(), &c_args, ep_, client); @@ -149,18 +148,18 @@ class Fixture { grpc_exec_ctx_finish(&exec_ctx_); } - grpc_chttp2_transport *chttp2_transport() { - return reinterpret_cast<grpc_chttp2_transport *>(t_); + grpc_chttp2_transport* chttp2_transport() { + return reinterpret_cast<grpc_chttp2_transport*>(t_); } - grpc_transport *transport() { return t_; } - grpc_exec_ctx *exec_ctx() { return &exec_ctx_; } + grpc_transport* transport() { return t_; } + grpc_exec_ctx* exec_ctx() { return &exec_ctx_; } void PushInput(grpc_slice slice) { ep_->PushInput(exec_ctx(), slice); } private: - DummyEndpoint *ep_; + DummyEndpoint* ep_; grpc_exec_ctx exec_ctx_ = GRPC_EXEC_CTX_INIT; - grpc_transport *t_; + grpc_transport* t_; }; class Closure : public grpc_closure { @@ -170,37 +169,37 @@ class Closure : public grpc_closure { template <class F> std::unique_ptr<Closure> MakeClosure( - F f, grpc_closure_scheduler *sched = grpc_schedule_on_exec_ctx) { + F f, grpc_closure_scheduler* sched = grpc_schedule_on_exec_ctx) { struct C : public Closure { - C(const F &f, grpc_closure_scheduler *sched) : f_(f) { + C(const F& f, grpc_closure_scheduler* sched) : f_(f) { GRPC_CLOSURE_INIT(this, Execute, this, sched); } F f_; - static void Execute(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - static_cast<C *>(arg)->f_(exec_ctx, error); + static void Execute(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + static_cast<C*>(arg)->f_(exec_ctx, error); } }; return std::unique_ptr<Closure>(new C(f, sched)); } template <class F> -grpc_closure *MakeOnceClosure( - F f, grpc_closure_scheduler *sched = grpc_schedule_on_exec_ctx) { +grpc_closure* MakeOnceClosure( + F f, grpc_closure_scheduler* sched = grpc_schedule_on_exec_ctx) { struct C : public grpc_closure { - C(const F &f) : f_(f) {} + C(const F& f) : f_(f) {} F f_; - static void Execute(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - static_cast<C *>(arg)->f_(exec_ctx, error); - delete static_cast<C *>(arg); + static void Execute(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + static_cast<C*>(arg)->f_(exec_ctx, error); + delete static_cast<C*>(arg); } }; - auto *c = new C{f}; + auto* c = new C{f}; return GRPC_CLOSURE_INIT(c, C::Execute, c, sched); } class Stream { public: - Stream(Fixture *f) : f_(f) { + Stream(Fixture* f) : f_(f) { stream_size_ = grpc_transport_stream_size(f->transport()); stream_ = gpr_malloc(stream_size_); arena_ = gpr_arena_create(4096); @@ -212,7 +211,7 @@ class Stream { gpr_arena_destroy(arena_); } - void Init(benchmark::State &state) { + void Init(benchmark::State& state) { GRPC_STREAM_REF_INIT(&refcount_, 1, &Stream::FinishDestroy, this, "test_stream"); gpr_event_init(&done_); @@ -222,11 +221,11 @@ class Stream { arena_ = gpr_arena_create(4096); } grpc_transport_init_stream(f_->exec_ctx(), f_->transport(), - static_cast<grpc_stream *>(stream_), &refcount_, + static_cast<grpc_stream*>(stream_), &refcount_, NULL, arena_); } - void DestroyThen(grpc_exec_ctx *exec_ctx, grpc_closure *closure) { + void DestroyThen(grpc_exec_ctx* exec_ctx, grpc_closure* closure) { destroy_closure_ = closure; #ifndef NDEBUG grpc_stream_unref(exec_ctx, &refcount_, "DestroyThen"); @@ -235,31 +234,31 @@ class Stream { #endif } - void Op(grpc_exec_ctx *exec_ctx, grpc_transport_stream_op_batch *op) { + void Op(grpc_exec_ctx* exec_ctx, grpc_transport_stream_op_batch* op) { grpc_transport_perform_stream_op(exec_ctx, f_->transport(), - static_cast<grpc_stream *>(stream_), op); + static_cast<grpc_stream*>(stream_), op); } - grpc_chttp2_stream *chttp2_stream() { - return static_cast<grpc_chttp2_stream *>(stream_); + grpc_chttp2_stream* chttp2_stream() { + return static_cast<grpc_chttp2_stream*>(stream_); } private: - static void FinishDestroy(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - auto stream = static_cast<Stream *>(arg); + static void FinishDestroy(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + auto stream = static_cast<Stream*>(arg); grpc_transport_destroy_stream(exec_ctx, stream->f_->transport(), - static_cast<grpc_stream *>(stream->stream_), + static_cast<grpc_stream*>(stream->stream_), stream->destroy_closure_); - gpr_event_set(&stream->done_, (void *)1); + gpr_event_set(&stream->done_, (void*)1); } - Fixture *f_; + Fixture* f_; grpc_stream_refcount refcount_; - gpr_arena *arena_; + gpr_arena* arena_; size_t stream_size_; - void *stream_; - grpc_closure *destroy_closure_ = nullptr; + void* stream_; + grpc_closure* destroy_closure_ = nullptr; gpr_event done_; }; @@ -267,7 +266,7 @@ class Stream { // Benchmarks // -static void BM_StreamCreateDestroy(benchmark::State &state) { +static void BM_StreamCreateDestroy(benchmark::State& state) { TrackCounters track_counters; Fixture f(grpc::ChannelArguments(), true); Stream s(&f); @@ -278,7 +277,7 @@ static void BM_StreamCreateDestroy(benchmark::State &state) { op.payload = &op_payload; op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; std::unique_ptr<Closure> next = - MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) { + MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { if (!state.KeepRunning()) return; s.Init(state); s.Op(exec_ctx, &op); @@ -292,9 +291,10 @@ BENCHMARK(BM_StreamCreateDestroy); class RepresentativeClientInitialMetadata { public: - static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) { + static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) { return { - GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_METHOD_POST, + GRPC_MDELEM_SCHEME_HTTP, + GRPC_MDELEM_METHOD_POST, grpc_mdelem_from_slices( exec_ctx, GRPC_MDSTR_PATH, grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))), @@ -312,7 +312,7 @@ class RepresentativeClientInitialMetadata { }; template <class Metadata> -static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State &state) { +static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { TrackCounters track_counters; Fixture f(grpc::ChannelArguments(), true); Stream s(&f); @@ -339,7 +339,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State &state) { } f.FlushExecCtx(); - start = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) { + start = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { if (!state.KeepRunning()) return; s.Init(state); reset_op(); @@ -348,7 +348,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State &state) { op.payload->send_initial_metadata.send_initial_metadata = &b; s.Op(exec_ctx, &op); }); - done = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) { + done = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { reset_op(); op.cancel_stream = true; op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; @@ -363,7 +363,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State &state) { BENCHMARK_TEMPLATE(BM_StreamCreateSendInitialMetadataDestroy, RepresentativeClientInitialMetadata); -static void BM_TransportEmptyOp(benchmark::State &state) { +static void BM_TransportEmptyOp(benchmark::State& state) { TrackCounters track_counters; Fixture f(grpc::ChannelArguments(), true); Stream s(&f); @@ -376,7 +376,7 @@ static void BM_TransportEmptyOp(benchmark::State &state) { op.payload = &op_payload; }; std::unique_ptr<Closure> c = - MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) { + MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { if (!state.KeepRunning()) return; reset_op(); op.on_complete = c.get(); @@ -388,8 +388,8 @@ static void BM_TransportEmptyOp(benchmark::State &state) { op.cancel_stream = true; op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; s.Op(f.exec_ctx(), &op); - s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx *exec_ctx, - grpc_error *error) {})); + s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx* exec_ctx, + grpc_error* error) {})); f.FlushExecCtx(); track_counters.Finish(state); } @@ -397,7 +397,7 @@ BENCHMARK(BM_TransportEmptyOp); std::vector<std::unique_ptr<gpr_event>> done_events; -static void BM_TransportStreamSend(benchmark::State &state) { +static void BM_TransportStreamSend(benchmark::State& state) { TrackCounters track_counters; Fixture f(grpc::ChannelArguments(), true); auto s = std::unique_ptr<Stream>(new Stream(&f)); @@ -428,13 +428,13 @@ static void BM_TransportStreamSend(benchmark::State &state) { grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i]))); } - gpr_event *bm_done = new gpr_event; + gpr_event* bm_done = new gpr_event; gpr_event_init(bm_done); std::unique_ptr<Closure> c = - MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) { + MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { if (!state.KeepRunning()) { - gpr_event_set(bm_done, (void *)1); + gpr_event_set(bm_done, (void*)1); return; } // force outgoing window to be yuge @@ -462,8 +462,8 @@ static void BM_TransportStreamSend(benchmark::State &state) { op.cancel_stream = true; op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; s->Op(f.exec_ctx(), &op); - s->DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx *exec_ctx, - grpc_error *error) {})); + s->DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx* exec_ctx, + grpc_error* error) {})); f.FlushExecCtx(); s.reset(); track_counters.Finish(state); @@ -529,7 +529,7 @@ static grpc_slice CreateIncomingDataSlice(size_t length, size_t frame_size) { return grpc_slice_from_copied_buffer(framed.data(), framed.size()); } -static void BM_TransportStreamRecv(benchmark::State &state) { +static void BM_TransportStreamRecv(benchmark::State& state) { TrackCounters track_counters; Fixture f(grpc::ChannelArguments(), true); Stream s(&f); @@ -537,7 +537,7 @@ static void BM_TransportStreamRecv(benchmark::State &state) { grpc_transport_stream_op_batch_payload op_payload; memset(&op_payload, 0, sizeof(op_payload)); grpc_transport_stream_op_batch op; - grpc_byte_stream *recv_stream; + grpc_byte_stream* recv_stream; grpc_slice incoming_data = CreateIncomingDataSlice(state.range(0), 16384); auto reset_op = [&]() { @@ -560,7 +560,7 @@ static void BM_TransportStreamRecv(benchmark::State &state) { } std::unique_ptr<Closure> do_nothing = - MakeClosure([](grpc_exec_ctx *exec_ctx, grpc_error *error) {}); + MakeClosure([](grpc_exec_ctx* exec_ctx, grpc_error* error) {}); uint32_t received; @@ -570,7 +570,7 @@ static void BM_TransportStreamRecv(benchmark::State &state) { grpc_slice recv_slice; std::unique_ptr<Closure> c = - MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) { + MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { if (!state.KeepRunning()) return; // force outgoing window to be yuge s.chttp2_stream()->flow_control->TestOnlyForceHugeWindow(); @@ -585,7 +585,7 @@ static void BM_TransportStreamRecv(benchmark::State &state) { f.PushInput(grpc_slice_ref(incoming_data)); }); - drain_start = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) { + drain_start = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { if (recv_stream == NULL) { GPR_ASSERT(!state.KeepRunning()); return; @@ -593,7 +593,7 @@ static void BM_TransportStreamRecv(benchmark::State &state) { GRPC_CLOSURE_RUN(exec_ctx, drain.get(), GRPC_ERROR_NONE); }); - drain = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) { + drain = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { do { if (received == recv_stream->length) { grpc_byte_stream_destroy(exec_ctx, recv_stream); @@ -609,7 +609,7 @@ static void BM_TransportStreamRecv(benchmark::State &state) { grpc_slice_unref_internal(exec_ctx, recv_slice), true)); }); - drain_continue = MakeClosure([&](grpc_exec_ctx *exec_ctx, grpc_error *error) { + drain_continue = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { grpc_byte_stream_pull(exec_ctx, recv_stream, &recv_slice); received += GRPC_SLICE_LENGTH(recv_slice); grpc_slice_unref_internal(exec_ctx, recv_slice); @@ -643,8 +643,8 @@ static void BM_TransportStreamRecv(benchmark::State &state) { op.cancel_stream = true; op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; s.Op(f.exec_ctx(), &op); - s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx *exec_ctx, - grpc_error *error) {})); + s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx* exec_ctx, + grpc_error* error) {})); f.FlushExecCtx(); track_counters.Finish(state); grpc_metadata_batch_destroy(f.exec_ctx(), &b); diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc index 3b9e261a22..458a2ceb13 100644 --- a/test/cpp/microbenchmarks/bm_closure.cc +++ b/test/cpp/microbenchmarks/bm_closure.cc @@ -98,9 +98,10 @@ static void BM_ClosureCreateAndRun(benchmark::State& state) { TrackCounters track_counters; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { - GRPC_CLOSURE_RUN(&exec_ctx, GRPC_CLOSURE_CREATE(DoNothing, NULL, - grpc_schedule_on_exec_ctx), - GRPC_ERROR_NONE); + GRPC_CLOSURE_RUN( + &exec_ctx, + GRPC_CLOSURE_CREATE(DoNothing, NULL, grpc_schedule_on_exec_ctx), + GRPC_ERROR_NONE); } grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); @@ -112,9 +113,10 @@ static void BM_ClosureInitAndRun(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_closure c; while (state.KeepRunning()) { - GRPC_CLOSURE_RUN(&exec_ctx, GRPC_CLOSURE_INIT(&c, DoNothing, NULL, - grpc_schedule_on_exec_ctx), - GRPC_ERROR_NONE); + GRPC_CLOSURE_RUN( + &exec_ctx, + GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx), + GRPC_ERROR_NONE); } grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index 25d243a104..f75c3e4436 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -135,8 +135,9 @@ class TrickledCHTTP2 : public EndpointPairFixture { ? static_cast<grpc_chttp2_stream*>(server->stream_map.values[0]) : nullptr; write_csv( - log_.get(), static_cast<double>(now.tv_sec) + - 1e-9 * static_cast<double>(now.tv_nsec), + log_.get(), + static_cast<double>(now.tv_sec) + + 1e-9 * static_cast<double>(now.tv_nsec), iteration, grpc_trickle_get_backlog(endpoint_pair_.client), grpc_trickle_get_backlog(endpoint_pair_.server), client->lists[GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT].head != nullptr, @@ -441,8 +442,8 @@ static void UnaryTrickleArgs(benchmark::internal::Benchmark* b) { } } BENCHMARK(BM_PumpUnbalancedUnary_Trickle)->Apply(UnaryTrickleArgs); -} -} +} // namespace testing +} // namespace grpc extern "C" gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type); diff --git a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h index 06d18b890d..6df044f344 100644 --- a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h @@ -278,7 +278,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { void* t; bool ok; - int expect_tags; + int need_tags; // Send 'max_ping_pongs' number of ping pong messages int ping_pong_cnt = 0; @@ -289,7 +289,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { request_rw->Write(send_request, tag(2)); // Start client send } - int await_tags = (1 << 2); + need_tags = (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5); if (ping_pong_cnt == 0) { // wait for the server call structure (call_hook, etc.) to be @@ -301,8 +301,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { // In some cases tag:2 comes before tag:0 (write tag comes out // first), this while loop is to make sure get tag:0. int i = (int)(intptr_t)t; - GPR_ASSERT(await_tags & (1 << i)); - await_tags &= ~(1 << i); + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); GPR_ASSERT(fixture->cq()->Next(&t, &ok)); } } @@ -310,11 +310,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { response_rw.Read(&recv_request, tag(3)); // Start server recv request_rw->Read(&recv_response, tag(4)); // Start client recv - await_tags |= (1 << 3) | (1 << 4); - expect_tags = await_tags; - await_tags |= (1 << 5); - - while (await_tags != 0) { + while (need_tags) { GPR_ASSERT(fixture->cq()->Next(&t, &ok)); GPR_ASSERT(ok); int i = (int)(intptr_t)t; @@ -325,39 +321,34 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { if (write_and_finish == 1) { response_rw.WriteAndFinish(send_response, WriteOptions(), Status::OK, tag(5)); - expect_tags |= (1 << 5); } else { response_rw.WriteLast(send_response, WriteOptions(), tag(5)); - // WriteLast buffers the write, so it's possible neither server - // write op nor client read op will finish inside the while - // loop. - await_tags &= ~(1 << 4); - await_tags &= ~(1 << 5); - expect_tags |= (1 << 5); + // WriteLast buffers the write, so neither server write op nor + // client read op will finish inside the while loop. + need_tags &= ~(1 << 4); + need_tags &= ~(1 << 5); } } else { response_rw.Write(send_response, tag(5)); - expect_tags |= (1 << 5); } } - GPR_ASSERT(expect_tags & (1 << i)); - expect_tags &= ~(1 << i); - await_tags &= ~(1 << i); + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); } ping_pong_cnt++; } if (max_ping_pongs == 0) { - expect_tags |= (1 << 6) | (1 << 7) | (1 << 8); + need_tags = (1 << 6) | (1 << 7) | (1 << 8); } else { if (write_and_finish == 1) { - expect_tags |= (1 << 8); + need_tags = (1 << 8); } else { // server's buffered write and the client's read of the buffered write // tags should come up. - expect_tags |= (1 << 7) | (1 << 8); + need_tags = (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8); } } @@ -369,8 +360,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { GPR_ASSERT(fixture->cq()->Next(&t, &ok)); while ((int)(intptr_t)t != 0) { int i = (int)(intptr_t)t; - GPR_ASSERT(expect_tags & (1 << i)); - expect_tags &= ~(1 << i); + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); GPR_ASSERT(fixture->cq()->Next(&t, &ok)); } response_rw.Finish(Status::OK, tag(7)); @@ -383,11 +374,11 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { Status recv_status; request_rw->Finish(&recv_status, tag(8)); - while (expect_tags) { + while (need_tags) { GPR_ASSERT(fixture->cq()->Next(&t, &ok)); int i = (int)(intptr_t)t; - GPR_ASSERT(expect_tags & (1 << i)); - expect_tags &= ~(1 << i); + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); } GPR_ASSERT(recv_status.ok()); diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc index 782f12e99a..a4c0a3a0ce 100644 --- a/test/cpp/microbenchmarks/helpers.cc +++ b/test/cpp/microbenchmarks/helpers.cc @@ -20,9 +20,9 @@ #include "test/cpp/microbenchmarks/helpers.h" -void TrackCounters::Finish(benchmark::State &state) { +void TrackCounters::Finish(benchmark::State& state) { std::ostringstream out; - for (const auto &l : labels_) { + for (const auto& l : labels_) { out << l << ' '; } AddToLabel(out, state); @@ -33,11 +33,11 @@ void TrackCounters::Finish(benchmark::State &state) { state.SetLabel(label.c_str()); } -void TrackCounters::AddLabel(const grpc::string &label) { +void TrackCounters::AddLabel(const grpc::string& label) { labels_.push_back(label); } -void TrackCounters::AddToLabel(std::ostream &out, benchmark::State &state) { +void TrackCounters::AddToLabel(std::ostream& out, benchmark::State& state) { grpc_stats_data stats_end; grpc_stats_collect(&stats_end); grpc_stats_data stats; @@ -58,9 +58,10 @@ void TrackCounters::AddToLabel(std::ostream &out, benchmark::State &state) { } #ifdef GPR_LOW_LEVEL_COUNTERS grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot(); - out << " locks/iter:" << ((double)(gpr_atm_no_barrier_load(&gpr_mu_locks) - - mu_locks_at_start_) / - (double)state.iterations()) + out << " locks/iter:" + << ((double)(gpr_atm_no_barrier_load(&gpr_mu_locks) - + mu_locks_at_start_) / + (double)state.iterations()) << " atm_cas/iter:" << ((double)(gpr_atm_no_barrier_load(&gpr_counter_atm_cas) - atm_cas_at_start_) / diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index a0ac4c501a..94adbcbd35 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -47,8 +47,8 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -using std::vector; using grpc::SubProcess; +using std::vector; using testing::UnorderedElementsAreArray; // Hack copied from "test/cpp/end2end/server_crash_test_client.cc"! @@ -83,12 +83,12 @@ class GrpcLBAddress final { GrpcLBAddress(std::string address, bool is_balancer) : is_balancer(is_balancer), address(address) {} - bool operator==(const GrpcLBAddress &other) const { + bool operator==(const GrpcLBAddress& other) const { return this->is_balancer == other.is_balancer && this->address == other.address; } - bool operator!=(const GrpcLBAddress &other) const { + bool operator!=(const GrpcLBAddress& other) const { return !(*this == other); } @@ -139,19 +139,19 @@ gpr_timespec TestDeadline(void) { struct ArgsStruct { gpr_event ev; gpr_atm done_atm; - gpr_mu *mu; - grpc_pollset *pollset; - grpc_pollset_set *pollset_set; - grpc_combiner *lock; - grpc_channel_args *channel_args; + gpr_mu* mu; + grpc_pollset* pollset; + grpc_pollset_set* pollset_set; + grpc_combiner* lock; + grpc_channel_args* channel_args; vector<GrpcLBAddress> expected_addrs; std::string expected_service_config_string; std::string expected_lb_policy; }; -void ArgsInit(grpc_exec_ctx *exec_ctx, ArgsStruct *args) { +void ArgsInit(grpc_exec_ctx* exec_ctx, ArgsStruct* args) { gpr_event_init(&args->ev); - args->pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); + args->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(args->pollset, &args->mu); args->pollset_set = grpc_pollset_set_create(); grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset); @@ -160,9 +160,9 @@ void ArgsInit(grpc_exec_ctx *exec_ctx, ArgsStruct *args) { args->channel_args = NULL; } -void DoNothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} +void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} -void ArgsFinish(grpc_exec_ctx *exec_ctx, ArgsStruct *args) { +void ArgsFinish(grpc_exec_ctx* exec_ctx, ArgsStruct* args) { GPR_ASSERT(gpr_event_wait(&args->ev, TestDeadline())); grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset); grpc_pollset_set_destroy(exec_ctx, args->pollset_set); @@ -182,7 +182,7 @@ gpr_timespec NSecondDeadline(int seconds) { gpr_time_from_seconds(seconds, GPR_TIMESPAN)); } -void PollPollsetUntilRequestDone(ArgsStruct *args) { +void PollPollsetUntilRequestDone(ArgsStruct* args) { gpr_timespec deadline = NSecondDeadline(10); while (true) { bool done = gpr_atm_acq_load(&args->done_atm) != 0; @@ -194,7 +194,7 @@ void PollPollsetUntilRequestDone(ArgsStruct *args) { gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done, time_left.tv_sec, time_left.tv_nsec); GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0); - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_mu_lock(args->mu); GRPC_LOG_IF_ERROR("pollset_work", @@ -204,12 +204,12 @@ void PollPollsetUntilRequestDone(ArgsStruct *args) { gpr_mu_unlock(args->mu); grpc_exec_ctx_finish(&exec_ctx); } - gpr_event_set(&args->ev, (void *)1); + gpr_event_set(&args->ev, (void*)1); } -void CheckServiceConfigResultLocked(grpc_channel_args *channel_args, - ArgsStruct *args) { - const grpc_arg *service_config_arg = +void CheckServiceConfigResultLocked(grpc_channel_args* channel_args, + ArgsStruct* args) { + const grpc_arg* service_config_arg = grpc_channel_args_find(channel_args, GRPC_ARG_SERVICE_CONFIG); if (args->expected_service_config_string != "") { GPR_ASSERT(service_config_arg != NULL); @@ -221,9 +221,9 @@ void CheckServiceConfigResultLocked(grpc_channel_args *channel_args, } } -void CheckLBPolicyResultLocked(grpc_channel_args *channel_args, - ArgsStruct *args) { - const grpc_arg *lb_policy_arg = +void CheckLBPolicyResultLocked(grpc_channel_args* channel_args, + ArgsStruct* args) { + const grpc_arg* lb_policy_arg = grpc_channel_args_find(channel_args, GRPC_ARG_LB_POLICY_NAME); if (args->expected_lb_policy != "") { GPR_ASSERT(lb_policy_arg != NULL); @@ -234,23 +234,23 @@ void CheckLBPolicyResultLocked(grpc_channel_args *channel_args, } } -void CheckResolverResultLocked(grpc_exec_ctx *exec_ctx, void *argsp, - grpc_error *err) { - ArgsStruct *args = (ArgsStruct *)argsp; - grpc_channel_args *channel_args = args->channel_args; - const grpc_arg *channel_arg = +void CheckResolverResultLocked(grpc_exec_ctx* exec_ctx, void* argsp, + grpc_error* err) { + ArgsStruct* args = (ArgsStruct*)argsp; + grpc_channel_args* channel_args = args->channel_args; + const grpc_arg* channel_arg = grpc_channel_args_find(channel_args, GRPC_ARG_LB_ADDRESSES); GPR_ASSERT(channel_arg != NULL); GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); - grpc_lb_addresses *addresses = - (grpc_lb_addresses *)channel_arg->value.pointer.p; + grpc_lb_addresses* addresses = + (grpc_lb_addresses*)channel_arg->value.pointer.p; gpr_log(GPR_INFO, "num addrs found: %" PRIdPTR ". expected %" PRIdPTR, addresses->num_addresses, args->expected_addrs.size()); GPR_ASSERT(addresses->num_addresses == args->expected_addrs.size()); std::vector<GrpcLBAddress> found_lb_addrs; for (size_t i = 0; i < addresses->num_addresses; i++) { grpc_lb_address addr = addresses->addresses[i]; - char *str; + char* str; grpc_sockaddr_to_string(&str, &addr.address, 1 /* normalize */); gpr_log(GPR_INFO, "%s", str); found_lb_addrs.emplace_back( @@ -258,8 +258,9 @@ void CheckResolverResultLocked(grpc_exec_ctx *exec_ctx, void *argsp, gpr_free(str); } if (args->expected_addrs.size() != found_lb_addrs.size()) { - gpr_log(GPR_DEBUG, "found lb addrs size is: %" PRIdPTR - ". expected addrs size is %" PRIdPTR, + gpr_log(GPR_DEBUG, + "found lb addrs size is: %" PRIdPTR + ". expected addrs size is %" PRIdPTR, found_lb_addrs.size(), args->expected_addrs.size()); abort(); } @@ -283,17 +284,17 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) { args.expected_service_config_string = FLAGS_expected_chosen_service_config; args.expected_lb_policy = FLAGS_expected_lb_policy; // maybe build the address with an authority - char *whole_uri = NULL; + char* whole_uri = NULL; GPR_ASSERT(asprintf(&whole_uri, "dns://%s/%s", FLAGS_local_dns_server_address.c_str(), FLAGS_target_name.c_str())); // create resolver and resolve - grpc_resolver *resolver = grpc_resolver_create(&exec_ctx, whole_uri, NULL, + grpc_resolver* resolver = grpc_resolver_create(&exec_ctx, whole_uri, NULL, args.pollset_set, args.lock); gpr_free(whole_uri); grpc_closure on_resolver_result_changed; GRPC_CLOSURE_INIT(&on_resolver_result_changed, CheckResolverResultLocked, - (void *)&args, grpc_combiner_scheduler(args.lock)); + (void*)&args, grpc_combiner_scheduler(args.lock)); grpc_resolver_next_locked(&exec_ctx, resolver, &args.channel_args, &on_resolver_result_changed); grpc_exec_ctx_flush(&exec_ctx); @@ -305,7 +306,7 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) { } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_init(); grpc_test_init(argc, argv); ::testing::InitGoogleTest(&argc, argv); diff --git a/test/cpp/naming/resolver_component_tests_runner_invoker.cc b/test/cpp/naming/resolver_component_tests_runner_invoker.cc index 96f2e5abb5..7ea005cc1d 100644 --- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc +++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc @@ -68,8 +68,8 @@ namespace { const int kTestTimeoutSeconds = 60 * 2; -void RunSigHandlingThread(SubProcess *test_driver, gpr_mu *test_driver_mu, - gpr_cv *test_driver_cv, int *test_driver_done) { +void RunSigHandlingThread(SubProcess* test_driver, gpr_mu* test_driver_mu, + gpr_cv* test_driver_cv, int* test_driver_done) { gpr_timespec overall_deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(kTestTimeoutSeconds, GPR_TIMESPAN)); @@ -92,7 +92,7 @@ void RunSigHandlingThread(SubProcess *test_driver, gpr_mu *test_driver_mu, test_driver->Interrupt(); return; } -} +} // namespace namespace grpc { @@ -104,7 +104,7 @@ void InvokeResolverComponentTestsRunner(std::string test_runner_bin_path, std::string records_config_path) { int test_dns_server_port = grpc_pick_unused_port_or_die(); - SubProcess *test_driver = new SubProcess( + SubProcess* test_driver = new SubProcess( {test_runner_bin_path, "--test_bin_path=" + test_bin_path, "--dns_server_bin_path=" + dns_server_bin_path, "--records_config_path=" + records_config_path, @@ -151,7 +151,7 @@ void InvokeResolverComponentTestsRunner(std::string test_runner_bin_path, } // namespace grpc -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc::testing::InitTest(&argc, &argv, true); grpc_init(); GPR_ASSERT(FLAGS_test_bin_name != ""); diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index a541f94fa5..f7cdfc2bd7 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -149,9 +149,9 @@ class AsyncClient : public ClientImpl<StubType, RequestType> { // Specify which protected members we are using since there is no // member name resolution until the template types are fully resolved public: + using Client::NextIssuer; using Client::SetupLoadTest; using Client::closed_loop_; - using Client::NextIssuer; using ClientImpl<StubType, RequestType>::cores_; using ClientImpl<StubType, RequestType>::channels_; using ClientImpl<StubType, RequestType>::request_; diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 5504c0b96a..22d039d4b7 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -43,10 +43,10 @@ #include "test/cpp/qps/stats.h" #include "test/cpp/util/test_credentials_provider.h" +using std::deque; using std::list; using std::thread; using std::unique_ptr; -using std::deque; using std::vector; namespace grpc { @@ -147,9 +147,8 @@ static void postprocess_scenario_result(ScenarioResult* result) { result->mutable_summary()->set_server_cpu_usage(0); } else { auto server_cpu_usage = - 100 - - 100 * average(result->server_stats(), ServerIdleCpuTime) / - average(result->server_stats(), ServerTotalCpuTime); + 100 - 100 * average(result->server_stats(), ServerIdleCpuTime) / + average(result->server_stats(), ServerTotalCpuTime); result->mutable_summary()->set_server_cpu_usage(server_cpu_usage); } diff --git a/test/cpp/qps/histogram.h b/test/cpp/qps/histogram.h index 3d04ee57da..e31d5d78a8 100644 --- a/test/cpp/qps/histogram.h +++ b/test/cpp/qps/histogram.h @@ -70,7 +70,7 @@ class Histogram { gpr_histogram* impl_; }; -} -} +} // namespace testing +} // namespace grpc #endif /* TEST_QPS_HISTOGRAM_H */ diff --git a/test/cpp/qps/interarrival.h b/test/cpp/qps/interarrival.h index 1fa310c209..9c48066c9c 100644 --- a/test/cpp/qps/interarrival.h +++ b/test/cpp/qps/interarrival.h @@ -102,7 +102,7 @@ class InterarrivalTimer { std::vector<time_table::const_iterator> thread_posns_; time_table random_table_; }; -} -} +} // namespace testing +} // namespace grpc #endif diff --git a/test/cpp/qps/parse_json.cc b/test/cpp/qps/parse_json.cc index 343e073f3f..a98ae394db 100644 --- a/test/cpp/qps/parse_json.cc +++ b/test/cpp/qps/parse_json.cc @@ -61,5 +61,5 @@ grpc::string SerializeJson(const GRPC_CUSTOM_MESSAGE& msg, return json_string; } -} // testing -} // grpc +} // namespace testing +} // namespace grpc diff --git a/test/cpp/qps/parse_json.h b/test/cpp/qps/parse_json.h index b320d26c1a..f2fffb52d4 100644 --- a/test/cpp/qps/parse_json.h +++ b/test/cpp/qps/parse_json.h @@ -31,7 +31,7 @@ void ParseJson(const grpc::string& json, const grpc::string& type, grpc::string SerializeJson(const GRPC_CUSTOM_MESSAGE& msg, const grpc::string& type); -} // testing -} // grpc +} // namespace testing +} // namespace grpc #endif // TEST_QPS_PARSE_JSON_H diff --git a/test/cpp/qps/qps_interarrival_test.cc b/test/cpp/qps/qps_interarrival_test.cc index 87f09e8c5f..461bf624ce 100644 --- a/test/cpp/qps/qps_interarrival_test.cc +++ b/test/cpp/qps/qps_interarrival_test.cc @@ -25,13 +25,13 @@ #include "test/cpp/qps/interarrival.h" #include "test/cpp/util/test_config.h" -using grpc::testing::RandomDistInterface; using grpc::testing::InterarrivalTimer; +using grpc::testing::RandomDistInterface; -static void RunTest(RandomDistInterface &&r, int threads, std::string title) { +static void RunTest(RandomDistInterface&& r, int threads, std::string title) { InterarrivalTimer timer; timer.init(r, threads); - gpr_histogram *h(gpr_histogram_create(0.01, 60e9)); + gpr_histogram* h(gpr_histogram_create(0.01, 60e9)); for (int i = 0; i < 10000000; i++) { for (int j = 0; j < threads; j++) { @@ -50,7 +50,7 @@ static void RunTest(RandomDistInterface &&r, int threads, std::string title) { using grpc::testing::ExpDist; -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc::testing::InitTest(&argc, &argv, true); RunTest(ExpDist(10.0), 5, std::string("Exponential(10)")); diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 1c1a5636a9..23c7e85283 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -48,30 +48,30 @@ template <class RequestType, class ResponseType, class ServiceType, class AsyncQpsServerTest final : public grpc::testing::Server { public: AsyncQpsServerTest( - const ServerConfig &config, - std::function<void(ServerBuilder *, ServiceType *)> register_service, - std::function<void(ServiceType *, ServerContextType *, RequestType *, - ServerAsyncResponseWriter<ResponseType> *, - CompletionQueue *, ServerCompletionQueue *, void *)> + const ServerConfig& config, + std::function<void(ServerBuilder*, ServiceType*)> register_service, + std::function<void(ServiceType*, ServerContextType*, RequestType*, + ServerAsyncResponseWriter<ResponseType>*, + CompletionQueue*, ServerCompletionQueue*, void*)> request_unary_function, - std::function<void(ServiceType *, ServerContextType *, - ServerAsyncReaderWriter<ResponseType, RequestType> *, - CompletionQueue *, ServerCompletionQueue *, void *)> + std::function<void(ServiceType*, ServerContextType*, + ServerAsyncReaderWriter<ResponseType, RequestType>*, + CompletionQueue*, ServerCompletionQueue*, void*)> request_streaming_function, - std::function<void(ServiceType *, ServerContextType *, - ServerAsyncReader<ResponseType, RequestType> *, - CompletionQueue *, ServerCompletionQueue *, void *)> + std::function<void(ServiceType*, ServerContextType*, + ServerAsyncReader<ResponseType, RequestType>*, + CompletionQueue*, ServerCompletionQueue*, void*)> request_streaming_from_client_function, - std::function<void(ServiceType *, ServerContextType *, RequestType *, - ServerAsyncWriter<ResponseType> *, CompletionQueue *, - ServerCompletionQueue *, void *)> + std::function<void(ServiceType*, ServerContextType*, RequestType*, + ServerAsyncWriter<ResponseType>*, CompletionQueue*, + ServerCompletionQueue*, void*)> request_streaming_from_server_function, - std::function<void(ServiceType *, ServerContextType *, - ServerAsyncReaderWriter<ResponseType, RequestType> *, - CompletionQueue *, ServerCompletionQueue *, void *)> + std::function<void(ServiceType*, ServerContextType*, + ServerAsyncReaderWriter<ResponseType, RequestType>*, + CompletionQueue*, ServerCompletionQueue*, void*)> request_streaming_both_ways_function, - std::function<grpc::Status(const PayloadConfig &, RequestType *, - ResponseType *)> + std::function<grpc::Status(const PayloadConfig&, RequestType*, + ResponseType*)> process_rpc) : Server(config) { ServerBuilder builder; @@ -79,7 +79,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - char *server_address = NULL; + char* server_address = NULL; gpr_join_host_port(&server_address, "::", port_num); builder.AddListeningPort(server_address, Server::CreateServerCredentials(config)); @@ -171,7 +171,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { } for (auto cq = srv_cqs_.begin(); cq != srv_cqs_.end(); ++cq) { bool ok; - void *got_tag; + void* got_tag; while ((*cq)->Next(&got_tag, &ok)) ; } @@ -187,7 +187,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { } std::shared_ptr<Channel> InProcessChannel( - const ChannelArguments &args) override { + const ChannelArguments& args) override { return server_->InProcessChannel(args); } @@ -201,12 +201,12 @@ class AsyncQpsServerTest final : public grpc::testing::Server { void ThreadFunc(int thread_idx) { // Wait until work is available or we are shutting down bool ok; - void *got_tag; + void* got_tag; if (!srv_cqs_[cq_[thread_idx]]->Next(&got_tag, &ok)) { return; } - ServerRpcContext *ctx; - std::mutex *mu_ptr = &shutdown_state_[thread_idx]->mutex; + ServerRpcContext* ctx; + std::mutex* mu_ptr = &shutdown_state_[thread_idx]->mutex; do { ctx = detag(got_tag); // The tag is a pointer to an RPC context to invoke @@ -240,22 +240,21 @@ class AsyncQpsServerTest final : public grpc::testing::Server { private: std::mutex mu_; }; - static void *tag(ServerRpcContext *func) { - return reinterpret_cast<void *>(func); + static void* tag(ServerRpcContext* func) { + return reinterpret_cast<void*>(func); } - static ServerRpcContext *detag(void *tag) { - return reinterpret_cast<ServerRpcContext *>(tag); + static ServerRpcContext* detag(void* tag) { + return reinterpret_cast<ServerRpcContext*>(tag); } class ServerRpcContextUnaryImpl final : public ServerRpcContext { public: ServerRpcContextUnaryImpl( - std::function<void(ServerContextType *, RequestType *, - grpc::ServerAsyncResponseWriter<ResponseType> *, - void *)> + std::function<void(ServerContextType*, RequestType*, + grpc::ServerAsyncResponseWriter<ResponseType>*, + void*)> request_method, - std::function<grpc::Status(RequestType *, ResponseType *)> - invoke_method) + std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method) : srv_ctx_(new ServerContextType), next_state_(&ServerRpcContextUnaryImpl::invoker), request_method_(request_method), @@ -297,10 +296,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server { RequestType req_; ResponseType response_; bool (ServerRpcContextUnaryImpl::*next_state_)(bool); - std::function<void(ServerContextType *, RequestType *, - grpc::ServerAsyncResponseWriter<ResponseType> *, void *)> + std::function<void(ServerContextType*, RequestType*, + grpc::ServerAsyncResponseWriter<ResponseType>*, void*)> request_method_; - std::function<grpc::Status(RequestType *, ResponseType *)> invoke_method_; + std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method_; grpc::ServerAsyncResponseWriter<ResponseType> response_writer_; }; @@ -308,11 +307,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server { public: ServerRpcContextStreamingImpl( std::function<void( - ServerContextType *, - grpc::ServerAsyncReaderWriter<ResponseType, RequestType> *, void *)> + ServerContextType*, + grpc::ServerAsyncReaderWriter<ResponseType, RequestType>*, void*)> request_method, - std::function<grpc::Status(RequestType *, ResponseType *)> - invoke_method) + std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method) : srv_ctx_(new ServerContextType), next_state_(&ServerRpcContextStreamingImpl::request_done), request_method_(request_method), @@ -376,10 +374,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server { ResponseType response_; bool (ServerRpcContextStreamingImpl::*next_state_)(bool); std::function<void( - ServerContextType *, - grpc::ServerAsyncReaderWriter<ResponseType, RequestType> *, void *)> + ServerContextType*, + grpc::ServerAsyncReaderWriter<ResponseType, RequestType>*, void*)> request_method_; - std::function<grpc::Status(RequestType *, ResponseType *)> invoke_method_; + std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method_; grpc::ServerAsyncReaderWriter<ResponseType, RequestType> stream_; }; @@ -387,12 +385,11 @@ class AsyncQpsServerTest final : public grpc::testing::Server { : public ServerRpcContext { public: ServerRpcContextStreamingFromClientImpl( - std::function<void(ServerContextType *, - grpc::ServerAsyncReader<ResponseType, RequestType> *, - void *)> + std::function<void(ServerContextType*, + grpc::ServerAsyncReader<ResponseType, RequestType>*, + void*)> request_method, - std::function<grpc::Status(RequestType *, ResponseType *)> - invoke_method) + std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method) : srv_ctx_(new ServerContextType), next_state_(&ServerRpcContextStreamingFromClientImpl::request_done), request_method_(request_method), @@ -445,11 +442,11 @@ class AsyncQpsServerTest final : public grpc::testing::Server { RequestType req_; ResponseType response_; bool (ServerRpcContextStreamingFromClientImpl::*next_state_)(bool); - std::function<void(ServerContextType *, - grpc::ServerAsyncReader<ResponseType, RequestType> *, - void *)> + std::function<void(ServerContextType*, + grpc::ServerAsyncReader<ResponseType, RequestType>*, + void*)> request_method_; - std::function<grpc::Status(RequestType *, ResponseType *)> invoke_method_; + std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method_; grpc::ServerAsyncReader<ResponseType, RequestType> stream_; }; @@ -457,11 +454,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server { : public ServerRpcContext { public: ServerRpcContextStreamingFromServerImpl( - std::function<void(ServerContextType *, RequestType *, - grpc::ServerAsyncWriter<ResponseType> *, void *)> + std::function<void(ServerContextType*, RequestType*, + grpc::ServerAsyncWriter<ResponseType>*, void*)> request_method, - std::function<grpc::Status(RequestType *, ResponseType *)> - invoke_method) + std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method) : srv_ctx_(new ServerContextType), next_state_(&ServerRpcContextStreamingFromServerImpl::request_done), request_method_(request_method), @@ -514,10 +510,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server { RequestType req_; ResponseType response_; bool (ServerRpcContextStreamingFromServerImpl::*next_state_)(bool); - std::function<void(ServerContextType *, RequestType *, - grpc::ServerAsyncWriter<ResponseType> *, void *)> + std::function<void(ServerContextType*, RequestType*, + grpc::ServerAsyncWriter<ResponseType>*, void*)> request_method_; - std::function<grpc::Status(RequestType *, ResponseType *)> invoke_method_; + std::function<grpc::Status(RequestType*, ResponseType*)> invoke_method_; grpc::ServerAsyncWriter<ResponseType> stream_; }; @@ -537,17 +533,17 @@ class AsyncQpsServerTest final : public grpc::testing::Server { std::vector<std::unique_ptr<PerThreadShutdownState>> shutdown_state_; }; -static void RegisterBenchmarkService(ServerBuilder *builder, - BenchmarkService::AsyncService *service) { +static void RegisterBenchmarkService(ServerBuilder* builder, + BenchmarkService::AsyncService* service) { builder->RegisterService(service); } -static void RegisterGenericService(ServerBuilder *builder, - grpc::AsyncGenericService *service) { +static void RegisterGenericService(ServerBuilder* builder, + grpc::AsyncGenericService* service) { builder->RegisterAsyncGenericService(service); } -static Status ProcessSimpleRPC(const PayloadConfig &, SimpleRequest *request, - SimpleResponse *response) { +static Status ProcessSimpleRPC(const PayloadConfig&, SimpleRequest* request, + SimpleResponse* response) { if (request->response_size() > 0) { if (!Server::SetPayload(request->response_type(), request->response_size(), response->mutable_payload())) { @@ -560,8 +556,8 @@ static Status ProcessSimpleRPC(const PayloadConfig &, SimpleRequest *request, return Status::OK; } -static Status ProcessGenericRPC(const PayloadConfig &payload_config, - ByteBuffer *request, ByteBuffer *response) { +static Status ProcessGenericRPC(const PayloadConfig& payload_config, + ByteBuffer* request, ByteBuffer* response) { // We are done using the request. Clear it to reduce working memory. // This proves to reduce cache misses in large message size cases. request->Clear(); @@ -572,7 +568,7 @@ static Status ProcessGenericRPC(const PayloadConfig &payload_config, return Status::OK; } -std::unique_ptr<Server> CreateAsyncServer(const ServerConfig &config) { +std::unique_ptr<Server> CreateAsyncServer(const ServerConfig& config) { return std::unique_ptr<Server>( new AsyncQpsServerTest<SimpleRequest, SimpleResponse, BenchmarkService::AsyncService, @@ -585,7 +581,7 @@ std::unique_ptr<Server> CreateAsyncServer(const ServerConfig &config) { &BenchmarkService::AsyncService::RequestStreamingBothWays, ProcessSimpleRPC)); } -std::unique_ptr<Server> CreateAsyncGenericServer(const ServerConfig &config) { +std::unique_ptr<Server> CreateAsyncGenericServer(const ServerConfig& config) { return std::unique_ptr<Server>( new AsyncQpsServerTest<ByteBuffer, ByteBuffer, grpc::AsyncGenericService, grpc::GenericServerContext>( diff --git a/test/cpp/test/server_context_test_spouse_test.cc b/test/cpp/test/server_context_test_spouse_test.cc index c1ddb0019b..d1dc9d7cac 100644 --- a/test/cpp/test/server_context_test_spouse_test.cc +++ b/test/cpp/test/server_context_test_spouse_test.cc @@ -87,7 +87,7 @@ TEST(ServerContextTestSpouseTest, TrailingMetadata) { ASSERT_EQ(metadata, spouse.GetTrailingMetadata()); } -} // namespace +} // namespace testing } // namespace grpc int main(int argc, char** argv) { diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc index 85e58f466e..af90d44495 100644 --- a/test/cpp/thread_manager/thread_manager_test.cc +++ b/test/cpp/thread_manager/thread_manager_test.cc @@ -37,8 +37,8 @@ class ThreadManagerTest final : public grpc::ThreadManager { num_poll_for_work_(0), num_work_found_(0) {} - grpc::ThreadManager::WorkStatus PollForWork(void **tag, bool *ok) override; - void DoWork(void *tag, bool ok) override; + grpc::ThreadManager::WorkStatus PollForWork(void** tag, bool* ok) override; + void DoWork(void* tag, bool ok) override; void PerformTest(); private: @@ -65,8 +65,8 @@ void ThreadManagerTest::SleepForMs(int duration_ms) { gpr_sleep_until(sleep_time); } -grpc::ThreadManager::WorkStatus ThreadManagerTest::PollForWork(void **tag, - bool *ok) { +grpc::ThreadManager::WorkStatus ThreadManagerTest::PollForWork(void** tag, + bool* ok) { int call_num = gpr_atm_no_barrier_fetch_add(&num_poll_for_work_, 1); if (call_num >= kMaxNumPollForWork) { @@ -89,7 +89,7 @@ grpc::ThreadManager::WorkStatus ThreadManagerTest::PollForWork(void **tag, } } -void ThreadManagerTest::DoWork(void *tag, bool ok) { +void ThreadManagerTest::DoWork(void* tag, bool ok) { gpr_atm_no_barrier_fetch_add(&num_do_work_, 1); SleepForMs(kDoWorkDurationMsec); // Simulate doing work by sleeping } @@ -110,7 +110,7 @@ void ThreadManagerTest::PerformTest() { } } // namespace grpc -int main(int argc, char **argv) { +int main(int argc, char** argv) { std::srand(std::time(NULL)); grpc::testing::InitTest(&argc, &argv, true); diff --git a/test/cpp/util/grpc_tool.h b/test/cpp/util/grpc_tool.h index 076ce530d9..a10422f882 100644 --- a/test/cpp/util/grpc_tool.h +++ b/test/cpp/util/grpc_tool.h @@ -28,9 +28,9 @@ namespace grpc { namespace testing { -typedef std::function<bool(const grpc::string &)> GrpcToolOutputCallback; +typedef std::function<bool(const grpc::string&)> GrpcToolOutputCallback; -int GrpcToolMainLib(int argc, const char **argv, const CliCredentials &cred, +int GrpcToolMainLib(int argc, const char** argv, const CliCredentials& cred, GrpcToolOutputCallback callback); } // namespace testing diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc index 184828c7b6..0f77934672 100644 --- a/test/cpp/util/proto_reflection_descriptor_database.cc +++ b/test/cpp/util/proto_reflection_descriptor_database.cc @@ -22,11 +22,11 @@ #include <grpc/support/log.h> +using grpc::reflection::v1alpha::ErrorResponse; +using grpc::reflection::v1alpha::ListServiceResponse; using grpc::reflection::v1alpha::ServerReflection; using grpc::reflection::v1alpha::ServerReflectionRequest; using grpc::reflection::v1alpha::ServerReflectionResponse; -using grpc::reflection::v1alpha::ListServiceResponse; -using grpc::reflection::v1alpha::ErrorResponse; namespace grpc { diff --git a/test/cpp/util/service_describer.h b/test/cpp/util/service_describer.h index b7a8c9207f..b7ab7578b4 100644 --- a/test/cpp/util/service_describer.h +++ b/test/cpp/util/service_describer.h @@ -36,7 +36,7 @@ grpc::string SummarizeService(const grpc::protobuf::ServiceDescriptor* service); grpc::string SummarizeMethod(const grpc::protobuf::MethodDescriptor* method); -} // namespase testing +} // namespace testing } // namespace grpc #endif // GRPC_TEST_CPP_UTIL_SERVICE_DESCRIBER_H diff --git a/test/cpp/util/test_config_cc.cc b/test/cpp/util/test_config_cc.cc index f7e034253e..e4b6886335 100644 --- a/test/cpp/util/test_config_cc.cc +++ b/test/cpp/util/test_config_cc.cc @@ -16,8 +16,8 @@ * */ -#include "test/cpp/util/test_config.h" #include <gflags/gflags.h> +#include "test/cpp/util/test_config.h" // In some distros, gflags is in the namespace google, and in some others, // in gflags. This hack is enabling us to find both. |