aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreek@google.com>2017-03-30 13:20:00 -0700
committerGravatar Sree Kuchibhotla <sreek@google.com>2017-03-30 13:20:00 -0700
commite04906dc54e95f16bea7146459dfc1ab599b3826 (patch)
tree00d308fc6b431548a23e1a619ea6d77187f7dde0 /test/core
parent359ffd83e01e236edd8d96b8ff7e9c326354c6fb (diff)
parentbea49665d418b69597b6bc058dd78744c0fa494d (diff)
Merge branch 'master' into cq_create_api_changes
Diffstat (limited to 'test/core')
-rw-r--r--test/core/bad_ssl/servers/cert.c8
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-5965570207907840bin0 -> 1883 bytes
-rw-r--r--test/core/handshake/BUILD12
-rw-r--r--test/core/handshake/client_ssl.c10
-rw-r--r--test/core/handshake/server_ssl.c8
-rwxr-xr-xtest/core/http/test_server.py4
-rw-r--r--test/core/iomgr/ev_epoll_linux_test.c85
-rw-r--r--test/core/security/secure_endpoint_test.c2
-rw-r--r--test/core/security/security_connector_test.c4
-rw-r--r--test/core/support/time_test.c18
-rw-r--r--test/core/surface/server_chttp2_test.c2
-rw-r--r--test/core/tsi/transport_security_test.c6
-rw-r--r--test/core/util/BUILD2
13 files changed, 133 insertions, 28 deletions
diff --git a/test/core/bad_ssl/servers/cert.c b/test/core/bad_ssl/servers/cert.c
index 9aadf452e2..2b014b2343 100644
--- a/test/core/bad_ssl/servers/cert.c
+++ b/test/core/bad_ssl/servers/cert.c
@@ -56,11 +56,11 @@ int main(int argc, char **argv) {
grpc_init();
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "load_file", grpc_load_file("src/core/lib/tsi/test_creds/badserver.pem",
- 1, &cert_slice)));
+ "load_file",
+ grpc_load_file("src/core/tsi/test_creds/badserver.pem", 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "load_file", grpc_load_file("src/core/lib/tsi/test_creds/badserver.key",
- 1, &key_slice)));
+ "load_file",
+ grpc_load_file("src/core/tsi/test_creds/badserver.key", 1, &key_slice)));
pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-5965570207907840 b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-5965570207907840
new file mode 100644
index 0000000000..a58dc7b244
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-5965570207907840
Binary files differ
diff --git a/test/core/handshake/BUILD b/test/core/handshake/BUILD
index eb8f3a9beb..996b503d35 100644
--- a/test/core/handshake/BUILD
+++ b/test/core/handshake/BUILD
@@ -34,9 +34,9 @@ cc_test(
srcs = ["client_ssl.c"],
copts = ["-std=c99"],
data = [
- "//src/core/lib/tsi/test_creds:ca.pem",
- "//src/core/lib/tsi/test_creds:server1.key",
- "//src/core/lib/tsi/test_creds:server1.pem",
+ "//src/core/tsi/test_creds:ca.pem",
+ "//src/core/tsi/test_creds:server1.key",
+ "//src/core/tsi/test_creds:server1.pem",
],
deps = [
"//:gpr",
@@ -51,9 +51,9 @@ cc_test(
srcs = ["server_ssl.c"],
copts = ["-std=c99"],
data = [
- "//src/core/lib/tsi/test_creds:ca.pem",
- "//src/core/lib/tsi/test_creds:server1.key",
- "//src/core/lib/tsi/test_creds:server1.pem",
+ "//src/core/tsi/test_creds:ca.pem",
+ "//src/core/tsi/test_creds:server1.key",
+ "//src/core/tsi/test_creds:server1.pem",
],
deps = [
"//:gpr",
diff --git a/test/core/handshake/client_ssl.c b/test/core/handshake/client_ssl.c
index 16a1f47e8e..f7fa919cd4 100644
--- a/test/core/handshake/client_ssl.c
+++ b/test/core/handshake/client_ssl.c
@@ -54,9 +54,9 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-#define SSL_CERT_PATH "src/core/lib/tsi/test_creds/server1.pem"
-#define SSL_KEY_PATH "src/core/lib/tsi/test_creds/server1.key"
-#define SSL_CA_PATH "src/core/lib/tsi/test_creds/ca.pem"
+#define SSL_CERT_PATH "src/core/tsi/test_creds/server1.pem"
+#define SSL_KEY_PATH "src/core/tsi/test_creds/server1.key"
+#define SSL_CA_PATH "src/core/tsi/test_creds/ca.pem"
// Arguments for TLS server thread.
typedef struct {
@@ -146,7 +146,7 @@ static int alpn_select_cb(SSL *ssl, const uint8_t **out, uint8_t *out_len,
// Minimal TLS server. This is largely based on the example at
// https://wiki.openssl.org/index.php/Simple_TLS_Server and the gRPC core
-// internals in src/core/lib/tsi/ssl_transport_security.c.
+// internals in src/core/tsi/ssl_transport_security.c.
static void server_thread(void *arg) {
const server_args *args = (server_args *)arg;
@@ -172,7 +172,7 @@ static void server_thread(void *arg) {
}
// Set the cipher list to match the one expressed in
- // src/core/lib/tsi/ssl_transport_security.c.
+ // src/core/tsi/ssl_transport_security.c.
const char *cipher_list =
"ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-"
"SHA384:ECDHE-RSA-AES256-GCM-SHA384";
diff --git a/test/core/handshake/server_ssl.c b/test/core/handshake/server_ssl.c
index 2f93277417..30f6474b3f 100644
--- a/test/core/handshake/server_ssl.c
+++ b/test/core/handshake/server_ssl.c
@@ -49,9 +49,9 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-#define SSL_CERT_PATH "src/core/lib/tsi/test_creds/server1.pem"
-#define SSL_KEY_PATH "src/core/lib/tsi/test_creds/server1.key"
-#define SSL_CA_PATH "src/core/lib/tsi/test_creds/ca.pem"
+#define SSL_CERT_PATH "src/core/tsi/test_creds/server1.pem"
+#define SSL_KEY_PATH "src/core/tsi/test_creds/server1.key"
+#define SSL_CA_PATH "src/core/tsi/test_creds/ca.pem"
// Handshake completed signal to server thread.
static gpr_event client_handshake_complete;
@@ -174,7 +174,7 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
}
// Set the cipher list to match the one expressed in
- // src/core/lib/tsi/ssl_transport_security.c.
+ // src/core/tsi/ssl_transport_security.c.
const char *cipher_list =
"ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-"
"SHA384:ECDHE-RSA-AES256-GCM-SHA384";
diff --git a/test/core/http/test_server.py b/test/core/http/test_server.py
index 86c2fe96bf..dbbf5ceb3c 100755
--- a/test/core/http/test_server.py
+++ b/test/core/http/test_server.py
@@ -36,8 +36,8 @@ import os
import ssl
import sys
-_PEM = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..', 'src/core/lib/tsi/test_creds/server1.pem'))
-_KEY = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..', 'src/core/lib/tsi/test_creds/server1.key'))
+_PEM = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..', 'src/core/tsi/test_creds/server1.pem'))
+_KEY = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..', 'src/core/tsi/test_creds/server1.key'))
print _PEM
open(_PEM).close()
diff --git a/test/core/iomgr/ev_epoll_linux_test.c b/test/core/iomgr/ev_epoll_linux_test.c
index 8a7a970275..5f8124aeda 100644
--- a/test/core/iomgr/ev_epoll_linux_test.c
+++ b/test/core/iomgr/ev_epoll_linux_test.c
@@ -43,6 +43,8 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/useful.h>
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/workqueue.h"
@@ -312,6 +314,88 @@ static void test_add_fd_to_pollset() {
#undef NUM_FDS
#undef NUM_POLLSETS
+typedef struct threading_shared {
+ gpr_mu *mu;
+ grpc_pollset *pollset;
+ grpc_wakeup_fd *wakeup_fd;
+ grpc_fd *wakeup_desc;
+ grpc_closure on_wakeup;
+ int wakeups;
+} threading_shared;
+
+static __thread int thread_wakeups = 0;
+
+static void test_threading_loop(void *arg) {
+ threading_shared *shared = arg;
+ while (thread_wakeups < 1000000) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_pollset_worker *worker;
+ gpr_mu_lock(shared->mu);
+ GPR_ASSERT(GRPC_LOG_IF_ERROR(
+ "pollset_work",
+ grpc_pollset_work(&exec_ctx, shared->pollset, &worker,
+ gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_inf_future(GPR_CLOCK_MONOTONIC))));
+ gpr_mu_unlock(shared->mu);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+}
+
+static void test_threading_wakeup(grpc_exec_ctx *exec_ctx, void *arg,
+ grpc_error *error) {
+ threading_shared *shared = arg;
+ ++shared->wakeups;
+ ++thread_wakeups;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR(
+ "consume_wakeup", grpc_wakeup_fd_consume_wakeup(shared->wakeup_fd)));
+ grpc_fd_notify_on_read(exec_ctx, shared->wakeup_desc, &shared->on_wakeup);
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_next",
+ grpc_wakeup_fd_wakeup(shared->wakeup_fd)));
+}
+
+static void test_threading(void) {
+ threading_shared shared;
+ shared.pollset = gpr_zalloc(grpc_pollset_size());
+ grpc_pollset_init(shared.pollset, &shared.mu);
+
+ gpr_thd_id thds[10];
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
+ gpr_thd_options opt = gpr_thd_options_default();
+ gpr_thd_options_set_joinable(&opt);
+ gpr_thd_new(&thds[i], test_threading_loop, &shared, &opt);
+ }
+ grpc_wakeup_fd fd;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&fd)));
+ shared.wakeup_fd = &fd;
+ shared.wakeup_desc = grpc_fd_create(fd.read_fd, "wakeup");
+ shared.wakeups = 0;
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_pollset_add_fd(&exec_ctx, shared.pollset, shared.wakeup_desc);
+ grpc_fd_notify_on_read(
+ &exec_ctx, shared.wakeup_desc,
+ grpc_closure_init(&shared.on_wakeup, test_threading_wakeup, &shared,
+ grpc_schedule_on_exec_ctx));
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_first",
+ grpc_wakeup_fd_wakeup(shared.wakeup_fd)));
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
+ gpr_thd_join(thds[i]);
+ }
+ fd.read_fd = 0;
+ grpc_wakeup_fd_destroy(&fd);
+ {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_fd_orphan(&exec_ctx, shared.wakeup_desc, NULL, NULL, "done");
+ grpc_pollset_shutdown(&exec_ctx, shared.pollset,
+ grpc_closure_create(destroy_pollset, shared.pollset,
+ grpc_schedule_on_exec_ctx));
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+ gpr_free(shared.pollset);
+}
+
int main(int argc, char **argv) {
const char *poll_strategy = NULL;
grpc_test_init(argc, argv);
@@ -321,6 +405,7 @@ int main(int argc, char **argv) {
if (poll_strategy != NULL && strcmp(poll_strategy, "epoll") == 0) {
test_add_fd_to_pollset();
test_pollset_queue_merge_items();
+ test_threading();
} else {
gpr_log(GPR_INFO,
"Skipping the test. The test is only relevant for 'epoll' "
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c
index b3775e91a7..8f11f98a9c 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.c
@@ -43,7 +43,7 @@
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/security/transport/secure_endpoint.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/tsi/fake_transport_security.h"
+#include "src/core/tsi/fake_transport_security.h"
#include "test/core/util/test_config.h"
static gpr_mu *g_mu;
diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.c
index 4219b134f2..6c7b8e688f 100644
--- a/test/core/security/security_connector_test.c
+++ b/test/core/security/security_connector_test.c
@@ -46,8 +46,8 @@
#include "src/core/lib/support/env.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/support/tmpfile.h"
-#include "src/core/lib/tsi/ssl_transport_security.h"
-#include "src/core/lib/tsi/transport_security.h"
+#include "src/core/tsi/ssl_transport_security.h"
+#include "src/core/tsi/transport_security.h"
#include "test/core/util/test_config.h"
static int check_transport_security_type(const grpc_auth_context *ctx) {
diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c
index e9ca08d041..4cb36a788c 100644
--- a/test/core/support/time_test.c
+++ b/test/core/support/time_test.c
@@ -255,6 +255,22 @@ static void test_similar(void) {
gpr_time_from_micros(10, GPR_TIMESPAN)));
}
+static void test_convert_extreme(void) {
+ gpr_timespec realtime = {INT64_MAX, 1, GPR_CLOCK_REALTIME};
+ gpr_timespec monotime = gpr_convert_clock_type(realtime, GPR_CLOCK_MONOTONIC);
+ GPR_ASSERT(monotime.tv_sec == realtime.tv_sec);
+ GPR_ASSERT(monotime.clock_type == GPR_CLOCK_MONOTONIC);
+}
+
+static void test_cmp_extreme(void) {
+ gpr_timespec t1 = {INT64_MAX, 1, GPR_CLOCK_REALTIME};
+ gpr_timespec t2 = {INT64_MAX, 2, GPR_CLOCK_REALTIME};
+ GPR_ASSERT(gpr_time_cmp(t1, t2) == 0);
+ t1.tv_sec = INT64_MIN;
+ t2.tv_sec = INT64_MIN;
+ GPR_ASSERT(gpr_time_cmp(t1, t2) == 0);
+}
+
int main(int argc, char *argv[]) {
grpc_test_init(argc, argv);
@@ -263,5 +279,7 @@ int main(int argc, char *argv[]) {
test_overflow();
test_sticky_infinities();
test_similar();
+ test_convert_extreme();
+ test_cmp_extreme();
return 0;
}
diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c
index 0d4de0e28b..06293e5102 100644
--- a/test/core/surface/server_chttp2_test.c
+++ b/test/core/surface/server_chttp2_test.c
@@ -39,7 +39,7 @@
#include <grpc/support/time.h>
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/credentials/fake/fake_credentials.h"
-#include "src/core/lib/tsi/fake_transport_security.h"
+#include "src/core/tsi/fake_transport_security.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/tsi/transport_security_test.c b/test/core/tsi/transport_security_test.c
index 01e8770b24..ee4a37c314 100644
--- a/test/core/tsi/transport_security_test.c
+++ b/test/core/tsi/transport_security_test.c
@@ -31,7 +31,7 @@
*
*/
-#include "src/core/lib/tsi/transport_security.h"
+#include "src/core/tsi/transport_security.h"
#include <string.h>
@@ -43,8 +43,8 @@
#include <openssl/crypto.h>
#include "src/core/lib/support/string.h"
-#include "src/core/lib/tsi/fake_transport_security.h"
-#include "src/core/lib/tsi/ssl_transport_security.h"
+#include "src/core/tsi/fake_transport_security.h"
+#include "src/core/tsi/ssl_transport_security.h"
#include "test/core/util/test_config.h"
typedef struct {
diff --git a/test/core/util/BUILD b/test/core/util/BUILD
index e6d0d247db..03c79f1f15 100644
--- a/test/core/util/BUILD
+++ b/test/core/util/BUILD
@@ -56,9 +56,11 @@ cc_library(
"reconnect_server.c",
"slice_splitter.c",
"test_tcp_server.c",
+ "trickle_endpoint.c",
],
hdrs = [
"debugger_macros.h",
+ "trickle_endpoint.h",
"grpc_profiler.h",
"mock_endpoint.h",
"parse_hexstring.h",