aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/surface
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/surface')
-rw-r--r--test/core/surface/BUILD48
-rw-r--r--test/core/surface/alarm_test.cc (renamed from test/core/surface/alarm_test.c)54
-rw-r--r--test/core/surface/byte_buffer_reader_test.cc (renamed from test/core/surface/byte_buffer_reader_test.c)26
-rw-r--r--test/core/surface/channel_create_test.cc (renamed from test/core/surface/channel_create_test.c)10
-rw-r--r--test/core/surface/completion_queue_test.cc (renamed from test/core/surface/completion_queue_test.c)165
-rw-r--r--test/core/surface/completion_queue_threading_test.cc (renamed from test/core/surface/completion_queue_threading_test.c)93
-rw-r--r--test/core/surface/concurrent_connectivity_test.cc (renamed from test/core/surface/concurrent_connectivity_test.c)88
-rw-r--r--test/core/surface/init_test.cc (renamed from test/core/surface/init_test.c)2
-rw-r--r--test/core/surface/invalid_channel_args_test.cc (renamed from test/core/surface/invalid_channel_args_test.c)48
-rw-r--r--test/core/surface/lame_client_test.cc (renamed from test/core/surface/lame_client_test.c)53
-rw-r--r--test/core/surface/num_external_connectivity_watchers_test.cc (renamed from test/core/surface/num_external_connectivity_watchers_test.c)85
-rw-r--r--test/core/surface/public_headers_must_be_c89.c287
-rw-r--r--test/core/surface/secure_channel_create_test.cc (renamed from test/core/surface/secure_channel_create_test.c)24
-rw-r--r--test/core/surface/sequential_connectivity_test.cc (renamed from test/core/surface/sequential_connectivity_test.c)93
-rw-r--r--test/core/surface/server_chttp2_test.cc (renamed from test/core/surface/server_chttp2_test.c)22
-rw-r--r--test/core/surface/server_test.cc (renamed from test/core/surface/server_test.c)95
16 files changed, 791 insertions, 402 deletions
diff --git a/test/core/surface/BUILD b/test/core/surface/BUILD
index 17db7737f7..6cec7feabc 100644
--- a/test/core/surface/BUILD
+++ b/test/core/surface/BUILD
@@ -20,8 +20,8 @@ grpc_package(name = "test/core/surface")
grpc_cc_test(
name = "alarm_test",
- srcs = ["alarm_test.c"],
- language = "C",
+ srcs = ["alarm_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -32,8 +32,8 @@ grpc_cc_test(
grpc_cc_test(
name = "grpc_byte_buffer_reader_test",
- srcs = ["byte_buffer_reader_test.c"],
- language = "C",
+ srcs = ["byte_buffer_reader_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -44,8 +44,8 @@ grpc_cc_test(
grpc_cc_test(
name = "channel_create_test",
- srcs = ["channel_create_test.c"],
- language = "C",
+ srcs = ["channel_create_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -56,8 +56,8 @@ grpc_cc_test(
grpc_cc_test(
name = "grpc_completion_queue_test",
- srcs = ["completion_queue_test.c"],
- language = "C",
+ srcs = ["completion_queue_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -68,8 +68,8 @@ grpc_cc_test(
grpc_cc_test(
name = "concurrent_connectivity_test",
- srcs = ["concurrent_connectivity_test.c"],
- language = "C",
+ srcs = ["concurrent_connectivity_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -80,8 +80,8 @@ grpc_cc_test(
grpc_cc_test(
name = "init_test",
- srcs = ["init_test.c"],
- language = "C",
+ srcs = ["init_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -92,8 +92,8 @@ grpc_cc_test(
grpc_cc_test(
name = "grpc_invalid_channel_args_test",
- srcs = ["invalid_channel_args_test.c"],
- language = "C",
+ srcs = ["invalid_channel_args_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -104,8 +104,8 @@ grpc_cc_test(
grpc_cc_test(
name = "lame_client_test",
- srcs = ["lame_client_test.c"],
- language = "C",
+ srcs = ["lame_client_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -129,8 +129,8 @@ grpc_cc_test(
grpc_cc_test(
name = "secure_channel_create_test",
- srcs = ["secure_channel_create_test.c"],
- language = "C",
+ srcs = ["secure_channel_create_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -141,8 +141,8 @@ grpc_cc_test(
grpc_cc_test(
name = "sequential_connectivity_test",
- srcs = ["sequential_connectivity_test.c"],
- language = "C",
+ srcs = ["sequential_connectivity_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -154,8 +154,8 @@ grpc_cc_test(
grpc_cc_test(
name = "server_chttp2_test",
- srcs = ["server_chttp2_test.c"],
- language = "C",
+ srcs = ["server_chttp2_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
@@ -166,8 +166,8 @@ grpc_cc_test(
grpc_cc_test(
name = "server_test",
- srcs = ["server_test.c"],
- language = "C",
+ srcs = ["server_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/surface/alarm_test.c b/test/core/surface/alarm_test.cc
index 4fd7cb93c6..8950603b41 100644
--- a/test/core/surface/alarm_test.c
+++ b/test/core/surface/alarm_test.cc
@@ -25,78 +25,82 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
-static void *create_test_tag(void) {
+static void* create_test_tag(void) {
static intptr_t i = 0;
- return (void *)(++i);
+ return (void*)(++i);
}
/* helper for tests to shutdown correctly and tersely */
-static void shutdown_and_destroy(grpc_completion_queue *cc) {
+static void shutdown_and_destroy(grpc_completion_queue* cc) {
grpc_event ev;
grpc_completion_queue_shutdown(cc);
- ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ ev =
+ grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
static void test_alarm(void) {
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
LOG_TEST("test_alarm");
- cc = grpc_completion_queue_create_for_next(NULL);
+ cc = grpc_completion_queue_create_for_next(nullptr);
{
/* regular expiry */
grpc_event ev;
- void *tag = create_test_tag();
- grpc_alarm *alarm = grpc_alarm_create(NULL);
- grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(1), tag, NULL);
+ void* tag = create_test_tag();
+ grpc_alarm* alarm = grpc_alarm_create(nullptr);
+ grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(1), tag,
+ nullptr);
ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(2),
- NULL);
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag);
GPR_ASSERT(ev.success);
- grpc_alarm_destroy(alarm, NULL);
+ grpc_alarm_destroy(alarm, nullptr);
}
{
/* cancellation */
grpc_event ev;
- void *tag = create_test_tag();
- grpc_alarm *alarm = grpc_alarm_create(NULL);
- grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag, NULL);
+ void* tag = create_test_tag();
+ grpc_alarm* alarm = grpc_alarm_create(nullptr);
+ grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag,
+ nullptr);
- grpc_alarm_cancel(alarm, NULL);
+ grpc_alarm_cancel(alarm, nullptr);
ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(1),
- NULL);
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag);
GPR_ASSERT(ev.success == 0);
- grpc_alarm_destroy(alarm, NULL);
+ grpc_alarm_destroy(alarm, nullptr);
}
{
/* alarm_destroy before cq_next */
grpc_event ev;
- void *tag = create_test_tag();
- grpc_alarm *alarm = grpc_alarm_create(NULL);
- grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag, NULL);
+ void* tag = create_test_tag();
+ grpc_alarm* alarm = grpc_alarm_create(nullptr);
+ grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag,
+ nullptr);
- grpc_alarm_destroy(alarm, NULL);
+ grpc_alarm_destroy(alarm, nullptr);
ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(1),
- NULL);
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag);
GPR_ASSERT(ev.success == 0);
}
{
/* alarm_destroy before set */
- grpc_alarm *alarm = grpc_alarm_create(NULL);
- grpc_alarm_destroy(alarm, NULL);
+ grpc_alarm* alarm = grpc_alarm_create(nullptr);
+ grpc_alarm_destroy(alarm, nullptr);
}
shutdown_and_destroy(cc);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_alarm();
diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.cc
index a6b4c86abc..e5d2d7c78d 100644
--- a/test/core/surface/byte_buffer_reader_test.c
+++ b/test/core/surface/byte_buffer_reader_test.cc
@@ -36,7 +36,7 @@
static void test_read_one_slice(void) {
grpc_slice slice;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice first_slice, second_slice;
int first_code, second_code;
@@ -58,7 +58,7 @@ static void test_read_one_slice(void) {
static void test_read_one_slice_malloc(void) {
grpc_slice slice;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice first_slice, second_slice;
int first_code, second_code;
@@ -81,7 +81,7 @@ static void test_read_one_slice_malloc(void) {
static void test_read_none_compressed_slice(void) {
grpc_slice slice;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice first_slice, second_slice;
int first_code, second_code;
@@ -103,7 +103,7 @@ static void test_read_none_compressed_slice(void) {
static void test_read_corrupted_slice(void) {
grpc_slice slice;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
LOG_TEST("test_read_corrupted_slice");
@@ -120,7 +120,7 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
grpc_slice input_slice;
grpc_slice_buffer sliceb_in;
grpc_slice_buffer sliceb_out;
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice read_slice;
size_t read_count = 0;
@@ -195,10 +195,10 @@ static void test_byte_buffer_from_reader(void) {
}
static void test_readall(void) {
- char *lotsa_as[512];
- char *lotsa_bs[1024];
+ char* lotsa_as[512];
+ char* lotsa_bs[1024];
grpc_slice slices[2];
- grpc_byte_buffer *buffer;
+ grpc_byte_buffer* buffer;
grpc_byte_buffer_reader reader;
grpc_slice slice_out;
@@ -229,11 +229,11 @@ static void test_readall(void) {
}
static void test_byte_buffer_copy(void) {
- char *lotsa_as[512];
- char *lotsa_bs[1024];
+ char* lotsa_as[512];
+ char* lotsa_bs[1024];
grpc_slice slices[2];
- grpc_byte_buffer *buffer;
- grpc_byte_buffer *copied_buffer;
+ grpc_byte_buffer* buffer;
+ grpc_byte_buffer* copied_buffer;
grpc_byte_buffer_reader reader;
grpc_slice slice_out;
@@ -265,7 +265,7 @@ static void test_byte_buffer_copy(void) {
grpc_byte_buffer_destroy(copied_buffer);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_read_one_slice();
test_read_one_slice_malloc();
diff --git a/test/core/surface/channel_create_test.c b/test/core/surface/channel_create_test.cc
index a6884750e7..f358b0fc8d 100644
--- a/test/core/surface/channel_create_test.c
+++ b/test/core/surface/channel_create_test.cc
@@ -27,16 +27,16 @@
#include "test/core/util/test_config.h"
void test_unknown_scheme_target(void) {
- grpc_channel *chan;
+ grpc_channel* chan;
/* avoid default prefix */
grpc_resolver_registry_shutdown();
grpc_resolver_registry_init();
- chan = grpc_insecure_channel_create("blah://blah", NULL, NULL);
- GPR_ASSERT(chan != NULL);
+ chan = grpc_insecure_channel_create("blah://blah", nullptr, nullptr);
+ GPR_ASSERT(chan != nullptr);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_element *elem =
+ grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
grpc_exec_ctx_finish(&exec_ctx);
@@ -44,7 +44,7 @@ void test_unknown_scheme_target(void) {
grpc_channel_destroy(chan);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_unknown_scheme_target();
diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.cc
index e6372a379c..c6e13d2386 100644
--- a/test/core/surface/completion_queue_test.c
+++ b/test/core/surface/completion_queue_test.cc
@@ -27,25 +27,25 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
-static void *create_test_tag(void) {
+static void* create_test_tag(void) {
static intptr_t i = 0;
- return (void *)(++i);
+ return (void*)(++i);
}
/* helper for tests to shutdown correctly and tersely */
-static void shutdown_and_destroy(grpc_completion_queue *cc) {
+static void shutdown_and_destroy(grpc_completion_queue* cc) {
grpc_event ev;
grpc_completion_queue_shutdown(cc);
switch (grpc_get_cq_completion_type(cc)) {
case GRPC_CQ_NEXT: {
ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
- NULL);
+ nullptr);
break;
}
case GRPC_CQ_PLUCK: {
- ev = grpc_completion_queue_pluck(cc, create_test_tag(),
- gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_pluck(
+ cc, create_test_tag(), gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
break;
}
default: {
@@ -72,7 +72,7 @@ static void test_no_op(void) {
attr.cq_completion_type = completion_types[i];
attr.cq_polling_type = polling_types[j];
shutdown_and_destroy(grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL));
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr));
}
}
}
@@ -81,7 +81,7 @@ static void test_pollset_conversion(void) {
grpc_cq_completion_type completion_types[] = {GRPC_CQ_NEXT, GRPC_CQ_PLUCK};
grpc_cq_polling_type polling_types[] = {GRPC_CQ_DEFAULT_POLLING,
GRPC_CQ_NON_LISTENING};
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
grpc_completion_queue_attributes attr;
LOG_TEST("test_pollset_conversion");
@@ -92,8 +92,8 @@ static void test_pollset_conversion(void) {
attr.cq_completion_type = completion_types[i];
attr.cq_polling_type = polling_types[j];
cq = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
- GPR_ASSERT(grpc_cq_pollset(cq) != NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
+ GPR_ASSERT(grpc_cq_pollset(cq) != nullptr);
shutdown_and_destroy(cq);
}
}
@@ -102,7 +102,7 @@ static void test_pollset_conversion(void) {
static void test_wait_empty(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_completion_queue_attributes attr;
grpc_event event;
@@ -113,26 +113,27 @@ static void test_wait_empty(void) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
- event = grpc_completion_queue_next(cc, gpr_now(GPR_CLOCK_REALTIME), NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
+ event =
+ grpc_completion_queue_next(cc, gpr_now(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT);
shutdown_and_destroy(cc);
}
}
-static void do_nothing_end_completion(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_cq_completion *c) {}
+static void do_nothing_end_completion(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_cq_completion* c) {}
static void test_cq_end_op(void) {
grpc_event ev;
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_cq_completion completion;
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_exec_ctx exec_ctx;
- void *tag = create_test_tag();
+ void* tag = create_test_tag();
LOG_TEST("test_cq_end_op");
@@ -142,13 +143,14 @@ static void test_cq_end_op(void) {
exec_ctx = init_exec_ctx; // Reset exec_ctx
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
GPR_ASSERT(grpc_cq_begin_op(cc, tag));
grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE,
- do_nothing_end_completion, NULL, &completion);
+ do_nothing_end_completion, nullptr, &completion);
- ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == tag);
GPR_ASSERT(ev.success);
@@ -158,10 +160,86 @@ static void test_cq_end_op(void) {
}
}
+static void test_cq_tls_cache_full(void) {
+ grpc_event ev;
+ grpc_completion_queue* cc;
+ grpc_cq_completion completion;
+ grpc_cq_polling_type polling_types[] = {
+ GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
+ grpc_completion_queue_attributes attr;
+ grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_exec_ctx exec_ctx;
+ void* tag = create_test_tag();
+ void* res_tag;
+ int ok;
+
+ LOG_TEST("test_cq_tls_cache_full");
+
+ attr.version = 1;
+ attr.cq_completion_type = GRPC_CQ_NEXT;
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
+ exec_ctx = init_exec_ctx; // Reset exec_ctx
+ attr.cq_polling_type = polling_types[i];
+ cc = grpc_completion_queue_create(
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
+
+ grpc_completion_queue_thread_local_cache_init(cc);
+ GPR_ASSERT(grpc_cq_begin_op(cc, tag));
+ grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE,
+ do_nothing_end_completion, nullptr, &completion);
+
+ ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
+
+ GPR_ASSERT(
+ grpc_completion_queue_thread_local_cache_flush(cc, &res_tag, &ok) == 1);
+ GPR_ASSERT(res_tag == tag);
+ GPR_ASSERT(ok);
+
+ ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
+
+ shutdown_and_destroy(cc);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+}
+
+static void test_cq_tls_cache_empty(void) {
+ grpc_completion_queue* cc;
+ grpc_cq_polling_type polling_types[] = {
+ GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
+ grpc_completion_queue_attributes attr;
+ grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_exec_ctx exec_ctx;
+ void* res_tag;
+ int ok;
+
+ LOG_TEST("test_cq_tls_cache_empty");
+
+ attr.version = 1;
+ attr.cq_completion_type = GRPC_CQ_NEXT;
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
+ exec_ctx = init_exec_ctx; // Reset exec_ctx
+ attr.cq_polling_type = polling_types[i];
+ cc = grpc_completion_queue_create(
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
+
+ GPR_ASSERT(
+ grpc_completion_queue_thread_local_cache_flush(cc, &res_tag, &ok) == 0);
+ grpc_completion_queue_thread_local_cache_init(cc);
+ GPR_ASSERT(
+ grpc_completion_queue_thread_local_cache_flush(cc, &res_tag, &ok) == 0);
+ shutdown_and_destroy(cc);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+}
+
static void test_shutdown_then_next_polling(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_completion_queue_attributes attr;
grpc_event event;
LOG_TEST("test_shutdown_then_next_polling");
@@ -171,10 +249,10 @@ static void test_shutdown_then_next_polling(void) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
grpc_completion_queue_shutdown(cc);
- event =
- grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ event = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
@@ -183,7 +261,7 @@ static void test_shutdown_then_next_polling(void) {
static void test_shutdown_then_next_with_timeout(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_completion_queue_attributes attr;
grpc_event event;
LOG_TEST("test_shutdown_then_next_with_timeout");
@@ -193,11 +271,11 @@ static void test_shutdown_then_next_with_timeout(void) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
grpc_completion_queue_shutdown(cc);
event = grpc_completion_queue_next(cc, gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL);
+ nullptr);
GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
@@ -205,8 +283,8 @@ static void test_shutdown_then_next_with_timeout(void) {
static void test_pluck(void) {
grpc_event ev;
- grpc_completion_queue *cc;
- void *tags[128];
+ grpc_completion_queue* cc;
+ void* tags[128];
grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)];
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
@@ -230,29 +308,30 @@ static void test_pluck(void) {
exec_ctx = init_exec_ctx; // reset exec_ctx
attr.cq_polling_type = polling_types[pidx];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE,
- do_nothing_end_completion, NULL, &completions[i]);
+ do_nothing_end_completion, nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
- ev = grpc_completion_queue_pluck(cc, tags[i],
- gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_pluck(
+ cc, tags[i], gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.tag == tags[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE,
- do_nothing_end_completion, NULL, &completions[i]);
+ do_nothing_end_completion, nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
ev = grpc_completion_queue_pluck(cc, tags[GPR_ARRAY_SIZE(tags) - i - 1],
- gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
GPR_ASSERT(ev.tag == tags[GPR_ARRAY_SIZE(tags) - i - 1]);
}
@@ -265,7 +344,7 @@ static void test_pluck_after_shutdown(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_event ev;
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
grpc_completion_queue_attributes attr;
LOG_TEST("test_pluck_after_shutdown");
@@ -275,21 +354,21 @@ static void test_pluck_after_shutdown(void) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
- grpc_completion_queue_factory_lookup(&attr), &attr, NULL);
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
grpc_completion_queue_shutdown(cc);
- ev = grpc_completion_queue_pluck(cc, NULL,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_pluck(
+ cc, nullptr, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
}
struct thread_state {
- grpc_completion_queue *cc;
- void *tag;
+ grpc_completion_queue* cc;
+ void* tag;
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_no_op();
@@ -300,6 +379,8 @@ int main(int argc, char **argv) {
test_cq_end_op();
test_pluck();
test_pluck_after_shutdown();
+ test_cq_tls_cache_full();
+ test_cq_tls_cache_empty();
grpc_shutdown();
return 0;
}
diff --git a/test/core/surface/completion_queue_threading_test.c b/test/core/surface/completion_queue_threading_test.cc
index 9996b6b840..af54e00c4a 100644
--- a/test/core/surface/completion_queue_threading_test.c
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -28,25 +28,25 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
-static void *create_test_tag(void) {
+static void* create_test_tag(void) {
static intptr_t i = 0;
- return (void *)(++i);
+ return (void*)(++i);
}
/* helper for tests to shutdown correctly and tersely */
-static void shutdown_and_destroy(grpc_completion_queue *cc) {
+static void shutdown_and_destroy(grpc_completion_queue* cc) {
grpc_event ev;
grpc_completion_queue_shutdown(cc);
switch (grpc_get_cq_completion_type(cc)) {
case GRPC_CQ_NEXT: {
ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
- NULL);
+ nullptr);
break;
}
case GRPC_CQ_PLUCK: {
- ev = grpc_completion_queue_pluck(cc, create_test_tag(),
- gpr_inf_past(GPR_CLOCK_REALTIME), NULL);
+ ev = grpc_completion_queue_pluck(
+ cc, create_test_tag(), gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
break;
}
default: {
@@ -59,24 +59,24 @@ static void shutdown_and_destroy(grpc_completion_queue *cc) {
grpc_completion_queue_destroy(cc);
}
-static void do_nothing_end_completion(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_cq_completion *c) {}
+static void do_nothing_end_completion(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_cq_completion* c) {}
struct thread_state {
- grpc_completion_queue *cc;
- void *tag;
+ grpc_completion_queue* cc;
+ void* tag;
};
-static void pluck_one(void *arg) {
- struct thread_state *state = arg;
+static void pluck_one(void* arg) {
+ struct thread_state* state = static_cast<struct thread_state*>(arg);
grpc_completion_queue_pluck(state->cc, state->tag,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
}
static void test_too_many_plucks(void) {
grpc_event ev;
- grpc_completion_queue *cc;
- void *tags[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS];
+ grpc_completion_queue* cc;
+ void* tags[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS];
grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)];
gpr_thd_id thread_ids[GPR_ARRAY_SIZE(tags)];
struct thread_state thread_states[GPR_ARRAY_SIZE(tags)];
@@ -86,7 +86,7 @@ static void test_too_many_plucks(void) {
LOG_TEST("test_too_many_plucks");
- cc = grpc_completion_queue_create_for_pluck(NULL);
+ cc = grpc_completion_queue_create_for_pluck(nullptr);
gpr_thd_options_set_joinable(&thread_options);
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -103,13 +103,13 @@ static void test_too_many_plucks(void) {
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1000));
ev = grpc_completion_queue_pluck(cc, create_test_tag(),
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE,
- do_nothing_end_completion, NULL, &completions[i]);
+ do_nothing_end_completion, nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -124,74 +124,75 @@ static void test_too_many_plucks(void) {
typedef struct test_thread_options {
gpr_event on_started;
- gpr_event *phase1;
+ gpr_event* phase1;
gpr_event on_phase1_done;
- gpr_event *phase2;
+ gpr_event* phase2;
gpr_event on_finished;
size_t events_triggered;
int id;
- grpc_completion_queue *cc;
+ grpc_completion_queue* cc;
} test_thread_options;
gpr_timespec ten_seconds_time(void) {
return grpc_timeout_seconds_to_deadline(10);
}
-static void free_completion(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_cq_completion *completion) {
+static void free_completion(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_cq_completion* completion) {
gpr_free(completion);
}
-static void producer_thread(void *arg) {
- test_thread_options *opt = arg;
+static void producer_thread(void* arg) {
+ test_thread_options* opt = static_cast<test_thread_options*>(arg);
int i;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_INFO, "producer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- GPR_ASSERT(grpc_cq_begin_op(opt->cc, (void *)(intptr_t)1));
+ GPR_ASSERT(grpc_cq_begin_op(opt->cc, (void*)(intptr_t)1));
}
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- grpc_cq_end_op(&exec_ctx, opt->cc, (void *)(intptr_t)1, GRPC_ERROR_NONE,
- free_completion, NULL,
- gpr_malloc(sizeof(grpc_cq_completion)));
+ grpc_cq_end_op(&exec_ctx, opt->cc, (void*)(intptr_t)1, GRPC_ERROR_NONE,
+ free_completion, nullptr,
+ static_cast<grpc_cq_completion*>(
+ gpr_malloc(sizeof(grpc_cq_completion))));
opt->events_triggered++;
grpc_exec_ctx_finish(&exec_ctx);
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
grpc_exec_ctx_finish(&exec_ctx);
}
-static void consumer_thread(void *arg) {
- test_thread_options *opt = arg;
+static void consumer_thread(void* arg) {
+ test_thread_options* opt = static_cast<test_thread_options*>(arg);
grpc_event ev;
gpr_log(GPR_INFO, "consumer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 1", opt->id);
gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 2", opt->id);
for (;;) {
- ev = grpc_completion_queue_next(opt->cc,
- gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
+ ev = grpc_completion_queue_next(
+ opt->cc, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
switch (ev.type) {
case GRPC_OP_COMPLETE:
GPR_ASSERT(ev.success);
@@ -199,7 +200,7 @@ static void consumer_thread(void *arg) {
break;
case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(intptr_t)1);
+ gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
return;
case GRPC_QUEUE_TIMEOUT:
gpr_log(GPR_ERROR, "Invalid timeout received");
@@ -209,11 +210,11 @@ static void consumer_thread(void *arg) {
}
static void test_threading(size_t producers, size_t consumers) {
- test_thread_options *options =
- gpr_malloc((producers + consumers) * sizeof(test_thread_options));
+ test_thread_options* options = static_cast<test_thread_options*>(
+ gpr_malloc((producers + consumers) * sizeof(test_thread_options)));
gpr_event phase1 = GPR_EVENT_INIT;
gpr_event phase2 = GPR_EVENT_INIT;
- grpc_completion_queue *cc = grpc_completion_queue_create_for_next(NULL);
+ grpc_completion_queue* cc = grpc_completion_queue_create_for_next(nullptr);
size_t i;
size_t total_consumed = 0;
static int optid = 101;
@@ -234,14 +235,14 @@ static void test_threading(size_t producers, size_t consumers) {
options[i].id = optid++;
GPR_ASSERT(gpr_thd_new(&id,
i < producers ? producer_thread : consumer_thread,
- options + i, NULL));
+ options + i, nullptr));
gpr_event_wait(&options[i].on_started, ten_seconds_time());
}
/* start phase1: producers will pre-declare all operations they will
complete */
gpr_log(GPR_INFO, "start phase 1");
- gpr_event_set(&phase1, (void *)(intptr_t)1);
+ gpr_event_set(&phase1, (void*)(intptr_t)1);
gpr_log(GPR_INFO, "wait phase 1");
for (i = 0; i < producers + consumers; i++) {
@@ -251,7 +252,7 @@ static void test_threading(size_t producers, size_t consumers) {
/* start phase2: operations will complete, and consumers will consume them */
gpr_log(GPR_INFO, "start phase 2");
- gpr_event_set(&phase2, (void *)(intptr_t)1);
+ gpr_event_set(&phase2, (void*)(intptr_t)1);
/* in parallel, we shutdown the completion channel - all events should still
be consumed */
@@ -280,7 +281,7 @@ static void test_threading(size_t producers, size_t consumers) {
gpr_free(options);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_too_many_plucks();
diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.cc
index 3595885ff6..8fa15ab331 100644
--- a/test/core/surface/concurrent_connectivity_test.c
+++ b/test/core/surface/concurrent_connectivity_test.cc
@@ -54,23 +54,25 @@
// end after the shorter delay_millis
#define POLL_MILLIS_SHORT_TIMEOUTS 30000
-static void *tag(int n) { return (void *)(uintptr_t)n; }
-static int detag(void *p) { return (int)(uintptr_t)p; }
+static void* tag(int n) { return (void*)(uintptr_t)n; }
+static int detag(void* p) { return (int)(uintptr_t)p; }
-void create_loop_destroy(void *addr) {
+void create_loop_destroy(void* addr) {
for (int i = 0; i < NUM_OUTER_LOOPS; ++i) {
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_channel* chan =
+ grpc_insecure_channel_create((char*)addr, nullptr, nullptr);
for (int j = 0; j < NUM_INNER_LOOPS; ++j) {
gpr_timespec later_time =
grpc_timeout_milliseconds_to_deadline(DELAY_MILLIS);
grpc_connectivity_state state =
grpc_channel_check_connectivity_state(chan, 1);
- grpc_channel_watch_connectivity_state(chan, state, later_time, cq, NULL);
+ grpc_channel_watch_connectivity_state(chan, state, later_time, cq,
+ nullptr);
gpr_timespec poll_time =
grpc_timeout_milliseconds_to_deadline(POLL_MILLIS);
- GPR_ASSERT(grpc_completion_queue_next(cq, poll_time, NULL).type ==
+ GPR_ASSERT(grpc_completion_queue_next(cq, poll_time, nullptr).type ==
GRPC_OP_COMPLETE);
/* check that the watcher from "watch state" was free'd */
GPR_ASSERT(grpc_channel_num_external_connectivity_watchers(chan) == 0);
@@ -81,47 +83,47 @@ void create_loop_destroy(void *addr) {
}
struct server_thread_args {
- char *addr;
- grpc_server *server;
- grpc_completion_queue *cq;
- grpc_pollset *pollset;
- gpr_mu *mu;
+ char* addr;
+ grpc_server* server;
+ grpc_completion_queue* cq;
+ grpc_pollset* pollset;
+ gpr_mu* mu;
gpr_event ready;
gpr_atm stop;
};
-void server_thread(void *vargs) {
- struct server_thread_args *args = (struct server_thread_args *)vargs;
+void server_thread(void* vargs) {
+ struct server_thread_args* args = (struct server_thread_args*)vargs;
grpc_event ev;
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
- ev = grpc_completion_queue_next(args->cq, deadline, NULL);
+ ev = grpc_completion_queue_next(args->cq, deadline, nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(detag(ev.tag) == 0xd1e);
}
-static void on_connect(grpc_exec_ctx *exec_ctx, void *vargs, grpc_endpoint *tcp,
- grpc_pollset *accepting_pollset,
- grpc_tcp_server_acceptor *acceptor) {
+static void on_connect(grpc_exec_ctx* exec_ctx, void* vargs, grpc_endpoint* tcp,
+ grpc_pollset* accepting_pollset,
+ grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
- struct server_thread_args *args = (struct server_thread_args *)vargs;
+ struct server_thread_args* args = (struct server_thread_args*)vargs;
grpc_endpoint_shutdown(exec_ctx, tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
grpc_endpoint_destroy(exec_ctx, tcp);
gpr_mu_lock(args->mu);
GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, NULL));
+ grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
-void bad_server_thread(void *vargs) {
- struct server_thread_args *args = (struct server_thread_args *)vargs;
+void bad_server_thread(void* vargs) {
+ struct server_thread_args* args = (struct server_thread_args*)vargs;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_resolved_address resolved_addr;
- struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr;
+ struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
int port;
- grpc_tcp_server *s;
- grpc_error *error = grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s);
+ grpc_tcp_server* s;
+ grpc_error* error = grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s);
GPR_ASSERT(error == GRPC_ERROR_NONE);
memset(&resolved_addr, 0, sizeof(resolved_addr));
addr->ss_family = AF_INET;
@@ -131,13 +133,13 @@ void bad_server_thread(void *vargs) {
gpr_asprintf(&args->addr, "localhost:%d", port);
grpc_tcp_server_start(&exec_ctx, s, &args->pollset, 1, on_connect, args);
- gpr_event_set(&args->ready, (void *)1);
+ gpr_event_set(&args->ready, (void*)1);
gpr_mu_lock(args->mu);
while (gpr_atm_acq_load(&args->stop) == 0) {
grpc_millis deadline = grpc_exec_ctx_now(&exec_ctx) + 100;
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker, deadline))) {
@@ -156,9 +158,9 @@ void bad_server_thread(void *vargs) {
gpr_free(args->addr);
}
-static void done_pollset_shutdown(grpc_exec_ctx *exec_ctx, void *pollset,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, pollset);
+static void done_pollset_shutdown(grpc_exec_ctx* exec_ctx, void* pollset,
+ grpc_error* error) {
+ grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(pollset));
gpr_free(pollset);
}
@@ -171,7 +173,7 @@ int run_concurrent_connectivity_test() {
gpr_thd_id threads[NUM_THREADS];
gpr_thd_id server;
- char *localhost = gpr_strdup("localhost:54321");
+ char* localhost = gpr_strdup("localhost:54321");
gpr_thd_options options = gpr_thd_options_default();
gpr_thd_options_set_joinable(&options);
@@ -189,10 +191,10 @@ int run_concurrent_connectivity_test() {
gpr_log(GPR_DEBUG, "Wave 2");
int port = grpc_pick_unused_port_or_die();
gpr_asprintf(&args.addr, "localhost:%d", port);
- args.server = grpc_server_create(NULL, NULL);
+ args.server = grpc_server_create(nullptr, nullptr);
grpc_server_add_insecure_http2_port(args.server, args.addr);
- args.cq = grpc_completion_queue_create_for_next(NULL);
- grpc_server_register_completion_queue(args.server, args.cq, NULL);
+ args.cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_server_register_completion_queue(args.server, args.cq, nullptr);
grpc_server_start(args.server);
gpr_thd_new(&server, server_thread, &args, &options);
@@ -211,7 +213,7 @@ int run_concurrent_connectivity_test() {
/* Third round, bogus tcp server */
gpr_log(GPR_DEBUG, "Wave 3");
- args.pollset = gpr_zalloc(grpc_pollset_size());
+ args.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(args.pollset, &args.mu);
gpr_event_init(&args.ready);
gpr_thd_new(&server, bad_server_thread, &args, &options);
@@ -236,10 +238,11 @@ int run_concurrent_connectivity_test() {
return 0;
}
-void watches_with_short_timeouts(void *addr) {
+void watches_with_short_timeouts(void* addr) {
for (int i = 0; i < NUM_OUTER_LOOPS_SHORT_TIMEOUTS; ++i) {
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_channel* chan =
+ grpc_insecure_channel_create((char*)addr, nullptr, nullptr);
for (int j = 0; j < NUM_INNER_LOOPS_SHORT_TIMEOUTS; ++j) {
gpr_timespec later_time =
@@ -247,10 +250,11 @@ void watches_with_short_timeouts(void *addr) {
grpc_connectivity_state state =
grpc_channel_check_connectivity_state(chan, 0);
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
- grpc_channel_watch_connectivity_state(chan, state, later_time, cq, NULL);
+ grpc_channel_watch_connectivity_state(chan, state, later_time, cq,
+ nullptr);
gpr_timespec poll_time =
grpc_timeout_milliseconds_to_deadline(POLL_MILLIS_SHORT_TIMEOUTS);
- grpc_event ev = grpc_completion_queue_next(cq, poll_time, NULL);
+ grpc_event ev = grpc_completion_queue_next(cq, poll_time, nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.success == false);
/* check that the watcher from "watch state" was free'd */
@@ -269,7 +273,7 @@ int run_concurrent_watches_with_short_timeouts_test() {
gpr_thd_id threads[NUM_THREADS];
- char *localhost = gpr_strdup("localhost:54321");
+ char* localhost = gpr_strdup("localhost:54321");
gpr_thd_options options = gpr_thd_options_default();
gpr_thd_options_set_joinable(&options);
@@ -285,7 +289,7 @@ int run_concurrent_watches_with_short_timeouts_test() {
return 0;
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
run_concurrent_connectivity_test();
diff --git a/test/core/surface/init_test.c b/test/core/surface/init_test.cc
index b835a2a884..5749bc8b36 100644
--- a/test/core/surface/init_test.c
+++ b/test/core/surface/init_test.cc
@@ -59,7 +59,7 @@ static void test_repeatedly() {
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test(1);
test(2);
diff --git a/test/core/surface/invalid_channel_args_test.c b/test/core/surface/invalid_channel_args_test.cc
index 9c84c30f03..7c5f1f0352 100644
--- a/test/core/surface/invalid_channel_args_test.c
+++ b/test/core/surface/invalid_channel_args_test.cc
@@ -24,10 +24,10 @@
#include <grpc/support/string_util.h>
#include "test/core/util/test_config.h"
-static char *g_last_log_error_message = NULL;
-static const char *g_file_name = "channel.cc";
+static char* g_last_log_error_message = nullptr;
+static const char* g_file_name = "channel.cc";
-static int ends_with(const char *src, const char *suffix) {
+static int ends_with(const char* src, const char* suffix) {
size_t src_len = strlen(src);
size_t suffix_len = strlen(suffix);
if (src_len < suffix_len) {
@@ -36,46 +36,46 @@ static int ends_with(const char *src, const char *suffix) {
return strcmp(src + src_len - suffix_len, suffix) == 0;
}
-static void log_error_sink(gpr_log_func_args *args) {
+static void log_error_sink(gpr_log_func_args* args) {
if (args->severity == GPR_LOG_SEVERITY_ERROR &&
ends_with(args->file, g_file_name)) {
g_last_log_error_message = gpr_strdup(args->message);
}
}
-static void verify_last_error(const char *message) {
- if (message == NULL) {
- GPR_ASSERT(g_last_log_error_message == NULL);
+static void verify_last_error(const char* message) {
+ if (message == nullptr) {
+ GPR_ASSERT(g_last_log_error_message == nullptr);
return;
}
GPR_ASSERT(strcmp(message, g_last_log_error_message) == 0);
gpr_free(g_last_log_error_message);
- g_last_log_error_message = NULL;
+ g_last_log_error_message = nullptr;
}
-static char *compose_error_string(const char *key, const char *message) {
- char *ret;
+static char* compose_error_string(const char* key, const char* message) {
+ char* ret;
gpr_asprintf(&ret, "%s%s", key, message);
return ret;
}
-static void one_test(grpc_channel_args *args, char *expected_error_message) {
- grpc_channel *chan =
- grpc_insecure_channel_create("nonexistant:54321", args, NULL);
+static void one_test(grpc_channel_args* args, char* expected_error_message) {
+ grpc_channel* chan =
+ grpc_insecure_channel_create("nonexistant:54321", args, nullptr);
verify_last_error(expected_error_message);
gpr_free(expected_error_message);
grpc_channel_destroy(chan);
}
-static void test_no_error_message(void) { one_test(NULL, NULL); }
+static void test_no_error_message(void) { one_test(nullptr, nullptr); }
static void test_default_authority_type(void) {
grpc_arg client_arg;
grpc_channel_args client_args;
- char *expected_error_message;
+ char* expected_error_message;
client_arg.type = GRPC_ARG_INTEGER;
- client_arg.key = GRPC_ARG_DEFAULT_AUTHORITY;
+ client_arg.key = const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY);
client_arg.value.integer = 0;
client_args.num_args = 1;
@@ -88,10 +88,10 @@ static void test_default_authority_type(void) {
static void test_ssl_name_override_type(void) {
grpc_arg client_arg;
grpc_channel_args client_args;
- char *expected_error_message;
+ char* expected_error_message;
client_arg.type = GRPC_ARG_INTEGER;
- client_arg.key = GRPC_SSL_TARGET_NAME_OVERRIDE_ARG;
+ client_arg.key = const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
client_arg.value.integer = 0;
client_args.num_args = 1;
@@ -104,14 +104,14 @@ static void test_ssl_name_override_type(void) {
static void test_ssl_name_override_failed(void) {
grpc_arg client_arg[2];
grpc_channel_args client_args;
- char *expected_error_message;
+ char* expected_error_message;
client_arg[0].type = GRPC_ARG_STRING;
- client_arg[0].key = GRPC_ARG_DEFAULT_AUTHORITY;
- client_arg[0].value.string = "default";
+ client_arg[0].key = const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY);
+ client_arg[0].value.string = const_cast<char*>("default");
client_arg[1].type = GRPC_ARG_STRING;
- client_arg[1].key = GRPC_SSL_TARGET_NAME_OVERRIDE_ARG;
- client_arg[1].value.string = "ssl";
+ client_arg[1].key = const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
+ client_arg[1].value.string = const_cast<char*>("ssl");
client_args.num_args = 2;
client_args.args = client_arg;
@@ -121,7 +121,7 @@ static void test_ssl_name_override_failed(void) {
one_test(&client_args, expected_error_message);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
gpr_set_log_function(log_error_sink);
diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.cc
index f623e1a743..f3df7f35a7 100644
--- a/test/core/surface/lame_client_test.c
+++ b/test/core/surface/lame_client_test.cc
@@ -30,53 +30,53 @@
grpc_closure transport_op_cb;
-static void *tag(intptr_t x) { return (void *)x; }
+static void* tag(intptr_t x) { return (void*)x; }
-void verify_connectivity(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_connectivity_state *state = arg;
+void verify_connectivity(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_connectivity_state* state = static_cast<grpc_connectivity_state*>(arg);
GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN == *state);
GPR_ASSERT(error == GRPC_ERROR_NONE);
}
-void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
+void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
-void test_transport_op(grpc_channel *channel) {
- grpc_transport_op *op;
- grpc_channel_element *elem;
+void test_transport_op(grpc_channel* channel) {
+ grpc_transport_op* op;
+ grpc_channel_element* elem;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GRPC_CLOSURE_INIT(&transport_op_cb, verify_connectivity, &state,
grpc_schedule_on_exec_ctx);
- op = grpc_make_transport_op(NULL);
+ op = grpc_make_transport_op(nullptr);
op->on_connectivity_state_change = &transport_op_cb;
op->connectivity_state = &state;
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
elem->filter->start_transport_op(&exec_ctx, elem, op);
grpc_exec_ctx_finish(&exec_ctx);
- GRPC_CLOSURE_INIT(&transport_op_cb, do_nothing, NULL,
+ GRPC_CLOSURE_INIT(&transport_op_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
op = grpc_make_transport_op(&transport_op_cb);
elem->filter->start_transport_op(&exec_ctx, elem, op);
grpc_exec_ctx_finish(&exec_ctx);
}
-int main(int argc, char **argv) {
- grpc_channel *chan;
- grpc_call *call;
- grpc_completion_queue *cq;
- cq_verifier *cqv;
+int main(int argc, char** argv) {
+ grpc_channel* chan;
+ grpc_call* call;
+ grpc_completion_queue* cq;
+ cq_verifier* cqv;
grpc_op ops[6];
- grpc_op *op;
+ grpc_op* op;
grpc_metadata_array initial_metadata_recv;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
grpc_call_error error;
grpc_slice details;
- char *peer;
+ char* peer;
grpc_test_init(argc, argv);
grpc_init();
@@ -93,12 +93,13 @@ int main(int argc, char **argv) {
GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN ==
grpc_channel_check_connectivity_state(chan, 0));
- cq = grpc_completion_queue_create_for_next(NULL);
+ cq = grpc_completion_queue_create_for_next(nullptr);
grpc_slice host = grpc_slice_from_static_string("anywhere");
- call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
- grpc_slice_from_static_string("/Foo"), &host,
- grpc_timeout_seconds_to_deadline(100), NULL);
+ call =
+ grpc_channel_create_call(chan, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
+ grpc_slice_from_static_string("/Foo"), &host,
+ grpc_timeout_seconds_to_deadline(100), nullptr);
GPR_ASSERT(call);
cqv = cq_verifier_create(cq);
@@ -107,14 +108,14 @@ int main(int argc, char **argv) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), NULL);
+ error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */
@@ -128,9 +129,9 @@ int main(int argc, char **argv) {
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(2), NULL);
+ error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */
diff --git a/test/core/surface/num_external_connectivity_watchers_test.c b/test/core/surface/num_external_connectivity_watchers_test.cc
index 16401bb7ac..f78d333673 100644
--- a/test/core/surface/num_external_connectivity_watchers_test.c
+++ b/test/core/surface/num_external_connectivity_watchers_test.cc
@@ -30,28 +30,28 @@
#include "test/core/util/test_config.h"
typedef struct test_fixture {
- const char *name;
- grpc_channel *(*create_channel)(const char *addr);
+ const char* name;
+ grpc_channel* (*create_channel)(const char* addr);
} test_fixture;
static size_t next_tag = 1;
-static void channel_idle_start_watch(grpc_channel *channel,
- grpc_completion_queue *cq) {
+static void channel_idle_start_watch(grpc_channel* channel,
+ grpc_completion_queue* cq) {
gpr_timespec connect_deadline = grpc_timeout_milliseconds_to_deadline(1);
GPR_ASSERT(grpc_channel_check_connectivity_state(channel, 0) ==
GRPC_CHANNEL_IDLE);
grpc_channel_watch_connectivity_state(
- channel, GRPC_CHANNEL_IDLE, connect_deadline, cq, (void *)(next_tag++));
+ channel, GRPC_CHANNEL_IDLE, connect_deadline, cq, (void*)(next_tag++));
gpr_log(GPR_DEBUG, "number of active connect watchers: %d",
grpc_channel_num_external_connectivity_watchers(channel));
}
-static void channel_idle_poll_for_timeout(grpc_channel *channel,
- grpc_completion_queue *cq) {
- grpc_event ev =
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+static void channel_idle_poll_for_timeout(grpc_channel* channel,
+ grpc_completion_queue* cq) {
+ grpc_event ev = grpc_completion_queue_next(
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
/* expect watch_connectivity_state to end with a timeout */
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
@@ -63,17 +63,17 @@ static void channel_idle_poll_for_timeout(grpc_channel *channel,
/* Test and use the "num_external_watchers" call to make sure
* that "connectivity watcher" structs are free'd just after, if
* their corresponding timeouts occur. */
-static void run_timeouts_test(const test_fixture *fixture) {
+static void run_timeouts_test(const test_fixture* fixture) {
gpr_log(GPR_INFO, "TEST: %s", fixture->name);
- char *addr;
+ char* addr;
grpc_init();
gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die());
- grpc_channel *channel = fixture->create_channel(addr);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_channel* channel = fixture->create_channel(addr);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
/* start 1 watcher and then let it time out */
channel_idle_start_watch(channel, cq);
@@ -105,9 +105,9 @@ static void run_timeouts_test(const test_fixture *fixture) {
grpc_channel_destroy(channel);
grpc_completion_queue_shutdown(cq);
- GPR_ASSERT(
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
- .type == GRPC_QUEUE_SHUTDOWN);
+ GPR_ASSERT(grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr)
+ .type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cq);
grpc_shutdown();
@@ -117,17 +117,17 @@ static void run_timeouts_test(const test_fixture *fixture) {
/* An edge scenario; sets channel state to explicitly, and outside
* of a polling call. */
static void run_channel_shutdown_before_timeout_test(
- const test_fixture *fixture) {
+ const test_fixture* fixture) {
gpr_log(GPR_INFO, "TEST: %s", fixture->name);
- char *addr;
+ char* addr;
grpc_init();
gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die());
- grpc_channel *channel = fixture->create_channel(addr);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ grpc_channel* channel = fixture->create_channel(addr);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
/* start 1 watcher and then shut down the channel before the timer goes off */
GPR_ASSERT(grpc_channel_num_external_connectivity_watchers(channel) == 0);
@@ -138,43 +138,45 @@ static void run_channel_shutdown_before_timeout_test(
GRPC_CHANNEL_IDLE);
grpc_channel_watch_connectivity_state(channel, GRPC_CHANNEL_IDLE,
- connect_deadline, cq, (void *)1);
+ connect_deadline, cq, (void*)1);
grpc_channel_destroy(channel);
- grpc_event ev =
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_event ev = grpc_completion_queue_next(
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
/* expect success with a state transition to CHANNEL_SHUTDOWN */
GPR_ASSERT(ev.success == true);
grpc_completion_queue_shutdown(cq);
- GPR_ASSERT(
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
- .type == GRPC_QUEUE_SHUTDOWN);
+ GPR_ASSERT(grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr)
+ .type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cq);
grpc_shutdown();
gpr_free(addr);
}
-static grpc_channel *insecure_test_create_channel(const char *addr) {
- return grpc_insecure_channel_create(addr, NULL, NULL);
+static grpc_channel* insecure_test_create_channel(const char* addr) {
+ return grpc_insecure_channel_create(addr, nullptr, nullptr);
}
static const test_fixture insecure_test = {
- "insecure", insecure_test_create_channel,
+ "insecure",
+ insecure_test_create_channel,
};
-static grpc_channel *secure_test_create_channel(const char *addr) {
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, NULL, NULL);
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
- grpc_channel_args *new_client_args =
- grpc_channel_args_copy_and_add(NULL, &ssl_name_override, 1);
- grpc_channel *channel =
- grpc_secure_channel_create(ssl_creds, addr, new_client_args, NULL);
+static grpc_channel* secure_test_create_channel(const char* addr) {
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
+ grpc_channel_args* new_client_args =
+ grpc_channel_args_copy_and_add(nullptr, &ssl_name_override, 1);
+ grpc_channel* channel =
+ grpc_secure_channel_create(ssl_creds, addr, new_client_args, nullptr);
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args_destroy(&exec_ctx, new_client_args);
@@ -185,10 +187,11 @@ static grpc_channel *secure_test_create_channel(const char *addr) {
}
static const test_fixture secure_test = {
- "secure", secure_test_create_channel,
+ "secure",
+ secure_test_create_channel,
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
run_timeouts_test(&insecure_test);
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index d36d116afb..b5a83c8eed 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -63,4 +63,289 @@
#include <grpc/support/useful.h>
#include <grpc/support/workaround_list.h>
-int main(int argc, char **argv) { return 0; }
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ printf("%lx", (unsigned long) grpc_compression_algorithm_parse);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_name);
+ printf("%lx", (unsigned long) grpc_stream_compression_algorithm_name);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_for_level);
+ printf("%lx", (unsigned long) grpc_stream_compression_algorithm_for_level);
+ printf("%lx", (unsigned long) grpc_compression_options_init);
+ printf("%lx", (unsigned long) grpc_compression_options_enable_algorithm);
+ printf("%lx", (unsigned long) grpc_compression_options_disable_algorithm);
+ printf("%lx", (unsigned long) grpc_compression_options_is_algorithm_enabled);
+ printf("%lx", (unsigned long) grpc_compression_options_is_stream_compression_algorithm_enabled);
+ printf("%lx", (unsigned long) grpc_metadata_array_init);
+ printf("%lx", (unsigned long) grpc_metadata_array_destroy);
+ printf("%lx", (unsigned long) grpc_call_details_init);
+ printf("%lx", (unsigned long) grpc_call_details_destroy);
+ printf("%lx", (unsigned long) grpc_register_plugin);
+ printf("%lx", (unsigned long) grpc_init);
+ printf("%lx", (unsigned long) grpc_shutdown);
+ printf("%lx", (unsigned long) grpc_version_string);
+ printf("%lx", (unsigned long) grpc_g_stands_for);
+ printf("%lx", (unsigned long) grpc_completion_queue_factory_lookup);
+ printf("%lx", (unsigned long) grpc_completion_queue_create_for_next);
+ printf("%lx", (unsigned long) grpc_completion_queue_create_for_pluck);
+ printf("%lx", (unsigned long) grpc_completion_queue_create);
+ printf("%lx", (unsigned long) grpc_completion_queue_next);
+ printf("%lx", (unsigned long) grpc_completion_queue_pluck);
+ printf("%lx", (unsigned long) grpc_completion_queue_shutdown);
+ printf("%lx", (unsigned long) grpc_completion_queue_destroy);
+ printf("%lx", (unsigned long) grpc_completion_queue_thread_local_cache_init);
+ printf("%lx", (unsigned long) grpc_completion_queue_thread_local_cache_flush);
+ printf("%lx", (unsigned long) grpc_alarm_create);
+ printf("%lx", (unsigned long) grpc_alarm_set);
+ printf("%lx", (unsigned long) grpc_alarm_cancel);
+ printf("%lx", (unsigned long) grpc_alarm_destroy);
+ printf("%lx", (unsigned long) grpc_channel_check_connectivity_state);
+ printf("%lx", (unsigned long) grpc_channel_num_external_connectivity_watchers);
+ printf("%lx", (unsigned long) grpc_channel_watch_connectivity_state);
+ printf("%lx", (unsigned long) grpc_channel_support_connectivity_watcher);
+ printf("%lx", (unsigned long) grpc_channel_create_call);
+ printf("%lx", (unsigned long) grpc_channel_ping);
+ printf("%lx", (unsigned long) grpc_channel_register_call);
+ printf("%lx", (unsigned long) grpc_channel_create_registered_call);
+ printf("%lx", (unsigned long) grpc_call_arena_alloc);
+ printf("%lx", (unsigned long) grpc_call_start_batch);
+ printf("%lx", (unsigned long) grpc_call_get_peer);
+ printf("%lx", (unsigned long) grpc_census_call_set_context);
+ printf("%lx", (unsigned long) grpc_census_call_get_context);
+ printf("%lx", (unsigned long) grpc_channel_get_target);
+ printf("%lx", (unsigned long) grpc_channel_get_info);
+ printf("%lx", (unsigned long) grpc_insecure_channel_create);
+ printf("%lx", (unsigned long) grpc_lame_client_channel_create);
+ printf("%lx", (unsigned long) grpc_channel_destroy);
+ printf("%lx", (unsigned long) grpc_call_cancel);
+ printf("%lx", (unsigned long) grpc_call_cancel_with_status);
+ printf("%lx", (unsigned long) grpc_call_ref);
+ printf("%lx", (unsigned long) grpc_call_unref);
+ printf("%lx", (unsigned long) grpc_server_request_call);
+ printf("%lx", (unsigned long) grpc_server_register_method);
+ printf("%lx", (unsigned long) grpc_server_request_registered_call);
+ printf("%lx", (unsigned long) grpc_server_create);
+ printf("%lx", (unsigned long) grpc_server_register_completion_queue);
+ printf("%lx", (unsigned long) grpc_server_add_insecure_http2_port);
+ printf("%lx", (unsigned long) grpc_server_start);
+ printf("%lx", (unsigned long) grpc_server_shutdown_and_notify);
+ printf("%lx", (unsigned long) grpc_server_cancel_all_calls);
+ printf("%lx", (unsigned long) grpc_server_destroy);
+ printf("%lx", (unsigned long) grpc_tracer_set_enabled);
+ printf("%lx", (unsigned long) grpc_header_key_is_legal);
+ printf("%lx", (unsigned long) grpc_header_nonbin_value_is_legal);
+ printf("%lx", (unsigned long) grpc_is_binary_header);
+ printf("%lx", (unsigned long) grpc_call_error_to_string);
+ printf("%lx", (unsigned long) grpc_resource_quota_create);
+ printf("%lx", (unsigned long) grpc_resource_quota_ref);
+ printf("%lx", (unsigned long) grpc_resource_quota_unref);
+ printf("%lx", (unsigned long) grpc_resource_quota_resize);
+ printf("%lx", (unsigned long) grpc_resource_quota_arg_vtable);
+ printf("%lx", (unsigned long) grpc_auth_property_iterator_next);
+ printf("%lx", (unsigned long) grpc_auth_context_property_iterator);
+ printf("%lx", (unsigned long) grpc_auth_context_peer_identity);
+ printf("%lx", (unsigned long) grpc_auth_context_find_properties_by_name);
+ printf("%lx", (unsigned long) grpc_auth_context_peer_identity_property_name);
+ printf("%lx", (unsigned long) grpc_auth_context_peer_is_authenticated);
+ printf("%lx", (unsigned long) grpc_call_auth_context);
+ printf("%lx", (unsigned long) grpc_auth_context_release);
+ printf("%lx", (unsigned long) grpc_auth_context_add_property);
+ printf("%lx", (unsigned long) grpc_auth_context_add_cstring_property);
+ printf("%lx", (unsigned long) grpc_auth_context_set_peer_identity_property_name);
+ printf("%lx", (unsigned long) grpc_channel_credentials_release);
+ printf("%lx", (unsigned long) grpc_google_default_credentials_create);
+ printf("%lx", (unsigned long) grpc_set_ssl_roots_override_callback);
+ printf("%lx", (unsigned long) grpc_ssl_credentials_create);
+ printf("%lx", (unsigned long) grpc_call_credentials_release);
+ printf("%lx", (unsigned long) grpc_composite_channel_credentials_create);
+ printf("%lx", (unsigned long) grpc_composite_call_credentials_create);
+ printf("%lx", (unsigned long) grpc_google_compute_engine_credentials_create);
+ printf("%lx", (unsigned long) grpc_max_auth_token_lifetime);
+ printf("%lx", (unsigned long) grpc_service_account_jwt_access_credentials_create);
+ printf("%lx", (unsigned long) grpc_google_refresh_token_credentials_create);
+ printf("%lx", (unsigned long) grpc_access_token_credentials_create);
+ printf("%lx", (unsigned long) grpc_google_iam_credentials_create);
+ printf("%lx", (unsigned long) grpc_metadata_credentials_create_from_plugin);
+ printf("%lx", (unsigned long) grpc_secure_channel_create);
+ printf("%lx", (unsigned long) grpc_server_credentials_release);
+ printf("%lx", (unsigned long) grpc_ssl_server_certificate_config_create);
+ printf("%lx", (unsigned long) grpc_ssl_server_certificate_config_destroy);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_ex);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_options_using_config);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_options_using_config_fetcher);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_options_destroy);
+ printf("%lx", (unsigned long) grpc_ssl_server_credentials_create_with_options);
+ printf("%lx", (unsigned long) grpc_server_add_secure_http2_port);
+ printf("%lx", (unsigned long) grpc_call_set_credentials);
+ printf("%lx", (unsigned long) grpc_server_credentials_set_auth_metadata_processor);
+ printf("%lx", (unsigned long) grpc_raw_byte_buffer_create);
+ printf("%lx", (unsigned long) grpc_raw_compressed_byte_buffer_create);
+ printf("%lx", (unsigned long) grpc_byte_buffer_copy);
+ printf("%lx", (unsigned long) grpc_byte_buffer_length);
+ printf("%lx", (unsigned long) grpc_byte_buffer_destroy);
+ printf("%lx", (unsigned long) grpc_byte_buffer_reader_init);
+ printf("%lx", (unsigned long) grpc_byte_buffer_reader_destroy);
+ printf("%lx", (unsigned long) grpc_byte_buffer_reader_next);
+ printf("%lx", (unsigned long) grpc_byte_buffer_reader_readall);
+ printf("%lx", (unsigned long) grpc_raw_byte_buffer_from_reader);
+ printf("%lx", (unsigned long) grpc_slice_ref);
+ printf("%lx", (unsigned long) grpc_slice_unref);
+ printf("%lx", (unsigned long) grpc_slice_copy);
+ printf("%lx", (unsigned long) grpc_slice_new);
+ printf("%lx", (unsigned long) grpc_slice_new_with_user_data);
+ printf("%lx", (unsigned long) grpc_slice_new_with_len);
+ printf("%lx", (unsigned long) grpc_slice_malloc);
+ printf("%lx", (unsigned long) grpc_slice_malloc_large);
+ printf("%lx", (unsigned long) grpc_slice_intern);
+ printf("%lx", (unsigned long) grpc_slice_from_copied_string);
+ printf("%lx", (unsigned long) grpc_slice_from_copied_buffer);
+ printf("%lx", (unsigned long) grpc_slice_from_static_string);
+ printf("%lx", (unsigned long) grpc_slice_from_static_buffer);
+ printf("%lx", (unsigned long) grpc_slice_sub);
+ printf("%lx", (unsigned long) grpc_slice_sub_no_ref);
+ printf("%lx", (unsigned long) grpc_slice_split_tail);
+ printf("%lx", (unsigned long) grpc_slice_split_tail_maybe_ref);
+ printf("%lx", (unsigned long) grpc_slice_split_head);
+ printf("%lx", (unsigned long) grpc_empty_slice);
+ printf("%lx", (unsigned long) grpc_slice_default_hash_impl);
+ printf("%lx", (unsigned long) grpc_slice_default_eq_impl);
+ printf("%lx", (unsigned long) grpc_slice_eq);
+ printf("%lx", (unsigned long) grpc_slice_cmp);
+ printf("%lx", (unsigned long) grpc_slice_str_cmp);
+ printf("%lx", (unsigned long) grpc_slice_buf_start_eq);
+ printf("%lx", (unsigned long) grpc_slice_rchr);
+ printf("%lx", (unsigned long) grpc_slice_chr);
+ printf("%lx", (unsigned long) grpc_slice_slice);
+ printf("%lx", (unsigned long) grpc_slice_hash);
+ printf("%lx", (unsigned long) grpc_slice_is_equivalent);
+ printf("%lx", (unsigned long) grpc_slice_dup);
+ printf("%lx", (unsigned long) grpc_slice_to_c_string);
+ printf("%lx", (unsigned long) grpc_slice_buffer_init);
+ printf("%lx", (unsigned long) grpc_slice_buffer_destroy);
+ printf("%lx", (unsigned long) grpc_slice_buffer_add);
+ printf("%lx", (unsigned long) grpc_slice_buffer_add_indexed);
+ printf("%lx", (unsigned long) grpc_slice_buffer_addn);
+ printf("%lx", (unsigned long) grpc_slice_buffer_tiny_add);
+ printf("%lx", (unsigned long) grpc_slice_buffer_pop);
+ printf("%lx", (unsigned long) grpc_slice_buffer_reset_and_unref);
+ printf("%lx", (unsigned long) grpc_slice_buffer_swap);
+ printf("%lx", (unsigned long) grpc_slice_buffer_move_into);
+ printf("%lx", (unsigned long) grpc_slice_buffer_trim_end);
+ printf("%lx", (unsigned long) grpc_slice_buffer_move_first);
+ printf("%lx", (unsigned long) grpc_slice_buffer_move_first_no_ref);
+ printf("%lx", (unsigned long) grpc_slice_buffer_move_first_into_buffer);
+ printf("%lx", (unsigned long) grpc_slice_buffer_take_first);
+ printf("%lx", (unsigned long) grpc_slice_buffer_undo_take_first);
+ printf("%lx", (unsigned long) gpr_malloc);
+ printf("%lx", (unsigned long) gpr_zalloc);
+ printf("%lx", (unsigned long) gpr_free);
+ printf("%lx", (unsigned long) gpr_realloc);
+ printf("%lx", (unsigned long) gpr_malloc_aligned);
+ printf("%lx", (unsigned long) gpr_free_aligned);
+ printf("%lx", (unsigned long) gpr_set_allocation_functions);
+ printf("%lx", (unsigned long) gpr_get_allocation_functions);
+ printf("%lx", (unsigned long) gpr_avl_create);
+ printf("%lx", (unsigned long) gpr_avl_ref);
+ printf("%lx", (unsigned long) gpr_avl_unref);
+ printf("%lx", (unsigned long) gpr_avl_add);
+ printf("%lx", (unsigned long) gpr_avl_remove);
+ printf("%lx", (unsigned long) gpr_avl_get);
+ printf("%lx", (unsigned long) gpr_avl_maybe_get);
+ printf("%lx", (unsigned long) gpr_avl_is_empty);
+ printf("%lx", (unsigned long) gpr_cmdline_create);
+ printf("%lx", (unsigned long) gpr_cmdline_add_int);
+ printf("%lx", (unsigned long) gpr_cmdline_add_flag);
+ printf("%lx", (unsigned long) gpr_cmdline_add_string);
+ printf("%lx", (unsigned long) gpr_cmdline_on_extra_arg);
+ printf("%lx", (unsigned long) gpr_cmdline_set_survive_failure);
+ printf("%lx", (unsigned long) gpr_cmdline_parse);
+ printf("%lx", (unsigned long) gpr_cmdline_destroy);
+ printf("%lx", (unsigned long) gpr_cmdline_usage_string);
+ printf("%lx", (unsigned long) gpr_cpu_num_cores);
+ printf("%lx", (unsigned long) gpr_cpu_current_cpu);
+ printf("%lx", (unsigned long) gpr_histogram_create);
+ printf("%lx", (unsigned long) gpr_histogram_destroy);
+ printf("%lx", (unsigned long) gpr_histogram_add);
+ printf("%lx", (unsigned long) gpr_histogram_merge);
+ printf("%lx", (unsigned long) gpr_histogram_percentile);
+ printf("%lx", (unsigned long) gpr_histogram_mean);
+ printf("%lx", (unsigned long) gpr_histogram_stddev);
+ printf("%lx", (unsigned long) gpr_histogram_variance);
+ printf("%lx", (unsigned long) gpr_histogram_maximum);
+ printf("%lx", (unsigned long) gpr_histogram_minimum);
+ printf("%lx", (unsigned long) gpr_histogram_count);
+ printf("%lx", (unsigned long) gpr_histogram_sum);
+ printf("%lx", (unsigned long) gpr_histogram_sum_of_squares);
+ printf("%lx", (unsigned long) gpr_histogram_get_contents);
+ printf("%lx", (unsigned long) gpr_histogram_merge_contents);
+ printf("%lx", (unsigned long) gpr_join_host_port);
+ printf("%lx", (unsigned long) gpr_split_host_port);
+ printf("%lx", (unsigned long) gpr_log_severity_string);
+ printf("%lx", (unsigned long) gpr_log);
+ printf("%lx", (unsigned long) gpr_log_message);
+ printf("%lx", (unsigned long) gpr_set_log_verbosity);
+ printf("%lx", (unsigned long) gpr_log_verbosity_init);
+ printf("%lx", (unsigned long) gpr_set_log_function);
+ printf("%lx", (unsigned long) gpr_strdup);
+ printf("%lx", (unsigned long) gpr_asprintf);
+ printf("%lx", (unsigned long) gpr_subprocess_binary_extension);
+ printf("%lx", (unsigned long) gpr_subprocess_create);
+ printf("%lx", (unsigned long) gpr_subprocess_destroy);
+ printf("%lx", (unsigned long) gpr_subprocess_join);
+ printf("%lx", (unsigned long) gpr_subprocess_interrupt);
+ printf("%lx", (unsigned long) gpr_mu_init);
+ printf("%lx", (unsigned long) gpr_mu_destroy);
+ printf("%lx", (unsigned long) gpr_mu_lock);
+ printf("%lx", (unsigned long) gpr_mu_unlock);
+ printf("%lx", (unsigned long) gpr_mu_trylock);
+ printf("%lx", (unsigned long) gpr_cv_init);
+ printf("%lx", (unsigned long) gpr_cv_destroy);
+ printf("%lx", (unsigned long) gpr_cv_wait);
+ printf("%lx", (unsigned long) gpr_cv_signal);
+ printf("%lx", (unsigned long) gpr_cv_broadcast);
+ printf("%lx", (unsigned long) gpr_once_init);
+ printf("%lx", (unsigned long) gpr_event_init);
+ printf("%lx", (unsigned long) gpr_event_set);
+ printf("%lx", (unsigned long) gpr_event_get);
+ printf("%lx", (unsigned long) gpr_event_wait);
+ printf("%lx", (unsigned long) gpr_ref_init);
+ printf("%lx", (unsigned long) gpr_ref);
+ printf("%lx", (unsigned long) gpr_ref_non_zero);
+ printf("%lx", (unsigned long) gpr_refn);
+ printf("%lx", (unsigned long) gpr_unref);
+ printf("%lx", (unsigned long) gpr_ref_is_unique);
+ printf("%lx", (unsigned long) gpr_stats_init);
+ printf("%lx", (unsigned long) gpr_stats_inc);
+ printf("%lx", (unsigned long) gpr_stats_read);
+ printf("%lx", (unsigned long) gpr_thd_new);
+ printf("%lx", (unsigned long) gpr_thd_options_default);
+ printf("%lx", (unsigned long) gpr_thd_options_set_detached);
+ printf("%lx", (unsigned long) gpr_thd_options_set_joinable);
+ printf("%lx", (unsigned long) gpr_thd_options_is_detached);
+ printf("%lx", (unsigned long) gpr_thd_options_is_joinable);
+ printf("%lx", (unsigned long) gpr_thd_currentid);
+ printf("%lx", (unsigned long) gpr_thd_join);
+ printf("%lx", (unsigned long) gpr_time_0);
+ printf("%lx", (unsigned long) gpr_inf_future);
+ printf("%lx", (unsigned long) gpr_inf_past);
+ printf("%lx", (unsigned long) gpr_time_init);
+ printf("%lx", (unsigned long) gpr_now);
+ printf("%lx", (unsigned long) gpr_convert_clock_type);
+ printf("%lx", (unsigned long) gpr_time_cmp);
+ printf("%lx", (unsigned long) gpr_time_max);
+ printf("%lx", (unsigned long) gpr_time_min);
+ printf("%lx", (unsigned long) gpr_time_add);
+ printf("%lx", (unsigned long) gpr_time_sub);
+ printf("%lx", (unsigned long) gpr_time_from_micros);
+ printf("%lx", (unsigned long) gpr_time_from_nanos);
+ printf("%lx", (unsigned long) gpr_time_from_millis);
+ printf("%lx", (unsigned long) gpr_time_from_seconds);
+ printf("%lx", (unsigned long) gpr_time_from_minutes);
+ printf("%lx", (unsigned long) gpr_time_from_hours);
+ printf("%lx", (unsigned long) gpr_time_to_millis);
+ printf("%lx", (unsigned long) gpr_time_similar);
+ printf("%lx", (unsigned long) gpr_sleep_until);
+ printf("%lx", (unsigned long) gpr_timespec_to_micros);
+ return 0;
+}
diff --git a/test/core/surface/secure_channel_create_test.c b/test/core/surface/secure_channel_create_test.cc
index 0c45135501..c31c61430c 100644
--- a/test/core/surface/secure_channel_create_test.c
+++ b/test/core/surface/secure_channel_create_test.cc
@@ -30,11 +30,11 @@
void test_unknown_scheme_target(void) {
grpc_resolver_registry_shutdown();
grpc_resolver_registry_init();
- grpc_channel_credentials *creds =
+ grpc_channel_credentials* creds =
grpc_fake_transport_security_credentials_create();
- grpc_channel *chan =
- grpc_secure_channel_create(creds, "blah://blah", NULL, NULL);
- grpc_channel_element *elem =
+ grpc_channel* chan =
+ grpc_secure_channel_create(creds, "blah://blah", nullptr, nullptr);
+ grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -46,13 +46,14 @@ void test_unknown_scheme_target(void) {
void test_security_connector_already_in_arg(void) {
grpc_arg arg;
arg.type = GRPC_ARG_POINTER;
- arg.value.pointer.p = NULL;
- arg.key = GRPC_ARG_SECURITY_CONNECTOR;
+ arg.value.pointer.p = nullptr;
+ arg.key = const_cast<char*>(GRPC_ARG_SECURITY_CONNECTOR);
grpc_channel_args args;
args.num_args = 1;
args.args = &arg;
- grpc_channel *chan = grpc_secure_channel_create(NULL, NULL, &args, NULL);
- grpc_channel_element *elem =
+ grpc_channel* chan =
+ grpc_secure_channel_create(nullptr, nullptr, &args, nullptr);
+ grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -61,8 +62,9 @@ void test_security_connector_already_in_arg(void) {
}
void test_null_creds(void) {
- grpc_channel *chan = grpc_secure_channel_create(NULL, NULL, NULL, NULL);
- grpc_channel_element *elem =
+ grpc_channel* chan =
+ grpc_secure_channel_create(nullptr, nullptr, nullptr, nullptr);
+ grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -70,7 +72,7 @@ void test_null_creds(void) {
grpc_exec_ctx_finish(&exec_ctx);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_security_connector_already_in_arg();
diff --git a/test/core/surface/sequential_connectivity_test.c b/test/core/surface/sequential_connectivity_test.cc
index d5fd2db81b..015db92cb0 100644
--- a/test/core/surface/sequential_connectivity_test.c
+++ b/test/core/surface/sequential_connectivity_test.cc
@@ -30,40 +30,40 @@
#include "test/core/util/test_config.h"
typedef struct test_fixture {
- const char *name;
- void (*add_server_port)(grpc_server *server, const char *addr);
- grpc_channel *(*create_channel)(const char *addr);
+ const char* name;
+ void (*add_server_port)(grpc_server* server, const char* addr);
+ grpc_channel* (*create_channel)(const char* addr);
} test_fixture;
#define NUM_CONNECTIONS 1000
typedef struct {
- grpc_server *server;
- grpc_completion_queue *cq;
+ grpc_server* server;
+ grpc_completion_queue* cq;
} server_thread_args;
-static void server_thread_func(void *args) {
- server_thread_args *a = args;
+static void server_thread_func(void* args) {
+ server_thread_args* a = static_cast<server_thread_args*>(args);
grpc_event ev = grpc_completion_queue_next(
- a->cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ a->cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- GPR_ASSERT(ev.tag == NULL);
+ GPR_ASSERT(ev.tag == nullptr);
GPR_ASSERT(ev.success == true);
}
-static void run_test(const test_fixture *fixture) {
+static void run_test(const test_fixture* fixture) {
gpr_log(GPR_INFO, "TEST: %s", fixture->name);
grpc_init();
- char *addr;
+ char* addr;
gpr_join_host_port(&addr, "localhost", grpc_pick_unused_port_or_die());
- grpc_server *server = grpc_server_create(NULL, NULL);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
fixture->add_server_port(server, addr);
- grpc_completion_queue *server_cq =
- grpc_completion_queue_create_for_next(NULL);
- grpc_server_register_completion_queue(server, server_cq, NULL);
+ grpc_completion_queue* server_cq =
+ grpc_completion_queue_create_for_next(nullptr);
+ grpc_server_register_completion_queue(server, server_cq, nullptr);
grpc_server_start(server);
server_thread_args sta = {server, server_cq};
@@ -72,8 +72,8 @@ static void run_test(const test_fixture *fixture) {
gpr_thd_options_set_joinable(&thdopt);
gpr_thd_new(&server_thread, server_thread_func, &sta, &thdopt);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_channel *channels[NUM_CONNECTIONS];
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_channel* channels[NUM_CONNECTIONS];
for (size_t i = 0; i < NUM_CONNECTIONS; i++) {
channels[i] = fixture->create_channel(addr);
@@ -82,31 +82,31 @@ static void run_test(const test_fixture *fixture) {
while ((state = grpc_channel_check_connectivity_state(channels[i], 1)) !=
GRPC_CHANNEL_READY) {
grpc_channel_watch_connectivity_state(channels[i], state,
- connect_deadline, cq, NULL);
+ connect_deadline, cq, nullptr);
grpc_event ev = grpc_completion_queue_next(
- cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
/* check that the watcher from "watch state" was free'd */
GPR_ASSERT(grpc_channel_num_external_connectivity_watchers(channels[i]) ==
0);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- GPR_ASSERT(ev.tag == NULL);
+ GPR_ASSERT(ev.tag == nullptr);
GPR_ASSERT(ev.success == true);
}
}
- grpc_server_shutdown_and_notify(server, server_cq, NULL);
+ grpc_server_shutdown_and_notify(server, server_cq, nullptr);
gpr_thd_join(server_thread);
grpc_completion_queue_shutdown(server_cq);
grpc_completion_queue_shutdown(cq);
while (grpc_completion_queue_next(server_cq,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
+ gpr_inf_future(GPR_CLOCK_REALTIME), nullptr)
.type != GRPC_QUEUE_SHUTDOWN)
;
- while (
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL)
- .type != GRPC_QUEUE_SHUTDOWN)
+ while (grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr)
+ .type != GRPC_QUEUE_SHUTDOWN)
;
for (size_t i = 0; i < NUM_CONNECTIONS; i++) {
@@ -121,37 +121,40 @@ static void run_test(const test_fixture *fixture) {
gpr_free(addr);
}
-static void insecure_test_add_port(grpc_server *server, const char *addr) {
+static void insecure_test_add_port(grpc_server* server, const char* addr) {
grpc_server_add_insecure_http2_port(server, addr);
}
-static grpc_channel *insecure_test_create_channel(const char *addr) {
- return grpc_insecure_channel_create(addr, NULL, NULL);
+static grpc_channel* insecure_test_create_channel(const char* addr) {
+ return grpc_insecure_channel_create(addr, nullptr, nullptr);
}
static const test_fixture insecure_test = {
- "insecure", insecure_test_add_port, insecure_test_create_channel,
+ "insecure",
+ insecure_test_add_port,
+ insecure_test_create_channel,
};
-static void secure_test_add_port(grpc_server *server, const char *addr) {
+static void secure_test_add_port(grpc_server* server, const char* addr) {
grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key,
test_server1_cert};
- grpc_server_credentials *ssl_creds =
- grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ nullptr, &pem_cert_key_pair, 1, 0, nullptr);
grpc_server_add_secure_http2_port(server, addr, ssl_creds);
grpc_server_credentials_release(ssl_creds);
}
-static grpc_channel *secure_test_create_channel(const char *addr) {
- grpc_channel_credentials *ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, NULL, NULL);
- grpc_arg ssl_name_override = {GRPC_ARG_STRING,
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
- {"foo.test.google.fr"}};
- grpc_channel_args *new_client_args =
- grpc_channel_args_copy_and_add(NULL, &ssl_name_override, 1);
- grpc_channel *channel =
- grpc_secure_channel_create(ssl_creds, addr, new_client_args, NULL);
+static grpc_channel* secure_test_create_channel(const char* addr) {
+ grpc_channel_credentials* ssl_creds =
+ grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
+ grpc_channel_args* new_client_args =
+ grpc_channel_args_copy_and_add(nullptr, &ssl_name_override, 1);
+ grpc_channel* channel =
+ grpc_secure_channel_create(ssl_creds, addr, new_client_args, nullptr);
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args_destroy(&exec_ctx, new_client_args);
@@ -162,10 +165,12 @@ static grpc_channel *secure_test_create_channel(const char *addr) {
}
static const test_fixture secure_test = {
- "secure", secure_test_add_port, secure_test_create_channel,
+ "secure",
+ secure_test_add_port,
+ secure_test_create_channel,
};
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
run_test(&insecure_test);
diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.cc
index cd8931e0d7..96eaa6a7a9 100644
--- a/test/core/surface/server_chttp2_test.c
+++ b/test/core/surface/server_chttp2_test.cc
@@ -29,8 +29,8 @@
#include "test/core/util/test_config.h"
void test_unparsable_target(void) {
- grpc_channel_args args = {0, NULL};
- grpc_server *server = grpc_server_create(&args, NULL);
+ grpc_channel_args args = {0, nullptr};
+ grpc_server* server = grpc_server_create(&args, nullptr);
int port = grpc_server_add_insecure_http2_port(server, "[");
GPR_ASSERT(port == 0);
grpc_server_destroy(server);
@@ -39,15 +39,15 @@ void test_unparsable_target(void) {
void test_add_same_port_twice() {
grpc_arg a;
a.type = GRPC_ARG_INTEGER;
- a.key = GRPC_ARG_ALLOW_REUSEPORT;
+ a.key = const_cast<char*>(GRPC_ARG_ALLOW_REUSEPORT);
a.value.integer = 0;
grpc_channel_args args = {1, &a};
int port = grpc_pick_unused_port_or_die();
- char *addr = NULL;
- grpc_completion_queue *cq = grpc_completion_queue_create_for_pluck(NULL);
- grpc_server *server = grpc_server_create(&args, NULL);
- grpc_server_credentials *fake_creds =
+ char* addr = nullptr;
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr);
+ grpc_server* server = grpc_server_create(&args, nullptr);
+ grpc_server_credentials* fake_creds =
grpc_fake_transport_security_server_credentials_create();
gpr_join_host_port(&addr, "localhost", port);
GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds));
@@ -55,14 +55,14 @@ void test_add_same_port_twice() {
grpc_server_credentials_release(fake_creds);
gpr_free(addr);
- grpc_server_shutdown_and_notify(server, cq, NULL);
- grpc_completion_queue_pluck(cq, NULL, gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL);
+ grpc_server_shutdown_and_notify(server, cq, nullptr);
+ grpc_completion_queue_pluck(cq, nullptr, gpr_inf_future(GPR_CLOCK_REALTIME),
+ nullptr);
grpc_server_destroy(server);
grpc_completion_queue_destroy(cq);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_unparsable_target();
diff --git a/test/core/surface/server_test.c b/test/core/surface/server_test.cc
index 4c185cd8ea..969b8cb11b 100644
--- a/test/core/surface/server_test.c
+++ b/test/core/surface/server_test.cc
@@ -28,40 +28,42 @@
#include "test/core/util/test_config.h"
void test_register_method_fail(void) {
- grpc_server *server = grpc_server_create(NULL, NULL);
- void *method;
- void *method_old;
- method =
- grpc_server_register_method(server, NULL, NULL, GRPC_SRM_PAYLOAD_NONE, 0);
- GPR_ASSERT(method == NULL);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
+ void* method;
+ void* method_old;
+ method = grpc_server_register_method(server, nullptr, nullptr,
+ GRPC_SRM_PAYLOAD_NONE, 0);
+ GPR_ASSERT(method == nullptr);
method_old =
grpc_server_register_method(server, "m", "h", GRPC_SRM_PAYLOAD_NONE, 0);
- GPR_ASSERT(method_old != NULL);
+ GPR_ASSERT(method_old != nullptr);
method = grpc_server_register_method(
server, "m", "h", GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, 0);
- GPR_ASSERT(method == NULL);
+ GPR_ASSERT(method == nullptr);
method_old =
grpc_server_register_method(server, "m2", "h2", GRPC_SRM_PAYLOAD_NONE,
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST);
- GPR_ASSERT(method_old != NULL);
+ GPR_ASSERT(method_old != nullptr);
method =
grpc_server_register_method(server, "m2", "h2", GRPC_SRM_PAYLOAD_NONE, 0);
- GPR_ASSERT(method == NULL);
+ GPR_ASSERT(method == nullptr);
method = grpc_server_register_method(
server, "m2", "h2", GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER,
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST);
- GPR_ASSERT(method == NULL);
+ GPR_ASSERT(method == nullptr);
grpc_server_destroy(server);
}
void test_request_call_on_no_server_cq(void) {
- grpc_completion_queue *cc = grpc_completion_queue_create_for_next(NULL);
- grpc_server *server = grpc_server_create(NULL, NULL);
+ grpc_completion_queue* cc = grpc_completion_queue_create_for_next(nullptr);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE ==
- grpc_server_request_call(server, NULL, NULL, NULL, cc, cc, NULL));
+ grpc_server_request_call(server, nullptr, nullptr, nullptr, cc, cc,
+ nullptr));
GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE ==
- grpc_server_request_registered_call(server, NULL, NULL, NULL, NULL,
- NULL, cc, cc, NULL));
+ grpc_server_request_registered_call(server, nullptr, nullptr,
+ nullptr, nullptr, nullptr, cc,
+ cc, nullptr));
grpc_completion_queue_destroy(cc);
grpc_server_destroy(server);
}
@@ -69,93 +71,94 @@ void test_request_call_on_no_server_cq(void) {
void test_bind_server_twice(void) {
grpc_arg a;
a.type = GRPC_ARG_INTEGER;
- a.key = GRPC_ARG_ALLOW_REUSEPORT;
+ a.key = const_cast<char*>(GRPC_ARG_ALLOW_REUSEPORT);
a.value.integer = 0;
grpc_channel_args args = {1, &a};
- char *addr;
- grpc_server *server1 = grpc_server_create(&args, NULL);
- grpc_server *server2 = grpc_server_create(&args, NULL);
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
+ char* addr;
+ grpc_server* server1 = grpc_server_create(&args, nullptr);
+ grpc_server* server2 = grpc_server_create(&args, nullptr);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
int port = grpc_pick_unused_port_or_die();
gpr_asprintf(&addr, "[::]:%d", port);
- grpc_server_register_completion_queue(server1, cq, NULL);
- grpc_server_register_completion_queue(server2, cq, NULL);
- GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, NULL));
+ grpc_server_register_completion_queue(server1, cq, nullptr);
+ grpc_server_register_completion_queue(server2, cq, nullptr);
+ GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, nullptr));
GPR_ASSERT(port == grpc_server_add_insecure_http2_port(server1, addr));
GPR_ASSERT(0 == grpc_server_add_insecure_http2_port(server2, addr));
- grpc_server_credentials *fake_creds =
+ grpc_server_credentials* fake_creds =
grpc_fake_transport_security_server_credentials_create();
GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, fake_creds));
grpc_server_credentials_release(fake_creds);
- grpc_server_shutdown_and_notify(server1, cq, NULL);
- grpc_server_shutdown_and_notify(server2, cq, NULL);
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
+ grpc_server_shutdown_and_notify(server1, cq, nullptr);
+ grpc_server_shutdown_and_notify(server2, cq, nullptr);
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
grpc_server_destroy(server1);
grpc_server_destroy(server2);
grpc_completion_queue_destroy(cq);
gpr_free(addr);
}
-void test_bind_server_to_addr(const char *host, bool secure) {
+void test_bind_server_to_addr(const char* host, bool secure) {
int port = grpc_pick_unused_port_or_die();
- char *addr;
+ char* addr;
gpr_join_host_port(&addr, host, port);
gpr_log(GPR_INFO, "Test bind to %s", addr);
- grpc_server *server = grpc_server_create(NULL, NULL);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
if (secure) {
- grpc_server_credentials *fake_creds =
+ grpc_server_credentials* fake_creds =
grpc_fake_transport_security_server_credentials_create();
GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds));
grpc_server_credentials_release(fake_creds);
} else {
GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr));
}
- grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
- grpc_server_register_completion_queue(server, cq, NULL);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ grpc_server_register_completion_queue(server, cq, nullptr);
grpc_server_start(server);
- grpc_server_shutdown_and_notify(server, cq, NULL);
- grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
+ grpc_server_shutdown_and_notify(server, cq, nullptr);
+ grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
grpc_server_destroy(server);
grpc_completion_queue_destroy(cq);
gpr_free(addr);
}
-static int external_dns_works(const char *host) {
- grpc_resolved_addresses *res = NULL;
- grpc_error *error = grpc_blocking_resolve_address(host, "80", &res);
+static int external_dns_works(const char* host) {
+ grpc_resolved_addresses* res = nullptr;
+ grpc_error* error = grpc_blocking_resolve_address(host, "80", &res);
GRPC_ERROR_UNREF(error);
- if (res != NULL) {
+ if (res != nullptr) {
grpc_resolved_addresses_destroy(res);
return 1;
}
return 0;
}
-static void test_bind_server_to_addrs(const char **addrs, size_t n) {
+static void test_bind_server_to_addrs(const char** addrs, size_t n) {
for (size_t i = 0; i < n; i++) {
test_bind_server_to_addr(addrs[i], false);
test_bind_server_to_addr(addrs[i], true);
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_register_method_fail();
test_request_call_on_no_server_cq();
test_bind_server_twice();
- static const char *addrs[] = {
+ static const char* addrs[] = {
"::1", "127.0.0.1", "::ffff:127.0.0.1", "localhost", "0.0.0.0", "::",
};
test_bind_server_to_addrs(addrs, GPR_ARRAY_SIZE(addrs));
if (external_dns_works("loopback46.unittest.grpc.io")) {
- static const char *dns_addrs[] = {
- "loopback46.unittest.grpc.io", "loopback4.unittest.grpc.io",
+ static const char* dns_addrs[] = {
+ "loopback46.unittest.grpc.io",
+ "loopback4.unittest.grpc.io",
};
test_bind_server_to_addrs(dns_addrs, GPR_ARRAY_SIZE(dns_addrs));
}