diff options
author | Craig Tiller <ctiller@google.com> | 2016-06-09 07:50:50 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-06-09 07:50:50 -0700 |
commit | 0ca68b7cb19d2735f965d283b9974d8cd42df51d (patch) | |
tree | 10abff4f54d5c109e8aa813a340729ba1ef2689f /test/core | |
parent | 16ebf5a124026f8e9d59894b214d2e743590a93e (diff) | |
parent | 1bc2976a0f51e14d3525aecbf4b3450445ed2d1b (diff) |
Merge github.com:grpc/grpc into error
Diffstat (limited to 'test/core')
52 files changed, 581 insertions, 76 deletions
diff --git a/test/core/bad_client/tests/large_metadata.c b/test/core/bad_client/tests/large_metadata.c index b7d329cb74..ded5f17d4a 100644 --- a/test/core/bad_client/tests/large_metadata.c +++ b/test/core/bad_client/tests/large_metadata.c @@ -163,6 +163,7 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server, meta.value_length = metadata_value_size; grpc_op op; + memset(&op, 0, sizeof(op)); op.op = GRPC_OP_SEND_INITIAL_METADATA; op.data.send_initial_metadata.count = 1; op.data.send_initial_metadata.metadata = &meta; diff --git a/test/core/bad_ssl/bad_ssl_test.c b/test/core/bad_ssl/bad_ssl_test.c index c4ae212ec2..bb06ab0bb9 100644 --- a/test/core/bad_ssl/bad_ssl_test.c +++ b/test/core/bad_ssl/bad_ssl_test.c @@ -84,6 +84,7 @@ static void run_test(const char *target, size_t nops) { "/foo", "foo.test.google.fr:1234", deadline, NULL); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/channel/channel_args_test.c b/test/core/channel/channel_args_test.c index c2fc05095a..8ef1bff22e 100644 --- a/test/core/channel/channel_args_test.c +++ b/test/core/channel/channel_args_test.c @@ -136,8 +136,10 @@ static void test_compression_algorithm_states(void) { int main(int argc, char **argv) { grpc_test_init(argc, argv); + grpc_init(); test_create(); test_set_compression_algorithm(); test_compression_algorithm_states(); + grpc_shutdown(); return 0; } diff --git a/test/core/client_config/lb_policies_test.c b/test/core/client_config/lb_policies_test.c index 2ec46124a8..1534360dea 100644 --- a/test/core/client_config/lb_policies_test.c +++ b/test/core/client_config/lb_policies_test.c @@ -275,6 +275,7 @@ static int *perform_request(servers_fixture *f, grpc_channel *client, GPR_ASSERT(c); completed_client = 0; + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -327,6 +328,7 @@ static int *perform_request(servers_fixture *f, grpc_channel *client, } if (s_idx >= 0) { + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -415,6 +417,7 @@ static grpc_call **perform_multirequest(servers_fixture *f, kill_server(f, i); } + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -640,7 +643,7 @@ static void print_failed_expectations(const int *expected_connection_sequence, const size_t num_iters) { size_t i; for (i = 0; i < num_iters; i++) { - gpr_log(GPR_ERROR, "FAILURE: Iter, expected, actual:%d (%d, %d)", i, + gpr_log(GPR_ERROR, "FAILURE: Iter (expected, actual): %d (%d, %d)", i, expected_connection_sequence[i % expected_seq_length], actual_connection_sequence[i]); } @@ -664,8 +667,6 @@ static void verify_vanilla_round_robin(const servers_fixture *f, const int actual = actual_connection_sequence[i]; const int expected = expected_connection_sequence[i % expected_seq_length]; if (actual != expected) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", expected, - actual, i); print_failed_expectations(expected_connection_sequence, actual_connection_sequence, expected_seq_length, num_iters); @@ -692,24 +693,21 @@ static void verify_vanishing_floor_round_robin( memcpy(expected_connection_sequence, actual_connection_sequence + 2, expected_seq_length * sizeof(int)); - /* first three elements of the sequence should be [<1st>, -1] */ - if (actual_connection_sequence[0] != expected_connection_sequence[0]) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", - expected_connection_sequence[0], actual_connection_sequence[0], 0); - print_failed_expectations(expected_connection_sequence, - actual_connection_sequence, expected_seq_length, - 1u); - abort(); - } - + /* first two elements of the sequence should be [0 (1st server), -1 (failure)] + */ + GPR_ASSERT(actual_connection_sequence[0] == 0); GPR_ASSERT(actual_connection_sequence[1] == -1); + /* the next two element must be [3, 0], repeating from that point: the 3 is + * brought forth by servers 1 and 2 disappearing after the intial pick of 0 */ + GPR_ASSERT(actual_connection_sequence[2] == 3); + GPR_ASSERT(actual_connection_sequence[3] == 0); + + /* make sure that the expectation obliges */ for (i = 2; i < num_iters; i++) { const int actual = actual_connection_sequence[i]; const int expected = expected_connection_sequence[i % expected_seq_length]; if (actual != expected) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", expected, - actual, i); print_failed_expectations(expected_connection_sequence, actual_connection_sequence, expected_seq_length, num_iters); @@ -757,8 +755,6 @@ static void verify_partial_carnage_round_robin( const int actual = actual_connection_sequence[i]; const int expected = expected_connection_sequence[i % expected_seq_length]; if (actual != expected) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", expected, - actual, i); print_failed_expectations(expected_connection_sequence, actual_connection_sequence, expected_seq_length, num_iters); @@ -856,8 +852,6 @@ static void verify_rebirth_round_robin(const servers_fixture *f, const int expected = expected_connection_sequence[j++ % expected_seq_length]; if (actual != expected) { - gpr_log(GPR_ERROR, "FAILURE: expected %d, actual %d at iter %d", expected, - actual, i); print_failed_expectations(expected_connection_sequence, actual_connection_sequence, expected_seq_length, num_iters); @@ -887,7 +881,8 @@ int main(int argc, char **argv) { GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, NULL, NULL) == NULL); spec = test_spec_create(NUM_ITERS, NUM_SERVERS); - /* everything is fine, all servers stay up the whole time and life's peachy */ + /* everything is fine, all servers stay up the whole time and life's peachy + */ spec->verifier = verify_vanilla_round_robin; spec->description = "test_all_server_up"; run_spec(spec); diff --git a/test/core/client_config/set_initial_connect_string_test.c b/test/core/client_config/set_initial_connect_string_test.c index 1641128301..0a0da92ce2 100644 --- a/test/core/client_config/set_initial_connect_string_test.c +++ b/test/core/client_config/set_initial_connect_string_test.c @@ -136,6 +136,7 @@ static void start_rpc(int use_creds, int target_port) { state.call = grpc_channel_create_call( state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq, "/Service/Method", "localhost", gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + memset(&state.op, 0, sizeof(state.op)); state.op.op = GRPC_OP_SEND_INITIAL_METADATA; state.op.data.send_initial_metadata.count = 0; state.op.flags = 0; diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 77afe588d7..8e9fa70b0e 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -284,6 +284,6 @@ static expectation *add(cq_verifier *v, grpc_completion_type type, void *tag) { return e; } -void cq_expect_completion(cq_verifier *v, void *tag, int success) { +void cq_expect_completion(cq_verifier *v, void *tag, bool success) { add(v, GRPC_OP_COMPLETE, tag)->success = success; } diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index b3e07c45a5..8c9a85c218 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -34,6 +34,8 @@ #ifndef GRPC_TEST_CORE_END2END_CQ_VERIFIER_H #define GRPC_TEST_CORE_END2END_CQ_VERIFIER_H +#include <stdbool.h> + #include <grpc/grpc.h> #include "test/core/util/test_config.h" @@ -57,7 +59,7 @@ void cq_verify_empty(cq_verifier *v); Any functions taking ... expect a NULL terminated list of key/value pairs (each pair using two parameter slots) of metadata that MUST be present in the event. */ -void cq_expect_completion(cq_verifier *v, void *tag, int success); +void cq_expect_completion(cq_verifier *v, void *tag, bool success); int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); int contains_metadata(grpc_metadata_array *array, const char *key, diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 9030ef50ad..65a8deb663 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -167,6 +167,7 @@ void test_connect(const char *server_host, const char *client_host, int port, "/foo", "foo.test.google.fr", deadline, NULL); GPR_ASSERT(c); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -201,6 +202,7 @@ void test_connect(const char *server_host, const char *client_host, int port, cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/fixtures/h2_fd.c b/test/core/end2end/fixtures/h2_fd.c new file mode 100644 index 0000000000..e938fe7730 --- /dev/null +++ b/test/core/end2end/fixtures/h2_fd.c @@ -0,0 +1,128 @@ +/* + * + * 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 "test/core/end2end/end2end_tests.h" + +#include <fcntl.h> +#include <string.h> + +#include <grpc/grpc.h> +#include <grpc/grpc_posix.h> +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/socket_utils_posix.h" +#include "src/core/lib/iomgr/unix_sockets_posix.h" +#include "test/core/util/test_config.h" + +typedef struct { int fd_pair[2]; } sp_fixture_data; + +static void create_sockets(int sv[2]) { + int flags; + grpc_create_socketpair_if_unix(sv); + flags = fcntl(sv[0], F_GETFL, 0); + GPR_ASSERT(fcntl(sv[0], F_SETFL, flags | O_NONBLOCK) == 0); + flags = fcntl(sv[1], F_GETFL, 0); + GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0); + GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv[0])); + GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv[1])); +} + +static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( + grpc_channel_args *client_args, grpc_channel_args *server_args) { + sp_fixture_data *fixture_data = gpr_malloc(sizeof(*fixture_data)); + + grpc_end2end_test_fixture f; + memset(&f, 0, sizeof(f)); + f.fixture_data = fixture_data; + f.cq = grpc_completion_queue_create(NULL); + + create_sockets(fixture_data->fd_pair); + + return f; +} + +static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + sp_fixture_data *sfd = f->fixture_data; + + GPR_ASSERT(!f->client); + f->client = grpc_insecure_channel_create_from_fd( + "fixture_client", sfd->fd_pair[0], client_args); + GPR_ASSERT(f->client); + + grpc_exec_ctx_finish(&exec_ctx); +} + +static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + sp_fixture_data *sfd = f->fixture_data; + GPR_ASSERT(!f->server); + f->server = grpc_server_create(server_args, NULL); + GPR_ASSERT(f->server); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + grpc_server_start(f->server); + + grpc_server_add_insecure_channel_from_fd(f->server, f->cq, sfd->fd_pair[1]); + + grpc_exec_ctx_finish(&exec_ctx); +} + +static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { + gpr_free(f->fixture_data); +} + +/* All test configurations */ +static grpc_end2end_test_config configs[] = { + {"chttp2/fd", 0, chttp2_create_fixture_socketpair, + chttp2_init_client_socketpair, chttp2_init_server_socketpair, + chttp2_tear_down_socketpair}, +}; + +int main(int argc, char **argv) { + size_t i; + + grpc_test_init(argc, argv); + grpc_end2end_tests_pre_init(); + grpc_init(); + + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(argc, argv, configs[i]); + } + + grpc_shutdown(); + + return 0; +} diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/fixtures/h2_ssl_cert.c index 0fa525175b..b476bf5516 100644 --- a/test/core/end2end/fixtures/h2_ssl_cert.c +++ b/test/core/end2end/fixtures/h2_ssl_cert.c @@ -321,6 +321,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, NULL); GPR_ASSERT(c); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c index 7f10649fa6..beed80df81 100644 --- a/test/core/end2end/fixtures/proxy.c +++ b/test/core/end2end/fixtures/proxy.c @@ -170,6 +170,7 @@ static void on_p2s_recv_initial_metadata(void *arg, int success) { grpc_op op; grpc_call_error err; + memset(&op, 0, sizeof(op)); if (!pc->proxy->shutdown) { op.op = GRPC_OP_SEND_INITIAL_METADATA; op.flags = 0; @@ -329,6 +330,7 @@ static void on_new_call(void *arg, int success) { if (success) { grpc_op op; + memset(&op, 0, sizeof(op)); proxy_call *pc = gpr_malloc(sizeof(*pc)); memset(pc, 0, sizeof(*pc)); pc->proxy = proxy; diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 0c5960a8ac..617d8058d2 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -744,6 +744,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { break; } grpc_op *ops = gpr_malloc(sizeof(grpc_op) * num_ops); + memset(ops, 0, sizeof(grpc_op) * num_ops); bool ok = true; size_t i; grpc_op *op; diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c index f6bb10720e..6cb0dcc059 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.c +++ b/test/core/end2end/fuzzers/client_fuzzer.c @@ -31,6 +31,8 @@ * */ +#include <string.h> + #include <grpc/grpc.h> #include <grpc/support/alloc.h> @@ -78,6 +80,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { size_t details_capacity = 0; grpc_op ops[6]; + memset(ops, 0, sizeof(ops)); grpc_op *op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index cf1ba7c68e..3d3bec1a69 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -45,6 +45,8 @@ default_unsecure_fixture_options = FixtureOptions( socketpair_unsecure_fixture_options = default_unsecure_fixture_options._replace(fullstack=False, dns_resolver=False) default_secure_fixture_options = default_unsecure_fixture_options._replace(secure=True) uds_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, platforms=['linux', 'mac', 'posix']) +fd_unsecure_fixture_options = default_unsecure_fixture_options._replace( + dns_resolver=False, fullstack=False, platforms=['linux', 'mac', 'posix']) # maps fixture name to whether it requires the security library @@ -52,6 +54,7 @@ END2END_FIXTURES = { 'h2_compress': default_unsecure_fixture_options, 'h2_census': default_unsecure_fixture_options, 'h2_fakesec': default_secure_fixture_options._replace(ci_mac=False), + 'h2_fd': fd_unsecure_fixture_options, 'h2_full': default_unsecure_fixture_options, 'h2_full+pipe': default_unsecure_fixture_options._replace( platforms=['linux']), @@ -73,7 +76,8 @@ END2END_FIXTURES = { } TestOptions = collections.namedtuple( - 'TestOptions', 'needs_fullstack needs_dns proxyable secure traceable cpu_cost') + 'TestOptions', + 'needs_fullstack needs_dns proxyable secure traceable cpu_cost') default_test_options = TestOptions(False, False, True, False, True, 1.0) connectivity_test_options = default_test_options._replace(needs_fullstack=True) @@ -90,8 +94,10 @@ END2END_TESTS = { 'cancel_before_invoke': default_test_options._replace(cpu_cost=LOWCPU), 'cancel_in_a_vacuum': default_test_options._replace(cpu_cost=LOWCPU), 'cancel_with_status': default_test_options._replace(cpu_cost=LOWCPU), - 'compressed_payload': default_test_options._replace(proxyable=False, cpu_cost=LOWCPU), - 'connectivity': connectivity_test_options._replace(proxyable=False, cpu_cost=LOWCPU), + 'compressed_payload': default_test_options._replace(proxyable=False, + cpu_cost=LOWCPU), + 'connectivity': connectivity_test_options._replace(proxyable=False, + cpu_cost=LOWCPU), 'default_host': default_test_options._replace(needs_fullstack=True, needs_dns=True), 'disappearing_server': connectivity_test_options, @@ -117,7 +123,8 @@ END2END_TESTS = { 'server_finishes_request': default_test_options, 'shutdown_finishes_calls': default_test_options, 'shutdown_finishes_tags': default_test_options, - 'simple_delayed_request': connectivity_test_options._replace(cpu_cost=LOWCPU), + 'simple_delayed_request': connectivity_test_options._replace( + cpu_cost=LOWCPU), 'simple_metadata': default_test_options, 'simple_request': default_test_options, 'trailing_metadata': default_test_options, diff --git a/test/core/end2end/goaway_server_test.c b/test/core/end2end/goaway_server_test.c index ada52f7670..67cc24c74c 100644 --- a/test/core/end2end/goaway_server_test.c +++ b/test/core/end2end/goaway_server_test.c @@ -133,6 +133,7 @@ int main(int argc, char **argv) { chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", "127.0.0.1", GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20), NULL); /* send initial metadata to probe connectivity */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -143,6 +144,7 @@ int main(int argc, char **argv) { (size_t)(op - ops), tag(0x101), NULL)); /* and receive status to probe termination */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv1; @@ -184,6 +186,7 @@ int main(int argc, char **argv) { tag(0x9999)); /* listen for close on the server call to probe for finishing */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled1; @@ -206,6 +209,7 @@ int main(int argc, char **argv) { chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", "127.0.0.1", GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20), NULL); /* send initial metadata to probe connectivity */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -216,6 +220,7 @@ int main(int argc, char **argv) { (size_t)(op - ops), tag(0x201), NULL)); /* and receive status to probe termination */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv2; @@ -250,6 +255,7 @@ int main(int argc, char **argv) { cq_verify(cqv); /* listen for close on the server call to probe for finishing */ + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled2; diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index cf42e92a1a..3545660701 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -30,11 +30,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + +#include <limits.h> +#include <string.h> + #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/host_port.h> #include <grpc/support/log.h> -#include <limits.h> + #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -74,6 +78,7 @@ static void prepare_test(int is_client) { g_state.cqv = cq_verifier_create(g_state.cq); g_state.details = NULL; g_state.details_capacity = 0; + memset(g_state.ops, 0, sizeof(g_state.ops)); if (is_client) { /* create a call, channel to a non existant server */ diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index 7a5cd2335f..08af382197 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -31,9 +31,12 @@ * */ +#include <string.h> + #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> + #include "test/core/end2end/cq_verifier.h" #include "test/core/util/test_config.h" @@ -65,6 +68,7 @@ int main(int argc, char **argv) { call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/Foo", "nonexistant", deadline, NULL); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index 3cb9b3d4b1..c9663c2155 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -123,6 +123,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 994c3bf1dd..3dd2612077 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -157,6 +157,7 @@ static void test_request_response_with_metadata_and_payload( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -201,6 +202,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -219,6 +221,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 5c6791f6f7..694a0aa9ef 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -193,6 +193,7 @@ static void request_response_with_payload_and_call_creds( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -248,6 +249,7 @@ static void request_response_with_payload_and_call_creds( /* Cannot set creds on the server call object. */ GPR_ASSERT(grpc_call_set_credentials(s, NULL) != GRPC_CALL_OK); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -265,6 +267,7 @@ static void request_response_with_payload_and_call_creds( cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; @@ -410,6 +413,7 @@ static void test_request_with_server_rejecting_client_creds( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index fc2a64a6c1..51c13da3b1 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -136,6 +136,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; @@ -174,6 +175,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, cq_expect_completion(cqv, tag(2), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message = &request_payload_recv; diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 3bafa8c85f..2b5a409dee 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -136,6 +136,7 @@ static void test_cancel_after_accept_and_writes_closed( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; @@ -178,6 +179,7 @@ static void test_cancel_after_accept_and_writes_closed( cq_expect_completion(cqv, tag(2), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message = &request_payload_recv; diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index fc2751af8e..85fbe9de7b 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -131,6 +131,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 33005db9e4..d99062c608 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -131,6 +131,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index c3ee4a6a0e..83629a9a02 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -122,6 +122,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 589bc314f8..ec5c012238 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -38,13 +38,15 @@ #include <grpc/byte_buffer.h> #include <grpc/byte_buffer_reader.h> +#include <grpc/compression.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include <grpc/support/time.h> #include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/compress_filter.h" +#include "src/core/lib/surface/call.h" #include "src/core/lib/surface/call_test_only.h" #include "test/core/end2end/cq_verifier.h" @@ -102,12 +104,12 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void request_with_payload_template( +static void request_for_disabled_algorithm( grpc_end2end_test_config config, const char *test_name, uint32_t send_flags_bitmask, - grpc_compression_algorithm requested_compression_algorithm, - grpc_compression_algorithm expected_compression_algorithm, - grpc_metadata *client_metadata) { + grpc_compression_algorithm algorithm_to_disable, + grpc_compression_algorithm requested_client_compression_algorithm, + grpc_status_code expected_error, grpc_metadata *client_metadata) { grpc_call *c; grpc_call *s; gpr_slice request_payload_slice; @@ -137,9 +139,11 @@ static void request_with_payload_template( request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); client_args = grpc_channel_args_set_compression_algorithm( - NULL, requested_compression_algorithm); - server_args = grpc_channel_args_set_compression_algorithm( - NULL, requested_compression_algorithm); + NULL, requested_client_compression_algorithm); + server_args = + grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_NONE); + server_args = grpc_channel_args_compression_algorithm_set_state( + &server_args, algorithm_to_disable, false); f = begin_test(config, test_name, client_args, server_args); cqv = cq_verifier_create(f.cq); @@ -153,6 +157,7 @@ static void request_with_payload_template( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; if (client_metadata != NULL) { @@ -193,11 +198,174 @@ static void request_with_payload_template( 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_expect_completion(cqv, tag(101), true); + cq_verify(cqv); + + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message = &request_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + cq_expect_completion(cqv, tag(102), false); + + op = ops; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + cq_expect_completion(cqv, tag(103), true); + cq_expect_completion(cqv, tag(1), true); cq_verify(cqv); - GPR_ASSERT( - GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer(s)) == 3); + /* call was cancelled (closed) ... */ + GPR_ASSERT(was_cancelled != 0); + /* with a certain error */ + GPR_ASSERT(status == expected_error); + + char *algo_name = NULL; + GPR_ASSERT(grpc_compression_algorithm_name(algorithm_to_disable, &algo_name)); + char *expected_details = NULL; + gpr_asprintf(&expected_details, "Compression algorithm '%s' is disabled.", + algo_name); + /* and we expect a specific reason for it */ + GPR_ASSERT(0 == strcmp(details, expected_details)); + gpr_free(expected_details); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + + grpc_call_destroy(c); + grpc_call_destroy(s); + + cq_verifier_destroy(cqv); + + gpr_slice_unref(request_payload_slice); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(request_payload_recv); + + grpc_channel_args_destroy(client_args); + grpc_channel_args_destroy(server_args); + + end_test(&f); + config.tear_down_data(&f); +} + +static void request_with_payload_template( + grpc_end2end_test_config config, const char *test_name, + uint32_t client_send_flags_bitmask, + grpc_compression_algorithm default_client_channel_compression_algorithm, + grpc_compression_algorithm default_server_channel_compression_algorithm, + grpc_compression_algorithm expected_algorithm_from_client, + grpc_compression_algorithm expected_algorithm_from_server, + grpc_metadata *client_init_metadata, bool set_server_level, + grpc_compression_level server_compression_level) { + grpc_call *c; + grpc_call *s; + gpr_slice request_payload_slice; + grpc_byte_buffer *request_payload; + gpr_timespec deadline = five_seconds_time(); + grpc_channel_args *client_args; + grpc_channel_args *server_args; + grpc_end2end_test_fixture f; + grpc_op ops[6]; + grpc_op *op; + grpc_metadata_array initial_metadata_recv; + grpc_metadata_array trailing_metadata_recv; + grpc_metadata_array request_metadata_recv; + grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer *response_payload; + grpc_byte_buffer *response_payload_recv; + grpc_call_details call_details; + grpc_status_code status; + grpc_call_error error; + char *details = NULL; + size_t details_capacity = 0; + int was_cancelled = 2; + cq_verifier *cqv; + char request_str[1024]; + char response_str[1024]; + + memset(request_str, 'x', 1023); + request_str[1023] = '\0'; + + memset(response_str, 'y', 1023); + response_str[1023] = '\0'; + + request_payload_slice = gpr_slice_from_copied_string(request_str); + gpr_slice response_payload_slice = gpr_slice_from_copied_string(response_str); + + client_args = grpc_channel_args_set_compression_algorithm( + NULL, default_client_channel_compression_algorithm); + server_args = grpc_channel_args_set_compression_algorithm( + NULL, default_server_channel_compression_algorithm); + + f = begin_test(config, test_name, client_args, server_args); + cqv = cq_verifier_create(f.cq); + + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); + + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + if (client_init_metadata != NULL) { + op->data.send_initial_metadata.count = 1; + op->data.send_initial_metadata.metadata = client_init_metadata; + } else { + op->data.send_initial_metadata.count = 0; + } + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata = &initial_metadata_recv; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; + op->data.recv_status_on_client.status = &status; + op->data.recv_status_on_client.status_details = &details; + op->data.recv_status_on_client.status_details_capacity = &details_capacity; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(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)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(100), true); + cq_verify(cqv); + + GPR_ASSERT(GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer( + s)) == GRPC_COMPRESS_ALGORITHMS_COUNT); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), GRPC_COMPRESS_NONE) != 0); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), @@ -205,29 +373,107 @@ static void request_with_payload_template( GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), GRPC_COMPRESS_GZIP) != 0); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; + if (set_server_level) { + op->data.send_initial_metadata.maybe_compression_level.is_set = true; + op->data.send_initial_metadata.maybe_compression_level.level = + server_compression_level; + } op->flags = 0; op->reserved = NULL; op++; - op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion(cqv, tag(102), 1); - cq_verify(cqv); + for (int i = 0; i < 2; i++) { + request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); + response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message = request_payload; + op->flags = client_send_flags_bitmask; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message = &response_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message = &request_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); + + GPR_ASSERT(request_payload_recv->type == GRPC_BB_RAW); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, request_str)); + GPR_ASSERT(request_payload_recv->data.raw.compression == + expected_algorithm_from_client); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message = response_payload; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(2), 1); + cq_verify(cqv); + + GPR_ASSERT(response_payload_recv->type == GRPC_BB_RAW); + GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, response_str)); + if (server_compression_level > GRPC_COMPRESS_LEVEL_NONE) { + const grpc_compression_algorithm algo_for_server_level = + grpc_call_compression_for_level(s, server_compression_level); + GPR_ASSERT(response_payload_recv->data.raw.compression == + algo_for_server_level); + } else { + GPR_ASSERT(response_payload_recv->data.raw.compression == + expected_algorithm_from_server); + } + + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); + } + + gpr_slice_unref(request_payload_slice); + gpr_slice_unref(response_payload_slice); + memset(ops, 0, sizeof(ops)); op = ops; - op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; - op->data.recv_close_on_server.cancelled = &was_cancelled; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op->flags = 0; op->reserved = NULL; op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + memset(ops, 0, sizeof(ops)); + op = ops; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; op->data.send_status_from_server.trailing_metadata_count = 0; op->data.send_status_from_server.status = GRPC_STATUS_OK; @@ -235,11 +481,13 @@ static void request_with_payload_template( op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion(cqv, tag(103), 1); cq_expect_completion(cqv, tag(1), 1); + cq_expect_completion(cqv, tag(3), 1); + cq_expect_completion(cqv, tag(101), 1); + cq_expect_completion(cqv, tag(104), 1); cq_verify(cqv); GPR_ASSERT(status == GRPC_STATUS_OK); @@ -248,12 +496,6 @@ static void request_with_payload_template( GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); GPR_ASSERT(was_cancelled == 0); - GPR_ASSERT(request_payload_recv->type == GRPC_BB_RAW); - GPR_ASSERT(request_payload_recv->data.raw.compression == - expected_compression_algorithm); - - GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, str)); - gpr_free(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); @@ -265,10 +507,6 @@ static void request_with_payload_template( cq_verifier_destroy(cqv); - gpr_slice_unref(request_payload_slice); - grpc_byte_buffer_destroy(request_payload); - grpc_byte_buffer_destroy(request_payload_recv); - grpc_channel_args_destroy(client_args); grpc_channel_args_destroy(server_args); @@ -280,61 +518,90 @@ 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_GZIP, + GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, NULL, false, + /* ignored */ GRPC_COMPRESS_LEVEL_NONE); } static void test_invoke_request_with_uncompressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_uncompressed_payload", 0, - GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, NULL); + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_NONE, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE); } static void test_invoke_request_with_compressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_compressed_payload", 0, - GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, NULL); + GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE); +} + +static void test_invoke_request_with_server_level( + grpc_end2end_test_config config) { + request_with_payload_template( + config, "test_invoke_request_with_server_level", 0, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE /* ignored */, + NULL, true, GRPC_COMPRESS_LEVEL_HIGH); } static void test_invoke_request_with_compressed_payload_md_override( grpc_end2end_test_config config) { grpc_metadata gzip_compression_override; - grpc_metadata none_compression_override; + grpc_metadata identity_compression_override; - gzip_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY; + gzip_compression_override.key = GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY; gzip_compression_override.value = "gzip"; - gzip_compression_override.value_length = 4; + gzip_compression_override.value_length = + strlen(gzip_compression_override.value); memset(&gzip_compression_override.internal_data, 0, sizeof(gzip_compression_override.internal_data)); - none_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY; - none_compression_override.value = "identity"; - none_compression_override.value_length = 4; - memset(&none_compression_override.internal_data, 0, - sizeof(none_compression_override.internal_data)); + identity_compression_override.key = GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY; + identity_compression_override.value = "identity"; + identity_compression_override.value_length = + strlen(identity_compression_override.value); + memset(&identity_compression_override.internal_data, 0, + sizeof(identity_compression_override.internal_data)); /* Channel default NONE (aka IDENTITY), call override to GZIP */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_1", 0, - GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, &gzip_compression_override); + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_NONE, &gzip_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE); /* Channel default DEFLATE, call override to GZIP */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_2", 0, - GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_GZIP, &gzip_compression_override); + GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_NONE, &gzip_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE); /* Channel default DEFLATE, call override to NONE (aka IDENTITY) */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_3", 0, - GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, &none_compression_override); + GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_NONE, &identity_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE); +} + +static void test_invoke_request_with_disabled_algorithm( + grpc_end2end_test_config config) { + request_for_disabled_algorithm( + config, "test_invoke_request_with_disabled_algorithm", 0, + GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_STATUS_UNIMPLEMENTED, NULL); } void compressed_payload(grpc_end2end_test_config config) { test_invoke_request_with_exceptionally_uncompressed_payload(config); test_invoke_request_with_uncompressed_payload(config); test_invoke_request_with_compressed_payload(config); + test_invoke_request_with_server_level(config); test_invoke_request_with_compressed_payload_md_override(config); + test_invoke_request_with_disabled_algorithm(config); } void compressed_payload_pre_init(void) {} diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index 44384a783e..728ee597b5 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -131,6 +131,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -173,6 +174,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { gpr_log(GPR_DEBUG, "client_peer=%s", peer); gpr_free(peer); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 03d1ded04c..536fbd0d8a 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -108,6 +108,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -145,6 +146,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, - and still complete the request */ grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index 02c4287648..526c05ca3e 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -134,6 +134,7 @@ static void test_request(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 26198f3bdf..f527b8617d 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -122,6 +122,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -160,6 +161,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead)); cq_verify_empty(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 374606dcb7..50e3c9cb89 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -128,6 +128,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -161,6 +162,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index 07d5d387b4..ee889b77a1 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -323,6 +323,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = GPR_ARRAY_SIZE(extra_metadata); @@ -357,6 +358,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index e53f3b2aaa..dfedcfebee 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -132,6 +132,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -174,6 +175,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { gpr_log(GPR_DEBUG, "client_peer=%s", peer); gpr_free(peer); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 6410305451..9c9ca95129 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -138,6 +138,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -181,6 +182,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -198,6 +200,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index ae1f68a2b4..1f27896019 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -142,6 +142,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); // Client: send request. op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -183,6 +184,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); // Server: send initial metadata and receive request. op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -201,6 +203,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); // Server: receive close and send status. This should trigger // completion of request on client. op = ops; diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 1bb53073cb..41de74ff87 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -124,6 +124,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -157,6 +158,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -270,6 +272,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { f.server, &s1, &call_details, &request_metadata_recv, f.cq, f.cq, tag(101))); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -283,6 +286,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv1; @@ -300,6 +304,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -313,6 +318,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv2; @@ -354,6 +360,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { } GPR_ASSERT(live_call == 300 || live_call == 400); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -388,6 +395,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(201), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 4f572789d9..08d326ab4d 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -143,6 +143,7 @@ static void test_max_message_length(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -181,6 +182,7 @@ static void test_max_message_length(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index 03e57a90f6..fd56c8b4ff 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -122,6 +122,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index bdfb135406..443d85eecc 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -131,6 +131,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -174,6 +175,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -191,6 +193,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 15e1c6e338..1d2f7943c1 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -135,6 +135,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -164,6 +165,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, cq_expect_completion(cqv, tag(100), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -182,6 +184,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message = request_payload; @@ -196,6 +199,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message = &request_payload_recv; @@ -207,6 +211,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message = response_payload; @@ -228,6 +233,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, gpr_slice_unref(request_payload_slice); gpr_slice_unref(response_payload_slice); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op->flags = 0; @@ -236,6 +242,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; op->data.send_status_from_server.trailing_metadata_count = 0; diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index 3c4edbae7d..ece6250ea1 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -125,6 +125,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -158,6 +159,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index f5a8d4d60c..b5d398bba9 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -131,6 +131,7 @@ static void test_invoke_request_with_flags( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 7706404090..d94267e09c 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -130,6 +130,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -167,6 +168,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -184,6 +186,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index a4f5319e5b..a723c6fd2c 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -126,6 +126,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -155,6 +156,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index 80287cd507..abb6b26a87 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -115,6 +115,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -149,6 +150,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index 400b3a0027..e1fcc035bb 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -117,6 +117,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -152,6 +153,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index 707b3c9512..c9b1a03da5 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -141,6 +141,7 @@ static void test_request_response_with_metadata_and_payload( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -185,6 +186,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -203,6 +205,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index 42108425e6..a8014e6894 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -132,6 +132,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -174,6 +175,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { gpr_log(GPR_DEBUG, "client_peer=%s", peer); gpr_free(peer); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 4dd8c12cba..41e0f00911 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -144,6 +144,7 @@ static void test_request_response_with_metadata_and_payload( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -188,6 +189,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 2; @@ -206,6 +208,7 @@ static void test_request_response_with_metadata_and_payload( cq_expect_completion(cqv, tag(102), 1); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; diff --git a/test/core/fling/client.c b/test/core/fling/client.c index 81562277ec..123f2b5bbe 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.c @@ -65,6 +65,7 @@ static void init_ping_pong_request(void) { grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c index ab5c279ac6..c506645b9d 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.c @@ -52,6 +52,7 @@ #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr.h" +#include "src/core/lib/iomgr/socket_utils_posix.h" #include "test/core/util/test_config.h" static gpr_mu *g_mu; @@ -68,17 +69,15 @@ static void create_test_socket(int port, int *socket_fd, struct sockaddr_in *sin) { int fd; int one = 1; - int buf_size = BUF_SIZE; + int buffer_size_bytes = BUF_SIZE; int flags; fd = socket(AF_INET, SOCK_STREAM, 0); setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); /* Reset the size of socket send buffer to the minimal value to facilitate buffer filling up and triggering notify_on_write */ - GPR_ASSERT( - setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size)) != -1); - GPR_ASSERT( - setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(buf_size)) != -1); + GPR_ASSERT(grpc_set_socket_sndbuf(fd, buffer_size_bytes)); + GPR_ASSERT(grpc_set_socket_rcvbuf(fd, buffer_size_bytes)); /* Make fd non-blocking */ flags = fcntl(fd, F_GETFL, 0); GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0); diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 6815747233..f36f980575 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -116,6 +116,7 @@ int main(int argc, char **argv) { GPR_ASSERT(call); cqv = cq_verifier_create(cq); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -134,6 +135,7 @@ int main(int argc, char **argv) { cq_expect_completion(cqv, tag(1), 0); cq_verify(cqv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; |