diff options
Diffstat (limited to 'test')
96 files changed, 687 insertions, 384 deletions
diff --git a/test/build/protobuf.cc b/test/build/protobuf.cc index bac33ad727..49cd8e8365 100644 --- a/test/build/protobuf.cc +++ b/test/build/protobuf.cc @@ -38,6 +38,4 @@ bool protobuf_test(const google::protobuf::MethodDescriptor *method) { return method->client_streaming() || method->server_streaming(); } -int main() { - return 0; -} +int main() { return 0; } diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index f7399770dd..24bf5d3625 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -150,9 +150,8 @@ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, grpc_endpoint_destroy(sfd.client); } grpc_server_shutdown_and_notify(a.server, a.cq, NULL); - GPR_ASSERT(grpc_completion_queue_pluck(a.cq, NULL, - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + a.cq, NULL, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(a.server); grpc_completion_queue_destroy(a.cq); diff --git a/test/core/bad_client/tests/connection_prefix.c b/test/core/bad_client/tests/connection_prefix.c index de62e923f0..ec85211605 100644 --- a/test/core/bad_client/tests/connection_prefix.c +++ b/test/core/bad_client/tests/connection_prefix.c @@ -36,9 +36,9 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq) { while (grpc_server_has_open_connections(server)) { - GPR_ASSERT( - grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), - NULL).type == GRPC_QUEUE_TIMEOUT); + GPR_ASSERT(grpc_completion_queue_next( + cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/bad_client/tests/initial_settings_frame.c b/test/core/bad_client/tests/initial_settings_frame.c index 28e9a39dff..261fecdaf2 100644 --- a/test/core/bad_client/tests/initial_settings_frame.c +++ b/test/core/bad_client/tests/initial_settings_frame.c @@ -38,9 +38,9 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq) { while (grpc_server_has_open_connections(server)) { - GPR_ASSERT( - grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), - NULL).type == GRPC_QUEUE_TIMEOUT); + GPR_ASSERT(grpc_completion_queue_next( + cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) + .type == GRPC_QUEUE_TIMEOUT); } } diff --git a/test/core/client_config/uri_parser_test.c b/test/core/client_config/uri_parser_test.c index 3451ca1e8c..d324029c7e 100644 --- a/test/core/client_config/uri_parser_test.c +++ b/test/core/client_config/uri_parser_test.c @@ -60,7 +60,8 @@ int main(int argc, char **argv) { test_succeeds("http://www.google.com:90", "http", "www.google.com:90", ""); test_succeeds("a192.4-df:foo.coom", "a192.4-df", "", "foo.coom"); test_succeeds("a+b:foo.coom", "a+b", "", "foo.coom"); - test_succeeds("zookeeper://127.0.0.1:2181/foo/bar", "zookeeper", "127.0.0.1:2181", "/foo/bar"); + test_succeeds("zookeeper://127.0.0.1:2181/foo/bar", "zookeeper", + "127.0.0.1:2181", "/foo/bar"); test_fails("xyz"); test_fails("http://www.google.com?why-are-you-using-queries"); test_fails("dns:foo.com#fragments-arent-supported-here"); diff --git a/test/core/compression/compression_test.c b/test/core/compression/compression_test.c new file mode 100644 index 0000000000..4df0acae37 --- /dev/null +++ b/test/core/compression/compression_test.c @@ -0,0 +1,77 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdlib.h> +#include <string.h> + +#include <grpc/compression.h> +#include <grpc/support/log.h> +#include <grpc/support/useful.h> + +#include "test/core/util/test_config.h" + +static void test_compression_algorithm_parse(void) { + size_t i; + 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"}; + + 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]; + grpc_compression_algorithm algorithm; + int success; + success = grpc_compression_algorithm_parse(valid_name, strlen(valid_name), + &algorithm); + GPR_ASSERT(success != 0); + GPR_ASSERT(algorithm == valid_algorithms[i]); + } + + for (i = 0; i < GPR_ARRAY_SIZE(invalid_names); i++) { + const char* invalid_name = invalid_names[i]; + grpc_compression_algorithm algorithm; + int success; + success = grpc_compression_algorithm_parse( + invalid_name, strlen(invalid_name), &algorithm); + GPR_ASSERT(success == 0); + /* the value of "algorithm" is undefined upon failure */ + } +} + +int main(int argc, char** argv) { + test_compression_algorithm_parse(); + + return 0; +} diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index f5f21cff25..495841c79f 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -69,8 +69,7 @@ static void assert_passthrough(gpr_slice value, "algorithm='%s' uncompressed_split='%s' compressed_split='%s'", GPR_SLICE_LENGTH(value), gpr_murmur_hash3(GPR_SLICE_START_PTR(value), GPR_SLICE_LENGTH(value), 0), - algorithm_name, - grpc_slice_split_mode_name(uncompressed_split_mode), + algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode), grpc_slice_split_mode_name(compressed_split_mode)); gpr_slice_buffer_init(&input); diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index a9ba78dfdb..922de268f4 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -146,7 +146,7 @@ static int byte_buffer_eq_slice(grpc_byte_buffer *bb, gpr_slice b) { 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; grpc_byte_buffer_reader_init(&reader, bb); diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index 1ecd4db5da..b3e07c45a5 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -60,6 +60,7 @@ void cq_verify_empty(cq_verifier *v); void cq_expect_completion(cq_verifier *v, void *tag, int success); 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(grpc_metadata_array *array, const char *key, + const char *value); -#endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */ +#endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */ diff --git a/test/core/end2end/data/ssl_test_data.h b/test/core/end2end/data/ssl_test_data.h index 4f4b30ef21..675249dbd5 100644 --- a/test/core/end2end/data/ssl_test_data.h +++ b/test/core/end2end/data/ssl_test_data.h @@ -38,4 +38,4 @@ extern const char test_root_cert[]; extern const char test_server1_cert[]; extern const char test_server1_key[]; -#endif /* GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H */ +#endif /* GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H */ diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 7b7dbc7472..1f64062bf7 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -220,9 +220,8 @@ void test_connect(const char *server_host, const char *client_host, int port, /* Destroy server. */ grpc_server_shutdown_and_notify(server, cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(server); grpc_completion_queue_shutdown(cq); diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c index 3c35baec6b..d82e623f22 100644 --- a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c +++ b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c @@ -55,8 +55,7 @@ typedef struct fullstack_secure_fixture_data { } fullstack_secure_fixture_data; static const grpc_metadata *find_metadata(const grpc_metadata *md, - size_t md_count, - const char *key, + size_t md_count, const char *key, const char *value) { size_t i; for (i = 0; i < md_count; i++) { diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c index 798d4e94d4..8ae9e0ebe3 100644 --- a/test/core/end2end/fixtures/proxy.c +++ b/test/core/end2end/fixtures/proxy.c @@ -177,9 +177,8 @@ static void on_p2s_recv_initial_metadata(void *arg, int success) { op.data.send_initial_metadata.count = pc->p2s_initial_metadata.count; op.data.send_initial_metadata.metadata = pc->p2s_initial_metadata.metadata; refpc(pc, "on_c2p_sent_initial_metadata"); - err = grpc_call_start_batch(pc->c2p, &op, 1, - new_closure(on_c2p_sent_initial_metadata, pc), - NULL); + err = grpc_call_start_batch( + pc->c2p, &op, 1, new_closure(on_c2p_sent_initial_metadata, pc), NULL); GPR_ASSERT(err == GRPC_CALL_OK); } @@ -339,18 +338,16 @@ static void on_new_call(void *arg, int success) { op.op = GRPC_OP_RECV_INITIAL_METADATA; op.data.recv_initial_metadata = &pc->p2s_initial_metadata; refpc(pc, "on_p2s_recv_initial_metadata"); - err = grpc_call_start_batch(pc->p2s, &op, 1, - new_closure(on_p2s_recv_initial_metadata, pc), - NULL); + err = grpc_call_start_batch( + pc->p2s, &op, 1, new_closure(on_p2s_recv_initial_metadata, pc), NULL); GPR_ASSERT(err == GRPC_CALL_OK); op.op = GRPC_OP_SEND_INITIAL_METADATA; op.data.send_initial_metadata.count = pc->c2p_initial_metadata.count; op.data.send_initial_metadata.metadata = pc->c2p_initial_metadata.metadata; refpc(pc, "on_p2s_sent_initial_metadata"); - err = grpc_call_start_batch(pc->p2s, &op, 1, - new_closure(on_p2s_sent_initial_metadata, pc), - NULL); + err = grpc_call_start_batch( + pc->p2s, &op, 1, new_closure(on_p2s_sent_initial_metadata, pc), NULL); GPR_ASSERT(err == GRPC_CALL_OK); op.op = GRPC_OP_RECV_MESSAGE; @@ -375,15 +372,15 @@ static void on_new_call(void *arg, int success) { op.data.recv_status_on_client.status_details_capacity = &pc->p2s_status_details_capacity; refpc(pc, "on_p2s_status"); - err = grpc_call_start_batch(pc->p2s, &op, 1, - new_closure(on_p2s_status, pc), NULL); + err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_status, pc), + NULL); GPR_ASSERT(err == GRPC_CALL_OK); op.op = GRPC_OP_RECV_CLOSE_ON_SERVER; op.data.recv_close_on_server.cancelled = &pc->c2p_server_cancelled; refpc(pc, "on_c2p_closed"); - err = grpc_call_start_batch(pc->c2p, &op, 1, - new_closure(on_c2p_closed, pc), NULL); + err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_closed, pc), + NULL); GPR_ASSERT(err == GRPC_CALL_OK); request_call(proxy); diff --git a/test/core/end2end/multiple_server_queues_test.c b/test/core/end2end/multiple_server_queues_test.c index 2befcd0124..5e2eaf4ae9 100644 --- a/test/core/end2end/multiple_server_queues_test.c +++ b/test/core/end2end/multiple_server_queues_test.c @@ -49,8 +49,8 @@ int main(int argc, char **argv) { grpc_server_register_completion_queue(server, cq2, NULL); grpc_server_start(server); grpc_server_shutdown_and_notify(server, cq2, NULL); - grpc_completion_queue_next( - cq2, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); /* cue queue hang */ + grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL); /* cue queue hang */ grpc_completion_queue_shutdown(cq1); grpc_completion_queue_shutdown(cq2); grpc_completion_queue_next(cq1, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index 6ae87288f7..619627ddd2 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -88,8 +88,9 @@ int main(int argc, char **argv) { GPR_ASSERT(status == GRPC_STATUS_DEADLINE_EXCEEDED); grpc_completion_queue_shutdown(cq); - while (grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), - NULL).type != GRPC_QUEUE_SHUTDOWN) + while ( + grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL) + .type != GRPC_QUEUE_SHUTDOWN) ; grpc_completion_queue_destroy(cq); grpc_call_destroy(call); diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index 61bbbe4855..8f28fa1e63 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -77,9 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 3715166348..313e0b05bd 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -76,9 +76,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c b/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c index ffb267c236..2430a6d218 100644 --- a/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c +++ b/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c @@ -76,9 +76,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 7e984da591..9991ee02f0 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -77,9 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 06e6602681..8b582e0c42 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index f57a44caa4..6c63d7c0ad 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -76,9 +76,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/cancel_test_helpers.h b/test/core/end2end/tests/cancel_test_helpers.h index 6ea822fa9a..f8fafae597 100644 --- a/test/core/end2end/tests/cancel_test_helpers.h +++ b/test/core/end2end/tests/cancel_test_helpers.h @@ -42,7 +42,7 @@ typedef struct { } cancellation_mode; static grpc_call_error wait_for_deadline(grpc_call *call, void *reserved) { - (void) reserved; + (void)reserved; return GRPC_CALL_OK; } diff --git a/test/core/end2end/tests/census_simple_request.c b/test/core/end2end/tests/census_simple_request.c index 8f615dec20..36b9e92884 100644 --- a/test/core/end2end/tests/census_simple_request.c +++ b/test/core/end2end/tests/census_simple_request.c @@ -66,9 +66,8 @@ static void *tag(gpr_intptr t) { return (void *)t; } static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -149,9 +148,9 @@ static void test_body(grpc_end2end_test_fixture f) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/channel_connectivity.c b/test/core/end2end/tests/channel_connectivity.c index ec0417abda..0b7a8a664b 100644 --- a/test/core/end2end/tests/channel_connectivity.c +++ b/test/core/end2end/tests/channel_connectivity.c @@ -48,33 +48,38 @@ static void test_connectivity(grpc_end2end_test_config config) { config.init_client(&f, NULL); /* channels should start life in IDLE, and stay there */ - GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == GRPC_CHANNEL_IDLE); + GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == + GRPC_CHANNEL_IDLE); gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100)); - GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == GRPC_CHANNEL_IDLE); + GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == + GRPC_CHANNEL_IDLE); /* start watching for a change */ - grpc_channel_watch_connectivity_state( - f.client, GRPC_CHANNEL_IDLE, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(1)); + grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_IDLE, + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + f.cq, tag(1)); /* nothing should happen */ cq_verify_empty(cqv); /* check that we're still in idle, and start connecting */ - GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 1) == GRPC_CHANNEL_IDLE); + GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 1) == + GRPC_CHANNEL_IDLE); /* and now the watch should trigger */ cq_expect_completion(cqv, tag(1), 1); cq_verify(cqv); state = grpc_channel_check_connectivity_state(f.client, 0); - GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE || + GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE || state == GRPC_CHANNEL_CONNECTING); /* quickly followed by a transition to TRANSIENT_FAILURE */ - grpc_channel_watch_connectivity_state( - f.client, GRPC_CHANNEL_CONNECTING, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(2)); + grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_CONNECTING, + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + f.cq, tag(2)); cq_expect_completion(cqv, tag(2), 1); cq_verify(cqv); state = grpc_channel_check_connectivity_state(f.client, 0); - GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE || + GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE || state == GRPC_CHANNEL_CONNECTING); gpr_log(GPR_DEBUG, "*** STARTING SERVER ***"); @@ -87,13 +92,13 @@ static void test_connectivity(grpc_end2end_test_config config) { /* we'll go through some set of transitions (some might be missed), until READY is reached */ while (state != GRPC_CHANNEL_READY) { - grpc_channel_watch_connectivity_state( - f.client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(3)); - cq_expect_completion(cqv, tag(3), 1); + grpc_channel_watch_connectivity_state( + f.client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(3)); + cq_expect_completion(cqv, tag(3), 1); cq_verify(cqv); state = grpc_channel_check_connectivity_state(f.client, 0); - GPR_ASSERT(state == GRPC_CHANNEL_READY || - state == GRPC_CHANNEL_CONNECTING || + GPR_ASSERT(state == GRPC_CHANNEL_READY || + state == GRPC_CHANNEL_CONNECTING || state == GRPC_CHANNEL_TRANSIENT_FAILURE); } @@ -101,8 +106,9 @@ static void test_connectivity(grpc_end2end_test_config config) { /* we should go immediately to TRANSIENT_FAILURE */ gpr_log(GPR_DEBUG, "*** SHUTTING DOWN SERVER ***"); - grpc_channel_watch_connectivity_state( - f.client, GRPC_CHANNEL_READY, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(4)); + grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_READY, + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + f.cq, tag(4)); grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead)); @@ -110,7 +116,7 @@ static void test_connectivity(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(0xdead), 1); cq_verify(cqv); state = grpc_channel_check_connectivity_state(f.client, 0); - GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE || + GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE || state == GRPC_CHANNEL_CONNECTING); /* cleanup server */ diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index 5cbf26b94f..91330c718e 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -77,9 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -154,9 +153,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(error == GRPC_CALL_OK); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(error == GRPC_CALL_OK); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); @@ -220,7 +219,9 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { } void grpc_end2end_tests(grpc_end2end_test_config config) { - if ((config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) != 0) return; - if ((config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) == 0) return; + if ((config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) != 0) + return; + if ((config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) == 0) + return; test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 0b98424c25..09762705e3 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -134,9 +134,9 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f->server, &s, &call_details, - &request_metadata_recv, f->cq, f->cq, - tag(101)); + error = + grpc_server_request_call(f->server, &s, &call_details, + &request_metadata_recv, f->cq, f->cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c index a5683129c1..233bc9bee2 100644 --- a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c +++ b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c @@ -142,9 +142,9 @@ static void test_early_server_shutdown_finishes_inflight_calls( error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index feb2f18166..c93d236a6a 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -77,9 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 9ec9430d47..d4e7a1ac6d 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -149,9 +149,9 @@ static void test_early_server_shutdown_finishes_inflight_calls( error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 5fe369ea45..7677084511 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -73,9 +73,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -175,9 +174,9 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 203d98d100..0ba620b851 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -151,9 +150,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index dd30e68f42..2b9560716f 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -171,9 +170,9 @@ static void test_max_message_length(grpc_end2end_test_config config) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c index 565d4ea280..157d0d5349 100644 --- a/test/core/end2end/tests/no_op.c +++ b/test/core/end2end/tests/no_op.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index e19f115e40..43abda4d7f 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -158,9 +157,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(100)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(100)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(100), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index 1ef595ee56..eddce6ded4 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -77,9 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -152,9 +151,9 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); @@ -205,9 +204,8 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { 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(f.client, "/foo", "foo.test.google.fr:1234", - NULL); + void *rc = grpc_channel_register_call(f.client, "/foo", + "foo.test.google.fr:1234", NULL); simple_request_body(f, rc); end_test(&f); @@ -218,9 +216,8 @@ 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(f.client, "/foo", "foo.test.google.fr:1234", - NULL); + void *rc = grpc_channel_register_call(f.client, "/foo", + "foo.test.google.fr:1234", NULL); for (i = 0; i < 10; i++) { simple_request_body(f, rc); diff --git a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c index de6f460795..2345f94044 100644 --- a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c +++ b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -195,9 +194,9 @@ static void test_request_response_with_metadata_and_payload( error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/request_response_with_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_metadata_and_payload.c index b6196ab46e..a4cc27896c 100644 --- a/test/core/end2end/tests/request_response_with_metadata_and_payload.c +++ b/test/core/end2end/tests/request_response_with_metadata_and_payload.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -110,10 +109,12 @@ static void test_request_response_with_metadata_and_payload( grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); - grpc_metadata meta_c[2] = {{"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; - grpc_metadata meta_s[2] = {{"KeY3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"KeY4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_c[2] = { + {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_s[2] = { + {"KeY3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"KeY4", "val4", 4, 0, {{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); @@ -177,9 +178,9 @@ static void test_request_response_with_metadata_and_payload( error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/request_response_with_payload.c b/test/core/end2end/tests/request_response_with_payload.c index 0a45a482a3..ff00ae6d9d 100644 --- a/test/core/end2end/tests/request_response_with_payload.c +++ b/test/core/end2end/tests/request_response_with_payload.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -168,9 +167,9 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/request_response_with_payload_and_call_creds.c b/test/core/end2end/tests/request_response_with_payload_and_call_creds.c index 8e0bc4e2ae..9bb3abb6bf 100644 --- a/test/core/end2end/tests/request_response_with_payload_and_call_creds.c +++ b/test/core/end2end/tests/request_response_with_payload_and_call_creds.c @@ -68,7 +68,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, grpc_arg fail_auth_arg = { GRPC_ARG_STRING, FAIL_AUTH_CHECK_SERVER_ARG_NAME, {NULL}}; grpc_channel_args args; - args.num_args= 1; + args.num_args = 1; args.args = &fail_auth_arg; config.init_server(&f, &args); } else { @@ -93,9 +93,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -251,9 +250,9 @@ static void request_response_with_payload_and_call_creds( error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c index 83744a8e24..8b764751f6 100644 --- a/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c +++ b/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -110,12 +109,15 @@ static void test_request_response_with_metadata_and_payload( grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); - grpc_metadata meta_c[2] = {{"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; - grpc_metadata meta_s[2] = {{"key3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}}; - grpc_metadata meta_t[2] = {{"key5", "val5", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key6", "val6", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_c[2] = { + {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_s[2] = { + {"key3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"key4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_metadata meta_t[2] = { + {"key5", "val5", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"key6", "val6", 4, 0, {{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); @@ -179,9 +181,9 @@ static void test_request_response_with_metadata_and_payload( error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/request_with_compressed_payload.c b/test/core/end2end/tests/request_with_compressed_payload.c index 6a067d8d1d..299943c548 100644 --- a/test/core/end2end/tests/request_with_compressed_payload.c +++ b/test/core/end2end/tests/request_with_compressed_payload.c @@ -46,6 +46,7 @@ #include "test/core/end2end/cq_verifier.h" #include "src/core/channel/channel_args.h" #include "src/core/channel/compress_filter.h" +#include "src/core/surface/call.h" enum { TIMEOUT = 200000 }; @@ -79,9 +80,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -131,7 +131,8 @@ static void request_with_payload_template( cq_verifier *cqv; char str[1024]; - memset(str, 'x', 1023); str[1023] = '\0'; + memset(str, 'x', 1023); + str[1023] = '\0'; request_payload_slice = gpr_slice_from_copied_string(str); request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); @@ -188,13 +189,21 @@ static void request_with_payload_template( error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, - f.cq, tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + GPR_ASSERT(GPR_BITCOUNT(grpc_call_get_encodings_accepted_by_peer(s)) == 3); + GPR_ASSERT(GPR_BITGET(grpc_call_get_encodings_accepted_by_peer(s), + GRPC_COMPRESS_NONE) != 0); + GPR_ASSERT(GPR_BITGET(grpc_call_get_encodings_accepted_by_peer(s), + GRPC_COMPRESS_DEFLATE) != 0); + GPR_ASSERT(GPR_BITGET(grpc_call_get_encodings_accepted_by_peer(s), + GRPC_COMPRESS_GZIP) != 0); + op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -270,8 +279,7 @@ static void test_invoke_request_with_exceptionally_uncompressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_exceptionally_uncompressed_payload", - GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_NONE, - NULL); + GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_NONE, NULL); } static void test_invoke_request_with_uncompressed_payload( diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 3255f14457..eb2e5dc7e8 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -76,9 +76,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/request_with_large_metadata.c b/test/core/end2end/tests/request_with_large_metadata.c index 5b43caf18c..98e47aaf98 100644 --- a/test/core/end2end/tests/request_with_large_metadata.c +++ b/test/core/end2end/tests/request_with_large_metadata.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -171,9 +170,9 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index c0013fb60f..149dbaeb00 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -75,9 +75,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index ab2f575263..8bacc6c730 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -77,9 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -149,9 +148,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index 277aa2596e..9133aacc35 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -63,9 +63,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -146,9 +145,9 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, config.init_server(f, server_args); - error = grpc_server_request_call(f->server, &s, &call_details, - &request_metadata_recv, f->cq, f->cq, - tag(101)); + error = + grpc_server_request_call(f->server, &s, &call_details, + &request_metadata_recv, f->cq, f->cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index d3d2f27560..0f62d958ae 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -77,9 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -159,9 +158,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c b/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c index 4fc206cbfc..0067bb4bef 100644 --- a/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c +++ b/test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c @@ -77,9 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -153,9 +152,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call(f.server, &s, &call_details, - &request_metadata_recv, f.cq, f.cq, - tag(101)); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); diff --git a/test/core/fling/fling_test.c b/test/core/fling/fling_test.c index f9ba461d24..29d9050704 100644 --- a/test/core/fling/fling_test.c +++ b/test/core/fling/fling_test.c @@ -57,22 +57,24 @@ int main(int argc, char **argv) { strcpy(root, "."); } /* start the server */ - gpr_asprintf(&args[0], "%s/fling_server%s", root, gpr_subprocess_binary_extension()); + gpr_asprintf(&args[0], "%s/fling_server%s", root, + gpr_subprocess_binary_extension()); args[1] = "--bind"; gpr_join_host_port(&args[2], "::", port); args[3] = "--no-secure"; - svr = gpr_subprocess_create(4, (const char**)args); + 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()); + gpr_asprintf(&args[0], "%s/fling_client%s", root, + gpr_subprocess_binary_extension()); args[1] = "--target"; gpr_join_host_port(&args[2], "127.0.0.1", port); args[3] = "--scenario=ping-pong-request"; args[4] = "--no-secure"; args[5] = 0; - cli = gpr_subprocess_create(6, (const char**)args); + cli = gpr_subprocess_create(6, (const char **)args); gpr_free(args[0]); gpr_free(args[2]); diff --git a/test/core/fling/server.c b/test/core/fling/server.c index 2873e4af4b..010217939d 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -248,7 +248,8 @@ int main(int argc, char **argv) { } ev = grpc_completion_queue_next( cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); + gpr_time_from_micros(1000000, GPR_TIMESPAN)), + NULL); s = ev.tag; switch (ev.type) { case GRPC_OP_COMPLETE: diff --git a/test/core/httpcli/format_request_test.c b/test/core/httpcli/format_request_test.c index da850049e2..82b2ccb122 100644 --- a/test/core/httpcli/format_request_test.c +++ b/test/core/httpcli/format_request_test.c @@ -142,8 +142,7 @@ static void test_format_post_request_content_type_override(void) { "POST /index.html HTTP/1.0\r\n" "Host: example.com\r\n" "Connection: close\r\n" - "User-Agent: " GRPC_HTTPCLI_USER_AGENT - "\r\n" + "User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n" "x-yz: abc\r\n" "Content-Type: application/x-www-form-urlencoded\r\n" "Content-Length: 11\r\n" diff --git a/test/core/json/json_test.c b/test/core/json/json_test.c index 3033419118..a500effcea 100644 --- a/test/core/json/json_test.c +++ b/test/core/json/json_test.c @@ -66,7 +66,7 @@ static testing_pair testing_pairs[] = { {"\"\\ud834\\udd1e\"", "\"\\ud834\\udd1e\""}, /* Testing nested empty containers. */ { - " [ [ ] , { } , [ ] ] ", "[[],{},[]]", + " [ [ ] , { } , [ ] ] ", "[[],{},[]]", }, /* Testing escapes and control chars in key strings. */ {" { \"\x7f\\n\\\\a , b\": 1, \"\": 0 } ", diff --git a/test/core/security/auth_context_test.c b/test/core/security/auth_context_test.c index d785eb6064..d091c7e7e6 100644 --- a/test/core/security/auth_context_test.c +++ b/test/core/security/auth_context_test.c @@ -151,4 +151,3 @@ int main(int argc, char **argv) { test_chained_context(); return 0; } - diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c index da57cef15c..0bac61eb54 100644 --- a/test/core/security/json_token_test.c +++ b/test/core/security/json_token_test.c @@ -263,8 +263,8 @@ static void check_jwt_header(grpc_json *header) { GPR_ASSERT(kid != NULL); GPR_ASSERT(kid->type == GRPC_JSON_STRING); - GPR_ASSERT(strcmp(kid->value, - "e6b5137873db8d2ef81e06a47289e6434ec8a165") == 0); + GPR_ASSERT(strcmp(kid->value, "e6b5137873db8d2ef81e06a47289e6434ec8a165") == + 0); } static void check_jwt_claim(grpc_json *claim, const char *expected_audience, @@ -298,9 +298,11 @@ static void check_jwt_claim(grpc_json *claim, const char *expected_audience, GPR_ASSERT(iss != NULL); GPR_ASSERT(iss->type == GRPC_JSON_STRING); - GPR_ASSERT(strcmp(iss->value, - "777-abaslkan11hlb6nmim3bpspl31ud@developer.gserviceaccount.com") - ==0); + GPR_ASSERT( + strcmp( + iss->value, + "777-abaslkan11hlb6nmim3bpspl31ud@developer.gserviceaccount.com") == + 0); if (expected_scope != NULL) { GPR_ASSERT(scope != NULL); diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index 440286ea1a..5cc8b2e9be 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -93,8 +93,7 @@ static const char json_key_str_part3_for_custom_email_issuer[] = "com\", \"type\": \"service_account\" }"; static grpc_jwt_verifier_email_domain_key_url_mapping custom_mapping = { - "bar.com", "keys.bar.com/jwk" -}; + "bar.com", "keys.bar.com/jwk"}; static const char expected_user_data[] = "user data"; @@ -153,7 +152,7 @@ static const char expired_claims[] = " \"iss\": \"blah.foo.com\"," " \"sub\": \"juju@blah.foo.com\"," " \"jti\": \"jwtuniqueid\"," - " \"iat\": 100," /* Way back in the past... */ + " \"iat\": 100," /* Way back in the past... */ " \"exp\": 120," " \"nbf\": 60," " \"foo\": \"bar\"}"; @@ -316,8 +315,8 @@ static void test_jwt_verifier_google_email_issuer_success(void) { GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); grpc_httpcli_set_override(httpcli_get_google_keys_for_email, httpcli_post_should_not_be_called); - jwt = - grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, NULL); + jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, + NULL); grpc_auth_json_key_destruct(&key); GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(verifier, NULL, jwt, expected_audience, @@ -348,8 +347,8 @@ static void test_jwt_verifier_custom_email_issuer_success(void) { GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); grpc_httpcli_set_override(httpcli_get_custom_keys_for_email, httpcli_post_should_not_be_called); - jwt = - grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, NULL); + jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, + NULL); grpc_auth_json_key_destruct(&key); GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(verifier, NULL, jwt, expected_audience, @@ -359,9 +358,10 @@ static void test_jwt_verifier_custom_email_issuer_success(void) { grpc_httpcli_set_override(NULL, NULL); } -static int httpcli_get_jwk_set( - const grpc_httpcli_request *request, gpr_timespec deadline, - grpc_httpcli_response_cb on_response, void *user_data) { +static int httpcli_get_jwk_set(const grpc_httpcli_request *request, + gpr_timespec deadline, + grpc_httpcli_response_cb on_response, + void *user_data) { grpc_httpcli_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); @@ -396,8 +396,8 @@ static void test_jwt_verifier_url_issuer_success(void) { GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); grpc_httpcli_set_override(httpcli_get_openid_config, httpcli_post_should_not_be_called); - jwt = - grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, NULL); + jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, + NULL); grpc_auth_json_key_destruct(&key); GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(verifier, NULL, jwt, expected_audience, @@ -436,8 +436,8 @@ static void test_jwt_verifier_url_issuer_bad_config(void) { GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); grpc_httpcli_set_override(httpcli_get_bad_json, httpcli_post_should_not_be_called); - jwt = - grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, NULL); + jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, + NULL); grpc_auth_json_key_destruct(&key); GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(verifier, NULL, jwt, expected_audience, @@ -457,8 +457,8 @@ static void test_jwt_verifier_bad_json_key(void) { GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); grpc_httpcli_set_override(httpcli_get_bad_json, httpcli_post_should_not_be_called); - jwt = - grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, NULL); + jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, + NULL); grpc_auth_json_key_destruct(&key); GPR_ASSERT(jwt != NULL); grpc_jwt_verifier_verify(verifier, NULL, jwt, expected_audience, @@ -503,8 +503,8 @@ static void test_jwt_verifier_bad_signature(void) { GPR_ASSERT(grpc_auth_json_key_is_valid(&key)); grpc_httpcli_set_override(httpcli_get_openid_config, httpcli_post_should_not_be_called); - jwt = - grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, NULL); + jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime, + NULL); grpc_auth_json_key_destruct(&key); corrupt_jwt_sig(jwt); GPR_ASSERT(jwt != NULL); @@ -546,7 +546,6 @@ static void test_jwt_verifier_bad_format(void) { /* bad signature custom provided email*/ /* bad key */ - int main(int argc, char **argv) { grpc_test_init(argc, argv); test_claims_success(); @@ -562,4 +561,3 @@ int main(int argc, char **argv) { test_jwt_verifier_bad_format(); return 0; } - diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c index 129b19bbe1..753221cada 100644 --- a/test/core/security/print_google_default_creds_token.c +++ b/test/core/security/print_google_default_creds_token.c @@ -49,8 +49,7 @@ typedef struct { int is_done; } synchronizer; -static void on_metadata_response(void *user_data, - grpc_credentials_md *md_elems, +static void on_metadata_response(void *user_data, grpc_credentials_md *md_elems, size_t num_md, grpc_credentials_status status) { synchronizer *sync = user_data; diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.c index b37fd7213d..3f6c592b0b 100644 --- a/test/core/security/security_connector_test.c +++ b/test/core/security/security_connector_test.c @@ -77,9 +77,9 @@ static void test_unauthenticated_ssl_peer(void) { } static int check_identity(const grpc_auth_context *ctx, - const char *expected_property_name, - const char **expected_identities, - size_t num_identities) { + const char *expected_property_name, + const char **expected_identities, + size_t num_identities) { grpc_auth_property_iterator it; const grpc_auth_property *prop; size_t i; @@ -166,7 +166,8 @@ static void test_cn_and_one_san_ssl_peer_to_auth_context(void) { ctx = tsi_ssl_peer_to_auth_context(&peer); GPR_ASSERT(ctx != NULL); GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx)); - GPR_ASSERT(check_identity(ctx, GRPC_X509_SAN_PROPERTY_NAME, &expected_san, 1)); + GPR_ASSERT( + check_identity(ctx, GRPC_X509_SAN_PROPERTY_NAME, &expected_san, 1)); GPR_ASSERT(check_transport_security_type(ctx)); GPR_ASSERT(check_x509_cn(ctx, expected_cn)); diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.c index 8c401e4f1b..f4432667ee 100644 --- a/test/core/security/verify_jwt.c +++ b/test/core/security/verify_jwt.c @@ -120,4 +120,3 @@ int main(int argc, char **argv) { gpr_cmdline_destroy(cl); return !sync.success; } - diff --git a/test/core/statistics/census_log_tests.h b/test/core/statistics/census_log_tests.h index 28bde086f3..ec3241b4f9 100644 --- a/test/core/statistics/census_log_tests.h +++ b/test/core/statistics/census_log_tests.h @@ -48,4 +48,4 @@ void test_multiple_writers(); void test_performance(); void test_small_log(); -#endif /* GRPC_TEST_CORE_STATISTICS_CENSUS_LOG_TESTS_H */ +#endif /* GRPC_TEST_CORE_STATISTICS_CENSUS_LOG_TESTS_H */ diff --git a/test/core/statistics/hash_table_test.c b/test/core/statistics/hash_table_test.c index 1e9e1c8d23..2568e96cba 100644 --- a/test/core/statistics/hash_table_test.c +++ b/test/core/statistics/hash_table_test.c @@ -65,8 +65,8 @@ static void free_data(void* data) { gpr_free(data); } static void test_create_table(void) { /* Create table with uint64 key type */ census_ht* ht = NULL; - census_ht_option ht_options = {CENSUS_HT_UINT64, 1999, NULL, - NULL, NULL, NULL}; + census_ht_option ht_options = { + CENSUS_HT_UINT64, 1999, NULL, NULL, NULL, NULL}; ht = census_ht_create(&ht_options); GPR_ASSERT(ht != NULL); GPR_ASSERT(census_ht_get_size(ht) == 0); @@ -97,7 +97,7 @@ 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*)(gpr_intptr) i); + census_ht_insert(ht, key, (void*)(gpr_intptr)i); GPR_ASSERT(census_ht_get_size(ht) == i + 1); } for (i = 0; i < 20; i++) { @@ -105,7 +105,7 @@ static void test_table_with_int_key(void) { census_ht_key key; key.val = i; val = census_ht_find(ht, key); - GPR_ASSERT(val == (void*)(gpr_intptr) i); + GPR_ASSERT(val == (void*)(gpr_intptr)i); } elements = census_ht_get_all_elements(ht, &num_elements); GPR_ASSERT(elements != NULL); @@ -212,9 +212,9 @@ 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[] = {"k1", "a", "000", - "apple", "banana_a_long_long_long_banana", "%$", - "111", "foo", "b"}; + 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}; int i = 0; GPR_ASSERT(ht != NULL); diff --git a/test/core/support/cmdline_test.c b/test/core/support/cmdline_test.c index 26153b192c..1c77c15233 100644 --- a/test/core/support/cmdline_test.c +++ b/test/core/support/cmdline_test.c @@ -287,8 +287,9 @@ static void test_usage(void) { gpr_cmdline_add_flag(cl, "flag", NULL, &flag); usage = gpr_cmdline_usage_string(cl, "test"); - GPR_ASSERT(0 == strcmp(usage, - "Usage: test [--str=string] [--x=int] [--flag|--no-flag]\n")); + GPR_ASSERT( + 0 == strcmp(usage, + "Usage: test [--str=string] [--x=int] [--flag|--no-flag]\n")); gpr_free(usage); gpr_cmdline_destroy(cl); diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c index 9023d0746b..f62cbe3435 100644 --- a/test/core/support/string_test.c +++ b/test/core/support/string_test.c @@ -71,7 +71,7 @@ static void test_dump(void) { expect_dump("\x01", 1, GPR_DUMP_HEX | GPR_DUMP_ASCII, "01 '.'"); expect_dump("\x01\x02", 2, GPR_DUMP_HEX, "01 02"); expect_dump("\x01\x23\x45\x67\x89\xab\xcd\xef", 8, GPR_DUMP_HEX, - "01 23 45 67 89 ab cd ef"); + "01 23 45 67 89 ab cd ef"); expect_dump("ab", 2, GPR_DUMP_HEX | GPR_DUMP_ASCII, "61 62 'ab'"); } @@ -221,7 +221,7 @@ static void test_strjoin_sep(void) { } static void test_strsplit(void) { - gpr_slice_buffer* parts; + gpr_slice_buffer *parts; gpr_slice str; LOG_TEST_NAME("test_strsplit"); diff --git a/test/core/support/thd_test.c b/test/core/support/thd_test.c index 7232cd9f5b..faba33c5e8 100644 --- a/test/core/support/thd_test.c +++ b/test/core/support/thd_test.c @@ -60,7 +60,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 that we can create a number of threads and wait for them. */ static void test(void) { diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index 0741ab920d..a5298a25e0 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -105,8 +105,8 @@ static void test_shutdown_then_next_polling(void) { cc = grpc_completion_queue_create(NULL); grpc_completion_queue_shutdown(cc); - event = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), - NULL); + event = + grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(cc); } @@ -118,8 +118,8 @@ static void test_shutdown_then_next_with_timeout(void) { cc = grpc_completion_queue_create(NULL); grpc_completion_queue_shutdown(cc); - event = grpc_completion_queue_next(cc, gpr_inf_future(GPR_CLOCK_REALTIME), - NULL); + event = + grpc_completion_queue_next(cc, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(cc); } diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 216eeca8e1..96434193c9 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -58,13 +58,13 @@ int main(int argc, char **argv) { grpc_metadata_array_init(&trailing_metadata_recv); - chan = grpc_lame_client_channel_create("lampoon:national"); + chan = grpc_lame_client_channel_create( + "lampoon:national", GRPC_STATUS_UNKNOWN, "Rpc sent on a lame channel."); GPR_ASSERT(chan); cq = grpc_completion_queue_create(NULL); call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/Foo", "anywhere", - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100), - NULL); + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100), NULL); GPR_ASSERT(call); cqv = cq_verifier_create(cq); diff --git a/test/core/transport/chttp2/stream_map_test.c b/test/core/transport/chttp2/stream_map_test.c index 3c6976ee9d..b0bb3a8904 100644 --- a/test/core/transport/chttp2/stream_map_test.c +++ b/test/core/transport/chttp2/stream_map_test.c @@ -93,7 +93,7 @@ static void test_basic_add_find(size_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 *)(gpr_uintptr) i); + grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); } GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0)); @@ -148,7 +148,7 @@ static void test_delete_evens_sweep(size_t n) { grpc_chttp2_stream_map_init(&map, 8); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i); + grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); } for (i = 1; i <= n; i++) { if ((i & 1) == 0) { @@ -170,7 +170,7 @@ static void test_delete_evens_incremental(size_t n) { grpc_chttp2_stream_map_init(&map, 8); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i); + grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); if ((i & 1) == 0) { grpc_chttp2_stream_map_delete(&map, i); } diff --git a/test/core/util/grpc_profiler.h b/test/core/util/grpc_profiler.h index 347a1d39d5..88ec6bcb0e 100644 --- a/test/core/util/grpc_profiler.h +++ b/test/core/util/grpc_profiler.h @@ -45,4 +45,4 @@ void grpc_profiler_stop(); } #endif /* __cplusplus */ -#endif /* GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H */ +#endif /* GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H */ diff --git a/test/core/util/parse_hexstring.h b/test/core/util/parse_hexstring.h index 22bbd1756f..ddbfe541c6 100644 --- a/test/core/util/parse_hexstring.h +++ b/test/core/util/parse_hexstring.h @@ -38,4 +38,4 @@ gpr_slice parse_hexstring(const char *hexstring); -#endif /* GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H */ +#endif /* GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H */ diff --git a/test/core/util/port.h b/test/core/util/port.h index b516ec5a48..93788bcab2 100644 --- a/test/core/util/port.h +++ b/test/core/util/port.h @@ -49,4 +49,4 @@ int grpc_pick_unused_port_or_die(); } #endif -#endif /* GRPC_TEST_CORE_UTIL_PORT_H */ +#endif /* GRPC_TEST_CORE_UTIL_PORT_H */ diff --git a/test/core/util/port_windows.c b/test/core/util/port_windows.c index fc52150435..5b072f805a 100644 --- a/test/core/util/port_windows.c +++ b/test/core/util/port_windows.c @@ -63,7 +63,8 @@ static int is_port_available(int *port, int is_tcp) { } /* Reuseaddr lets us start up a server immediately after it exits */ - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&one, sizeof(one)) < 0) { + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&one, + sizeof(one)) < 0) { gpr_log(GPR_ERROR, "setsockopt() failed: %s", strerror(errno)); closesocket(fd); return 0; @@ -75,14 +76,14 @@ static int is_port_available(int *port, int is_tcp) { addr.sin_port = htons(*port); if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { gpr_log(GPR_DEBUG, "bind(port=%d) failed: %s", *port, strerror(errno)); - closesocket(fd); + closesocket(fd); return 0; } /* Get the bound port number */ if (getsockname(fd, (struct sockaddr *)&addr, &alen) < 0) { gpr_log(GPR_ERROR, "getsockname() failed: %s", strerror(errno)); - closesocket(fd); + closesocket(fd); return 0; } GPR_ASSERT(alen <= sizeof(addr)); @@ -113,11 +114,13 @@ int grpc_pick_unused_port(void) { /* Type of port to first pick in next iteration */ int is_tcp = 1; - int try = 0; + int try + = 0; for (;;) { int port; - try++; + try + ++; if (try == 1) { port = _getpid() % (65536 - 30000) + 30000; } else if (try <= NUM_RANDOM_PORTS_TO_PICK) { diff --git a/test/core/util/slice_splitter.h b/test/core/util/slice_splitter.h index 1ce1c097e2..d030c2cb55 100644 --- a/test/core/util/slice_splitter.h +++ b/test/core/util/slice_splitter.h @@ -65,4 +65,4 @@ gpr_slice grpc_slice_merge(gpr_slice *slices, size_t nslices); const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode); -#endif /* GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H */ +#endif /* GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H */ diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index cadf88a7c6..685bdff530 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -78,16 +78,16 @@ void abort_handler(int sig) { } static void install_crash_handler() { - SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) crash_handler); + SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)crash_handler); _set_abort_behavior(0, _WRITE_ABORT_MSG); _set_abort_behavior(0, _CALL_REPORTFAULT); signal(SIGABRT, abort_handler); } #else -static void install_crash_handler() { } +static void install_crash_handler() {} #endif -void grpc_test_init(int argc, char **argv) { +void grpc_test_init(int argc, char** argv) { install_crash_handler(); gpr_log(GPR_DEBUG, "test slowdown: machine=%f build=%f total=%f", (double)GRPC_TEST_SLOWDOWN_MACHINE_FACTOR, diff --git a/test/cpp/common/auth_property_iterator_test.cc b/test/cpp/common/auth_property_iterator_test.cc index 74b18ced0d..bf17842a84 100644 --- a/test/cpp/common/auth_property_iterator_test.cc +++ b/test/cpp/common/auth_property_iterator_test.cc @@ -61,11 +61,8 @@ class AuthPropertyIteratorTest : public ::testing::Test { EXPECT_EQ(1, grpc_auth_context_set_peer_identity_property_name(ctx_, "name")); } - void TearDown() GRPC_OVERRIDE { - grpc_auth_context_release(ctx_); - } + void TearDown() GRPC_OVERRIDE { grpc_auth_context_release(ctx_); } grpc_auth_context* ctx_; - }; TEST_F(AuthPropertyIteratorTest, DefaultCtor) { @@ -100,7 +97,7 @@ TEST_F(AuthPropertyIteratorTest, GeneralTest) { } // namespace } // namespace grpc -int main(int argc, char **argv) { +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/cpp/common/secure_auth_context_test.cc b/test/cpp/common/secure_auth_context_test.cc index 075d4ce8c9..e0376c9cc7 100644 --- a/test/cpp/common/secure_auth_context_test.cc +++ b/test/cpp/common/secure_auth_context_test.cc @@ -101,7 +101,7 @@ TEST_F(SecureAuthContextTest, Iterators) { } // namespace } // namespace grpc -int main(int argc, char **argv) { +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index 906f124c05..1c2a5c3a36 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -77,17 +77,14 @@ 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::cpp::test::util::TestService::NewStub( CreateChannel(addr, InsecureCredentials(), ChannelArguments())); } - void KillServer() { - server_.reset(); - } + void KillServer() { server_.reset(); } private: std::unique_ptr<SubProcess> server_; diff --git a/test/cpp/end2end/client_crash_test_server.cc b/test/cpp/end2end/client_crash_test_server.cc index 20808a0240..3fd8c2c2f9 100644 --- a/test/cpp/end2end/client_crash_test_server.cc +++ b/test/cpp/end2end/client_crash_test_server.cc @@ -58,7 +58,8 @@ using namespace gflags; namespace grpc { namespace testing { -class ServiceImpl GRPC_FINAL : public ::grpc::cpp::test::util::TestService::Service { +class ServiceImpl GRPC_FINAL + : public ::grpc::cpp::test::util::TestService::Service { Status BidiStream(ServerContext* context, ServerReaderWriter<EchoResponse, EchoRequest>* stream) GRPC_OVERRIDE { diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 3827cdf730..350b10726f 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -270,7 +270,7 @@ class End2endTest : public ::testing::TestWithParam<bool> { // Setup server ServerBuilder builder; SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key, - test_server1_cert}; + test_server1_cert}; SslServerCredentialsOptions ssl_opts; ssl_opts.pem_root_certs = ""; ssl_opts.pem_key_cert_pairs.push_back(pkcp); @@ -295,8 +295,8 @@ class End2endTest : public ::testing::TestWithParam<bool> { ChannelArguments args; args.SetSslTargetNameOverride("foo.test.google.fr"); args.SetString(GRPC_ARG_SECONDARY_USER_AGENT_STRING, "end2end_test"); - channel_ = CreateChannel(server_address_.str(), SslCredentials(ssl_opts), - args); + channel_ = + CreateChannel(server_address_.str(), SslCredentials(ssl_opts), args); } void ResetStub(bool use_proxy) { @@ -583,15 +583,15 @@ TEST_F(End2endTest, BadCredentials) { Status s = stub->Echo(&context, request, &response); EXPECT_EQ("", response.message()); EXPECT_FALSE(s.ok()); - EXPECT_EQ(StatusCode::UNKNOWN, s.error_code()); - EXPECT_EQ("Rpc sent on a lame channel.", s.error_message()); + EXPECT_EQ(StatusCode::INVALID_ARGUMENT, s.error_code()); + EXPECT_EQ("Invalid credentials.", s.error_message()); ClientContext context2; auto stream = stub->BidiStream(&context2); s = stream->Finish(); EXPECT_FALSE(s.ok()); - EXPECT_EQ(StatusCode::UNKNOWN, s.error_code()); - EXPECT_EQ("Rpc sent on a lame channel.", s.error_message()); + EXPECT_EQ(StatusCode::INVALID_ARGUMENT, s.error_code()); + EXPECT_EQ("Invalid credentials.", s.error_message()); } void CancelRpc(ClientContext* context, int delay_us, TestServiceImpl* service) { @@ -874,7 +874,7 @@ TEST_P(End2endTest, HugeResponse) { namespace { void ReaderThreadFunc(ClientReaderWriter<EchoRequest, EchoResponse>* stream, - gpr_event *ev) { + gpr_event* ev) { EchoResponse resp; gpr_event_set(ev, (void*)1); while (stream->Read(&resp)) { @@ -929,8 +929,8 @@ TEST_F(End2endTest, ChannelState) { EXPECT_FALSE(ok); EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(true)); - EXPECT_TRUE(channel_->WaitForStateChange( - GRPC_CHANNEL_IDLE, gpr_inf_future(GPR_CLOCK_REALTIME))); + EXPECT_TRUE(channel_->WaitForStateChange(GRPC_CHANNEL_IDLE, + gpr_inf_future(GPR_CLOCK_REALTIME))); EXPECT_EQ(GRPC_CHANNEL_CONNECTING, channel_->GetState(false)); } diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index b53c32144b..3120cec938 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -68,7 +68,7 @@ namespace grpc { namespace testing { namespace { -void* tag(int i) { return (void*)(gpr_intptr) i; } +void* tag(int i) { return (void*)(gpr_intptr)i; } void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { bool ok; @@ -107,7 +107,8 @@ class GenericEnd2endTest : public ::testing::Test { server_address_ << server_host_ << ":" << port; // Setup server ServerBuilder builder; - builder.AddListeningPort(server_address_.str(), InsecureServerCredentials()); + builder.AddListeningPort(server_address_.str(), + InsecureServerCredentials()); builder.RegisterAsyncGenericService(&generic_service_); srv_cq_ = builder.AddCompletionQueue(); server_ = builder.BuildAndStart(); diff --git a/test/cpp/end2end/server_crash_test_client.cc b/test/cpp/end2end/server_crash_test_client.cc index 497ccb4cb2..1da4f05c8d 100644 --- a/test/cpp/end2end/server_crash_test_client.cc +++ b/test/cpp/end2end/server_crash_test_client.cc @@ -60,8 +60,8 @@ using namespace gflags; int main(int argc, char** argv) { ParseCommandLineFlags(&argc, &argv, true); - auto stub = grpc::cpp::test::util::TestService::NewStub( - grpc::CreateChannel(FLAGS_address, grpc::InsecureCredentials(), grpc::ChannelArguments())); + auto stub = grpc::cpp::test::util::TestService::NewStub(grpc::CreateChannel( + FLAGS_address, grpc::InsecureCredentials(), grpc::ChannelArguments())); EchoRequest request; EchoResponse response; diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc index a48c497d9a..f5eba66cb2 100644 --- a/test/cpp/end2end/zookeeper_test.cc +++ b/test/cpp/end2end/zookeeper_test.cc @@ -89,8 +89,7 @@ class ZookeeperTest : public ::testing::Test { RegisterService("/test/1", value); // Registers service instance /test/2 in zookeeper - value = - "{\"host\":\"localhost\",\"port\":\"" + to_string(port2) + "\"}"; + value = "{\"host\":\"localhost\",\"port\":\"" + to_string(port2) + "\"}"; RegisterService("/test/2", value); } @@ -196,7 +195,7 @@ TEST_F(ZookeeperTest, ZookeeperStateChangeTwoRpc) { EXPECT_TRUE(s1.ok()); // Zookeeper state changes - gpr_log(GPR_DEBUG, "Zookeeper state change"); + gpr_log(GPR_DEBUG, "Zookeeper state change"); ChangeZookeeperState(); // Waits for re-resolving addresses // TODO(ctiller): RPC will probably fail if not waiting diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index ebc5cfc85a..48143b2e53 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -56,8 +56,12 @@ DEFINE_string(test_case, "large_unary", "Configure different test cases. Valid options are: " "empty_unary : empty (zero bytes) request and response; " "large_unary : single request and (large) response; " + "large_compressed_unary : single request and compressed (large) " + "response; " "client_streaming : request streaming with single response; " "server_streaming : single request with response streaming; " + "server_compressed_streaming : single request with compressed " + "response streaming; " "slow_consumer : single request with response; " " streaming with slow client consumer; " "half_duplex : half-duplex streaming; " @@ -70,7 +74,7 @@ DEFINE_string(test_case, "large_unary", "jwt_token_creds: large_unary with JWT token auth; " "oauth2_auth_token: raw oauth2 access token auth; " "per_rpc_creds: raw oauth2 access token on a single rpc; " - "status_code_and_message: verify status code & message; " + "status_code_and_message: verify status code & message; " "all : all of above."); DEFINE_string(default_service_account, "", "Email of GCE default service account"); @@ -91,10 +95,14 @@ int main(int argc, char** argv) { client.DoEmpty(); } else if (FLAGS_test_case == "large_unary") { client.DoLargeUnary(); + } else if (FLAGS_test_case == "large_compressed_unary") { + client.DoLargeCompressedUnary(); } else if (FLAGS_test_case == "client_streaming") { client.DoRequestStreaming(); } else if (FLAGS_test_case == "server_streaming") { client.DoResponseStreaming(); + } else if (FLAGS_test_case == "server_compressed_streaming") { + client.DoResponseCompressedStreaming(); } else if (FLAGS_test_case == "slow_consumer") { client.DoResponseStreamingWithSlowConsumer(); } else if (FLAGS_test_case == "half_duplex") { @@ -129,6 +137,7 @@ int main(int argc, char** argv) { client.DoLargeUnary(); client.DoRequestStreaming(); client.DoResponseStreaming(); + client.DoResponseCompressedStreaming(); client.DoHalfDuplex(); client.DoPingPong(); client.DoCancelAfterBegin(); @@ -148,10 +157,11 @@ int main(int argc, char** argv) { gpr_log( GPR_ERROR, "Unsupported test case %s. Valid options are all|empty_unary|" - "large_unary|client_streaming|server_streaming|half_duplex|ping_pong|" - "cancel_after_begin|cancel_after_first_response|" - "timeout_on_sleeping_server|service_account_creds|compute_engine_creds|" - "jwt_token_creds|oauth2_auth_token|per_rpc_creds", + "large_unary|large_compressed_unary|client_streaming|server_streaming|" + "server_compressed_streaming|half_duplex|ping_pong|cancel_after_begin|" + "cancel_after_first_response|timeout_on_sleeping_server|" + "service_account_creds|compute_engine_creds|jwt_token_creds|" + "oauth2_auth_token|per_rpc_creds", FLAGS_test_case.c_str()); ret = 1; } diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 73d82f7b88..65fdc63b43 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -48,10 +48,13 @@ #include <grpc++/create_channel.h> #include <grpc++/credentials.h> #include <grpc++/stream.h> -#include "src/cpp/client/secure_credentials.h" + #include "test/core/security/oauth2_utils.h" #include "test/cpp/util/create_test_channel.h" +#include "src/core/surface/call.h" +#include "src/cpp/client/secure_credentials.h" + DECLARE_bool(enable_ssl); DECLARE_bool(use_prod_roots); DECLARE_int32(server_port); @@ -62,6 +65,8 @@ DECLARE_string(default_service_account); DECLARE_string(service_account_key_file); DECLARE_string(oauth_scope); +using grpc::testing::CompressionType; + namespace grpc { namespace testing { @@ -138,5 +143,32 @@ std::shared_ptr<ChannelInterface> CreateChannelForTestCase( } } +CompressionType GetInteropCompressionTypeFromCompressionAlgorithm( + grpc_compression_algorithm algorithm) { + switch (algorithm) { + case GRPC_COMPRESS_NONE: + return CompressionType::NONE; + case GRPC_COMPRESS_GZIP: + return CompressionType::GZIP; + case GRPC_COMPRESS_DEFLATE: + return CompressionType::DEFLATE; + default: + GPR_ASSERT(false); + } +} + +InteropClientContextInspector::InteropClientContextInspector( + const ::grpc::ClientContext& context) + : context_(context) {} + +grpc_compression_algorithm +InteropClientContextInspector::GetCallCompressionAlgorithm() const { + return grpc_call_get_compression_algorithm(context_.call_); +} + +gpr_uint32 InteropClientContextInspector::GetMessageFlags() const { + return grpc_call_get_message_flags(context_.call_); +} + } // namespace testing } // namespace grpc diff --git a/test/cpp/interop/client_helper.h b/test/cpp/interop/client_helper.h index c4361bb9de..28fca3266c 100644 --- a/test/cpp/interop/client_helper.h +++ b/test/cpp/interop/client_helper.h @@ -39,6 +39,8 @@ #include <grpc++/config.h> #include <grpc++/channel_interface.h> +#include "test/proto/messages.grpc.pb.h" + namespace grpc { namespace testing { @@ -49,6 +51,22 @@ grpc::string GetOauth2AccessToken(); std::shared_ptr<ChannelInterface> CreateChannelForTestCase( const grpc::string& test_case); +grpc::testing::CompressionType +GetInteropCompressionTypeFromCompressionAlgorithm( + grpc_compression_algorithm algorithm); + +class InteropClientContextInspector { + public: + InteropClientContextInspector(const ::grpc::ClientContext& context); + + // Inspector methods, able to peek inside ClientContext, follow. + grpc_compression_algorithm GetCallCompressionAlgorithm() const; + gpr_uint32 GetMessageFlags() const; + + private: + const ::grpc::ClientContext& context_; +}; + } // namespace testing } // namespace grpc diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 066877e0c6..ddf91aa5eb 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -33,25 +33,31 @@ #include "test/cpp/interop/interop_client.h" +#include <fstream> #include <memory> #include <unistd.h> #include <grpc/grpc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include <grpc++/channel_interface.h> #include <grpc++/client_context.h> #include <grpc++/credentials.h> #include <grpc++/status.h> #include <grpc++/stream.h> + #include "test/cpp/interop/client_helper.h" #include "test/proto/test.grpc.pb.h" #include "test/proto/empty.grpc.pb.h" #include "test/proto/messages.grpc.pb.h" +#include "src/core/transport/stream_op.h" namespace grpc { namespace testing { +static const char* kRandomFile = "test/cpp/interop/rnd.dat"; + namespace { // The same value is defined by the Java client. const std::vector<int> request_stream_sizes = {27182, 8, 1828, 45904}; @@ -95,17 +101,48 @@ void InteropClient::PerformLargeUnary(SimpleRequest* request, std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_)); ClientContext context; - request->set_response_type(PayloadType::COMPRESSABLE); + InteropClientContextInspector inspector(context); + // If the request doesn't already specify the response type, default to + // COMPRESSABLE. request->set_response_size(kLargeResponseSize); grpc::string payload(kLargeRequestSize, '\0'); request->mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); Status s = stub->UnaryCall(&context, *request, response); + // Compression related checks. + GPR_ASSERT(request->response_compression() == + GetInteropCompressionTypeFromCompressionAlgorithm( + inspector.GetCallCompressionAlgorithm())); + if (request->response_compression() == NONE) { + GPR_ASSERT(!(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS)); + } else if (request->response_type() == PayloadType::COMPRESSABLE) { + // requested compression and compressable response => results should always + // be compressed. + GPR_ASSERT(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS); + } + AssertOkOrPrintErrorStatus(s); - GPR_ASSERT(response->payload().type() == PayloadType::COMPRESSABLE); - GPR_ASSERT(response->payload().body() == - grpc::string(kLargeResponseSize, '\0')); + + // Payload related checks. + if (request->response_type() != PayloadType::RANDOM) { + GPR_ASSERT(response->payload().type() == request->response_type()); + } + switch (response->payload().type()) { + case PayloadType::COMPRESSABLE: + GPR_ASSERT(response->payload().body() == + grpc::string(kLargeResponseSize, '\0')); + break; + case PayloadType::UNCOMPRESSABLE: { + std::ifstream rnd_file(kRandomFile); + GPR_ASSERT(rnd_file.good()); + for (int i = 0; i < kLargeResponseSize; i++) { + GPR_ASSERT(response->payload().body()[i] == (char)rnd_file.get()); + } + } break; + default: + GPR_ASSERT(false); + } } void InteropClient::DoComputeEngineCreds( @@ -117,6 +154,7 @@ void InteropClient::DoComputeEngineCreds( SimpleResponse response; request.set_fill_username(true); request.set_fill_oauth_scope(true); + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); gpr_log(GPR_INFO, "Got username %s", response.username().c_str()); gpr_log(GPR_INFO, "Got oauth_scope %s", response.oauth_scope().c_str()); @@ -136,6 +174,7 @@ void InteropClient::DoServiceAccountCreds(const grpc::string& username, SimpleResponse response; request.set_fill_username(true); request.set_fill_oauth_scope(true); + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(!response.oauth_scope().empty()); @@ -199,6 +238,7 @@ void InteropClient::DoJwtTokenCreds(const grpc::string& username) { SimpleRequest request; SimpleResponse response; request.set_fill_username(true); + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(username.find(response.username()) != grpc::string::npos); @@ -209,10 +249,33 @@ void InteropClient::DoLargeUnary() { gpr_log(GPR_INFO, "Sending a large unary rpc..."); SimpleRequest request; SimpleResponse response; + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); gpr_log(GPR_INFO, "Large unary done."); } +void InteropClient::DoLargeCompressedUnary() { + const CompressionType compression_types[] = {NONE, GZIP, DEFLATE}; + const PayloadType payload_types[] = {COMPRESSABLE, UNCOMPRESSABLE, RANDOM}; + for (const auto payload_type : payload_types) { + for (const auto compression_type : compression_types) { + char* log_suffix; + gpr_asprintf(&log_suffix, "(compression=%s; payload=%s)", + CompressionType_Name(compression_type).c_str(), + PayloadType_Name(payload_type).c_str()); + + gpr_log(GPR_INFO, "Sending a large compressed unary rpc %s.", log_suffix); + SimpleRequest request; + SimpleResponse response; + request.set_response_type(payload_type); + request.set_response_compression(compression_type); + PerformLargeUnary(&request, &response); + gpr_log(GPR_INFO, "Large compressed unary done %s.", log_suffix); + gpr_free(log_suffix); + } + } +} + void InteropClient::DoRequestStreaming() { gpr_log(GPR_INFO, "Sending request steaming rpc ..."); std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_)); @@ -261,11 +324,73 @@ void InteropClient::DoResponseStreaming() { } GPR_ASSERT(response_stream_sizes.size() == i); Status s = stream->Finish(); - AssertOkOrPrintErrorStatus(s); gpr_log(GPR_INFO, "Response streaming done."); } +void InteropClient::DoResponseCompressedStreaming() { + std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_)); + + const CompressionType compression_types[] = {NONE, GZIP, DEFLATE}; + const PayloadType payload_types[] = {COMPRESSABLE, UNCOMPRESSABLE, RANDOM}; + for (const auto payload_type : payload_types) { + for (const auto compression_type : compression_types) { + ClientContext context; + InteropClientContextInspector inspector(context); + StreamingOutputCallRequest request; + + char* log_suffix; + gpr_asprintf(&log_suffix, "(compression=%s; payload=%s)", + CompressionType_Name(compression_type).c_str(), + PayloadType_Name(payload_type).c_str()); + + gpr_log(GPR_INFO, "Receiving response steaming rpc %s.", log_suffix); + + request.set_response_type(payload_type); + request.set_response_compression(compression_type); + + for (unsigned int i = 0; i < response_stream_sizes.size(); ++i) { + ResponseParameters* response_parameter = + request.add_response_parameters(); + response_parameter->set_size(response_stream_sizes[i]); + } + StreamingOutputCallResponse response; + + std::unique_ptr<ClientReader<StreamingOutputCallResponse>> stream( + stub->StreamingOutputCall(&context, request)); + + unsigned int i = 0; + while (stream->Read(&response)) { + GPR_ASSERT(response.payload().body() == + grpc::string(response_stream_sizes[i], '\0')); + + // Compression related checks. + GPR_ASSERT(request.response_compression() == + GetInteropCompressionTypeFromCompressionAlgorithm( + inspector.GetCallCompressionAlgorithm())); + if (request.response_compression() == NONE) { + GPR_ASSERT( + !(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS)); + } else if (request.response_type() == PayloadType::COMPRESSABLE) { + // requested compression and compressable response => results should + // always be compressed. + GPR_ASSERT(inspector.GetMessageFlags() & + GRPC_WRITE_INTERNAL_COMPRESS); + } + + ++i; + } + + GPR_ASSERT(response_stream_sizes.size() == i); + Status s = stream->Finish(); + + AssertOkOrPrintErrorStatus(s); + gpr_log(GPR_INFO, "Response streaming done %s.", log_suffix); + gpr_free(log_suffix); + } + } +} + void InteropClient::DoResponseStreamingWithSlowConsumer() { gpr_log(GPR_INFO, "Receiving response steaming rpc with slow consumer ..."); std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_)); @@ -427,7 +552,7 @@ void InteropClient::DoStatusWithMessage() { ClientContext context; SimpleRequest request; SimpleResponse response; - EchoStatus *requested_status = request.mutable_response_status(); + EchoStatus* requested_status = request.mutable_response_status(); requested_status->set_code(grpc::StatusCode::UNKNOWN); grpc::string test_msg = "This is a test message"; requested_status->set_message(test_msg); diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 6e26c49e5d..d6fb9bff39 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -52,10 +52,12 @@ class InteropClient { void DoEmpty(); void DoLargeUnary(); + void DoLargeCompressedUnary(); void DoPingPong(); void DoHalfDuplex(); void DoRequestStreaming(); void DoResponseStreaming(); + void DoResponseCompressedStreaming(); void DoResponseStreamingWithSlowConsumer(); void DoCancelAfterBegin(); void DoCancelAfterFirstResponse(); diff --git a/test/cpp/interop/rnd.dat b/test/cpp/interop/rnd.dat Binary files differnew file mode 100644 index 0000000000..8c7f38f9e0 --- /dev/null +++ b/test/cpp/interop/rnd.dat diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc index 4e809ed902..760bb18f73 100644 --- a/test/cpp/interop/server.cc +++ b/test/cpp/interop/server.cc @@ -31,6 +31,7 @@ * */ +#include <fstream> #include <memory> #include <sstream> #include <thread> @@ -41,6 +42,8 @@ #include <gflags/gflags.h> #include <grpc/grpc.h> #include <grpc/support/log.h> +#include <grpc/support/useful.h> + #include <grpc++/config.h> #include <grpc++/server.h> #include <grpc++/server_builder.h> @@ -48,6 +51,7 @@ #include <grpc++/server_credentials.h> #include <grpc++/status.h> #include <grpc++/stream.h> + #include "test/proto/test.grpc.pb.h" #include "test/proto/empty.grpc.pb.h" #include "test/proto/messages.grpc.pb.h" @@ -65,6 +69,7 @@ using grpc::ServerReader; using grpc::ServerReaderWriter; using grpc::ServerWriter; using grpc::SslServerCredentialsOptions; +using grpc::testing::InteropServerContextInspector; using grpc::testing::Payload; using grpc::testing::PayloadType; using grpc::testing::SimpleRequest; @@ -77,19 +82,54 @@ using grpc::testing::TestService; using grpc::Status; static bool got_sigint = false; +static const char* kRandomFile = "test/cpp/interop/rnd.dat"; bool SetPayload(PayloadType type, int size, Payload* payload) { - PayloadType response_type = type; - // TODO(yangg): Support UNCOMPRESSABLE payload. - if (type != PayloadType::COMPRESSABLE) { - return false; + PayloadType response_type; + if (type == PayloadType::RANDOM) { + response_type = + rand() & 0x1 ? PayloadType::COMPRESSABLE : PayloadType::UNCOMPRESSABLE; + } else { + response_type = type; } payload->set_type(response_type); - std::unique_ptr<char[]> body(new char[size]()); - payload->set_body(body.get(), size); + switch (response_type) { + case PayloadType::COMPRESSABLE: { + std::unique_ptr<char[]> body(new char[size]()); + payload->set_body(body.get(), size); + } break; + case PayloadType::UNCOMPRESSABLE: { + std::unique_ptr<char[]> body(new char[size]()); + std::ifstream rnd_file(kRandomFile); + GPR_ASSERT(rnd_file.good()); + rnd_file.read(body.get(), size); + GPR_ASSERT(!rnd_file.eof()); // Requested more rnd bytes than available + payload->set_body(body.get(), size); + } break; + default: + GPR_ASSERT(false); + } return true; } +template <typename RequestType> +void SetResponseCompression(ServerContext* context, + const RequestType& request) { + switch (request.response_compression()) { + case grpc::testing::NONE: + context->set_compression_algorithm(GRPC_COMPRESS_NONE); + break; + case grpc::testing::GZIP: + context->set_compression_algorithm(GRPC_COMPRESS_GZIP); + break; + case grpc::testing::DEFLATE: + context->set_compression_algorithm(GRPC_COMPRESS_DEFLATE); + break; + default: + abort(); + } +} + class TestServiceImpl : public TestService::Service { public: Status EmptyCall(ServerContext* context, const grpc::testing::Empty* request, @@ -99,6 +139,7 @@ class TestServiceImpl : public TestService::Service { Status UnaryCall(ServerContext* context, const SimpleRequest* request, SimpleResponse* response) { + SetResponseCompression(context, *request); if (request->response_size() > 0) { if (!SetPayload(request->response_type(), request->response_size(), response->mutable_payload())) { @@ -107,9 +148,9 @@ class TestServiceImpl : public TestService::Service { } if (request->has_response_status()) { - return Status(static_cast<grpc::StatusCode> - (request->response_status().code()), - request->response_status().message()); + return Status( + static_cast<grpc::StatusCode>(request->response_status().code()), + request->response_status().message()); } return Status::OK; @@ -118,6 +159,7 @@ class TestServiceImpl : public TestService::Service { Status StreamingOutputCall( ServerContext* context, const StreamingOutputCallRequest* request, ServerWriter<StreamingOutputCallResponse>* writer) { + SetResponseCompression(context, *request); StreamingOutputCallResponse response; bool write_success = true; response.mutable_payload()->set_type(request->response_type()); @@ -156,6 +198,7 @@ class TestServiceImpl : public TestService::Service { StreamingOutputCallResponse response; bool write_success = true; while (write_success && stream->Read(&request)) { + SetResponseCompression(context, request); if (request.response_parameters_size() != 0) { response.mutable_payload()->set_type(request.payload().type()); response.mutable_payload()->set_body( diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc index 30a78ffddf..3721d79635 100644 --- a/test/cpp/interop/server_helper.cc +++ b/test/cpp/interop/server_helper.cc @@ -36,10 +36,12 @@ #include <memory> #include <gflags/gflags.h> -#include "test/core/end2end/data/ssl_test_data.h" #include <grpc++/config.h> #include <grpc++/server_credentials.h> +#include "src/core/surface/call.h" +#include "test/core/end2end/data/ssl_test_data.h" + DECLARE_bool(enable_ssl); namespace grpc { @@ -58,16 +60,25 @@ std::shared_ptr<ServerCredentials> CreateInteropServerCredentials() { } } -InteropContextInspector::InteropContextInspector( +InteropServerContextInspector::InteropServerContextInspector( const ::grpc::ServerContext& context) : context_(context) {} -std::shared_ptr<const AuthContext> InteropContextInspector::GetAuthContext() - const { +grpc_compression_algorithm +InteropServerContextInspector::GetCallCompressionAlgorithm() const { + return grpc_call_get_compression_algorithm(context_.call_); +} + +gpr_uint32 InteropServerContextInspector::GetEncodingsAcceptedByClient() const { + return grpc_call_get_encodings_accepted_by_peer(context_.call_); +} + +std::shared_ptr<const AuthContext> +InteropServerContextInspector::GetAuthContext() const { return context_.auth_context(); } -bool InteropContextInspector::IsCancelled() const { +bool InteropServerContextInspector::IsCancelled() const { return context_.IsCancelled(); } diff --git a/test/cpp/interop/server_helper.h b/test/cpp/interop/server_helper.h index ce977b4705..7b6b12cd4d 100644 --- a/test/cpp/interop/server_helper.h +++ b/test/cpp/interop/server_helper.h @@ -36,6 +36,7 @@ #include <memory> +#include <grpc/compression.h> #include <grpc++/server_context.h> #include <grpc++/server_credentials.h> @@ -44,13 +45,15 @@ namespace testing { std::shared_ptr<ServerCredentials> CreateInteropServerCredentials(); -class InteropContextInspector { +class InteropServerContextInspector { public: - InteropContextInspector(const ::grpc::ServerContext& context); + InteropServerContextInspector(const ::grpc::ServerContext& context); // Inspector methods, able to peek inside ServerContext, follow. std::shared_ptr<const AuthContext> GetAuthContext() const; bool IsCancelled() const; + grpc_compression_algorithm GetCallCompressionAlgorithm() const; + gpr_uint32 GetEncodingsAcceptedByClient() const; private: const ::grpc::ServerContext& context_; diff --git a/test/cpp/qps/perf_db_client.cc b/test/cpp/qps/perf_db_client.cc index 08d20f0b8d..98efd8c3e3 100644 --- a/test/cpp/qps/perf_db_client.cc +++ b/test/cpp/qps/perf_db_client.cc @@ -44,9 +44,7 @@ void PerfDbClient::setConfigs(const ClientConfig& client_config, } // sets the QPS -void PerfDbClient::setQps(double qps) { - qps_ = qps; -} +void PerfDbClient::setQps(double qps) { qps_ = qps; } // sets the QPS per core void PerfDbClient::setQpsPerCore(double qps_per_core) { @@ -54,10 +52,8 @@ void PerfDbClient::setQpsPerCore(double qps_per_core) { } // sets the 50th, 90th, 95th, 99th and 99.9th percentile latency -void PerfDbClient::setLatencies(double perc_lat_50, - double perc_lat_90, - double perc_lat_95, - double perc_lat_99, +void PerfDbClient::setLatencies(double perc_lat_50, double perc_lat_90, + double perc_lat_95, double perc_lat_99, double perc_lat_99_point_9) { perc_lat_50_ = perc_lat_50; perc_lat_90_ = perc_lat_90; @@ -68,7 +64,8 @@ void PerfDbClient::setLatencies(double perc_lat_50, // sets the server and client, user and system times void PerfDbClient::setTimes(double server_system_time, double server_user_time, - double client_system_time, double client_user_time) { + double client_system_time, + double client_user_time) { server_system_time_ = server_system_time; server_user_time_ = server_user_time; client_system_time_ = client_system_time; diff --git a/test/cpp/qps/perf_db_client.h b/test/cpp/qps/perf_db_client.h index ce7a88bbff..7a9d86d3a6 100644 --- a/test/cpp/qps/perf_db_client.h +++ b/test/cpp/qps/perf_db_client.h @@ -82,9 +82,8 @@ class PerfDbClient { void setQpsPerCore(double qps_per_core); // sets the 50th, 90th, 95th, 99th and 99.9th percentile latency - void setLatencies(double perc_lat_50, double perc_lat_90, - double perc_lat_95, double perc_lat_99, - double perc_lat_99_point_9); + void setLatencies(double perc_lat_50, double perc_lat_90, double perc_lat_95, + double perc_lat_99, double perc_lat_99_point_9); // sets the server and client, user and system times void setTimes(double server_system_time, double server_user_time, diff --git a/test/cpp/qps/qps_interarrival_test.cc b/test/cpp/qps/qps_interarrival_test.cc index cecd1be03f..1eed956a1c 100644 --- a/test/cpp/qps/qps_interarrival_test.cc +++ b/test/cpp/qps/qps_interarrival_test.cc @@ -42,7 +42,7 @@ using grpc::testing::RandomDist; using grpc::testing::InterarrivalTimer; -void RunTest(RandomDist&& r, int threads, std::string title) { +void RunTest(RandomDist &&r, int threads, std::string title) { InterarrivalTimer timer; timer.init(r, threads); gpr_histogram *h(gpr_histogram_create(0.01, 60e9)); diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc index 96a9b4504c..9a7313f6e8 100644 --- a/test/cpp/qps/qps_openloop_test.cc +++ b/test/cpp/qps/qps_openloop_test.cc @@ -59,8 +59,8 @@ static void RunQPS() { client_config.set_async_client_threads(8); client_config.set_rpc_type(UNARY); client_config.set_load_type(POISSON); - client_config.mutable_load_params()-> - mutable_poisson()->set_offered_load(1000.0); + client_config.mutable_load_params()->mutable_poisson()->set_offered_load( + 1000.0); ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 91fbbf9677..3c38221b4c 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -37,7 +37,8 @@ DEFINE_bool(enable_log_reporter, true, "Enable reporting of benchmark results through GprLog"); -DEFINE_bool(report_metrics_db, false, "True if metrics to be reported to performance database"); +DEFINE_bool(report_metrics_db, false, + "True if metrics to be reported to performance database"); DEFINE_string(hashed_id, "", "Hash of the user id"); @@ -45,7 +46,8 @@ DEFINE_string(test_name, "", "Name of the test being executed"); DEFINE_string(sys_info, "", "System information"); -DEFINE_string(server_address, "localhost:50052", "Address of the performance database server"); +DEFINE_string(server_address, "localhost:50052", + "Address of the performance database server"); DEFINE_string(tag, "", "Optional tag for the test"); @@ -69,10 +71,10 @@ static std::shared_ptr<Reporter> InitBenchmarkReporters() { composite_reporter->add( std::unique_ptr<Reporter>(new GprLogReporter("LogReporter"))); } - if(FLAGS_report_metrics_db) { - composite_reporter->add( - std::unique_ptr<Reporter>(new PerfDbReporter("PerfDbReporter", FLAGS_hashed_id, FLAGS_test_name, - FLAGS_sys_info, FLAGS_server_address, FLAGS_tag))); + if (FLAGS_report_metrics_db) { + composite_reporter->add(std::unique_ptr<Reporter>( + new PerfDbReporter("PerfDbReporter", FLAGS_hashed_id, FLAGS_test_name, + FLAGS_sys_info, FLAGS_server_address, FLAGS_tag))); } return std::shared_ptr<Reporter>(composite_reporter); diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc index 13eb49730a..5195575f99 100644 --- a/test/cpp/util/byte_buffer_test.cc +++ b/test/cpp/util/byte_buffer_test.cc @@ -46,8 +46,7 @@ namespace { const char* kContent1 = "hello xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char* kContent2 = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy world"; -class ByteBufferTest : public ::testing::Test { -}; +class ByteBufferTest : public ::testing::Test {}; TEST_F(ByteBufferTest, CreateFromSingleSlice) { gpr_slice hello = gpr_slice_from_copied_string(kContent1); diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index 83a7a1744a..ac88910a01 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -49,7 +49,7 @@ namespace grpc { namespace testing { namespace { -void* tag(int i) { return (void*)(gpr_intptr) i; } +void* tag(int i) { return (void*)(gpr_intptr)i; } } // namespace Status CliCall::Call(std::shared_ptr<grpc::ChannelInterface> channel, |