aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
Diffstat (limited to 'test/core')
-rw-r--r--test/core/channel/channel_stack_test.c11
-rw-r--r--test/core/channel/metadata_buffer_test.c2
-rw-r--r--test/core/echo/server.c69
-rw-r--r--test/core/end2end/fixtures/chttp2_fake_security.c3
-rw-r--r--test/core/end2end/fixtures/chttp2_fullstack.c3
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c3
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c6
-rw-r--r--test/core/end2end/fixtures/chttp2_socket_pair.c3
-rw-r--r--test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c3
-rw-r--r--test/core/end2end/tests/cancel_test_helpers.h3
-rw-r--r--test/core/end2end/tests/max_concurrent_streams.c2
-rw-r--r--test/core/end2end/tests/thread_stress.c4
-rw-r--r--test/core/fling/client.c3
-rw-r--r--test/core/iomgr/alarm_list_test.c14
-rw-r--r--test/core/iomgr/endpoint_tests.c4
-rw-r--r--test/core/iomgr/poll_kick_posix_test.c (renamed from test/core/iomgr/poll_kick_test.c)16
-rw-r--r--test/core/iomgr/resolve_address_test.c14
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c2
-rw-r--r--test/core/iomgr/tcp_posix_test.c3
-rw-r--r--test/core/security/secure_endpoint_test.c3
-rw-r--r--test/core/statistics/census_log_tests.c6
-rw-r--r--test/core/support/sync_test.c12
-rw-r--r--test/core/surface/completion_queue_benchmark.c14
-rw-r--r--test/core/surface/completion_queue_test.c20
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.c4
-rw-r--r--test/core/transport/chttp2/stream_map_test.c6
-rw-r--r--test/core/transport/chttp2_transport_end2end_test.c3
-rw-r--r--test/core/transport/transport_end2end_tests.c18
-rw-r--r--test/core/util/port_posix.c7
29 files changed, 150 insertions, 111 deletions
diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c
index d0ea79c34e..a400fb15bd 100644
--- a/test/core/channel/channel_stack_test.c
+++ b/test/core/channel/channel_stack_test.c
@@ -77,13 +77,10 @@ static void channel_func(grpc_channel_element *elem,
}
static void test_create_channel_stack(void) {
- const grpc_channel_filter filter = {
- call_func, channel_func,
-
- sizeof(int), call_init_func, call_destroy_func,
-
- sizeof(int), channel_init_func, channel_destroy_func,
- };
+ const grpc_channel_filter
+ filter = {call_func, channel_func, sizeof(int),
+ call_init_func, call_destroy_func, sizeof(int),
+ channel_init_func, channel_destroy_func, };
const grpc_channel_filter *filters = &filter;
grpc_channel_stack *channel_stack;
grpc_call_stack *call_stack;
diff --git a/test/core/channel/metadata_buffer_test.c b/test/core/channel/metadata_buffer_test.c
index d2bc30cc3c..9d7e1591f8 100644
--- a/test/core/channel/metadata_buffer_test.c
+++ b/test/core/channel/metadata_buffer_test.c
@@ -149,7 +149,7 @@ static void test_case(size_t key_prefix_len, size_t value_prefix_len,
op.flags = i;
op.data.metadata = grpc_mdelem_from_slices(mdctx, key, value);
op.done_cb = do_nothing;
- op.user_data = (void *)(gpr_uintptr) i;
+ op.user_data = (void *)(gpr_uintptr)i;
grpc_metadata_buffer_queue(&buffer, &op);
}
diff --git a/test/core/echo/server.c b/test/core/echo/server.c
index 57b083779c..6b67334248 100644
--- a/test/core/echo/server.c
+++ b/test/core/echo/server.c
@@ -32,6 +32,8 @@
*/
#include <grpc/grpc.h>
+#include <grpc/grpc_http.h>
+#include <grpc/grpc_security.h>
#include <signal.h>
#include <stdio.h>
@@ -42,10 +44,12 @@
#include "src/core/support/string.h"
#include "test/core/util/test_config.h"
#include <grpc/support/alloc.h>
+#include <grpc/support/cmdline.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "test/core/util/port.h"
+#include "test/core/end2end/data/ssl_test_data.h"
static grpc_completion_queue *cq;
static grpc_server *server;
@@ -83,29 +87,74 @@ static void sigint_handler(int x) { got_sigint = 1; }
int main(int argc, char **argv) {
grpc_event *ev;
- char *addr;
call_state *s;
+ char *addr_buf = NULL;
+ gpr_cmdline *cl;
int shutdown_started = 0;
int shutdown_finished = 0;
- grpc_test_init(argc, argv);
+ int secure = 0;
+ char *addr = NULL;
+
+ char *fake_argv[1];
+
+#define MAX_ARGS 4
+ grpc_arg arge[MAX_ARGS];
+ grpc_arg *e;
+ grpc_channel_args args = {0, NULL};
+
+ grpc_http_server_page home_page = {"/", "text/html",
+ "<head>\n"
+ "<title>Echo Server</title>\n"
+ "</head>\n"
+ "<body>\n"
+ "Welcome to the world of the future!\n"
+ "</body>\n"};
+
+ GPR_ASSERT(argc >= 1);
+ fake_argv[0] = argv[0];
+ grpc_test_init(1, fake_argv);
grpc_init();
srand(clock());
-
- if (argc == 2) {
- addr = gpr_strdup(argv[1]);
- } else {
- gpr_join_host_port(&addr, "::", grpc_pick_unused_port_or_die());
+ memset(arge, 0, sizeof(arge));
+ args.args = arge;
+
+ cl = gpr_cmdline_create("echo server");
+ gpr_cmdline_add_string(cl, "bind", "Bind host:port", &addr);
+ gpr_cmdline_add_flag(cl, "secure", "Run with security?", &secure);
+ gpr_cmdline_parse(cl, argc, argv);
+ gpr_cmdline_destroy(cl);
+
+ e = &arge[args.num_args++];
+ e->type = GRPC_ARG_POINTER;
+ e->key = GRPC_ARG_SERVE_OVER_HTTP;
+ e->value.pointer.p = &home_page;
+
+ if (addr == NULL) {
+ gpr_join_host_port(&addr_buf, "::", grpc_pick_unused_port_or_die());
+ addr = addr_buf;
}
gpr_log(GPR_INFO, "creating server on: %s", addr);
cq = grpc_completion_queue_create();
- server = grpc_server_create(cq, NULL);
- GPR_ASSERT(grpc_server_add_http2_port(server, addr));
- gpr_free(addr);
+ if (secure) {
+ grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
+ test_server1_cert};
+ grpc_server_credentials *ssl_creds =
+ grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1);
+ server = grpc_secure_server_create(ssl_creds, cq, &args);
+ GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr));
+ grpc_server_credentials_release(ssl_creds);
+ } else {
+ server = grpc_server_create(cq, &args);
+ GPR_ASSERT(grpc_server_add_http2_port(server, addr));
+ }
grpc_server_start(server);
+ gpr_free(addr_buf);
+ addr = addr_buf = NULL;
+
request_call();
signal(SIGINT, sigint_handler);
diff --git a/test/core/end2end/fixtures/chttp2_fake_security.c b/test/core/end2end/fixtures/chttp2_fake_security.c
index e170a55db5..38c3b22834 100644
--- a/test/core/end2end/fixtures/chttp2_fake_security.c
+++ b/test/core/end2end/fixtures/chttp2_fake_security.c
@@ -117,8 +117,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_create_fixture_secure_fullstack,
chttp2_init_client_fake_secure_fullstack,
chttp2_init_server_fake_secure_fullstack,
- chttp2_tear_down_secure_fullstack},
-};
+ chttp2_tear_down_secure_fullstack}, };
int main(int argc, char **argv) {
size_t i;
diff --git a/test/core/end2end/fixtures/chttp2_fullstack.c b/test/core/end2end/fixtures/chttp2_fullstack.c
index 86d5dd708b..82bf267ce5 100644
--- a/test/core/end2end/fixtures/chttp2_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_fullstack.c
@@ -99,8 +99,7 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
static grpc_end2end_test_config configs[] = {
{"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
- chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
-};
+ chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, };
int main(int argc, char **argv) {
size_t i;
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
index e5cdec8ea7..a70819e47e 100644
--- a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
@@ -125,8 +125,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_create_fixture_secure_fullstack,
chttp2_init_client_simple_ssl_secure_fullstack,
chttp2_init_server_simple_ssl_secure_fullstack,
- chttp2_tear_down_secure_fullstack},
-};
+ chttp2_tear_down_secure_fullstack}, };
int main(int argc, char **argv) {
size_t i;
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
index 8bfa465696..fb241cd460 100644
--- a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
@@ -99,7 +99,8 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(test_root_cert, NULL);
+ grpc_credentials *ssl_creds =
+ grpc_ssl_credentials_create(test_root_cert, NULL);
grpc_credentials *oauth2_creds =
grpc_fake_oauth2_credentials_create("Bearer aaslkfjs424535asdf", 1);
grpc_credentials *ssl_oauth2_creds =
@@ -132,8 +133,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_create_fixture_secure_fullstack,
chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack,
chttp2_init_server_simple_ssl_secure_fullstack,
- chttp2_tear_down_secure_fullstack},
-};
+ chttp2_tear_down_secure_fullstack}, };
int main(int argc, char **argv) {
size_t i;
diff --git a/test/core/end2end/fixtures/chttp2_socket_pair.c b/test/core/end2end/fixtures/chttp2_socket_pair.c
index cb5c6f7cad..b5b7cee85f 100644
--- a/test/core/end2end/fixtures/chttp2_socket_pair.c
+++ b/test/core/end2end/fixtures/chttp2_socket_pair.c
@@ -133,8 +133,7 @@ static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) {
static grpc_end2end_test_config configs[] = {
{"chttp2/socketpair", 0, chttp2_create_fixture_socketpair,
chttp2_init_client_socketpair, chttp2_init_server_socketpair,
- chttp2_tear_down_socketpair},
-};
+ chttp2_tear_down_socketpair}, };
int main(int argc, char **argv) {
size_t i;
diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
index 25121683c5..2de67913d7 100644
--- a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
+++ b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
@@ -133,8 +133,7 @@ static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) {
static grpc_end2end_test_config configs[] = {
{"chttp2/socketpair_one_byte_at_a_time", 0,
chttp2_create_fixture_socketpair, chttp2_init_client_socketpair,
- chttp2_init_server_socketpair, chttp2_tear_down_socketpair},
-};
+ chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, };
int main(int argc, char **argv) {
size_t i;
diff --git a/test/core/end2end/tests/cancel_test_helpers.h b/test/core/end2end/tests/cancel_test_helpers.h
index bc6bfa9424..35c81fa792 100644
--- a/test/core/end2end/tests/cancel_test_helpers.h
+++ b/test/core/end2end/tests/cancel_test_helpers.h
@@ -46,7 +46,6 @@ static grpc_call_error wait_for_deadline(grpc_call *call) {
static const cancellation_mode cancellation_modes[] = {
{grpc_call_cancel, GRPC_STATUS_CANCELLED, NULL},
- {wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, "Deadline Exceeded"},
-};
+ {wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, "Deadline Exceeded"}, };
#endif
diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c
index 20f124ee9f..a177a7b2f2 100644
--- a/test/core/end2end/tests/max_concurrent_streams.c
+++ b/test/core/end2end/tests/max_concurrent_streams.c
@@ -204,7 +204,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
/* 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) - 3;
+ live_call = ((int)(gpr_intptr)ev->tag) - 3;
grpc_event_finish(ev);
cq_expect_server_rpc_new(v_server, &s1, tag(100),
diff --git a/test/core/end2end/tests/thread_stress.c b/test/core/end2end/tests/thread_stress.c
index 6a3488e7dd..8fdb765951 100644
--- a/test/core/end2end/tests/thread_stress.c
+++ b/test/core/end2end/tests/thread_stress.c
@@ -278,11 +278,11 @@ static void run_test(grpc_end2end_test_config config, int requests_in_flight) {
/* kick off threads */
for (i = 0; i < CLIENT_THREADS; i++) {
gpr_event_init(&g_client_done[i]);
- gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr) i, NULL);
+ gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr)i, NULL);
}
for (i = 0; i < SERVER_THREADS; i++) {
gpr_event_init(&g_server_done[i]);
- gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr) i, NULL);
+ gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr)i, NULL);
}
/* start requests */
diff --git a/test/core/fling/client.c b/test/core/fling/client.c
index 7eb195811b..7947ffecc5 100644
--- a/test/core/fling/client.c
+++ b/test/core/fling/client.c
@@ -98,8 +98,7 @@ typedef struct {
static const scenario scenarios[] = {
{"ping-pong-request", init_ping_pong_request, step_ping_pong_request},
- {"ping-pong-stream", init_ping_pong_stream, step_ping_pong_stream},
-};
+ {"ping-pong-stream", init_ping_pong_stream, step_ping_pong_stream}, };
int main(int argc, char **argv) {
gpr_slice slice = gpr_slice_from_copied_string("x");
diff --git a/test/core/iomgr/alarm_list_test.c b/test/core/iomgr/alarm_list_test.c
index ce9b7f4c66..a250951231 100644
--- a/test/core/iomgr/alarm_list_test.c
+++ b/test/core/iomgr/alarm_list_test.c
@@ -61,13 +61,13 @@ static void add_test(void) {
/* 10 ms alarms. will expire in the current epoch */
for (i = 0; i < 10; i++) {
grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(10)),
- cb, (void *)(gpr_intptr) i, start);
+ cb, (void *)(gpr_intptr)i, start);
}
/* 1010 ms alarms. will expire in the next epoch */
for (i = 10; i < 20; i++) {
grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(1010)),
- cb, (void *)(gpr_intptr) i, start);
+ cb, (void *)(gpr_intptr)i, start);
}
/* collect alarms. Only the first batch should be ready. */
@@ -115,15 +115,15 @@ void destruction_test(void) {
memset(cb_called, 0, sizeof(cb_called));
grpc_alarm_init(&alarms[0], gpr_time_from_millis(100), cb,
- (void *)(gpr_intptr) 0, gpr_time_0);
+ (void *)(gpr_intptr)0, gpr_time_0);
grpc_alarm_init(&alarms[1], gpr_time_from_millis(3), cb,
- (void *)(gpr_intptr) 1, gpr_time_0);
+ (void *)(gpr_intptr)1, gpr_time_0);
grpc_alarm_init(&alarms[2], gpr_time_from_millis(100), cb,
- (void *)(gpr_intptr) 2, gpr_time_0);
+ (void *)(gpr_intptr)2, gpr_time_0);
grpc_alarm_init(&alarms[3], gpr_time_from_millis(3), cb,
- (void *)(gpr_intptr) 3, gpr_time_0);
+ (void *)(gpr_intptr)3, gpr_time_0);
grpc_alarm_init(&alarms[4], gpr_time_from_millis(1), cb,
- (void *)(gpr_intptr) 4, gpr_time_0);
+ (void *)(gpr_intptr)4, gpr_time_0);
GPR_ASSERT(1 == grpc_alarm_check(NULL, gpr_time_from_millis(2), NULL));
GPR_ASSERT(1 == cb_called[4][1]);
grpc_alarm_cancel(&alarms[0]);
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c
index dc5747bf57..125cde4678 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.c
@@ -290,7 +290,7 @@ static void shutdown_during_write_test_read_handler(
if (error != GRPC_ENDPOINT_CB_OK) {
grpc_endpoint_destroy(st->ep);
- gpr_event_set(&st->ev, (void *)(gpr_intptr) error);
+ gpr_event_set(&st->ev, (void *)(gpr_intptr)error);
} else {
grpc_endpoint_notify_on_read(
st->ep, shutdown_during_write_test_read_handler, user_data);
@@ -309,7 +309,7 @@ static void shutdown_during_write_test_write_handler(
gpr_log(GPR_ERROR,
"shutdown_during_write_test_write_handler completed unexpectedly");
}
- gpr_event_set(&st->ev, (void *)(gpr_intptr) 1);
+ gpr_event_set(&st->ev, (void *)(gpr_intptr)1);
}
static void shutdown_during_write_test(grpc_endpoint_test_config config,
diff --git a/test/core/iomgr/poll_kick_test.c b/test/core/iomgr/poll_kick_posix_test.c
index c30a7b9ee0..3c6d815c9d 100644
--- a/test/core/iomgr/poll_kick_test.c
+++ b/test/core/iomgr/poll_kick_posix_test.c
@@ -107,17 +107,23 @@ static void test_over_free(void) {
}
}
-int main(int argc, char **argv) {
- grpc_test_init(argc, argv);
-
- grpc_pollset_kick_global_init();
-
+static void run_tests(void) {
test_allocation();
test_basic_kick();
test_non_poll_kick();
test_non_kick();
test_over_free();
+}
+
+int main(int argc, char **argv) {
+ grpc_test_init(argc, argv);
+
+ grpc_pollset_kick_global_init();
+ run_tests();
+ grpc_pollset_kick_global_destroy();
+ grpc_pollset_kick_global_init_fallback_fd();
+ run_tests();
grpc_pollset_kick_global_destroy();
return 0;
}
diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c
index 319ee634d6..4cc101b6b0 100644
--- a/test/core/iomgr/resolve_address_test.c
+++ b/test/core/iomgr/resolve_address_test.c
@@ -83,9 +83,8 @@ static void test_ipv6_with_port(void) {
}
static void test_ipv6_without_port(void) {
- const char* const kCases[] = {
- "2001:db8::1", "2001:db8::1.2.3.4", "[2001:db8::1]",
- };
+ const char* const kCases[] = {"2001:db8::1", "2001:db8::1.2.3.4",
+ "[2001:db8::1]", };
int i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
gpr_event ev;
@@ -96,9 +95,7 @@ static void test_ipv6_without_port(void) {
}
static void test_invalid_ip_addresses(void) {
- const char* const kCases[] = {
- "293.283.1238.3:1", "[2001:db8::11111]:1",
- };
+ const char* const kCases[] = {"293.283.1238.3:1", "[2001:db8::11111]:1", };
int i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
gpr_event ev;
@@ -109,9 +106,8 @@ static void test_invalid_ip_addresses(void) {
}
static void test_unparseable_hostports(void) {
- const char* const kCases[] = {
- "[", "[::1", "[::1]bad", "[1.2.3.4]", "[localhost]", "[localhost]:1",
- };
+ const char* const kCases[] = {"[", "[::1", "[::1]bad",
+ "[1.2.3.4]", "[localhost]", "[localhost]:1", };
int i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
gpr_event ev;
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index f9212e7373..00b10f9364 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -140,7 +140,7 @@ void test_times_out(void) {
/* tie up the listen buffer, which is somewhat arbitrarily sized. */
for (i = 0; i < NUM_CLIENT_CONNECTS; ++i) {
client_fd[i] = socket(AF_INET, SOCK_STREAM, 0);
- grpc_set_socket_nonblocking(client_fd[i], 1);
+ grpc_set_socket_nonblocking(client_fd[i], 1);
do {
r = connect(client_fd[i], (struct sockaddr *)&addr, addr_len);
} while (r == -1 && errno == EINTR);
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index 182ccba3f6..24634b4700 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -484,8 +484,7 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
}
static grpc_endpoint_test_config configs[] = {
- {"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up},
-};
+ {"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up}, };
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c
index 0db15d48b4..5d875025ec 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.c
@@ -131,8 +131,7 @@ static grpc_endpoint_test_config configs[] = {
{"secure_ep/tcp_socketpair",
secure_endpoint_create_fixture_tcp_socketpair_noleftover, clean_up},
{"secure_ep/tcp_socketpair_leftover",
- secure_endpoint_create_fixture_tcp_socketpair_leftover, clean_up},
-};
+ secure_endpoint_create_fixture_tcp_socketpair_leftover, clean_up}, };
static void verify_leftover(void *user_data, gpr_slice *slices, size_t nslices,
grpc_endpoint_cb_status error) {
diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c
index 6a3c8adcc5..ca2d1dedb0 100644
--- a/test/core/statistics/census_log_tests.c
+++ b/test/core/statistics/census_log_tests.c
@@ -123,11 +123,11 @@ static void assert_log_empty(void) {
/* Given log size and record size, computes the minimum usable space. */
static gpr_int32 min_usable_space(size_t log_size, size_t record_size) {
gpr_int32 usable_space;
- gpr_int32 num_blocks = log_size / CENSUS_LOG_MAX_RECORD_SIZE;
+ gpr_int32 num_blocks = GPR_MAX(log_size / CENSUS_LOG_MAX_RECORD_SIZE,
+ gpr_cpu_num_cores());
gpr_int32 waste_per_block = CENSUS_LOG_MAX_RECORD_SIZE % record_size;
/* In the worst case, all except one core-local block is full. */
- gpr_int32 num_full_blocks = GPR_MAX(gpr_cpu_num_cores() - 2, 2);
- GPR_ASSERT(num_blocks >= num_full_blocks);
+ gpr_int32 num_full_blocks = num_blocks - 1;
usable_space = (gpr_int32)log_size -
(num_full_blocks * CENSUS_LOG_MAX_RECORD_SIZE) -
((num_blocks - num_full_blocks) * waste_per_block);
diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c
index 93f9c4cc8d..540d9d1c64 100644
--- a/test/core/support/sync_test.c
+++ b/test/core/support/sync_test.c
@@ -53,12 +53,12 @@ typedef struct queue {
gpr_cv non_empty; /* Signalled when length becomes non-zero. */
gpr_cv non_full; /* Signalled when length becomes non-N. */
gpr_mu mu; /* Protects all fields below.
- (That is, except during initialization or
- destruction, the fields below should be accessed
- only by a thread that holds mu.) */
- int head; /* Index of head of queue 0..N-1. */
- int length; /* Number of valid elements in queue 0..N. */
- int elem[N]; /* elem[head .. head+length-1] are queue elements. */
+ (That is, except during initialization or
+ destruction, the fields below should be accessed
+ only by a thread that holds mu.) */
+ int head; /* Index of head of queue 0..N-1. */
+ int length; /* Number of valid elements in queue 0..N. */
+ int elem[N]; /* elem[head .. head+length-1] are queue elements. */
} queue;
/* Initialize *q. */
diff --git a/test/core/surface/completion_queue_benchmark.c b/test/core/surface/completion_queue_benchmark.c
index 5360d7c6c3..e1b9d0d035 100644
--- a/test/core/surface/completion_queue_benchmark.c
+++ b/test/core/surface/completion_queue_benchmark.c
@@ -53,23 +53,23 @@ static void producer_thread(void *arg) {
test_thread_options *opt = arg;
int i;
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future));
for (i = 0; i < opt->iterations; i++) {
grpc_cq_begin_op(opt->cc, NULL, GRPC_WRITE_ACCEPTED);
- grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL,
- NULL, GRPC_OP_OK);
+ grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL,
+ GRPC_OP_OK);
}
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
}
static void consumer_thread(void *arg) {
test_thread_options *opt = arg;
grpc_event *ev;
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future));
for (;;) {
@@ -78,7 +78,7 @@ static void consumer_thread(void *arg) {
case GRPC_WRITE_ACCEPTED:
break;
case GRPC_QUEUE_SHUTDOWN:
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
return;
default:
gpr_log(GPR_ERROR, "Invalid event received: %d", ev->type);
@@ -112,7 +112,7 @@ double ops_per_second(int consumers, int producers, int iterations) {
/* start the benchmark */
t_start = gpr_now();
- gpr_event_set(&start, (void *)(gpr_intptr) 1);
+ gpr_event_set(&start, (void *)(gpr_intptr)1);
/* wait for producers to finish */
for (i = 0; i < producers; i++) {
diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c
index 4bbe9cc96f..71f9cc2291 100644
--- a/test/core/surface/completion_queue_test.c
+++ b/test/core/surface/completion_queue_test.c
@@ -282,7 +282,7 @@ static void producer_thread(void *arg) {
int i;
gpr_log(GPR_INFO, "producer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
@@ -291,18 +291,18 @@ static void producer_thread(void *arg) {
}
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL,
- NULL, GRPC_OP_OK);
+ grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL,
+ GRPC_OP_OK);
opt->events_triggered++;
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
}
static void consumer_thread(void *arg) {
@@ -310,13 +310,13 @@ static void consumer_thread(void *arg) {
grpc_event *ev;
gpr_log(GPR_INFO, "consumer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 1", opt->id);
gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 2", opt->id);
@@ -331,7 +331,7 @@ static void consumer_thread(void *arg) {
break;
case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
grpc_event_finish(ev);
return;
default:
@@ -376,7 +376,7 @@ static void test_threading(int producers, int consumers) {
/* start phase1: producers will pre-declare all operations they will
complete */
gpr_log(GPR_INFO, "start phase 1");
- gpr_event_set(&phase1, (void *)(gpr_intptr) 1);
+ gpr_event_set(&phase1, (void *)(gpr_intptr)1);
gpr_log(GPR_INFO, "wait phase 1");
for (i = 0; i < producers + consumers; i++) {
@@ -386,7 +386,7 @@ static void test_threading(int producers, int consumers) {
/* start phase2: operations will complete, and consumers will consume them */
gpr_log(GPR_INFO, "start phase 2");
- gpr_event_set(&phase2, (void *)(gpr_intptr) 1);
+ gpr_event_set(&phase2, (void *)(gpr_intptr)1);
/* in parallel, we shutdown the completion channel - all events should still
be consumed */
diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c
index 12f8b35ada..3be6c366f5 100644
--- a/test/core/transport/chttp2/hpack_parser_test.c
+++ b/test/core/transport/chttp2/hpack_parser_test.c
@@ -42,7 +42,9 @@
#include "test/core/util/slice_splitter.h"
#include "test/core/util/test_config.h"
-typedef struct { va_list args; } test_checker;
+typedef struct {
+ va_list args;
+} test_checker;
static void onhdr(void *ud, grpc_mdelem *md) {
const char *ekey, *evalue;
diff --git a/test/core/transport/chttp2/stream_map_test.c b/test/core/transport/chttp2/stream_map_test.c
index 30cd63ca67..9b4446f7f8 100644
--- a/test/core/transport/chttp2/stream_map_test.c
+++ b/test/core/transport/chttp2/stream_map_test.c
@@ -93,7 +93,7 @@ static void test_basic_add_find(size_t n) {
grpc_chttp2_stream_map_init(&map, 8);
GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map));
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i);
+ grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i);
}
GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map));
GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0));
@@ -148,7 +148,7 @@ static void test_delete_evens_sweep(size_t n) {
grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i);
+ grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i);
}
for (i = 1; i <= n; i++) {
if ((i & 1) == 0) {
@@ -170,7 +170,7 @@ static void test_delete_evens_incremental(size_t n) {
grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i);
+ grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i);
if ((i & 1) == 0) {
grpc_chttp2_stream_map_delete(&map, i);
}
diff --git a/test/core/transport/chttp2_transport_end2end_test.c b/test/core/transport/chttp2_transport_end2end_test.c
index 8b0f9aa25b..34e3aeba38 100644
--- a/test/core/transport/chttp2_transport_end2end_test.c
+++ b/test/core/transport/chttp2_transport_end2end_test.c
@@ -100,8 +100,7 @@ grpc_transport_test_config fixture_configs[] = {
{"chttp2_on_socketpair/medium",
create_http2_transport_for_test_medium_slices},
{"chttp2_on_socketpair/large",
- create_http2_transport_for_test_large_slices},
-};
+ create_http2_transport_for_test_large_slices}, };
/* Driver function: run the test suite for each test configuration */
int main(int argc, char **argv) {
diff --git a/test/core/transport/transport_end2end_tests.c b/test/core/transport/transport_end2end_tests.c
index 8e9b4a2cc9..25276c0fca 100644
--- a/test/core/transport/transport_end2end_tests.c
+++ b/test/core/transport/transport_end2end_tests.c
@@ -63,7 +63,9 @@ static int g_pending_ops;
typedef struct test_fixture test_fixture;
/* User data passed to the transport and handed to each callback */
-typedef struct test_user_data { test_fixture *fixture; } test_user_data;
+typedef struct test_user_data {
+ test_fixture *fixture;
+} test_user_data;
/* A message we expect to receive (forms a singly linked list with next) */
typedef struct expected_message {
@@ -129,7 +131,7 @@ static void expect_metadata(test_stream *s, int from_client, const char *key,
/* Convert some number of seconds into a gpr_timespec that many seconds in the
future */
static gpr_timespec deadline_from_seconds(double deadline_seconds) {
- return gpr_time_add(gpr_now(),
+ return gpr_time_add(gpr_now(),
gpr_time_from_micros((long)(deadline_seconds * 1e6)));
}
@@ -589,10 +591,9 @@ static void begin_test(test_fixture *f, grpc_transport_test_config *config,
f->client_transport = NULL;
f->server_transport = NULL;
- GPR_ASSERT(0 ==
- config->create_transport(setup_client_transport, f,
- setup_server_transport, f,
- g_metadata_context));
+ GPR_ASSERT(0 == config->create_transport(setup_client_transport, f,
+ setup_server_transport, f,
+ g_metadata_context));
gpr_mu_lock(&f->mu);
while (!f->client_transport || !f->server_transport) {
@@ -908,9 +909,8 @@ static void test_ping(grpc_transport_test_config *config) {
* Test driver
*/
-static const size_t interesting_message_lengths[] = {
- 1, 100, 10000, 100000, 1000000,
-};
+static const size_t interesting_message_lengths[] = {1, 100, 10000,
+ 100000, 1000000, };
void grpc_transport_end2end_tests(grpc_transport_test_config *config) {
int i;
diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c
index 52008895dc..067ca0fafa 100644
--- a/test/core/util/port_posix.c
+++ b/test/core/util/port_posix.c
@@ -113,12 +113,11 @@ int grpc_pick_unused_port(void) {
/* Type of port to first pick in next iteration */
int is_tcp = 1;
- int try
- = 0;
+ int try = 0;
for (;;) {
- int port = try
- < NUM_RANDOM_PORTS_TO_PICK ? rand() % (65536 - 30000) + 30000 : 0;
+ int port =
+ try < NUM_RANDOM_PORTS_TO_PICK ? rand() % (65536 - 30000) + 30000 : 0;
if (!is_port_available(&port, is_tcp)) {
continue;
}