aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end/tests
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/end2end/tests')
-rw-r--r--test/core/end2end/tests/bad_hostname.c154
-rw-r--r--test/core/end2end/tests/binary_metadata.c259
-rw-r--r--test/core/end2end/tests/call_creds.c477
-rw-r--r--test/core/end2end/tests/cancel_after_accept.c189
-rw-r--r--test/core/end2end/tests/cancel_after_client_done.c189
-rw-r--r--test/core/end2end/tests/cancel_after_invoke.c165
-rw-r--r--test/core/end2end/tests/cancel_before_invoke.c161
-rw-r--r--test/core/end2end/tests/cancel_in_a_vacuum.c124
-rw-r--r--test/core/end2end/tests/cancel_test_helpers.h17
-rw-r--r--test/core/end2end/tests/census_simple_request.c173
-rw-r--r--test/core/end2end/tests/channel_connectivity.c120
-rw-r--r--test/core/end2end/tests/compressed_payload.c297
-rw-r--r--test/core/end2end/tests/default_host.c203
-rw-r--r--test/core/end2end/tests/disappearing_server.c180
-rw-r--r--test/core/end2end/tests/empty_batch.c129
-rw-r--r--test/core/end2end/tests/graceful_server_shutdown.c169
-rw-r--r--test/core/end2end/tests/high_initial_seqno.c191
-rw-r--r--test/core/end2end/tests/invoke_large_request.c202
-rw-r--r--test/core/end2end/tests/large_metadata.c199
-rw-r--r--test/core/end2end/tests/max_concurrent_streams.c335
-rw-r--r--test/core/end2end/tests/max_message_length.c173
-rw-r--r--test/core/end2end/tests/metadata.c219
-rw-r--r--test/core/end2end/tests/no_op.c102
-rw-r--r--test/core/end2end/tests/payload.c228
-rw-r--r--test/core/end2end/tests/ping_pong_streaming.c284
-rw-r--r--test/core/end2end/tests/registered_call.c208
-rw-r--r--test/core/end2end/tests/request_with_flags.c193
-rw-r--r--test/core/end2end/tests/request_with_payload.c187
-rw-r--r--test/core/end2end/tests/server_finishes_request.c176
-rw-r--r--test/core/end2end/tests/shutdown_finishes_calls.c160
-rw-r--r--test/core/end2end/tests/shutdown_finishes_tags.c117
-rw-r--r--test/core/end2end/tests/simple_delayed_request.c188
-rw-r--r--test/core/end2end/tests/simple_request.c231
-rw-r--r--test/core/end2end/tests/trailing_metadata.c226
34 files changed, 3626 insertions, 2999 deletions
diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c
index 93e2df1e43..901b4b2210 100644
--- a/test/core/end2end/tests/bad_hostname.c
+++ b/test/core/end2end/tests/bad_hostname.c
@@ -45,64 +45,86 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void simple_request_body(grpc_end2end_test_fixture f) {
+static void
+simple_request_body (grpc_end2end_test_fixture f)
+{
grpc_call *c;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -114,14 +136,13 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
char *details = NULL;
size_t details_capacity = 0;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "slartibartfast.local", deadline, NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "slartibartfast.local", 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -146,36 +167,41 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_INVALID_ARGUMENT);
+ GPR_ASSERT (status == GRPC_STATUS_INVALID_ARGUMENT);
- 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);
+ 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 (c);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-static void test_invoke_simple_request(grpc_end2end_test_config config) {
+static void
+test_invoke_simple_request (grpc_end2end_test_config config)
+{
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
- simple_request_body(f);
- end_test(&f);
- config.tear_down_data(&f);
+ f = begin_test (config, "test_invoke_simple_request", NULL, NULL);
+ simple_request_body (f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- if (config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) {
- test_invoke_simple_request(config);
- }
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ if (config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION)
+ {
+ test_invoke_simple_request (config);
+ }
}
diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c
index 21e0bbcc49..2b32077847 100644
--- a/test/core/end2end/tests/binary_metadata.c
+++ b/test/core/end2end/tests/binary_metadata.c
@@ -43,97 +43,117 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Request/response with metadata and payload.*/
-static void test_request_response_with_metadata_and_payload(
- grpc_end2end_test_config config) {
+static void
+test_request_response_with_metadata_and_payload (grpc_end2end_test_config config)
+{
grpc_call *c;
grpc_call *s;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
- grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ 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-bin",
- "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc",
- 13,
- 0,
- {{NULL, NULL, NULL, NULL}}},
- {"key2-bin",
- "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d",
- 14,
- 0,
- {{NULL, NULL, NULL, NULL}}}};
+ {"key1-bin",
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc",
+ 13,
+ 0,
+ {{NULL, NULL, NULL, NULL}}},
+ {"key2-bin",
+ "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d",
+ 14,
+ 0,
+ {{NULL, NULL, NULL, NULL}}}
+ };
grpc_metadata meta_s[2] = {
- {"key3-bin",
- "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee",
- 15,
- 0,
- {{NULL, NULL, NULL, NULL}}},
- {"key4-bin",
- "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
- 16,
- 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);
+ {"key3-bin",
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee",
+ 15,
+ 0,
+ {{NULL, NULL, NULL, NULL}}},
+ {"key4-bin",
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+ 16,
+ 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);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -148,14 +168,13 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -191,15 +210,13 @@ static void test_request_response_with_metadata_and_payload(
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -213,11 +230,11 @@ static void test_request_response_with_metadata_and_payload(
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);
+ 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);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -237,53 +254,47 @@ static void test_request_response_with_metadata_and_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);
+ 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(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (103), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 0);
- GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
- GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you"));
- GPR_ASSERT(contains_metadata(
- &request_metadata_recv, "key1-bin",
- "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc"));
- GPR_ASSERT(contains_metadata(
- &request_metadata_recv, "key2-bin",
- "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d"));
- GPR_ASSERT(contains_metadata(
- &initial_metadata_recv, "key3-bin",
- "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee"));
- GPR_ASSERT(contains_metadata(
- &initial_metadata_recv, "key4-bin",
- "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"));
+ GPR_ASSERT (status == GRPC_STATUS_OK);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 0);
+ GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world"));
+ GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you"));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, "key1-bin", "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc"));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, "key2-bin", "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d"));
+ GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key3-bin", "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee"));
+ GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key4-bin", "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"));
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- 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);
+ 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);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_request_response_with_metadata_and_payload(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_request_response_with_metadata_and_payload (config);
}
diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c
index 4e905aafc7..a8ec505ffb 100644
--- a/test/core/end2end/tests/call_creds.c
+++ b/test/core/end2end/tests/call_creds.c
@@ -51,120 +51,147 @@ static const char iam_selector[] = "selector";
static const char overridden_iam_token[] = "overridden_token";
static const char overridden_iam_selector[] = "overridden_selector";
-typedef enum { NONE, OVERRIDE, DESTROY } override_mode;
+typedef enum
+{ NONE, OVERRIDE, DESTROY } override_mode;
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- int fail_server_auth_check) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, int fail_server_auth_check)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(NULL, NULL);
- config.init_client(&f, NULL);
- if (fail_server_auth_check) {
- grpc_arg fail_auth_arg = {
- GRPC_ARG_STRING, FAIL_AUTH_CHECK_SERVER_ARG_NAME, {NULL}};
- grpc_channel_args args;
- args.num_args = 1;
- args.args = &fail_auth_arg;
- config.init_server(&f, &args);
- } else {
- config.init_server(&f, NULL);
- }
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (NULL, NULL);
+ config.init_client (&f, NULL);
+ if (fail_server_auth_check)
+ {
+ grpc_arg fail_auth_arg = {
+ GRPC_ARG_STRING, FAIL_AUTH_CHECK_SERVER_ARG_NAME, {NULL}
+ };
+ grpc_channel_args args;
+ args.num_args = 1;
+ args.args = &fail_auth_arg;
+ config.init_server (&f, &args);
+ }
+ else
+ {
+ config.init_server (&f, NULL);
+ }
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void print_auth_context(int is_client, const grpc_auth_context *ctx) {
+static void
+print_auth_context (int is_client, const grpc_auth_context * ctx)
+{
const grpc_auth_property *p;
grpc_auth_property_iterator it;
- gpr_log(GPR_INFO, "%s peer:", is_client ? "client" : "server");
- gpr_log(GPR_INFO, "\tauthenticated: %s",
- grpc_auth_context_peer_is_authenticated(ctx) ? "YES" : "NO");
- it = grpc_auth_context_peer_identity(ctx);
- while ((p = grpc_auth_property_iterator_next(&it)) != NULL) {
- gpr_log(GPR_INFO, "\t\t%s: %s", p->name, p->value);
- }
- gpr_log(GPR_INFO, "\tall properties:");
- it = grpc_auth_context_property_iterator(ctx);
- while ((p = grpc_auth_property_iterator_next(&it)) != NULL) {
- gpr_log(GPR_INFO, "\t\t%s: %s", p->name, p->value);
- }
+ gpr_log (GPR_INFO, "%s peer:", is_client ? "client" : "server");
+ gpr_log (GPR_INFO, "\tauthenticated: %s", grpc_auth_context_peer_is_authenticated (ctx) ? "YES" : "NO");
+ it = grpc_auth_context_peer_identity (ctx);
+ while ((p = grpc_auth_property_iterator_next (&it)) != NULL)
+ {
+ gpr_log (GPR_INFO, "\t\t%s: %s", p->name, p->value);
+ }
+ gpr_log (GPR_INFO, "\tall properties:");
+ it = grpc_auth_context_property_iterator (ctx);
+ while ((p = grpc_auth_property_iterator_next (&it)) != NULL)
+ {
+ gpr_log (GPR_INFO, "\t\t%s: %s", p->name, p->value);
+ }
}
-static void test_call_creds_failure(grpc_end2end_test_config config) {
+static void
+test_call_creds_failure (grpc_end2end_test_config config)
+{
grpc_call *c;
grpc_credentials *creds = NULL;
- grpc_end2end_test_fixture f =
- begin_test(config, "test_call_creds_failure", 0);
- gpr_timespec deadline = five_seconds_time();
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ grpc_end2end_test_fixture f = begin_test (config, "test_call_creds_failure", 0);
+ gpr_timespec deadline = five_seconds_time ();
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL);
+ GPR_ASSERT (c);
/* Try with credentials unfit to be set on a call (channel creds). */
- creds = grpc_fake_transport_security_credentials_create();
- GPR_ASSERT(grpc_call_set_credentials(c, creds) != GRPC_CALL_OK);
- grpc_credentials_release(creds);
+ creds = grpc_fake_transport_security_credentials_create ();
+ GPR_ASSERT (grpc_call_set_credentials (c, creds) != GRPC_CALL_OK);
+ grpc_credentials_release (creds);
- grpc_call_destroy(c);
+ grpc_call_destroy (c);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-static void request_response_with_payload_and_call_creds(
- const char *test_name, grpc_end2end_test_config config,
- override_mode mode) {
+static void
+request_response_with_payload_and_call_creds (const char *test_name, grpc_end2end_test_config config, override_mode mode)
+{
grpc_call *c;
grpc_call *s;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
- grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1);
+ gpr_timespec deadline = five_seconds_time ();
grpc_end2end_test_fixture f;
cq_verifier *cqv;
grpc_op ops[6];
@@ -184,35 +211,34 @@ static void request_response_with_payload_and_call_creds(
grpc_auth_context *s_auth_context = NULL;
grpc_auth_context *c_auth_context = NULL;
- f = begin_test(config, test_name, 0);
- cqv = cq_verifier_create(f.cq);
+ f = begin_test (config, test_name, 0);
+ 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);
- creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL);
- GPR_ASSERT(creds != NULL);
- GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK);
- switch (mode) {
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL);
+ GPR_ASSERT (c);
+ creds = grpc_google_iam_credentials_create (iam_token, iam_selector, NULL);
+ GPR_ASSERT (creds != NULL);
+ GPR_ASSERT (grpc_call_set_credentials (c, creds) == GRPC_CALL_OK);
+ switch (mode)
+ {
case NONE:
break;
case OVERRIDE:
- grpc_credentials_release(creds);
- creds = grpc_google_iam_credentials_create(overridden_iam_token,
- overridden_iam_selector, NULL);
- GPR_ASSERT(creds != NULL);
- GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK);
+ grpc_credentials_release (creds);
+ creds = grpc_google_iam_credentials_create (overridden_iam_token, overridden_iam_selector, NULL);
+ GPR_ASSERT (creds != NULL);
+ GPR_ASSERT (grpc_call_set_credentials (c, creds) == GRPC_CALL_OK);
break;
case DESTROY:
- GPR_ASSERT(grpc_call_set_credentials(c, NULL) == GRPC_CALL_OK);
+ GPR_ASSERT (grpc_call_set_credentials (c, NULL) == GRPC_CALL_OK);
break;
- }
- grpc_credentials_release(creds);
+ }
+ grpc_credentials_release (creds);
- 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -247,27 +273,25 @@ static void request_response_with_payload_and_call_creds(
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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
- s_auth_context = grpc_call_auth_context(s);
- GPR_ASSERT(s_auth_context != NULL);
- print_auth_context(0, s_auth_context);
- grpc_auth_context_release(s_auth_context);
-
- c_auth_context = grpc_call_auth_context(c);
- GPR_ASSERT(c_auth_context != NULL);
- print_auth_context(1, c_auth_context);
- grpc_auth_context_release(c_auth_context);
+ 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 (101));
+ GPR_ASSERT (GRPC_CALL_OK == error);
+ cq_expect_completion (cqv, tag (101), 1);
+ cq_verify (cqv);
+ s_auth_context = grpc_call_auth_context (s);
+ GPR_ASSERT (s_auth_context != NULL);
+ print_auth_context (0, s_auth_context);
+ grpc_auth_context_release (s_auth_context);
+
+ c_auth_context = grpc_call_auth_context (c);
+ GPR_ASSERT (c_auth_context != NULL);
+ print_auth_context (1, c_auth_context);
+ grpc_auth_context_release (c_auth_context);
/* Cannot set creds on the server call object. */
- GPR_ASSERT(grpc_call_set_credentials(s, NULL) != GRPC_CALL_OK);
+ GPR_ASSERT (grpc_call_set_credentials (s, NULL) != GRPC_CALL_OK);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -280,11 +304,11 @@ static void request_response_with_payload_and_call_creds(
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);
+ 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);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -304,101 +328,85 @@ static void request_response_with_payload_and_call_creds(
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(1), 1);
- cq_verify(cqv);
-
- GPR_ASSERT(status == GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 0);
- GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
- GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you"));
-
- switch (mode) {
+ 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 (1), 1);
+ cq_verify (cqv);
+
+ GPR_ASSERT (status == GRPC_STATUS_OK);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 0);
+ GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world"));
+ GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you"));
+
+ switch (mode)
+ {
case NONE:
- GPR_ASSERT(contains_metadata(&request_metadata_recv,
- GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
- iam_token));
- GPR_ASSERT(contains_metadata(&request_metadata_recv,
- GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
- iam_selector));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, iam_token));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, iam_selector));
break;
case OVERRIDE:
- GPR_ASSERT(contains_metadata(&request_metadata_recv,
- GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
- overridden_iam_token));
- GPR_ASSERT(contains_metadata(&request_metadata_recv,
- GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
- overridden_iam_selector));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, overridden_iam_token));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, overridden_iam_selector));
break;
case DESTROY:
- GPR_ASSERT(!contains_metadata(&request_metadata_recv,
- GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
- iam_token));
- GPR_ASSERT(!contains_metadata(&request_metadata_recv,
- GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
- iam_selector));
- GPR_ASSERT(!contains_metadata(&request_metadata_recv,
- GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
- overridden_iam_token));
- GPR_ASSERT(!contains_metadata(&request_metadata_recv,
- GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
- overridden_iam_selector));
+ GPR_ASSERT (!contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, iam_token));
+ GPR_ASSERT (!contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, iam_selector));
+ GPR_ASSERT (!contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, overridden_iam_token));
+ GPR_ASSERT (!contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, overridden_iam_selector));
break;
- }
+ }
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- 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);
+ 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);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-static void test_request_response_with_payload_and_call_creds(
- grpc_end2end_test_config config) {
- request_response_with_payload_and_call_creds(
- "test_request_response_with_payload_and_call_creds", config, NONE);
+static void
+test_request_response_with_payload_and_call_creds (grpc_end2end_test_config config)
+{
+ request_response_with_payload_and_call_creds ("test_request_response_with_payload_and_call_creds", config, NONE);
}
-static void test_request_response_with_payload_and_overridden_call_creds(
- grpc_end2end_test_config config) {
- request_response_with_payload_and_call_creds(
- "test_request_response_with_payload_and_overridden_call_creds", config,
- OVERRIDE);
+static void
+test_request_response_with_payload_and_overridden_call_creds (grpc_end2end_test_config config)
+{
+ request_response_with_payload_and_call_creds ("test_request_response_with_payload_and_overridden_call_creds", config, OVERRIDE);
}
-static void test_request_response_with_payload_and_deleted_call_creds(
- grpc_end2end_test_config config) {
- request_response_with_payload_and_call_creds(
- "test_request_response_with_payload_and_deleted_call_creds", config,
- DESTROY);
+static void
+test_request_response_with_payload_and_deleted_call_creds (grpc_end2end_test_config config)
+{
+ request_response_with_payload_and_call_creds ("test_request_response_with_payload_and_deleted_call_creds", config, DESTROY);
}
-static void test_request_with_server_rejecting_client_creds(
- grpc_end2end_test_config config) {
+static void
+test_request_with_server_rejecting_client_creds (grpc_end2end_test_config config)
+{
grpc_op ops[6];
grpc_op *op;
grpc_call *c;
grpc_end2end_test_fixture f;
- gpr_timespec deadline = five_seconds_time();
+ gpr_timespec deadline = five_seconds_time ();
cq_verifier *cqv;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
@@ -409,27 +417,25 @@ static void test_request_with_server_rejecting_client_creds(
char *details = NULL;
size_t details_capacity = 0;
grpc_byte_buffer *response_payload_recv = NULL;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
grpc_credentials *creds;
- f = begin_test(config, "test_request_with_server_rejecting_client_creds", 1);
- cqv = cq_verifier_create(f.cq);
+ f = begin_test (config, "test_request_with_server_rejecting_client_creds", 1);
+ 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);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL);
+ GPR_ASSERT (c);
- creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL);
- GPR_ASSERT(creds != NULL);
- GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK);
- grpc_credentials_release(creds);
+ creds = grpc_google_iam_credentials_create (iam_token, iam_selector, NULL);
+ GPR_ASSERT (creds != NULL);
+ GPR_ASSERT (grpc_call_set_credentials (c, creds) == GRPC_CALL_OK);
+ grpc_credentials_release (creds);
- 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);
+ 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);
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
@@ -464,36 +470,39 @@ static void test_request_with_server_rejecting_client_creds(
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
- GPR_ASSERT(error == GRPC_CALL_OK);
+ error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL);
+ GPR_ASSERT (error == GRPC_CALL_OK);
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNAUTHENTICATED);
+ GPR_ASSERT (status == GRPC_STATUS_UNAUTHENTICATED);
- 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_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_byte_buffer_destroy(request_payload);
- grpc_byte_buffer_destroy(response_payload_recv);
- gpr_free(details);
+ grpc_byte_buffer_destroy (request_payload);
+ grpc_byte_buffer_destroy (response_payload_recv);
+ gpr_free (details);
- grpc_call_destroy(c);
+ grpc_call_destroy (c);
- cq_verifier_destroy(cqv);
- end_test(&f);
- config.tear_down_data(&f);
+ cq_verifier_destroy (cqv);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) {
- test_call_creds_failure(config);
- test_request_response_with_payload_and_call_creds(config);
- test_request_response_with_payload_and_overridden_call_creds(config);
- test_request_response_with_payload_and_deleted_call_creds(config);
- test_request_with_server_rejecting_client_creds(config);
- }
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS)
+ {
+ test_call_creds_failure (config);
+ test_request_response_with_payload_and_call_creds (config);
+ test_request_response_with_payload_and_overridden_call_creds (config);
+ test_request_response_with_payload_and_deleted_call_creds (config);
+ test_request_with_server_rejecting_client_creds (config);
+ }
}
diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c
index 10e62275ab..bbef223229 100644
--- a/test/core/end2end/tests/cancel_after_accept.c
+++ b/test/core/end2end/tests/cancel_after_accept.c
@@ -44,71 +44,91 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Cancel after accept, no payload */
-static void test_cancel_after_accept(grpc_end2end_test_config config,
- cancellation_mode mode) {
+static void
+test_cancel_after_accept (grpc_end2end_test_config config, cancellation_mode mode)
+{
grpc_op ops[6];
grpc_op *op;
grpc_call *c;
grpc_call *s;
- grpc_end2end_test_fixture f =
- begin_test(config, "cancel_after_accept", NULL, NULL);
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f = begin_test (config, "cancel_after_accept", NULL, NULL);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -119,22 +139,19 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
size_t details_capacity = 0;
grpc_byte_buffer *request_payload_recv = NULL;
grpc_byte_buffer *response_payload_recv = NULL;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
- grpc_raw_byte_buffer_create(&response_payload_slice, 1);
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1);
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
@@ -165,14 +182,13 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
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_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(2));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(2), 1);
- cq_verify(cqv);
+ error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (2));
+ GPR_ASSERT (GRPC_CALL_OK == error);
+ cq_expect_completion (cqv, tag (2), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_MESSAGE;
@@ -195,41 +211,44 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (3), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
- GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL));
+ GPR_ASSERT (GRPC_CALL_OK == mode.initiate_cancel (c, NULL));
- cq_expect_completion(cqv, tag(3), 1);
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (3), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL);
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == mode.expect_status || status == GRPC_STATUS_INTERNAL);
+ GPR_ASSERT (was_cancelled == 1);
- 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_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_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_free(details);
+ 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_free (details);
- grpc_call_destroy(c);
- grpc_call_destroy(s);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
- end_test(&f);
- config.tear_down_data(&f);
+ cq_verifier_destroy (cqv);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
unsigned i;
- for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) {
- test_cancel_after_accept(config, cancellation_modes[i]);
- }
+ for (i = 0; i < GPR_ARRAY_SIZE (cancellation_modes); i++)
+ {
+ test_cancel_after_accept (config, cancellation_modes[i]);
+ }
}
diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c
index 4fed5be5f7..b02d40c250 100644
--- a/test/core/end2end/tests/cancel_after_client_done.c
+++ b/test/core/end2end/tests/cancel_after_client_done.c
@@ -44,71 +44,91 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Cancel after accept with a writes closed, no payload */
-static void test_cancel_after_accept_and_writes_closed(
- grpc_end2end_test_config config, cancellation_mode mode) {
+static void
+test_cancel_after_accept_and_writes_closed (grpc_end2end_test_config config, cancellation_mode mode)
+{
grpc_op ops[6];
grpc_op *op;
grpc_call *c;
grpc_call *s;
- grpc_end2end_test_fixture f = begin_test(
- config, "test_cancel_after_accept_and_writes_closed", NULL, NULL);
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f = begin_test (config, "test_cancel_after_accept_and_writes_closed", NULL, NULL);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -119,22 +139,19 @@ static void test_cancel_after_accept_and_writes_closed(
size_t details_capacity = 0;
grpc_byte_buffer *request_payload_recv = NULL;
grpc_byte_buffer *response_payload_recv = NULL;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
- grpc_raw_byte_buffer_create(&response_payload_slice, 1);
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1);
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
@@ -169,14 +186,13 @@ static void test_cancel_after_accept_and_writes_closed(
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_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(2));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(2), 1);
- cq_verify(cqv);
+ error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (2));
+ GPR_ASSERT (GRPC_CALL_OK == error);
+ cq_expect_completion (cqv, tag (2), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_MESSAGE;
@@ -199,41 +215,44 @@ static void test_cancel_after_accept_and_writes_closed(
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (3), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
- GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL));
+ GPR_ASSERT (GRPC_CALL_OK == mode.initiate_cancel (c, NULL));
- cq_expect_completion(cqv, tag(3), 1);
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (3), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL);
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == mode.expect_status || status == GRPC_STATUS_INTERNAL);
+ GPR_ASSERT (was_cancelled == 1);
- 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_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_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_free(details);
+ 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_free (details);
- grpc_call_destroy(c);
- grpc_call_destroy(s);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
- end_test(&f);
- config.tear_down_data(&f);
+ cq_verifier_destroy (cqv);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
unsigned i;
- for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) {
- test_cancel_after_accept_and_writes_closed(config, cancellation_modes[i]);
- }
+ for (i = 0; i < GPR_ARRAY_SIZE (cancellation_modes); i++)
+ {
+ test_cancel_after_accept_and_writes_closed (config, cancellation_modes[i]);
+ }
}
diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c
index 40595e4c7b..4f83a3ea7c 100644
--- a/test/core/end2end/tests/cancel_after_invoke.c
+++ b/test/core/end2end/tests/cancel_after_invoke.c
@@ -44,71 +44,90 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- cancellation_mode mode,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, cancellation_mode mode, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s/%s", test_name, config.name, mode.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s/%s", test_name, config.name, mode.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Cancel after invoke, no payload */
-static void test_cancel_after_invoke(grpc_end2end_test_config config,
- cancellation_mode mode, size_t test_ops) {
+static void
+test_cancel_after_invoke (grpc_end2end_test_config config, cancellation_mode mode, size_t test_ops)
+{
grpc_op ops[6];
grpc_op *op;
grpc_call *c;
- grpc_end2end_test_fixture f =
- begin_test(config, "test_cancel_after_invoke", mode, NULL, NULL);
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f = begin_test (config, "test_cancel_after_invoke", mode, NULL, NULL);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -118,18 +137,16 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
char *details = NULL;
size_t details_capacity = 0;
grpc_byte_buffer *response_payload_recv = NULL;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
@@ -164,38 +181,42 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c, ops, test_ops, tag(1), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ error = grpc_call_start_batch (c, ops, test_ops, tag (1), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
- GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL));
+ GPR_ASSERT (GRPC_CALL_OK == mode.initiate_cancel (c, NULL));
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL);
+ GPR_ASSERT (status == mode.expect_status || status == GRPC_STATUS_INTERNAL);
- 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_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_byte_buffer_destroy(request_payload);
- grpc_byte_buffer_destroy(response_payload_recv);
- gpr_free(details);
+ grpc_byte_buffer_destroy (request_payload);
+ grpc_byte_buffer_destroy (response_payload_recv);
+ gpr_free (details);
- grpc_call_destroy(c);
+ grpc_call_destroy (c);
- cq_verifier_destroy(cqv);
- end_test(&f);
- config.tear_down_data(&f);
+ cq_verifier_destroy (cqv);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
unsigned i, j;
- for (j = 2; j < 6; j++) {
- for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) {
- test_cancel_after_invoke(config, cancellation_modes[i], j);
+ for (j = 2; j < 6; j++)
+ {
+ for (i = 0; i < GPR_ARRAY_SIZE (cancellation_modes); i++)
+ {
+ test_cancel_after_invoke (config, cancellation_modes[i], j);
+ }
}
- }
}
diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c
index c049e0c2d6..065ed43ebd 100644
--- a/test/core/end2end/tests/cancel_before_invoke.c
+++ b/test/core/end2end/tests/cancel_before_invoke.c
@@ -43,70 +43,90 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Cancel before invoke */
-static void test_cancel_before_invoke(grpc_end2end_test_config config,
- size_t test_ops) {
+static void
+test_cancel_before_invoke (grpc_end2end_test_config config, size_t test_ops)
+{
grpc_op ops[6];
grpc_op *op;
grpc_call *c;
- grpc_end2end_test_fixture f =
- begin_test(config, "cancel_before_invoke", NULL, NULL);
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f = begin_test (config, "cancel_before_invoke", NULL, NULL);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -116,20 +136,18 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
char *details = NULL;
size_t details_capacity = 0;
grpc_byte_buffer *response_payload_recv = NULL;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL);
+ GPR_ASSERT (c);
- GPR_ASSERT(GRPC_CALL_OK == grpc_call_cancel(c, NULL));
+ GPR_ASSERT (GRPC_CALL_OK == grpc_call_cancel (c, NULL));
- 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);
+ 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);
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
@@ -164,33 +182,36 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c, ops, test_ops, tag(1), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ error = grpc_call_start_batch (c, ops, test_ops, tag (1), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_CANCELLED);
+ GPR_ASSERT (status == GRPC_STATUS_CANCELLED);
- 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_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_byte_buffer_destroy(request_payload);
- grpc_byte_buffer_destroy(response_payload_recv);
- gpr_free(details);
+ grpc_byte_buffer_destroy (request_payload);
+ grpc_byte_buffer_destroy (response_payload_recv);
+ gpr_free (details);
- grpc_call_destroy(c);
+ grpc_call_destroy (c);
- cq_verifier_destroy(cqv);
- end_test(&f);
- config.tear_down_data(&f);
+ cq_verifier_destroy (cqv);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
size_t i;
- for (i = 1; i <= 6; i++) {
- test_cancel_before_invoke(config, i);
- }
+ for (i = 1; i <= 6; i++)
+ {
+ test_cancel_before_invoke (config, i);
+ }
}
diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c
index 6c63d7c0ad..512bceb6e5 100644
--- a/test/core/end2end/tests/cancel_in_a_vacuum.c
+++ b/test/core/end2end/tests/cancel_in_a_vacuum.c
@@ -44,86 +44,108 @@
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/tests/cancel_test_helpers.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Cancel and do nothing */
-static void test_cancel_in_a_vacuum(grpc_end2end_test_config config,
- cancellation_mode mode) {
+static void
+test_cancel_in_a_vacuum (grpc_end2end_test_config config, cancellation_mode mode)
+{
grpc_call *c;
- grpc_end2end_test_fixture f =
- begin_test(config, "test_cancel_in_a_vacuum", NULL, NULL);
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *v_client = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f = begin_test (config, "test_cancel_in_a_vacuum", NULL, NULL);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *v_client = 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);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL);
+ GPR_ASSERT (c);
- GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL));
+ GPR_ASSERT (GRPC_CALL_OK == mode.initiate_cancel (c, NULL));
- grpc_call_destroy(c);
+ grpc_call_destroy (c);
- cq_verifier_destroy(v_client);
- end_test(&f);
- config.tear_down_data(&f);
+ cq_verifier_destroy (v_client);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
unsigned i;
- for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) {
- test_cancel_in_a_vacuum(config, cancellation_modes[i]);
- }
+ for (i = 0; i < GPR_ARRAY_SIZE (cancellation_modes); i++)
+ {
+ test_cancel_in_a_vacuum (config, cancellation_modes[i]);
+ }
}
diff --git a/test/core/end2end/tests/cancel_test_helpers.h b/test/core/end2end/tests/cancel_test_helpers.h
index f8fafae597..20bcfc86aa 100644
--- a/test/core/end2end/tests/cancel_test_helpers.h
+++ b/test/core/end2end/tests/cancel_test_helpers.h
@@ -34,22 +34,25 @@
#ifndef GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H
#define GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H
-typedef struct {
+typedef struct
+{
const char *name;
- grpc_call_error (*initiate_cancel)(grpc_call *call, void *reserved);
+ grpc_call_error (*initiate_cancel) (grpc_call * call, void *reserved);
grpc_status_code expect_status;
const char *expect_details;
} cancellation_mode;
-static grpc_call_error wait_for_deadline(grpc_call *call, void *reserved) {
- (void)reserved;
+static grpc_call_error
+wait_for_deadline (grpc_call * call, void *reserved)
+{
+ (void) reserved;
return GRPC_CALL_OK;
}
static const cancellation_mode cancellation_modes[] = {
- {"cancel", grpc_call_cancel, GRPC_STATUS_CANCELLED, "Cancelled"},
- {"deadline", wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED,
- "Deadline Exceeded"},
+ {"cancel", grpc_call_cancel, GRPC_STATUS_CANCELLED, "Cancelled"},
+ {"deadline", wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED,
+ "Deadline Exceeded"},
};
#endif /* GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H */
diff --git a/test/core/end2end/tests/census_simple_request.c b/test/core/end2end/tests/census_simple_request.c
index adf855ca60..71fd9e0e49 100644
--- a/test/core/end2end/tests/census_simple_request.c
+++ b/test/core/end2end/tests/census_simple_request.c
@@ -45,61 +45,78 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static void *tag(gpr_intptr t) { return (void *)t; }
+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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, n_seconds_time(5), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, n_seconds_time (5), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void test_body(grpc_end2end_test_fixture f) {
+static void
+test_body (grpc_end2end_test_fixture f)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = n_seconds_time(5);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = n_seconds_time (5);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -112,15 +129,13 @@ static void test_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr:1234", deadline,
- NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -145,15 +160,13 @@ static void test_body(grpc_end2end_test_fixture f) {
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -173,34 +186,34 @@ static void test_body(grpc_end2end_test_fixture f) {
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);
+ 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_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-static void test_invoke_request_with_census(
- grpc_end2end_test_config config, const char *name,
- void (*body)(grpc_end2end_test_fixture f)) {
+static void
+test_invoke_request_with_census (grpc_end2end_test_config config, const char *name, void (*body) (grpc_end2end_test_fixture f))
+{
char *fullname;
grpc_end2end_test_fixture f;
grpc_arg client_arg, server_arg;
@@ -219,14 +232,16 @@ static void test_invoke_request_with_census(
server_args.num_args = 1;
server_args.args = &server_arg;
- gpr_asprintf(&fullname, "%s/%s", "test_invoke_request_with_census", name);
- f = begin_test(config, fullname, &client_args, &server_args);
- body(f);
- end_test(&f);
- config.tear_down_data(&f);
- gpr_free(fullname);
+ gpr_asprintf (&fullname, "%s/%s", "test_invoke_request_with_census", name);
+ f = begin_test (config, fullname, &client_args, &server_args);
+ body (f);
+ end_test (&f);
+ config.tear_down_data (&f);
+ gpr_free (fullname);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_invoke_request_with_census(config, "census_simple_request", test_body);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_invoke_request_with_census (config, "census_simple_request", test_body);
}
diff --git a/test/core/end2end/tests/channel_connectivity.c b/test/core/end2end/tests/channel_connectivity.c
index 0b7a8a664b..54e719e545 100644
--- a/test/core/end2end/tests/channel_connectivity.c
+++ b/test/core/end2end/tests/channel_connectivity.c
@@ -38,101 +38,95 @@
#include "test/core/end2end/cq_verifier.h"
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static void test_connectivity(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
+static void
+test_connectivity (grpc_end2end_test_config config)
+{
+ grpc_end2end_test_fixture f = config.create_fixture (NULL, NULL);
grpc_connectivity_state state;
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
- config.init_client(&f, NULL);
+ 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_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);
+ gpr_sleep_until (GRPC_TIMEOUT_MILLIS_TO_DEADLINE (100));
+ 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);
+ 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 ||
- state == GRPC_CHANNEL_CONNECTING);
+ 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 || 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));
- 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 ||
- state == GRPC_CHANNEL_CONNECTING);
+ 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 || state == GRPC_CHANNEL_CONNECTING);
- gpr_log(GPR_DEBUG, "*** STARTING SERVER ***");
+ gpr_log (GPR_DEBUG, "*** STARTING SERVER ***");
/* now let's bring up a server to connect to */
- config.init_server(&f, NULL);
+ config.init_server (&f, NULL);
- gpr_log(GPR_DEBUG, "*** STARTED SERVER ***");
+ gpr_log (GPR_DEBUG, "*** STARTED SERVER ***");
/* 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);
- cq_verify(cqv);
- state = grpc_channel_check_connectivity_state(f.client, 0);
- GPR_ASSERT(state == GRPC_CHANNEL_READY ||
- state == GRPC_CHANNEL_CONNECTING ||
- state == GRPC_CHANNEL_TRANSIENT_FAILURE);
- }
+ 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);
+ cq_verify (cqv);
+ state = grpc_channel_check_connectivity_state (f.client, 0);
+ GPR_ASSERT (state == GRPC_CHANNEL_READY || state == GRPC_CHANNEL_CONNECTING || state == GRPC_CHANNEL_TRANSIENT_FAILURE);
+ }
/* bring down the server again */
/* we should go immediately to TRANSIENT_FAILURE */
- gpr_log(GPR_DEBUG, "*** SHUTTING DOWN SERVER ***");
+ 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));
+ grpc_server_shutdown_and_notify (f.server, f.cq, tag (0xdead));
- cq_expect_completion(cqv, tag(4), 1);
- 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 ||
- state == GRPC_CHANNEL_CONNECTING);
+ cq_expect_completion (cqv, tag (4), 1);
+ 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 || state == GRPC_CHANNEL_CONNECTING);
/* cleanup server */
- grpc_server_destroy(f.server);
+ grpc_server_destroy (f.server);
- gpr_log(GPR_DEBUG, "*** SHUTDOWN SERVER ***");
+ gpr_log (GPR_DEBUG, "*** SHUTDOWN SERVER ***");
- grpc_channel_destroy(f.client);
- grpc_completion_queue_shutdown(f.cq);
- grpc_completion_queue_destroy(f.cq);
- config.tear_down_data(&f);
+ grpc_channel_destroy (f.client);
+ grpc_completion_queue_shutdown (f.cq);
+ grpc_completion_queue_destroy (f.cq);
+ config.tear_down_data (&f);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
- test_connectivity(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ GPR_ASSERT (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
+ test_connectivity (config);
}
diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c
index c50eaba8b2..e7c0768d22 100644
--- a/test/core/end2end/tests/compressed_payload.c
+++ b/test/core/end2end/tests/compressed_payload.c
@@ -48,71 +48,88 @@
#include "src/core/channel/compress_filter.h"
#include "src/core/surface/call.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void request_with_payload_template(
- grpc_end2end_test_config config, const char *test_name,
- gpr_uint32 send_flags_bitmask,
- grpc_compression_algorithm requested_compression_algorithm,
- grpc_compression_algorithm expected_compression_algorithm,
- grpc_metadata *client_metadata) {
+static void
+request_with_payload_template (grpc_end2end_test_config config, const char *test_name, gpr_uint32 send_flags_bitmask, grpc_compression_algorithm requested_compression_algorithm, grpc_compression_algorithm expected_compression_algorithm, grpc_metadata * client_metadata)
+{
grpc_call *c;
grpc_call *s;
gpr_slice request_payload_slice;
grpc_byte_buffer *request_payload;
- gpr_timespec deadline = five_seconds_time();
+ gpr_timespec deadline = five_seconds_time ();
grpc_channel_args *client_args;
grpc_channel_args *server_args;
grpc_end2end_test_fixture f;
@@ -131,36 +148,36 @@ static void request_with_payload_template(
cq_verifier *cqv;
char str[1024];
- memset(str, 'x', 1023);
+ 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);
+ request_payload_slice = gpr_slice_from_copied_string (str);
+ 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);
+ client_args = grpc_channel_args_set_compression_algorithm (NULL, requested_compression_algorithm);
+ server_args = grpc_channel_args_set_compression_algorithm (NULL, requested_compression_algorithm);
- f = begin_test(config, test_name, client_args, server_args);
- cqv = cq_verifier_create(f.cq);
+ 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);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
- if (client_metadata != NULL) {
- op->data.send_initial_metadata.count = 1;
- op->data.send_initial_metadata.metadata = client_metadata;
- } else {
- op->data.send_initial_metadata.count = 0;
- }
+ if (client_metadata != NULL)
+ {
+ op->data.send_initial_metadata.count = 1;
+ op->data.send_initial_metadata.metadata = client_metadata;
+ }
+ else
+ {
+ op->data.send_initial_metadata.count = 0;
+ }
op->flags = 0;
op->reserved = NULL;
op++;
@@ -186,23 +203,18 @@ static void request_with_payload_template(
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(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);
+ 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 (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;
@@ -215,11 +227,11 @@ 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(102), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ 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);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -234,104 +246,95 @@ 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);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ 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(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (103), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 0);
+ GPR_ASSERT (status == GRPC_STATUS_OK);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ 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 (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_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);
- grpc_metadata_array_destroy(&request_metadata_recv);
- grpc_call_details_destroy(&call_details);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- gpr_slice_unref(request_payload_slice);
- grpc_byte_buffer_destroy(request_payload);
- grpc_byte_buffer_destroy(request_payload_recv);
+ 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);
+ grpc_channel_args_destroy (client_args);
+ grpc_channel_args_destroy (server_args);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-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);
+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);
}
-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);
+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);
}
-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);
+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);
}
-static void test_invoke_request_with_compressed_payload_md_override(
- grpc_end2end_test_config config) {
+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;
gzip_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY;
gzip_compression_override.value = "gzip";
gzip_compression_override.value_length = 4;
- memset(&gzip_compression_override.internal_data, 0,
- sizeof(gzip_compression_override.internal_data));
+ 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));
+ memset (&none_compression_override.internal_data, 0, sizeof (none_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);
+ request_with_payload_template (config, "test_invoke_request_with_compressed_payload_md_override_1", 0, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, &gzip_compression_override);
/* 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);
+ request_with_payload_template (config, "test_invoke_request_with_compressed_payload_md_override_2", 0, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_GZIP, &gzip_compression_override);
/* 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);
+ request_with_payload_template (config, "test_invoke_request_with_compressed_payload_md_override_3", 0, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, &none_compression_override);
}
-void grpc_end2end_tests(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_compressed_payload_md_override(config);
+void
+grpc_end2end_tests (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_compressed_payload_md_override (config);
}
diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c
index 7b62505a9a..2bffa8d692 100644
--- a/test/core/end2end/tests/default_host.c
+++ b/test/core/end2end/tests/default_host.c
@@ -45,65 +45,87 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void simple_request_body(grpc_end2end_test_fixture f) {
+static void
+simple_request_body (grpc_end2end_test_fixture f)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -117,19 +139,18 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
int was_cancelled = 2;
char *peer;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", NULL, deadline, NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", NULL, deadline, NULL);
+ GPR_ASSERT (c);
- peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
- gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
- gpr_free(peer);
+ peer = grpc_call_get_peer (c);
+ GPR_ASSERT (peer != NULL);
+ gpr_log (GPR_DEBUG, "client_peer_before_call=%s", peer);
+ gpr_free (peer);
- 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -154,24 +175,22 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(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));
- GPR_ASSERT(error == GRPC_CALL_OK);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
-
- peer = grpc_call_get_peer(s);
- GPR_ASSERT(peer != NULL);
- gpr_log(GPR_DEBUG, "server_peer=%s", peer);
- gpr_free(peer);
- peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
- gpr_log(GPR_DEBUG, "client_peer=%s", peer);
- gpr_free(peer);
+ error = grpc_call_start_batch (c, ops, (size_t) (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));
+ GPR_ASSERT (error == GRPC_CALL_OK);
+ cq_expect_completion (cqv, tag (101), 1);
+ cq_verify (cqv);
+
+ peer = grpc_call_get_peer (s);
+ GPR_ASSERT (peer != NULL);
+ gpr_log (GPR_DEBUG, "server_peer=%s", peer);
+ gpr_free (peer);
+ peer = grpc_call_get_peer (c);
+ GPR_ASSERT (peer != NULL);
+ gpr_log (GPR_DEBUG, "client_peer=%s", peer);
+ gpr_free (peer);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -191,44 +210,48 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
- GPR_ASSERT(error == GRPC_CALL_OK);
+ error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL);
+ GPR_ASSERT (error == GRPC_CALL_OK);
- cq_expect_completion(cqv, tag(102), 1);
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strncmp(call_details.host, "localhost", 9));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strncmp (call_details.host, "localhost", 9));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-static void test_invoke_simple_request(grpc_end2end_test_config config) {
+static void
+test_invoke_simple_request (grpc_end2end_test_config config)
+{
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
- simple_request_body(f);
- end_test(&f);
- config.tear_down_data(&f);
+ f = begin_test (config, "test_invoke_simple_request", NULL, NULL);
+ simple_request_body (f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(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;
- test_invoke_simple_request(config);
+ test_invoke_simple_request (config);
}
diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c
index de3ea16f66..e1758706bc 100644
--- a/test/core/end2end/tests/disappearing_server.c
+++ b/test/core/end2end/tests/disappearing_server.c
@@ -43,49 +43,73 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- if (!f->server) return;
- grpc_server_destroy(f->server);
+static void
+shutdown_server (grpc_end2end_test_fixture * f)
+{
+ if (!f->server)
+ return;
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
- cq_verifier *cqv) {
+static void
+do_request_and_shutdown_server (grpc_end2end_test_fixture * f, cq_verifier * cqv)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
+ gpr_timespec deadline = five_seconds_time ();
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -98,15 +122,13 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
- "/foo", "foo.test.google.fr:1234", deadline,
- NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, "/foo", "foo.test.google.fr:1234", 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -131,19 +153,17 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
/* should be able to shut down the server early
- and still complete the request */
- grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
+ grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -163,53 +183,57 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
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_expect_completion(cqv, tag(1), 1);
- cq_expect_completion(cqv, tag(1000), 1);
- cq_verify(cqv);
-
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
- GPR_ASSERT(was_cancelled == 1);
-
- 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);
+ 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_expect_completion (cqv, tag (1), 1);
+ cq_expect_completion (cqv, tag (1000), 1);
+ cq_verify (cqv);
+
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234"));
+ GPR_ASSERT (was_cancelled == 1);
+
+ 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);
}
-static void disappearing_server_test(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+static void
+disappearing_server_test (grpc_end2end_test_config config)
+{
+ grpc_end2end_test_fixture f = config.create_fixture (NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
- gpr_log(GPR_INFO, "%s/%s", "disappearing_server_test", config.name);
+ gpr_log (GPR_INFO, "%s/%s", "disappearing_server_test", config.name);
- config.init_client(&f, NULL);
- config.init_server(&f, NULL);
+ config.init_client (&f, NULL);
+ config.init_server (&f, NULL);
- do_request_and_shutdown_server(&f, cqv);
+ do_request_and_shutdown_server (&f, cqv);
/* now destroy and recreate the server */
- config.init_server(&f, NULL);
+ config.init_server (&f, NULL);
- do_request_and_shutdown_server(&f, cqv);
+ do_request_and_shutdown_server (&f, cqv);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
- disappearing_server_test(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ GPR_ASSERT (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
+ disappearing_server_test (config);
}
diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c
index c93d236a6a..a73bdc7b3f 100644
--- a/test/core/end2end/tests/empty_batch.c
+++ b/test/core/end2end/tests/empty_batch.c
@@ -45,90 +45,115 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void empty_batch_body(grpc_end2end_test_fixture f) {
+static void
+empty_batch_body (grpc_end2end_test_fixture f)
+{
grpc_call *c;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_call_error error;
grpc_op *op = NULL;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL);
+ GPR_ASSERT (c);
- error = grpc_call_start_batch(c, op, 0, tag(1), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ error = grpc_call_start_batch (c, op, 0, tag (1), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- grpc_call_destroy(c);
+ grpc_call_destroy (c);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-static void test_invoke_empty_body(grpc_end2end_test_config config) {
+static void
+test_invoke_empty_body (grpc_end2end_test_config config)
+{
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_empty_body", NULL, NULL);
- empty_batch_body(f);
- end_test(&f);
- config.tear_down_data(&f);
+ f = begin_test (config, "test_invoke_empty_body", NULL, NULL);
+ empty_batch_body (f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_invoke_empty_body(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_invoke_empty_body (config);
}
diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c
index df420a9846..b3e30964ae 100644
--- a/test/core/end2end/tests/graceful_server_shutdown.c
+++ b/test/core/end2end/tests/graceful_server_shutdown.c
@@ -43,64 +43,86 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- if (!f->server) return;
- grpc_server_destroy(f->server);
+static void
+shutdown_server (grpc_end2end_test_fixture * f)
+{
+ if (!f->server)
+ return;
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void test_early_server_shutdown_finishes_inflight_calls(
- grpc_end2end_test_config config) {
+static void
+test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config config)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- grpc_end2end_test_fixture f = begin_test(
- config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ grpc_end2end_test_fixture f = begin_test (config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -113,14 +135,13 @@ static void test_early_server_shutdown_finishes_inflight_calls(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -146,19 +167,17 @@ static void test_early_server_shutdown_finishes_inflight_calls(
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
/* shutdown and destroy the server */
- grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead));
- cq_verify_empty(cqv);
+ grpc_server_shutdown_and_notify (f.server, f.cq, tag (0xdead));
+ cq_verify_empty (cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -178,35 +197,37 @@ static void test_early_server_shutdown_finishes_inflight_calls(
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);
+ 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_expect_completion(cqv, tag(0xdead), 1);
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (0xdead), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- grpc_call_destroy(s);
+ grpc_call_destroy (s);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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 (c);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_early_server_shutdown_finishes_inflight_calls(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_early_server_shutdown_finishes_inflight_calls (config);
}
diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c
index 44d6a60c10..4d9d09cd80 100644
--- a/test/core/end2end/tests/high_initial_seqno.c
+++ b/test/core/end2end/tests/high_initial_seqno.c
@@ -45,65 +45,87 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void simple_request_body(grpc_end2end_test_fixture f) {
+static void
+simple_request_body (grpc_end2end_test_fixture f)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -116,15 +138,13 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr:1234", deadline,
- NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -149,15 +169,13 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -177,33 +195,34 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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);
+ 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_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-static void test_invoke_10_simple_requests(grpc_end2end_test_config config,
- int initial_sequence_number) {
+static void
+test_invoke_10_simple_requests (grpc_end2end_test_config config, int initial_sequence_number)
+{
int i;
grpc_end2end_test_fixture f;
grpc_arg client_arg;
@@ -216,18 +235,22 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config,
client_args.num_args = 1;
client_args.args = &client_arg;
- f = begin_test(config, "test_invoke_10_simple_requests", &client_args, NULL);
- for (i = 0; i < 10; i++) {
- simple_request_body(f);
- gpr_log(GPR_INFO, "Passed simple request %d", i);
- }
- end_test(&f);
- config.tear_down_data(&f);
+ f = begin_test (config, "test_invoke_10_simple_requests", &client_args, NULL);
+ for (i = 0; i < 10; i++)
+ {
+ simple_request_body (f);
+ gpr_log (GPR_INFO, "Passed simple request %d", i);
+ }
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_invoke_10_simple_requests(config, 16777213);
- if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) {
- test_invoke_10_simple_requests(config, 2147483645);
- }
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_invoke_10_simple_requests (config, 16777213);
+ if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION)
+ {
+ test_invoke_10_simple_requests (config, 2147483645);
+ }
}
diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c
index f79d146da1..da19222c53 100644
--- a/test/core/end2end/tests/invoke_large_request.c
+++ b/test/core/end2end/tests/invoke_large_request.c
@@ -43,78 +43,95 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, n_seconds_time(5), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, n_seconds_time (5), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static gpr_slice large_slice(void) {
- gpr_slice slice = gpr_slice_malloc(1000000);
- memset(GPR_SLICE_START_PTR(slice), 'x', GPR_SLICE_LENGTH(slice));
+static gpr_slice
+large_slice (void)
+{
+ gpr_slice slice = gpr_slice_malloc (1000000);
+ memset (GPR_SLICE_START_PTR (slice), 'x', GPR_SLICE_LENGTH (slice));
return slice;
}
-static void test_invoke_large_request(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_large_request", NULL, NULL);
+static void
+test_invoke_large_request (grpc_end2end_test_config config)
+{
+ grpc_end2end_test_fixture f = begin_test (config, "test_invoke_large_request", NULL, NULL);
- gpr_slice request_payload_slice = large_slice();
- gpr_slice response_payload_slice = large_slice();
+ gpr_slice request_payload_slice = large_slice ();
+ gpr_slice response_payload_slice = large_slice ();
grpc_call *c;
grpc_call *s;
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
- grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- gpr_timespec deadline = n_seconds_time(30);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1);
+ gpr_timespec deadline = n_seconds_time (30);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -129,14 +146,13 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -171,15 +187,13 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -192,11 +206,11 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
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);
+ 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);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -216,41 +230,43 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
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);
+ 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(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (103), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- 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);
+ 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);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_invoke_large_request(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_invoke_large_request (config);
}
diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c
index 87529639a7..ff7605ebe9 100644
--- a/test/core/end2end/tests/large_metadata.c
+++ b/test/core/end2end/tests/large_metadata.c
@@ -43,72 +43,92 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Request with a large amount of metadata.*/
-static void test_request_with_large_metadata(grpc_end2end_test_config config) {
+static void
+test_request_with_large_metadata (grpc_end2end_test_config config)
+{
grpc_call *c;
grpc_call *s;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ gpr_timespec deadline = five_seconds_time ();
grpc_metadata meta;
- grpc_end2end_test_fixture f =
- begin_test(config, "test_request_with_large_metadata", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_end2end_test_fixture f = begin_test (config, "test_request_with_large_metadata", NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -123,20 +143,19 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
int was_cancelled = 2;
const size_t large_size = 64 * 1024;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL);
+ GPR_ASSERT (c);
meta.key = "key";
- meta.value = gpr_malloc(large_size + 1);
- memset((char *)meta.value, 'a', large_size);
- ((char *)meta.value)[large_size] = 0;
+ meta.value = gpr_malloc (large_size + 1);
+ memset ((char *) meta.value, 'a', large_size);
+ ((char *) meta.value)[large_size] = 0;
meta.value_length = large_size;
- 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -167,15 +186,13 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -188,11 +205,11 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
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);
+ 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);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -207,41 +224,43 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
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);
+ 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(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (103), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 0);
- GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
- GPR_ASSERT(contains_metadata(&request_metadata_recv, "key", meta.value));
+ GPR_ASSERT (status == GRPC_STATUS_OK);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 0);
+ GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world"));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, "key", meta.value));
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- grpc_byte_buffer_destroy(request_payload);
- grpc_byte_buffer_destroy(request_payload_recv);
+ grpc_byte_buffer_destroy (request_payload);
+ grpc_byte_buffer_destroy (request_payload_recv);
- gpr_free((char *)meta.value);
+ gpr_free ((char *) meta.value);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_request_with_large_metadata(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_request_with_large_metadata (config);
}
diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c
index 87eb4dd451..1d4ba32ee0 100644
--- a/test/core/end2end/tests/max_concurrent_streams.c
+++ b/test/core/end2end/tests/max_concurrent_streams.c
@@ -43,65 +43,87 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void simple_request_body(grpc_end2end_test_fixture f) {
+static void
+simple_request_body (grpc_end2end_test_fixture f)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -114,15 +136,13 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr:1234", deadline,
- NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -147,15 +167,13 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -175,32 +193,34 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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);
+ 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_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-static void test_max_concurrent_streams(grpc_end2end_test_config config) {
+static void
+test_max_concurrent_streams (grpc_end2end_test_config config)
+{
grpc_end2end_test_fixture f;
grpc_arg server_arg;
grpc_channel_args server_args;
@@ -238,37 +258,31 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
server_args.num_args = 1;
server_args.args = &server_arg;
- f = begin_test(config, "test_max_concurrent_streams", NULL, &server_args);
- cqv = cq_verifier_create(f.cq);
+ f = begin_test (config, "test_max_concurrent_streams", NULL, &server_args);
+ cqv = cq_verifier_create (f.cq);
- grpc_metadata_array_init(&request_metadata_recv);
- grpc_metadata_array_init(&initial_metadata_recv1);
- grpc_metadata_array_init(&trailing_metadata_recv1);
- grpc_metadata_array_init(&initial_metadata_recv2);
- grpc_metadata_array_init(&trailing_metadata_recv2);
- grpc_call_details_init(&call_details);
+ grpc_metadata_array_init (&request_metadata_recv);
+ grpc_metadata_array_init (&initial_metadata_recv1);
+ grpc_metadata_array_init (&trailing_metadata_recv1);
+ grpc_metadata_array_init (&initial_metadata_recv2);
+ grpc_metadata_array_init (&trailing_metadata_recv2);
+ grpc_call_details_init (&call_details);
/* perform a ping-pong to ensure that settings have had a chance to round
trip */
- simple_request_body(f);
+ simple_request_body (f);
/* perform another one to make sure that the one stream case still works */
- simple_request_body(f);
+ simple_request_body (f);
/* start two requests - ensuring that the second is not accepted until
the first completes */
- deadline = n_seconds_time(1000);
- c1 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/alpha", "foo.test.google.fr:1234", deadline,
- NULL);
- GPR_ASSERT(c1);
- c2 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/beta", "foo.test.google.fr:1234", deadline,
- NULL);
- GPR_ASSERT(c2);
-
- GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
- f.server, &s1, &call_details,
- &request_metadata_recv, f.cq, f.cq, tag(101)));
+ deadline = n_seconds_time (1000);
+ c1 = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/alpha", "foo.test.google.fr:1234", deadline, NULL);
+ GPR_ASSERT (c1);
+ c2 = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/beta", "foo.test.google.fr:1234", deadline, NULL);
+ GPR_ASSERT (c2);
+
+ GPR_ASSERT (GRPC_CALL_OK == grpc_server_request_call (f.server, &s1, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -280,8 +294,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ error = grpc_call_start_batch (c1, ops, (size_t) (op - ops), tag (301), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
@@ -297,8 +311,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ error = grpc_call_start_batch (c1, ops, (size_t) (op - ops), tag (302), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -310,8 +324,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ error = grpc_call_start_batch (c2, ops, (size_t) (op - ops), tag (401), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
@@ -327,32 +341,35 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ error = grpc_call_start_batch (c2, ops, (size_t) (op - ops), tag (402), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
got_client_start = 0;
got_server_start = 0;
live_call = -1;
- while (!got_client_start || !got_server_start) {
- ev = grpc_completion_queue_next(f.cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3),
- NULL);
- GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- GPR_ASSERT(ev.success);
- if (ev.tag == tag(101)) {
- GPR_ASSERT(!got_server_start);
- got_server_start = 1;
- } else {
- GPR_ASSERT(!got_client_start);
- GPR_ASSERT(ev.tag == tag(301) || ev.tag == tag(401));
- /* The /alpha or /beta calls started above could be invoked (but NOT
- * both);
- * check this here */
- /* We'll get tag 303 or 403, we want 300, 400 */
- live_call = ((int)(gpr_intptr)ev.tag) - 1;
- got_client_start = 1;
+ while (!got_client_start || !got_server_start)
+ {
+ ev = grpc_completion_queue_next (f.cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE (3), NULL);
+ GPR_ASSERT (ev.type == GRPC_OP_COMPLETE);
+ GPR_ASSERT (ev.success);
+ if (ev.tag == tag (101))
+ {
+ GPR_ASSERT (!got_server_start);
+ got_server_start = 1;
+ }
+ else
+ {
+ GPR_ASSERT (!got_client_start);
+ GPR_ASSERT (ev.tag == tag (301) || ev.tag == tag (401));
+ /* The /alpha or /beta calls started above could be invoked (but NOT
+ * both);
+ * check this here */
+ /* We'll get tag 303 or 403, we want 300, 400 */
+ live_call = ((int) (gpr_intptr) ev.tag) - 1;
+ got_client_start = 1;
+ }
}
- }
- GPR_ASSERT(live_call == 300 || live_call == 400);
+ GPR_ASSERT (live_call == 300 || live_call == 400);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -372,21 +389,19 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ error = grpc_call_start_batch (s1, ops, (size_t) (op - ops), tag (102), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(102), 1);
- cq_expect_completion(cqv, tag(live_call + 2), 1);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (live_call + 2), 1);
/* first request is finished, we should be able to start the second */
live_call = (live_call == 300) ? 400 : 300;
- cq_expect_completion(cqv, tag(live_call + 1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (live_call + 1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
- f.server, &s2, &call_details,
- &request_metadata_recv, f.cq, f.cq, tag(201)));
- cq_expect_completion(cqv, tag(201), 1);
- cq_verify(cqv);
+ GPR_ASSERT (GRPC_CALL_OK == grpc_server_request_call (f.server, &s2, &call_details, &request_metadata_recv, f.cq, f.cq, tag (201)));
+ cq_expect_completion (cqv, tag (201), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -406,33 +421,35 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
-
- cq_expect_completion(cqv, tag(live_call + 2), 1);
- cq_expect_completion(cqv, tag(202), 1);
- cq_verify(cqv);
-
- cq_verifier_destroy(cqv);
-
- grpc_call_destroy(c1);
- grpc_call_destroy(s1);
- grpc_call_destroy(c2);
- grpc_call_destroy(s2);
-
- gpr_free(details1);
- gpr_free(details2);
- grpc_metadata_array_destroy(&initial_metadata_recv1);
- grpc_metadata_array_destroy(&trailing_metadata_recv1);
- grpc_metadata_array_destroy(&initial_metadata_recv2);
- grpc_metadata_array_destroy(&trailing_metadata_recv2);
- grpc_metadata_array_destroy(&request_metadata_recv);
- grpc_call_details_destroy(&call_details);
-
- end_test(&f);
- config.tear_down_data(&f);
+ error = grpc_call_start_batch (s2, ops, (size_t) (op - ops), tag (202), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
+
+ cq_expect_completion (cqv, tag (live_call + 2), 1);
+ cq_expect_completion (cqv, tag (202), 1);
+ cq_verify (cqv);
+
+ cq_verifier_destroy (cqv);
+
+ grpc_call_destroy (c1);
+ grpc_call_destroy (s1);
+ grpc_call_destroy (c2);
+ grpc_call_destroy (s2);
+
+ gpr_free (details1);
+ gpr_free (details2);
+ grpc_metadata_array_destroy (&initial_metadata_recv1);
+ grpc_metadata_array_destroy (&trailing_metadata_recv1);
+ grpc_metadata_array_destroy (&initial_metadata_recv2);
+ grpc_metadata_array_destroy (&trailing_metadata_recv2);
+ grpc_metadata_array_destroy (&request_metadata_recv);
+ grpc_call_details_destroy (&call_details);
+
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_max_concurrent_streams(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_max_concurrent_streams (config);
}
diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c
index 782b9d0f26..e1949692ca 100644
--- a/test/core/end2end/tests/max_message_length.c
+++ b/test/core/end2end/tests/max_message_length.c
@@ -43,61 +43,83 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void test_max_message_length(grpc_end2end_test_config config) {
+static void
+test_max_message_length (grpc_end2end_test_config config)
+{
grpc_end2end_test_fixture f;
grpc_arg server_arg;
grpc_channel_args server_args;
@@ -106,9 +128,8 @@ static void test_max_message_length(grpc_end2end_test_config config) {
cq_verifier *cqv;
grpc_op ops[6];
grpc_op *op;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
@@ -126,18 +147,16 @@ static void test_max_message_length(grpc_end2end_test_config config) {
server_args.num_args = 1;
server_args.args = &server_arg;
- f = begin_test(config, "test_max_message_length", NULL, &server_args);
- cqv = cq_verifier_create(f.cq);
+ f = begin_test (config, "test_max_message_length", NULL, &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:1234",
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", gpr_inf_future (GPR_CLOCK_REALTIME), 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -167,15 +186,13 @@ static void test_max_message_length(grpc_end2end_test_config config) {
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -183,34 +200,36 @@ static void test_max_message_length(grpc_end2end_test_config config) {
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);
+ 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_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status != GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status != GRPC_STATUS_OK);
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234"));
+ GPR_ASSERT (was_cancelled == 1);
- 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_byte_buffer_destroy(request_payload);
+ 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_byte_buffer_destroy (request_payload);
- grpc_call_destroy(c);
- grpc_call_destroy(s);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_max_message_length(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_max_message_length (config);
}
diff --git a/test/core/end2end/tests/metadata.c b/test/core/end2end/tests/metadata.c
index d0604cc6b6..b1aefa77c6 100644
--- a/test/core/end2end/tests/metadata.c
+++ b/test/core/end2end/tests/metadata.c
@@ -43,81 +43,101 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Request/response with metadata and payload.*/
-static void test_request_response_with_metadata_and_payload(
- grpc_end2end_test_config config) {
+static void
+test_request_response_with_metadata_and_payload (grpc_end2end_test_config config)
+{
grpc_call *c;
grpc_call *s;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
- grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ 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}}}};
+ {"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);
+ {"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);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -132,14 +152,13 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -175,15 +194,13 @@ static void test_request_response_with_metadata_and_payload(
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -197,11 +214,11 @@ static void test_request_response_with_metadata_and_payload(
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);
+ 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);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -221,45 +238,47 @@ static void test_request_response_with_metadata_and_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);
+ 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(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (103), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 0);
- GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
- GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you"));
- GPR_ASSERT(contains_metadata(&request_metadata_recv, "key1", "val1"));
- GPR_ASSERT(contains_metadata(&request_metadata_recv, "key2", "val2"));
- GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key3", "val3"));
- GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key4", "val4"));
+ GPR_ASSERT (status == GRPC_STATUS_OK);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 0);
+ GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world"));
+ GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you"));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, "key1", "val1"));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, "key2", "val2"));
+ GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key3", "val3"));
+ GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key4", "val4"));
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- 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);
+ 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);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_request_response_with_metadata_and_payload(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_request_response_with_metadata_and_payload (config);
}
diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c
index 157d0d5349..0f15963a4a 100644
--- a/test/core/end2end/tests/no_op.c
+++ b/test/core/end2end/tests/no_op.c
@@ -43,64 +43,90 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void test_no_op(grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = begin_test(config, "no-op", NULL, NULL);
- end_test(&f);
- config.tear_down_data(&f);
+static void
+test_no_op (grpc_end2end_test_config config)
+{
+ grpc_end2end_test_fixture f = begin_test (config, "no-op", NULL, NULL);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) { test_no_op(config); }
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_no_op (config);
+}
diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c
index 0b303268fc..1674974135 100644
--- a/test/core/end2end/tests/payload.c
+++ b/test/core/end2end/tests/payload.c
@@ -43,71 +43,91 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void request_response_with_payload(grpc_end2end_test_fixture f) {
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
+static void
+request_response_with_payload (grpc_end2end_test_fixture f)
+{
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you");
grpc_call *c;
grpc_call *s;
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
- grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -122,14 +142,13 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -164,15 +183,13 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -185,11 +202,11 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
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);
+ 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);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -209,62 +226,65 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
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);
+ 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(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (103), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 0);
- GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
- GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you"));
+ GPR_ASSERT (status == GRPC_STATUS_OK);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 0);
+ GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world"));
+ GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you"));
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- 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);
+ 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);
}
/* Client sends a request with payload, server reads then returns a response
payload and status. */
-static void test_invoke_request_response_with_payload(
- grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = begin_test(
- config, "test_invoke_request_response_with_payload", NULL, NULL);
- request_response_with_payload(f);
- end_test(&f);
- config.tear_down_data(&f);
+static void
+test_invoke_request_response_with_payload (grpc_end2end_test_config config)
+{
+ grpc_end2end_test_fixture f = begin_test (config, "test_invoke_request_response_with_payload", NULL, NULL);
+ request_response_with_payload (f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-static void test_invoke_10_request_response_with_payload(
- grpc_end2end_test_config config) {
+static void
+test_invoke_10_request_response_with_payload (grpc_end2end_test_config config)
+{
int i;
- grpc_end2end_test_fixture f = begin_test(
- config, "test_invoke_10_request_response_with_payload", NULL, NULL);
- for (i = 0; i < 10; i++) {
- request_response_with_payload(f);
- }
- end_test(&f);
- config.tear_down_data(&f);
+ grpc_end2end_test_fixture f = begin_test (config, "test_invoke_10_request_response_with_payload", NULL, NULL);
+ for (i = 0; i < 10; i++)
+ {
+ request_response_with_payload (f);
+ }
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_invoke_request_response_with_payload(config);
- test_invoke_10_request_response_with_payload(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_invoke_request_response_with_payload (config);
+ test_invoke_10_request_response_with_payload (config);
}
diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c
index 39682d8bc5..c3431dd03d 100644
--- a/test/core/end2end/tests/ping_pong_streaming.c
+++ b/test/core/end2end/tests/ping_pong_streaming.c
@@ -43,69 +43,89 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Client pings and server pongs. Repeat messages rounds before finishing. */
-static void test_pingpong_streaming(grpc_end2end_test_config config,
- int messages) {
- grpc_end2end_test_fixture f =
- begin_test(config, "test_pingpong_streaming", NULL, NULL);
+static void
+test_pingpong_streaming (grpc_end2end_test_config config, int messages)
+{
+ grpc_end2end_test_fixture f = begin_test (config, "test_pingpong_streaming", NULL, NULL);
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -122,18 +142,16 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
grpc_byte_buffer *response_payload;
grpc_byte_buffer *response_payload_recv;
int i;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you");
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr:1234", deadline,
- NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -154,15 +172,13 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
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_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), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -175,66 +191,67 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
-
- for (i = 0; i < messages; i++) {
- request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1);
-
- op = ops;
- op->op = GRPC_OP_SEND_MESSAGE;
- op->data.send_message = request_payload;
- op->flags = 0;
- 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);
-
- 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);
-
- 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);
-
- 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);
+ error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (101), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
+
+ for (i = 0; i < messages; i++)
+ {
+ request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1);
+
+ op = ops;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message = request_payload;
+ op->flags = 0;
+ 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);
+
+ 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);
+
+ 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);
+
+ 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);
op = ops;
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);
+ error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (3), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
op = ops;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
@@ -244,34 +261,37 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
- GPR_ASSERT(GRPC_CALL_OK == error);
+ 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(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);
+ 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);
- grpc_call_destroy(c);
- grpc_call_destroy(s);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- 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);
- 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);
+ gpr_free (details);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
int i;
- for (i = 1; i < 10; i++) {
- test_pingpong_streaming(config, i);
- }
+ for (i = 1; i < 10; i++)
+ {
+ test_pingpong_streaming (config, i);
+ }
}
diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c
index b3156e0248..b30498a990 100644
--- a/test/core/end2end/tests/registered_call.c
+++ b/test/core/end2end/tests/registered_call.c
@@ -45,65 +45,87 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
+static void
+simple_request_body (grpc_end2end_test_fixture f, void *rc)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -116,14 +138,13 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_registered_call(
- f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, rc, deadline, NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_registered_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, rc, 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -148,15 +169,13 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -176,58 +195,63 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
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);
+ 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_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-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);
+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);
- simple_request_body(f, rc);
- end_test(&f);
- config.tear_down_data(&f);
+ simple_request_body (f, rc);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-static void test_invoke_10_simple_requests(grpc_end2end_test_config config) {
+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);
-
- for (i = 0; i < 10; i++) {
- simple_request_body(f, rc);
- gpr_log(GPR_INFO, "Passed simple request %d", i);
- }
- end_test(&f);
- config.tear_down_data(&f);
+ 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);
+
+ for (i = 0; i < 10; i++)
+ {
+ simple_request_body (f, rc);
+ gpr_log (GPR_INFO, "Passed simple request %d", i);
+ }
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_invoke_simple_request(config);
- test_invoke_10_simple_requests(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_invoke_simple_request (config);
+ test_invoke_10_simple_requests (config);
}
diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c
index b9cdf5168c..49474bb14f 100644
--- a/test/core/end2end/tests/request_with_flags.c
+++ b/test/core/end2end/tests/request_with_flags.c
@@ -44,71 +44,89 @@
#include "src/core/transport/stream_op.h"
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void test_invoke_request_with_flags(
- grpc_end2end_test_config config, gpr_uint32 *flags_for_op,
- grpc_call_error call_start_batch_expected_result) {
+static void
+test_invoke_request_with_flags (grpc_end2end_test_config config, gpr_uint32 * flags_for_op, grpc_call_error call_start_batch_expected_result)
+{
grpc_call *c;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- gpr_timespec deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10);
- grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_request_with_flags", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ gpr_timespec deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE (10);
+ grpc_end2end_test_fixture f = begin_test (config, "test_invoke_request_with_flags", NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -122,14 +140,13 @@ static void test_invoke_request_with_flags(
size_t details_capacity = 0;
grpc_call_error expectation;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -160,57 +177,63 @@ static void test_invoke_request_with_flags(
op->reserved = NULL;
op++;
expectation = call_start_batch_expected_result;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
- GPR_ASSERT(expectation == error);
+ error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL);
+ GPR_ASSERT (expectation == error);
- if (expectation == GRPC_CALL_OK) {
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
- }
+ if (expectation == GRPC_CALL_OK)
+ {
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
+ }
- 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);
+ 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 (c);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- grpc_byte_buffer_destroy(request_payload);
- grpc_byte_buffer_destroy(request_payload_recv);
+ grpc_byte_buffer_destroy (request_payload);
+ grpc_byte_buffer_destroy (request_payload_recv);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
size_t i;
gpr_uint32 flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER + 1];
{
/* check that all grpc_op_types fail when their flag value is set to an
* invalid value */
- int indices[] = {GRPC_OP_SEND_INITIAL_METADATA, GRPC_OP_SEND_MESSAGE,
- GRPC_OP_SEND_CLOSE_FROM_CLIENT,
- GRPC_OP_RECV_INITIAL_METADATA,
- GRPC_OP_RECV_STATUS_ON_CLIENT};
- for (i = 0; i < GPR_ARRAY_SIZE(indices); ++i) {
- memset(flags_for_op, 0, sizeof(flags_for_op));
- flags_for_op[indices[i]] = 0xDEADBEEF;
- test_invoke_request_with_flags(config, flags_for_op,
- GRPC_CALL_ERROR_INVALID_FLAGS);
- }
+ int indices[] = { GRPC_OP_SEND_INITIAL_METADATA, GRPC_OP_SEND_MESSAGE,
+ GRPC_OP_SEND_CLOSE_FROM_CLIENT,
+ GRPC_OP_RECV_INITIAL_METADATA,
+ GRPC_OP_RECV_STATUS_ON_CLIENT
+ };
+ for (i = 0; i < GPR_ARRAY_SIZE (indices); ++i)
+ {
+ memset (flags_for_op, 0, sizeof (flags_for_op));
+ flags_for_op[indices[i]] = 0xDEADBEEF;
+ test_invoke_request_with_flags (config, flags_for_op, GRPC_CALL_ERROR_INVALID_FLAGS);
+ }
}
{
/* check valid operation with allowed flags for GRPC_OP_SEND_BUFFER */
- gpr_uint32 flags[] = {GRPC_WRITE_BUFFER_HINT, GRPC_WRITE_NO_COMPRESS,
- GRPC_WRITE_INTERNAL_COMPRESS};
- for (i = 0; i < GPR_ARRAY_SIZE(flags); ++i) {
- memset(flags_for_op, 0, sizeof(flags_for_op));
- flags_for_op[GRPC_OP_SEND_MESSAGE] = flags[i];
- test_invoke_request_with_flags(config, flags_for_op, GRPC_CALL_OK);
- }
+ gpr_uint32 flags[] = { GRPC_WRITE_BUFFER_HINT, GRPC_WRITE_NO_COMPRESS,
+ GRPC_WRITE_INTERNAL_COMPRESS
+ };
+ for (i = 0; i < GPR_ARRAY_SIZE (flags); ++i)
+ {
+ memset (flags_for_op, 0, sizeof (flags_for_op));
+ flags_for_op[GRPC_OP_SEND_MESSAGE] = flags[i];
+ test_invoke_request_with_flags (config, flags_for_op, GRPC_CALL_OK);
+ }
}
}
diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c
index a323b43ab0..bbfbae8140 100644
--- a/test/core/end2end/tests/request_with_payload.c
+++ b/test/core/end2end/tests/request_with_payload.c
@@ -43,71 +43,91 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Client sends a request with payload, server reads then returns status. */
-static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
+static void
+test_invoke_request_with_payload (grpc_end2end_test_config config)
+{
grpc_call *c;
grpc_call *s;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
- grpc_end2end_test_fixture f =
- begin_test(config, "test_invoke_request_with_payload", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ gpr_timespec deadline = five_seconds_time ();
+ grpc_end2end_test_fixture f = begin_test (config, "test_invoke_request_with_payload", NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -121,14 +141,13 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -158,14 +177,12 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
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_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
- GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
- f.server, &s, &call_details,
- &request_metadata_recv, f.cq, f.cq, tag(101)));
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ GPR_ASSERT (GRPC_CALL_OK == grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)));
+ cq_expect_completion (cqv, tag (101), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -178,11 +195,11 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
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);
+ 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);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -197,38 +214,40 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
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);
+ 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(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (103), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 0);
- GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
+ GPR_ASSERT (status == GRPC_STATUS_OK);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 0);
+ GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world"));
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- grpc_byte_buffer_destroy(request_payload);
- grpc_byte_buffer_destroy(request_payload_recv);
+ grpc_byte_buffer_destroy (request_payload);
+ grpc_byte_buffer_destroy (request_payload_recv);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_invoke_request_with_payload(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_invoke_request_with_payload (config);
}
diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c
index bdc18a5e38..14830735a2 100644
--- a/test/core/end2end/tests/server_finishes_request.c
+++ b/test/core/end2end/tests/server_finishes_request.c
@@ -45,65 +45,87 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void simple_request_body(grpc_end2end_test_fixture f) {
+static void
+simple_request_body (grpc_end2end_test_fixture f)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -116,15 +138,13 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr:1234", deadline,
- NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -145,15 +165,13 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -173,40 +191,44 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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);
+ 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_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-static void test_invoke_simple_request(grpc_end2end_test_config config) {
+static void
+test_invoke_simple_request (grpc_end2end_test_config config)
+{
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
- simple_request_body(f);
- end_test(&f);
- config.tear_down_data(&f);
+ f = begin_test (config, "test_invoke_simple_request", NULL, NULL);
+ simple_request_body (f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_invoke_simple_request(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_invoke_simple_request (config);
}
diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c
index ad7def09a9..a9d8535e31 100644
--- a/test/core/end2end/tests/shutdown_finishes_calls.c
+++ b/test/core/end2end/tests/shutdown_finishes_calls.c
@@ -43,57 +43,76 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void test_early_server_shutdown_finishes_inflight_calls(
- grpc_end2end_test_config config) {
+static void
+test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config config)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- grpc_end2end_test_fixture f = begin_test(
- config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ grpc_end2end_test_fixture f = begin_test (config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -106,14 +125,13 @@ static void test_early_server_shutdown_finishes_inflight_calls(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -139,15 +157,13 @@ static void test_early_server_shutdown_finishes_inflight_calls(
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -155,40 +171,42 @@ static void test_early_server_shutdown_finishes_inflight_calls(
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);
+ error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
/* shutdown and destroy the server */
- grpc_server_shutdown_and_notify(f.server, f.cq, tag(1000));
- grpc_server_cancel_all_calls(f.server);
+ grpc_server_shutdown_and_notify (f.server, f.cq, tag (1000));
+ grpc_server_cancel_all_calls (f.server);
- cq_expect_completion(cqv, tag(1000), 1);
- cq_expect_completion(cqv, tag(102), 1);
- cq_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (1000), 1);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- grpc_server_destroy(f.server);
+ grpc_server_destroy (f.server);
- GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNAVAILABLE);
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_early_server_shutdown_finishes_inflight_calls(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_early_server_shutdown_finishes_inflight_calls (config);
}
diff --git a/test/core/end2end/tests/shutdown_finishes_tags.c b/test/core/end2end/tests/shutdown_finishes_tags.c
index 9b678a1754..9569d42424 100644
--- a/test/core/end2end/tests/shutdown_finishes_tags.c
+++ b/test/core/end2end/tests/shutdown_finishes_tags.c
@@ -43,79 +43,98 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void test_early_server_shutdown_finishes_tags(
- grpc_end2end_test_config config) {
- grpc_end2end_test_fixture f = begin_test(
- config, "test_early_server_shutdown_finishes_tags", NULL, NULL);
- cq_verifier *cqv = cq_verifier_create(f.cq);
- grpc_call *s = (void *)1;
+static void
+test_early_server_shutdown_finishes_tags (grpc_end2end_test_config config)
+{
+ grpc_end2end_test_fixture f = begin_test (config, "test_early_server_shutdown_finishes_tags", NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create (f.cq);
+ grpc_call *s = (void *) 1;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
- grpc_metadata_array_init(&request_metadata_recv);
- grpc_call_details_init(&call_details);
+ grpc_metadata_array_init (&request_metadata_recv);
+ grpc_call_details_init (&call_details);
/* upon shutdown, the server should finish all requested calls indicating
no new call */
- GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
- f.server, &s, &call_details,
- &request_metadata_recv, f.cq, f.cq, tag(101)));
- grpc_server_shutdown_and_notify(f.server, f.cq, tag(1000));
- cq_expect_completion(cqv, tag(101), 0);
- cq_expect_completion(cqv, tag(1000), 1);
- cq_verify(cqv);
- GPR_ASSERT(s == NULL);
-
- grpc_server_destroy(f.server);
-
- end_test(&f);
- config.tear_down_data(&f);
- cq_verifier_destroy(cqv);
+ GPR_ASSERT (GRPC_CALL_OK == grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)));
+ grpc_server_shutdown_and_notify (f.server, f.cq, tag (1000));
+ cq_expect_completion (cqv, tag (101), 0);
+ cq_expect_completion (cqv, tag (1000), 1);
+ cq_verify (cqv);
+ GPR_ASSERT (s == NULL);
+
+ grpc_server_destroy (f.server);
+
+ end_test (&f);
+ config.tear_down_data (&f);
+ cq_verifier_destroy (cqv);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_early_server_shutdown_finishes_tags(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_early_server_shutdown_finishes_tags (config);
}
diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c
index 14e0ac8f66..ea21827b3e 100644
--- a/test/core/end2end/tests/simple_delayed_request.c
+++ b/test/core/end2end/tests/simple_delayed_request.c
@@ -43,57 +43,76 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void simple_delayed_request_body(grpc_end2end_test_config config,
- grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args,
- long delay_us) {
+static void
+simple_delayed_request_body (grpc_end2end_test_config config, grpc_end2end_test_fixture * f, grpc_channel_args * client_args, grpc_channel_args * server_args, long delay_us)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f->cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f->cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -106,16 +125,15 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
size_t details_capacity = 0;
int was_cancelled = 2;
- config.init_client(f, client_args);
+ config.init_client (f, client_args);
- c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -140,17 +158,15 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
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_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL);
+ GPR_ASSERT (GRPC_CALL_OK == error);
- config.init_server(f, server_args);
+ 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));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -170,54 +186,60 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
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);
+ 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_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-static void test_simple_delayed_request_short(grpc_end2end_test_config config) {
+static void
+test_simple_delayed_request_short (grpc_end2end_test_config config)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", "test_simple_delayed_request_short", config.name);
- f = config.create_fixture(NULL, NULL);
- simple_delayed_request_body(config, &f, NULL, NULL, 100000);
- end_test(&f);
- config.tear_down_data(&f);
+ gpr_log (GPR_INFO, "%s/%s", "test_simple_delayed_request_short", config.name);
+ f = config.create_fixture (NULL, NULL);
+ simple_delayed_request_body (config, &f, NULL, NULL, 100000);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-static void test_simple_delayed_request_long(grpc_end2end_test_config config) {
+static void
+test_simple_delayed_request_long (grpc_end2end_test_config config)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", "test_simple_delayed_request_long", config.name);
- f = config.create_fixture(NULL, NULL);
+ gpr_log (GPR_INFO, "%s/%s", "test_simple_delayed_request_long", config.name);
+ f = config.create_fixture (NULL, NULL);
/* This timeout should be longer than a single retry */
- simple_delayed_request_body(config, &f, NULL, NULL, 1500000);
- end_test(&f);
- config.tear_down_data(&f);
+ simple_delayed_request_body (config, &f, NULL, NULL, 1500000);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
- test_simple_delayed_request_short(config);
- test_simple_delayed_request_long(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ GPR_ASSERT (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
+ test_simple_delayed_request_short (config);
+ test_simple_delayed_request_long (config);
}
diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c
index a874640837..76f0091298 100644
--- a/test/core/end2end/tests/simple_request.c
+++ b/test/core/end2end/tests/simple_request.c
@@ -45,65 +45,87 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
-static void simple_request_body(grpc_end2end_test_fixture f) {
+static void
+simple_request_body (grpc_end2end_test_fixture f)
+{
grpc_call *c;
grpc_call *s;
- gpr_timespec deadline = five_seconds_time();
- cq_verifier *cqv = cq_verifier_create(f.cq);
+ gpr_timespec deadline = five_seconds_time ();
+ cq_verifier *cqv = cq_verifier_create (f.cq);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -117,20 +139,18 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
int was_cancelled = 2;
char *peer;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr:1234", deadline,
- NULL);
- GPR_ASSERT(c);
+ c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, NULL);
+ GPR_ASSERT (c);
- peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
- gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
- gpr_free(peer);
+ peer = grpc_call_get_peer (c);
+ GPR_ASSERT (peer != NULL);
+ gpr_log (GPR_DEBUG, "client_peer_before_call=%s", peer);
+ gpr_free (peer);
- 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -155,24 +175,22 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
-
- peer = grpc_call_get_peer(s);
- GPR_ASSERT(peer != NULL);
- gpr_log(GPR_DEBUG, "server_peer=%s", peer);
- gpr_free(peer);
- peer = grpc_call_get_peer(c);
- GPR_ASSERT(peer != NULL);
- gpr_log(GPR_DEBUG, "client_peer=%s", peer);
- gpr_free(peer);
+ 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 (101));
+ GPR_ASSERT (GRPC_CALL_OK == error);
+ cq_expect_completion (cqv, tag (101), 1);
+ cq_verify (cqv);
+
+ peer = grpc_call_get_peer (s);
+ GPR_ASSERT (peer != NULL);
+ gpr_log (GPR_DEBUG, "server_peer=%s", peer);
+ gpr_free (peer);
+ peer = grpc_call_get_peer (c);
+ GPR_ASSERT (peer != NULL);
+ gpr_log (GPR_DEBUG, "client_peer=%s", peer);
+ gpr_free (peer);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -192,56 +210,63 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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);
+ 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_expect_completion(cqv, tag(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
- GPR_ASSERT(was_cancelled == 1);
+ GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234"));
+ GPR_ASSERT (was_cancelled == 1);
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
}
-static void test_invoke_simple_request(grpc_end2end_test_config config) {
+static void
+test_invoke_simple_request (grpc_end2end_test_config config)
+{
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
- simple_request_body(f);
- end_test(&f);
- config.tear_down_data(&f);
+ f = begin_test (config, "test_invoke_simple_request", NULL, NULL);
+ simple_request_body (f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-static void test_invoke_10_simple_requests(grpc_end2end_test_config config) {
+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);
- for (i = 0; i < 10; i++) {
- simple_request_body(f);
- gpr_log(GPR_INFO, "Passed simple request %d", i);
- }
- end_test(&f);
- config.tear_down_data(&f);
+ grpc_end2end_test_fixture f = begin_test (config, "test_invoke_10_simple_requests", NULL, NULL);
+ for (i = 0; i < 10; i++)
+ {
+ simple_request_body (f);
+ gpr_log (GPR_INFO, "Passed simple request %d", i);
+ }
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
int i;
- for (i = 0; i < 10; i++) {
- test_invoke_simple_request(config);
- }
- test_invoke_10_simple_requests(config);
+ for (i = 0; i < 10; i++)
+ {
+ test_invoke_simple_request (config);
+ }
+ test_invoke_10_simple_requests (config);
}
diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c
index c040b9fac1..28bcfadc8a 100644
--- a/test/core/end2end/tests/trailing_metadata.c
+++ b/test/core/end2end/tests/trailing_metadata.c
@@ -43,84 +43,105 @@
#include <grpc/support/useful.h>
#include "test/core/end2end/cq_verifier.h"
-enum { TIMEOUT = 200000 };
+enum
+{ TIMEOUT = 200000 };
-static void *tag(gpr_intptr t) { return (void *)t; }
+static void *
+tag (gpr_intptr t)
+{
+ return (void *) t;
+}
-static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
- const char *test_name,
- grpc_channel_args *client_args,
- grpc_channel_args *server_args) {
+static grpc_end2end_test_fixture
+begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args)
+{
grpc_end2end_test_fixture f;
- gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
- f = config.create_fixture(client_args, server_args);
- config.init_client(&f, client_args);
- config.init_server(&f, server_args);
+ gpr_log (GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture (client_args, server_args);
+ config.init_client (&f, client_args);
+ config.init_server (&f, server_args);
return f;
}
-static gpr_timespec n_seconds_time(int n) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+static gpr_timespec
+n_seconds_time (int n)
+{
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n);
}
-static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+static gpr_timespec
+five_seconds_time (void)
+{
+ return n_seconds_time (5);
+}
-static void drain_cq(grpc_completion_queue *cq) {
+static void
+drain_cq (grpc_completion_queue * cq)
+{
grpc_event ev;
- do {
- ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
- } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+ do
+ {
+ ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL);
+ }
+ while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
-static void shutdown_server(grpc_end2end_test_fixture *f) {
- 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)
- .type == GRPC_OP_COMPLETE);
- grpc_server_destroy(f->server);
+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).type == GRPC_OP_COMPLETE);
+ grpc_server_destroy (f->server);
f->server = NULL;
}
-static void shutdown_client(grpc_end2end_test_fixture *f) {
- if (!f->client) return;
- grpc_channel_destroy(f->client);
+static void
+shutdown_client (grpc_end2end_test_fixture * f)
+{
+ if (!f->client)
+ return;
+ grpc_channel_destroy (f->client);
f->client = NULL;
}
-static void end_test(grpc_end2end_test_fixture *f) {
- shutdown_server(f);
- shutdown_client(f);
+static void
+end_test (grpc_end2end_test_fixture * f)
+{
+ shutdown_server (f);
+ shutdown_client (f);
- grpc_completion_queue_shutdown(f->cq);
- drain_cq(f->cq);
- grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_shutdown (f->cq);
+ drain_cq (f->cq);
+ grpc_completion_queue_destroy (f->cq);
}
/* Request/response with metadata and payload.*/
-static void test_request_response_with_metadata_and_payload(
- grpc_end2end_test_config config) {
+static void
+test_request_response_with_metadata_and_payload (grpc_end2end_test_config config)
+{
grpc_call *c;
grpc_call *s;
- gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
- gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you");
- grpc_byte_buffer *request_payload =
- grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_byte_buffer *response_payload =
- grpc_raw_byte_buffer_create(&response_payload_slice, 1);
- gpr_timespec deadline = five_seconds_time();
+ gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world");
+ gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you");
+ grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1);
+ 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}}}};
+ {"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}}}};
+ {"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);
+ {"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);
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@@ -135,14 +156,13 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
+ 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);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -178,15 +198,13 @@ static void test_request_response_with_metadata_and_payload(
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_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(101));
- GPR_ASSERT(GRPC_CALL_OK == error);
- cq_expect_completion(cqv, tag(101), 1);
- cq_verify(cqv);
+ 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);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -200,11 +218,11 @@ static void test_request_response_with_metadata_and_payload(
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);
+ 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);
+ cq_expect_completion (cqv, tag (102), 1);
+ cq_verify (cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@@ -225,46 +243,48 @@ static void test_request_response_with_metadata_and_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);
+ 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(1), 1);
- cq_verify(cqv);
+ cq_expect_completion (cqv, tag (103), 1);
+ cq_expect_completion (cqv, tag (1), 1);
+ cq_verify (cqv);
- GPR_ASSERT(status == GRPC_STATUS_OK);
- GPR_ASSERT(0 == strcmp(details, "xyz"));
- GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
- GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
- GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world"));
- GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you"));
- GPR_ASSERT(contains_metadata(&request_metadata_recv, "key1", "val1"));
- GPR_ASSERT(contains_metadata(&request_metadata_recv, "key2", "val2"));
- GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key3", "val3"));
- GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key4", "val4"));
- GPR_ASSERT(contains_metadata(&trailing_metadata_recv, "key5", "val5"));
- GPR_ASSERT(contains_metadata(&trailing_metadata_recv, "key6", "val6"));
+ GPR_ASSERT (status == GRPC_STATUS_OK);
+ GPR_ASSERT (0 == strcmp (details, "xyz"));
+ GPR_ASSERT (0 == strcmp (call_details.method, "/foo"));
+ GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr"));
+ GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world"));
+ GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you"));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, "key1", "val1"));
+ GPR_ASSERT (contains_metadata (&request_metadata_recv, "key2", "val2"));
+ GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key3", "val3"));
+ GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key4", "val4"));
+ GPR_ASSERT (contains_metadata (&trailing_metadata_recv, "key5", "val5"));
+ GPR_ASSERT (contains_metadata (&trailing_metadata_recv, "key6", "val6"));
- 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);
+ 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);
+ grpc_call_destroy (c);
+ grpc_call_destroy (s);
- cq_verifier_destroy(cqv);
+ cq_verifier_destroy (cqv);
- 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);
+ 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);
- end_test(&f);
- config.tear_down_data(&f);
+ end_test (&f);
+ config.tear_down_data (&f);
}
-void grpc_end2end_tests(grpc_end2end_test_config config) {
- test_request_response_with_metadata_and_payload(config);
+void
+grpc_end2end_tests (grpc_end2end_test_config config)
+{
+ test_request_response_with_metadata_and_payload (config);
}