aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Chen Wang <chenw@google.com>2015-01-21 18:57:46 -0800
committerGravatar Chen Wang <chenw@google.com>2015-01-21 18:57:46 -0800
commit69330757f11223d3ae7a624f2d7da1073009060f (patch)
tree3720d0c161d6496a2bd9e89d5c0bd82b8d4fe72a /test
parent86af8cffc5122426c5fc82ca55c4d7fd7d8257d5 (diff)
parentc0b1785a17b373031bb1e930cc214e7345d6ad0d (diff)
Merge branch 'master' of github.com:google/grpc into tips
Diffstat (limited to 'test')
-rw-r--r--test/build/perftools.c7
-rw-r--r--test/core/channel/channel_stack_test.c4
-rw-r--r--test/core/channel/metadata_buffer_test.c4
-rw-r--r--test/core/end2end/cq_verifier.c1
-rw-r--r--test/core/end2end/data/prod_roots_certs.c5
-rw-r--r--test/core/end2end/data/server1_cert.c5
-rw-r--r--test/core/end2end/data/server1_key.c5
-rw-r--r--test/core/end2end/data/ssl_test_data.h12
-rw-r--r--test/core/end2end/data/test_root_cert.c5
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c11
-rw-r--r--test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c10
-rwxr-xr-xtest/core/end2end/gen_build_json.py4
-rw-r--r--test/core/end2end/tests/max_concurrent_streams.c2
-rw-r--r--test/core/end2end/tests/thread_stress.c4
-rw-r--r--test/core/fling/server.c16
-rw-r--r--test/core/iomgr/alarm_list_test.c14
-rw-r--r--test/core/iomgr/endpoint_tests.c4
-rw-r--r--test/core/iomgr/poll_kick_test.c123
-rw-r--r--test/core/security/credentials_test.c10
-rw-r--r--test/core/statistics/hash_table_test.c22
-rw-r--r--test/core/surface/completion_queue_benchmark.c14
-rw-r--r--test/core/surface/completion_queue_test.c20
-rw-r--r--test/core/transport/chttp2/stream_map_test.c6
-rw-r--r--test/core/util/grpc_profiler.c18
-rw-r--r--test/cpp/client/credentials_test.cc9
-rw-r--r--test/cpp/interop/server.cc6
-rw-r--r--test/cpp/util/create_test_channel.cc7
27 files changed, 243 insertions, 105 deletions
diff --git a/test/build/perftools.c b/test/build/perftools.c
new file mode 100644
index 0000000000..03548b4c7e
--- /dev/null
+++ b/test/build/perftools.c
@@ -0,0 +1,7 @@
+#include <gperftools/profiler.h>
+
+int main() {
+ ProfilerStart("/dev/null");
+ ProfilerStop();
+ return 0;
+}
diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c
index fb52fe3270..d0ea79c34e 100644
--- a/test/core/channel/channel_stack_test.c
+++ b/test/core/channel/channel_stack_test.c
@@ -78,9 +78,9 @@ static void channel_func(grpc_channel_element *elem,
static void test_create_channel_stack(void) {
const grpc_channel_filter filter = {
- call_func, channel_func,
+ call_func, channel_func,
- sizeof(int), call_init_func, call_destroy_func,
+ sizeof(int), call_init_func, call_destroy_func,
sizeof(int), channel_init_func, channel_destroy_func,
};
diff --git a/test/core/channel/metadata_buffer_test.c b/test/core/channel/metadata_buffer_test.c
index 5604e25705..aa2399272f 100644
--- a/test/core/channel/metadata_buffer_test.c
+++ b/test/core/channel/metadata_buffer_test.c
@@ -78,7 +78,7 @@ static void expect_call_op(grpc_call_element *elem,
GPR_ASSERT(op->dir == GRPC_CALL_DOWN);
GPR_ASSERT(op->flags == *n);
GPR_ASSERT(op->done_cb == do_nothing);
- GPR_ASSERT(op->user_data == (void *)(gpr_uintptr)*n);
+ GPR_ASSERT(op->user_data == (void *)(gpr_uintptr) * n);
GPR_ASSERT(0 == gpr_slice_cmp(op->data.metadata->key->slice, key));
GPR_ASSERT(0 == gpr_slice_cmp(op->data.metadata->value->slice, value));
@@ -148,7 +148,7 @@ static void test_case(size_t key_prefix_len, size_t value_prefix_len,
op.flags = i;
op.data.metadata = grpc_mdelem_from_slices(mdctx, key, value);
op.done_cb = do_nothing;
- op.user_data = (void *)(gpr_uintptr)i;
+ op.user_data = (void *)(gpr_uintptr) i;
grpc_metadata_buffer_queue(&buffer, &op);
}
diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c
index 60b0bf3303..9fa513126f 100644
--- a/test/core/end2end/cq_verifier.c
+++ b/test/core/end2end/cq_verifier.c
@@ -495,4 +495,3 @@ void cq_expect_finished(cq_verifier *v, void *tag, ...) {
void cq_expect_server_shutdown(cq_verifier *v, void *tag) {
add(v, GRPC_SERVER_SHUTDOWN, tag);
}
-
diff --git a/test/core/end2end/data/prod_roots_certs.c b/test/core/end2end/data/prod_roots_certs.c
index 21a199ce37..3b66d236c3 100644
--- a/test/core/end2end/data/prod_roots_certs.c
+++ b/test/core/end2end/data/prod_roots_certs.c
@@ -31,7 +31,7 @@
*
*/
-unsigned char prod_roots_certs[] = {
+const char prod_roots_certs[] = {
0x23, 0x20, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x4e,
0x3d, 0x47, 0x54, 0x45, 0x20, 0x43, 0x79, 0x62, 0x65, 0x72, 0x54, 0x72,
0x75, 0x73, 0x74, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x20, 0x52,
@@ -11270,5 +11270,4 @@ unsigned char prod_roots_certs[] = {
0x33, 0x50, 0x59, 0x74, 0x6c, 0x4e, 0x58, 0x4c, 0x66, 0x62, 0x51, 0x34,
0x64, 0x64, 0x49, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44,
0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45,
- 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a};
-unsigned int prod_roots_certs_size = 134862;
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x00};
diff --git a/test/core/end2end/data/server1_cert.c b/test/core/end2end/data/server1_cert.c
index da1d36653c..134b9cb98e 100644
--- a/test/core/end2end/data/server1_cert.c
+++ b/test/core/end2end/data/server1_cert.c
@@ -31,7 +31,7 @@
*
*/
-unsigned char test_server1_cert[] = {
+const char test_server1_cert[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43,
0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6d, 0x7a, 0x43, 0x43,
@@ -112,5 +112,4 @@ unsigned char test_server1_cert[] = {
0x32, 0x77, 0x65, 0x2f, 0x4b, 0x44, 0x34, 0x6f, 0x6a, 0x66, 0x39, 0x73,
0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43,
0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
- 0x2d, 0x2d, 0x2d, 0x0a};
-unsigned int test_server1_cert_size = 964;
+ 0x2d, 0x2d, 0x2d, 0x0a, 0x00};
diff --git a/test/core/end2end/data/server1_key.c b/test/core/end2end/data/server1_key.c
index 3540505467..992d3c032a 100644
--- a/test/core/end2end/data/server1_key.c
+++ b/test/core/end2end/data/server1_key.c
@@ -31,7 +31,7 @@
*
*/
-unsigned char test_server1_key[] = {
+const char test_server1_key[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52,
0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b,
0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43,
@@ -105,5 +105,4 @@ unsigned char test_server1_key[] = {
0x6e, 0x68, 0x66, 0x66, 0x46, 0x79, 0x65, 0x37, 0x53, 0x42, 0x58, 0x79,
0x61, 0x67, 0x3d, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e,
0x44, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54,
- 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a};
-unsigned int test_server1_key_size = 887;
+ 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x00};
diff --git a/test/core/end2end/data/ssl_test_data.h b/test/core/end2end/data/ssl_test_data.h
index 6ac19945b2..3456ebebd4 100644
--- a/test/core/end2end/data/ssl_test_data.h
+++ b/test/core/end2end/data/ssl_test_data.h
@@ -34,14 +34,10 @@
#ifndef __GRPC_TEST_END2END_DATA_SSL_TEST_DATA_H__
#define __GRPC_TEST_END2END_DATA_SSL_TEST_DATA_H__
-extern unsigned char test_root_cert[];
-extern unsigned int test_root_cert_size;
-extern unsigned char test_server1_cert[];
-extern unsigned int test_server1_cert_size;
-extern unsigned char test_server1_key[];
-extern unsigned int test_server1_key_size;
+extern const char test_root_cert[];
+extern const char test_server1_cert[];
+extern const char test_server1_key[];
-extern unsigned char prod_roots_certs[];
-extern unsigned int prod_roots_certs_size;
+extern const char prod_roots_certs[];
#endif /* __GRPC_TEST_END2END_DATA_SSL_TEST_DATA_H__ */
diff --git a/test/core/end2end/data/test_root_cert.c b/test/core/end2end/data/test_root_cert.c
index fd01953ccb..f358b0b79a 100644
--- a/test/core/end2end/data/test_root_cert.c
+++ b/test/core/end2end/data/test_root_cert.c
@@ -31,7 +31,7 @@
*
*/
-unsigned char test_root_cert[] = {
+const char test_root_cert[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43,
0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x49, 0x7a, 0x43, 0x43,
@@ -98,5 +98,4 @@ unsigned char test_root_cert[] = {
0x31, 0x59, 0x75, 0x58, 0x32, 0x72, 0x6e, 0x65, 0x78, 0x30, 0x4a, 0x68,
0x75, 0x54, 0x51, 0x66, 0x63, 0x49, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49,
- 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a};
-unsigned int test_root_cert_size = 802;
+ 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x00};
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
index 7718d30b3e..e5cdec8ea7 100644
--- a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
@@ -98,8 +98,8 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(
- test_root_cert, test_root_cert_size, NULL, 0, NULL, 0);
+ grpc_credentials *ssl_creds =
+ grpc_ssl_credentials_create(test_root_cert, NULL);
grpc_arg ssl_name_override = {GRPC_ARG_STRING,
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
{"foo.test.google.com"}};
@@ -111,9 +111,10 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
static void chttp2_init_server_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
- grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create(
- NULL, 0, test_server1_key, test_server1_key_size, test_server1_cert,
- test_server1_cert_size);
+ 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);
chttp2_init_server_secure_fullstack(f, server_args, ssl_creds);
}
diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
index bb8af88c54..8bfa465696 100644
--- a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
+++ b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
@@ -99,8 +99,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(
- test_root_cert, test_root_cert_size, NULL, 0, NULL, 0);
+ grpc_credentials *ssl_creds = grpc_ssl_credentials_create(test_root_cert, NULL);
grpc_credentials *oauth2_creds =
grpc_fake_oauth2_credentials_create("Bearer aaslkfjs424535asdf", 1);
grpc_credentials *ssl_oauth2_creds =
@@ -118,9 +117,10 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
static void chttp2_init_server_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *server_args) {
- grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create(
- NULL, 0, test_server1_key, test_server1_key_size, test_server1_cert,
- test_server1_cert_size);
+ grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
+ test_server1_cert};
+ grpc_server_credentials *ssl_creds =
+ grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1);
chttp2_init_server_secure_fullstack(f, server_args, ssl_creds);
}
diff --git a/test/core/end2end/gen_build_json.py b/test/core/end2end/gen_build_json.py
index 8a851ddd37..2c4368fe76 100755
--- a/test/core/end2end/gen_build_json.py
+++ b/test/core/end2end/gen_build_json.py
@@ -48,6 +48,7 @@ def main():
{
'name': 'end2end_fixture_%s' % f,
'build': 'private',
+ 'language': 'c',
'secure': True,
'src': ['test/core/end2end/fixtures/%s.c' % f]
}
@@ -55,6 +56,7 @@ def main():
{
'name': 'end2end_test_%s' % t,
'build': 'private',
+ 'language': 'c',
'secure': False,
'src': ['test/core/end2end/tests/%s.c' % t],
'headers': ['test/core/end2end/tests/cancel_test_helpers.h']
@@ -63,6 +65,7 @@ def main():
{
'name': 'end2end_certs',
'build': 'private',
+ 'language': 'c',
'src': [
"test/core/end2end/data/test_root_cert.c",
"test/core/end2end/data/prod_roots_certs.c",
@@ -75,6 +78,7 @@ def main():
{
'name': '%s_%s_test' % (f, t),
'build': 'test',
+ 'language': 'c',
'src': [],
'deps': [
'end2end_fixture_%s' % f,
diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c
index e88f418cb0..1db32b1de9 100644
--- a/test/core/end2end/tests/max_concurrent_streams.c
+++ b/test/core/end2end/tests/max_concurrent_streams.c
@@ -203,7 +203,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
GPR_ASSERT(ev->data.invoke_accepted == GRPC_OP_OK);
/* The /alpha or /beta calls started above could be invoked (but NOT both);
* check this here */
- live_call = (int)(gpr_intptr)ev->tag;
+ live_call = (int)(gpr_intptr) ev->tag;
live_call_obj = live_call == 300 ? c1 : c2;
grpc_event_finish(ev);
diff --git a/test/core/end2end/tests/thread_stress.c b/test/core/end2end/tests/thread_stress.c
index 5410258201..2de0497a7a 100644
--- a/test/core/end2end/tests/thread_stress.c
+++ b/test/core/end2end/tests/thread_stress.c
@@ -282,11 +282,11 @@ static void run_test(grpc_end2end_test_config config, int requests_in_flight) {
/* kick off threads */
for (i = 0; i < CLIENT_THREADS; i++) {
gpr_event_init(&g_client_done[i]);
- gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr)i, NULL);
+ gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr) i, NULL);
}
for (i = 0; i < SERVER_THREADS; i++) {
gpr_event_init(&g_server_done[i]);
- gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr)i, NULL);
+ gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr) i, NULL);
}
/* start requests */
diff --git a/test/core/fling/server.c b/test/core/fling/server.c
index 705ab3aca2..f811aac284 100644
--- a/test/core/fling/server.c
+++ b/test/core/fling/server.c
@@ -32,6 +32,7 @@
*/
#include <grpc/grpc.h>
+#include <grpc/grpc_security.h>
#include <signal.h>
#include <stdio.h>
@@ -47,6 +48,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "test/core/util/port.h"
+#include "test/core/end2end/data/ssl_test_data.h"
static grpc_completion_queue *cq;
static grpc_server *server;
@@ -98,8 +100,18 @@ int main(int argc, char **argv) {
gpr_log(GPR_INFO, "creating server on: %s", addr);
cq = grpc_completion_queue_create();
- server = grpc_server_create(cq, NULL);
- GPR_ASSERT(grpc_server_add_http2_port(server, addr));
+ if (secure) {
+ grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
+ test_server1_cert};
+ grpc_server_credentials *ssl_creds =
+ grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1);
+ server = grpc_secure_server_create(ssl_creds, cq, NULL);
+ GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr));
+ grpc_server_credentials_release(ssl_creds);
+ } else {
+ server = grpc_server_create(cq, NULL);
+ GPR_ASSERT(grpc_server_add_http2_port(server, addr));
+ }
grpc_server_start(server);
gpr_free(addr_buf);
diff --git a/test/core/iomgr/alarm_list_test.c b/test/core/iomgr/alarm_list_test.c
index a250951231..ce9b7f4c66 100644
--- a/test/core/iomgr/alarm_list_test.c
+++ b/test/core/iomgr/alarm_list_test.c
@@ -61,13 +61,13 @@ static void add_test(void) {
/* 10 ms alarms. will expire in the current epoch */
for (i = 0; i < 10; i++) {
grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(10)),
- cb, (void *)(gpr_intptr)i, start);
+ cb, (void *)(gpr_intptr) i, start);
}
/* 1010 ms alarms. will expire in the next epoch */
for (i = 10; i < 20; i++) {
grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(1010)),
- cb, (void *)(gpr_intptr)i, start);
+ cb, (void *)(gpr_intptr) i, start);
}
/* collect alarms. Only the first batch should be ready. */
@@ -115,15 +115,15 @@ void destruction_test(void) {
memset(cb_called, 0, sizeof(cb_called));
grpc_alarm_init(&alarms[0], gpr_time_from_millis(100), cb,
- (void *)(gpr_intptr)0, gpr_time_0);
+ (void *)(gpr_intptr) 0, gpr_time_0);
grpc_alarm_init(&alarms[1], gpr_time_from_millis(3), cb,
- (void *)(gpr_intptr)1, gpr_time_0);
+ (void *)(gpr_intptr) 1, gpr_time_0);
grpc_alarm_init(&alarms[2], gpr_time_from_millis(100), cb,
- (void *)(gpr_intptr)2, gpr_time_0);
+ (void *)(gpr_intptr) 2, gpr_time_0);
grpc_alarm_init(&alarms[3], gpr_time_from_millis(3), cb,
- (void *)(gpr_intptr)3, gpr_time_0);
+ (void *)(gpr_intptr) 3, gpr_time_0);
grpc_alarm_init(&alarms[4], gpr_time_from_millis(1), cb,
- (void *)(gpr_intptr)4, gpr_time_0);
+ (void *)(gpr_intptr) 4, gpr_time_0);
GPR_ASSERT(1 == grpc_alarm_check(NULL, gpr_time_from_millis(2), NULL));
GPR_ASSERT(1 == cb_called[4][1]);
grpc_alarm_cancel(&alarms[0]);
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c
index 125cde4678..dc5747bf57 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.c
@@ -290,7 +290,7 @@ static void shutdown_during_write_test_read_handler(
if (error != GRPC_ENDPOINT_CB_OK) {
grpc_endpoint_destroy(st->ep);
- gpr_event_set(&st->ev, (void *)(gpr_intptr)error);
+ gpr_event_set(&st->ev, (void *)(gpr_intptr) error);
} else {
grpc_endpoint_notify_on_read(
st->ep, shutdown_during_write_test_read_handler, user_data);
@@ -309,7 +309,7 @@ static void shutdown_during_write_test_write_handler(
gpr_log(GPR_ERROR,
"shutdown_during_write_test_write_handler completed unexpectedly");
}
- gpr_event_set(&st->ev, (void *)(gpr_intptr)1);
+ gpr_event_set(&st->ev, (void *)(gpr_intptr) 1);
}
static void shutdown_during_write_test(grpc_endpoint_test_config config,
diff --git a/test/core/iomgr/poll_kick_test.c b/test/core/iomgr/poll_kick_test.c
new file mode 100644
index 0000000000..c30a7b9ee0
--- /dev/null
+++ b/test/core/iomgr/poll_kick_test.c
@@ -0,0 +1,123 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "src/core/iomgr/pollset_kick.h"
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include "test/core/util/test_config.h"
+
+static void test_allocation(void) {
+ grpc_pollset_kick_state state;
+ grpc_pollset_kick_init(&state);
+ grpc_pollset_kick_destroy(&state);
+}
+
+static void test_non_kick(void) {
+ grpc_pollset_kick_state state;
+ int fd;
+
+ grpc_pollset_kick_init(&state);
+ fd = grpc_pollset_kick_pre_poll(&state);
+ GPR_ASSERT(fd >= 0);
+
+ grpc_pollset_kick_post_poll(&state);
+ grpc_pollset_kick_destroy(&state);
+}
+
+static void test_basic_kick(void) {
+ /* Kicked during poll */
+ grpc_pollset_kick_state state;
+ int fd;
+ grpc_pollset_kick_init(&state);
+
+ fd = grpc_pollset_kick_pre_poll(&state);
+ GPR_ASSERT(fd >= 0);
+
+ grpc_pollset_kick_kick(&state);
+
+ /* Now hypothetically we polled and found that we were kicked */
+ grpc_pollset_kick_consume(&state);
+
+ grpc_pollset_kick_post_poll(&state);
+
+ grpc_pollset_kick_destroy(&state);
+}
+
+static void test_non_poll_kick(void) {
+ /* Kick before entering poll */
+ grpc_pollset_kick_state state;
+ int fd;
+
+ grpc_pollset_kick_init(&state);
+
+ grpc_pollset_kick_kick(&state);
+ fd = grpc_pollset_kick_pre_poll(&state);
+ GPR_ASSERT(fd < 0);
+ grpc_pollset_kick_destroy(&state);
+}
+
+#define GRPC_MAX_CACHED_PIPES 50
+
+static void test_over_free(void) {
+ /* Check high watermark pipe free logic */
+ int i;
+ struct grpc_pollset_kick_state *kick_state =
+ gpr_malloc(sizeof(grpc_pollset_kick_state) * GRPC_MAX_CACHED_PIPES);
+ for (i = 0; i < GRPC_MAX_CACHED_PIPES; ++i) {
+ int fd;
+ grpc_pollset_kick_init(&kick_state[i]);
+ fd = grpc_pollset_kick_pre_poll(&kick_state[i]);
+ GPR_ASSERT(fd >= 0);
+ }
+
+ for (i = 0; i < GRPC_MAX_CACHED_PIPES; ++i) {
+ grpc_pollset_kick_post_poll(&kick_state[i]);
+ grpc_pollset_kick_destroy(&kick_state[i]);
+ }
+}
+
+int main(int argc, char **argv) {
+ grpc_test_init(argc, argv);
+
+ grpc_pollset_kick_global_init();
+
+ test_allocation();
+ test_basic_kick();
+ test_non_poll_kick();
+ test_non_kick();
+ test_over_free();
+
+ grpc_pollset_kick_global_destroy();
+ return 0;
+}
diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c
index 619f09308e..9c60f4c233 100644
--- a/test/core/security/credentials_test.c
+++ b/test/core/security/credentials_test.c
@@ -48,7 +48,7 @@ static const char test_iam_authorization_token[] = "blahblahblhahb";
static const char test_iam_authority_selector[] = "respectmyauthoritah";
static const char test_oauth2_bearer_token[] =
"Bearer blaaslkdjfaslkdfasdsfasf";
-static const unsigned char test_root_cert[] = {0xDE, 0xAD, 0xBE, 0xEF};
+static const char test_root_cert[] = "I am the root!";
/* This JSON key was generated with the GCE console and revoked immediately.
The identifiers have been changed as well.
@@ -275,8 +275,8 @@ static void check_ssl_oauth2_composite_metadata(
}
static void test_ssl_oauth2_composite_creds(void) {
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(
- test_root_cert, sizeof(test_root_cert), NULL, 0, NULL, 0);
+ grpc_credentials *ssl_creds =
+ grpc_ssl_credentials_create(test_root_cert, NULL);
const grpc_credentials_array *creds_array;
grpc_credentials *oauth2_creds =
grpc_fake_oauth2_credentials_create(test_oauth2_bearer_token, 0);
@@ -312,8 +312,8 @@ static void check_ssl_oauth2_iam_composite_metadata(
}
static void test_ssl_oauth2_iam_composite_creds(void) {
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(
- test_root_cert, sizeof(test_root_cert), NULL, 0, NULL, 0);
+ grpc_credentials *ssl_creds =
+ grpc_ssl_credentials_create(test_root_cert, NULL);
const grpc_credentials_array *creds_array;
grpc_credentials *oauth2_creds =
grpc_fake_oauth2_credentials_create(test_oauth2_bearer_token, 0);
diff --git a/test/core/statistics/hash_table_test.c b/test/core/statistics/hash_table_test.c
index 5d05ab5bc4..ebfc2a2a9a 100644
--- a/test/core/statistics/hash_table_test.c
+++ b/test/core/statistics/hash_table_test.c
@@ -64,8 +64,8 @@ static void free_data(void* data) { gpr_free(data); }
static void test_create_table(void) {
/* Create table with uint64 key type */
census_ht* ht = NULL;
- census_ht_option ht_options = {CENSUS_HT_UINT64, 1999, NULL, NULL, NULL,
- NULL};
+ census_ht_option ht_options = {CENSUS_HT_UINT64, 1999, NULL,
+ NULL, NULL, NULL};
ht = census_ht_create(&ht_options);
GPR_ASSERT(ht != NULL);
GPR_ASSERT(census_ht_get_size(ht) == 0);
@@ -119,8 +119,8 @@ static void test_table_with_int_key(void) {
/* Test that there is no memory leak when keys and values are owned by table. */
static void test_value_and_key_deleter(void) {
- census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64, &cmp_str_keys,
- &free_data, &free_data};
+ census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64,
+ &cmp_str_keys, &free_data, &free_data};
census_ht* ht = census_ht_create(&opt);
census_ht_key key;
char* val = NULL;
@@ -184,8 +184,8 @@ static void test_simple_add_and_erase(void) {
}
static void test_insertion_and_deletion_with_high_collision_rate(void) {
- census_ht_option opt = {CENSUS_HT_POINTER, 13, &force_collision,
- &cmp_str_keys, NULL, NULL};
+ census_ht_option opt = {CENSUS_HT_POINTER, 13, &force_collision,
+ &cmp_str_keys, NULL, NULL};
census_ht* ht = census_ht_create(&opt);
char key_str[1000][10];
gpr_uint64 val = 0;
@@ -208,12 +208,12 @@ static void test_insertion_and_deletion_with_high_collision_rate(void) {
}
static void test_table_with_string_key(void) {
- census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64, &cmp_str_keys, NULL,
- NULL};
+ census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64,
+ &cmp_str_keys, NULL, NULL};
census_ht* ht = census_ht_create(&opt);
- const char* keys[] = {"k1", "a", "000", "apple",
- "banana_a_long_long_long_banana", "%$", "111", "foo",
- "b"};
+ const char* keys[] = {"k1", "a", "000",
+ "apple", "banana_a_long_long_long_banana", "%$",
+ "111", "foo", "b"};
const int vals[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
int i = 0;
GPR_ASSERT(ht != NULL);
diff --git a/test/core/surface/completion_queue_benchmark.c b/test/core/surface/completion_queue_benchmark.c
index e1b9d0d035..5360d7c6c3 100644
--- a/test/core/surface/completion_queue_benchmark.c
+++ b/test/core/surface/completion_queue_benchmark.c
@@ -53,23 +53,23 @@ static void producer_thread(void *arg) {
test_thread_options *opt = arg;
int i;
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future));
for (i = 0; i < opt->iterations; i++) {
grpc_cq_begin_op(opt->cc, NULL, GRPC_WRITE_ACCEPTED);
- grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL,
- GRPC_OP_OK);
+ grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL,
+ NULL, GRPC_OP_OK);
}
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
}
static void consumer_thread(void *arg) {
test_thread_options *opt = arg;
grpc_event *ev;
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future));
for (;;) {
@@ -78,7 +78,7 @@ static void consumer_thread(void *arg) {
case GRPC_WRITE_ACCEPTED:
break;
case GRPC_QUEUE_SHUTDOWN:
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
return;
default:
gpr_log(GPR_ERROR, "Invalid event received: %d", ev->type);
@@ -112,7 +112,7 @@ double ops_per_second(int consumers, int producers, int iterations) {
/* start the benchmark */
t_start = gpr_now();
- gpr_event_set(&start, (void *)(gpr_intptr)1);
+ gpr_event_set(&start, (void *)(gpr_intptr) 1);
/* wait for producers to finish */
for (i = 0; i < producers; i++) {
diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c
index 71f9cc2291..4bbe9cc96f 100644
--- a/test/core/surface/completion_queue_test.c
+++ b/test/core/surface/completion_queue_test.c
@@ -282,7 +282,7 @@ static void producer_thread(void *arg) {
int i;
gpr_log(GPR_INFO, "producer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
@@ -291,18 +291,18 @@ static void producer_thread(void *arg) {
}
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL,
- GRPC_OP_OK);
+ grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL,
+ NULL, GRPC_OP_OK);
opt->events_triggered++;
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
}
static void consumer_thread(void *arg) {
@@ -310,13 +310,13 @@ static void consumer_thread(void *arg) {
grpc_event *ev;
gpr_log(GPR_INFO, "consumer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 1", opt->id);
gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 2", opt->id);
@@ -331,7 +331,7 @@ static void consumer_thread(void *arg) {
break;
case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
grpc_event_finish(ev);
return;
default:
@@ -376,7 +376,7 @@ static void test_threading(int producers, int consumers) {
/* start phase1: producers will pre-declare all operations they will
complete */
gpr_log(GPR_INFO, "start phase 1");
- gpr_event_set(&phase1, (void *)(gpr_intptr)1);
+ gpr_event_set(&phase1, (void *)(gpr_intptr) 1);
gpr_log(GPR_INFO, "wait phase 1");
for (i = 0; i < producers + consumers; i++) {
@@ -386,7 +386,7 @@ static void test_threading(int producers, int consumers) {
/* start phase2: operations will complete, and consumers will consume them */
gpr_log(GPR_INFO, "start phase 2");
- gpr_event_set(&phase2, (void *)(gpr_intptr)1);
+ gpr_event_set(&phase2, (void *)(gpr_intptr) 1);
/* in parallel, we shutdown the completion channel - all events should still
be consumed */
diff --git a/test/core/transport/chttp2/stream_map_test.c b/test/core/transport/chttp2/stream_map_test.c
index 9b4446f7f8..30cd63ca67 100644
--- a/test/core/transport/chttp2/stream_map_test.c
+++ b/test/core/transport/chttp2/stream_map_test.c
@@ -93,7 +93,7 @@ static void test_basic_add_find(size_t n) {
grpc_chttp2_stream_map_init(&map, 8);
GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map));
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i);
+ grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i);
}
GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map));
GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0));
@@ -148,7 +148,7 @@ static void test_delete_evens_sweep(size_t n) {
grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i);
+ grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i);
}
for (i = 1; i <= n; i++) {
if ((i & 1) == 0) {
@@ -170,7 +170,7 @@ static void test_delete_evens_incremental(size_t n) {
grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i);
+ grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i);
if ((i & 1) == 0) {
grpc_chttp2_stream_map_delete(&map, i);
}
diff --git a/test/core/util/grpc_profiler.c b/test/core/util/grpc_profiler.c
index 340b2d53b9..46bfc1f533 100644
--- a/test/core/util/grpc_profiler.c
+++ b/test/core/util/grpc_profiler.c
@@ -33,6 +33,22 @@
#include "test/core/util/grpc_profiler.h"
-void grpc_profiler_start(const char *filename) {}
+#if GRPC_HAVE_PERFTOOLS
+#include <gperftools/profiler.h>
+
+void grpc_profiler_start(const char *filename) { ProfilerStart(filename); }
+
+void grpc_profiler_stop() { ProfilerStop(); }
+#else
+#include <grpc/support/log.h>
+
+void grpc_profiler_start(const char *filename) {
+ gpr_log(GPR_DEBUG,
+ "You do not have google-perftools installed, profiling is disabled");
+ gpr_log(GPR_DEBUG,
+ "To install on ubuntu: sudo apt-get install google-perftools "
+ "libgoogle-perftools-dev");
+}
void grpc_profiler_stop(void) {}
+#endif
diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc
index ea088b87bd..174d2187b0 100644
--- a/test/cpp/client/credentials_test.cc
+++ b/test/cpp/client/credentials_test.cc
@@ -45,15 +45,6 @@ class CredentialsTest : public ::testing::Test {
protected:
};
-TEST_F(CredentialsTest, InvalidSslCreds) {
- std::unique_ptr<Credentials> bad1 =
- CredentialsFactory::SslCredentials({"", "", ""});
- EXPECT_EQ(nullptr, bad1.get());
- std::unique_ptr<Credentials> bad2 =
- CredentialsFactory::SslCredentials({"", "bla", "bla"});
- EXPECT_EQ(nullptr, bad2.get());
-}
-
TEST_F(CredentialsTest, InvalidServiceAccountCreds) {
std::unique_ptr<Credentials> bad1 =
CredentialsFactory::ServiceAccountCredentials("", "",
diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc
index 561b134c27..5b5c35416c 100644
--- a/test/cpp/interop/server.cc
+++ b/test/cpp/interop/server.cc
@@ -203,11 +203,7 @@ void RunServer() {
builder.RegisterService(service.service());
if (FLAGS_enable_ssl) {
SslServerCredentialsOptions ssl_opts = {
- "",
- {reinterpret_cast<const char*>(test_server1_key),
- test_server1_key_size},
- {reinterpret_cast<const char*>(test_server1_cert),
- test_server1_cert_size}};
+ "", {{test_server1_key, test_server1_cert}}};
std::shared_ptr<ServerCredentials> creds =
ServerCredentialsFactory::SslCredentials(ssl_opts);
builder.SetCredentials(creds);
diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc
index f0d35d98c2..68f6244a53 100644
--- a/test/cpp/util/create_test_channel.cc
+++ b/test/cpp/util/create_test_channel.cc
@@ -56,11 +56,8 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(
ChannelArguments channel_args;
if (enable_ssl) {
const char* roots_certs =
- use_prod_roots ? reinterpret_cast<const char*>(prod_roots_certs)
- : reinterpret_cast<const char*>(test_root_cert);
- unsigned int roots_certs_size =
- use_prod_roots ? prod_roots_certs_size : test_root_cert_size;
- SslCredentialsOptions ssl_opts = {{roots_certs, roots_certs_size}, "", ""};
+ use_prod_roots ? prod_roots_certs : test_root_cert;
+ SslCredentialsOptions ssl_opts = {roots_certs, "", ""};
std::unique_ptr<Credentials> creds =
CredentialsFactory::SslCredentials(ssl_opts);