aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/bad_client/tests/initial_settings_frame.c2
-rw-r--r--test/core/bad_client/tests/simple_request.c30
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py1
-rw-r--r--test/core/end2end/tests/channel_ping.c97
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c5
-rw-r--r--test/core/support/sync_test.c2
-rw-r--r--test/core/support/time_test.c4
-rw-r--r--test/core/surface/lame_client_test.c38
8 files changed, 173 insertions, 6 deletions
diff --git a/test/core/bad_client/tests/initial_settings_frame.c b/test/core/bad_client/tests/initial_settings_frame.c
index 17ad99df4e..5b17c08df2 100644
--- a/test/core/bad_client/tests/initial_settings_frame.c
+++ b/test/core/bad_client/tests/initial_settings_frame.c
@@ -94,7 +94,7 @@ int main(int argc, char **argv) {
/* some settings values are illegal */
/* max frame size = 0 */
GRPC_RUN_BAD_CLIENT_TEST(verifier,
- PFX_STR ONE_SETTING_HDR "\x00\x05\x00\x00\x00\x00",
+ PFX_STR ONE_SETTING_HDR "\x00\x05\x00\x00\x00\x00",
GRPC_BAD_CLIENT_DISCONNECT);
GRPC_RUN_BAD_CLIENT_TEST(verifier,
PFX_STR ONE_SETTING_HDR "\x00\x06\xff\xff\xff\xff",
diff --git a/test/core/bad_client/tests/simple_request.c b/test/core/bad_client/tests/simple_request.c
index 5cddafc0b5..b3cd556421 100644
--- a/test/core/bad_client/tests/simple_request.c
+++ b/test/core/bad_client/tests/simple_request.c
@@ -99,6 +99,14 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq) {
cq_verifier_destroy(cqv);
}
+static void failure_verifier(grpc_server *server, grpc_completion_queue *cq) {
+ while (grpc_server_has_open_connections(server)) {
+ GPR_ASSERT(grpc_completion_queue_next(cq,
+ GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20),
+ NULL).type == GRPC_QUEUE_TIMEOUT);
+ }
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
@@ -115,6 +123,28 @@ int main(int argc, char **argv) {
/* push a data frame with bad flags */
GRPC_RUN_BAD_CLIENT_TEST(verifier,
PFX_STR "\x00\x00\x00\x00\x02\x00\x00\x00\x01", 0);
+ /* push a window update with a bad length */
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier,
+ PFX_STR "\x00\x00\x01\x08\x00\x00\x00\x00\x01", 0);
+ /* push a window update with bad flags */
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier,
+ PFX_STR "\x00\x00\x00\x08\x10\x00\x00\x00\x01", 0);
+ /* push a window update with bad data */
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier,
+ PFX_STR "\x00\x00\x04\x08\x00\x00\x00\x00\x01" "\xff\xff\xff\xff", 0);
+ /* push a short goaway */
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier,
+ PFX_STR "\x00\x00\x04\x07\x00\x00\x00\x00\x00", 0);
+ /* disconnect before sending goaway */
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier,
+ PFX_STR "\x00\x01\x12\x07\x00\x00\x00\x00\x00",
+ GRPC_BAD_CLIENT_DISCONNECT);
+ /* push a rst_stream with a bad length */
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier,
+ PFX_STR "\x00\x00\x01\x03\x00\x00\x00\x00\x01", 0);
+ /* push a rst_stream with bad flags */
+ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier,
+ PFX_STR "\x00\x00\x00\x03\x10\x00\x00\x00\x01", 0);
return 0;
}
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index b8bb346d59..97bb79b0c1 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -89,6 +89,7 @@ END2END_TESTS = {
'cancel_in_a_vacuum': default_test_options,
'cancel_with_status': default_test_options,
'channel_connectivity': connectivity_test_options._replace(proxyable=False),
+ 'channel_ping': connectivity_test_options._replace(proxyable=False),
'compressed_payload': default_test_options._replace(proxyable=False),
'default_host': default_test_options._replace(needs_fullstack=True,
needs_dns=True),
diff --git a/test/core/end2end/tests/channel_ping.c b/test/core/end2end/tests/channel_ping.c
new file mode 100644
index 0000000000..441e49ee7a
--- /dev/null
+++ b/test/core/end2end/tests/channel_ping.c
@@ -0,0 +1,97 @@
+/*
+ *
+ * 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 "test/core/end2end/end2end_tests.h"
+
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+
+#include "test/core/end2end/cq_verifier.h"
+
+static void *tag(gpr_intptr t) { return (void *)t; }
+
+static void test_ping(grpc_end2end_test_config config) {
+ grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL);
+ cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
+ int i;
+
+ config.init_client(&f, NULL);
+ config.init_server(&f, NULL);
+
+ grpc_channel_ping(f.client, f.cq, tag(0), NULL);
+ cq_expect_completion(cqv, tag(0), 0);
+
+ /* check that we're still in idle, and start connecting */
+ GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 1) ==
+ GRPC_CHANNEL_IDLE);
+ /* we'll go through some set of transitions (some might be missed), until
+ READY is reached */
+ while (state != GRPC_CHANNEL_READY) {
+ grpc_channel_watch_connectivity_state(
+ f.client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(99));
+ cq_expect_completion(cqv, tag(99), 1);
+ cq_verify(cqv);
+ state = grpc_channel_check_connectivity_state(f.client, 0);
+ GPR_ASSERT(state == GRPC_CHANNEL_READY ||
+ state == GRPC_CHANNEL_CONNECTING ||
+ state == GRPC_CHANNEL_TRANSIENT_FAILURE);
+ }
+
+ for (i = 1; i <= 5; i++) {
+ grpc_channel_ping(f.client, f.cq, tag(i), NULL);
+ cq_expect_completion(cqv, tag(i), 1);
+ cq_verify(cqv);
+ }
+
+ grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead));
+ cq_expect_completion(cqv, tag(0xdead), 1);
+ cq_verify(cqv);
+
+ /* cleanup server */
+ grpc_server_destroy(f.server);
+
+ grpc_channel_destroy(f.client);
+ grpc_completion_queue_shutdown(f.cq);
+ grpc_completion_queue_destroy(f.cq);
+ config.tear_down_data(&f);
+
+ cq_verifier_destroy(cqv);
+}
+
+void grpc_end2end_tests(grpc_end2end_test_config config) {
+ GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION);
+ test_ping(config);
+}
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index a61cccdb02..833ceace54 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -234,8 +234,9 @@ void test_times_out(void) {
if (gpr_time_cmp(now, finish_time) > 0) {
break;
}
- gpr_log(GPR_DEBUG, "now=%d.%09d connect_deadline=%d.%09d", now.tv_sec,
- now.tv_nsec, connect_deadline.tv_sec, connect_deadline.tv_nsec);
+ gpr_log(GPR_DEBUG, "now=%lld.%09d connect_deadline=%lld.%09d",
+ (long long)now.tv_sec, (int)now.tv_nsec,
+ (long long)connect_deadline.tv_sec, (int)connect_deadline.tv_nsec);
if (is_after_deadline && gpr_time_cmp(now, restart_verifying_time) <= 0) {
/* allow some slack before insisting that things be done */
} else {
diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c
index 6bc5f792e5..e538af93f2 100644
--- a/test/core/support/sync_test.c
+++ b/test/core/support/sync_test.c
@@ -272,7 +272,7 @@ static void test(const char *name, void (*body)(void *m),
test_destroy(m);
}
time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
- fprintf(stderr, " done %ld.%09d s\n", (long)time_taken.tv_sec,
+ fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec,
(int)time_taken.tv_nsec);
}
diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c
index ce35edd83c..b921052e7b 100644
--- a/test/core/support/time_test.c
+++ b/test/core/support/time_test.c
@@ -98,7 +98,7 @@ static void test_values(void) {
fprintf(stderr, "far future ");
i_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
fprintf(stderr, "\n");
- GPR_ASSERT(x.tv_sec >= INT_MAX);
+ GPR_ASSERT(x.tv_sec == INT64_MAX);
fprintf(stderr, "far future ");
ts_to_s(x, &to_fp, stderr);
fprintf(stderr, "\n");
@@ -107,7 +107,7 @@ static void test_values(void) {
fprintf(stderr, "far past ");
i_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
fprintf(stderr, "\n");
- GPR_ASSERT(x.tv_sec <= INT_MIN);
+ GPR_ASSERT(x.tv_sec == INT64_MIN);
fprintf(stderr, "far past ");
ts_to_s(x, &to_fp, stderr);
fprintf(stderr, "\n");
diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c
index 971055e6fd..1b1955fa0e 100644
--- a/test/core/surface/lame_client_test.c
+++ b/test/core/surface/lame_client_test.c
@@ -36,11 +36,47 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/channel/channel_stack.h"
+#include "src/core/iomgr/closure.h"
+#include "src/core/surface/channel.h"
+#include "src/core/transport/transport.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/test_config.h"
+grpc_closure transport_op_cb;
+
static void *tag(gpr_intptr x) { return (void *)x; }
+void verify_connectivity(grpc_exec_ctx *exec_ctx, void *arg, int success) {
+ grpc_transport_op* op = arg;
+ GPR_ASSERT(GRPC_CHANNEL_FATAL_FAILURE == *op->connectivity_state);
+ GPR_ASSERT(success);
+}
+
+void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, int success) { }
+
+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;
+
+ memset(&op, 0, sizeof(op));
+ grpc_closure_init(&transport_op_cb, verify_connectivity, &op);
+
+ 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);
+
+ memset(&op, 0, sizeof(op));
+ grpc_closure_init(&transport_op_cb, do_nothing, NULL);
+ op.on_consumed = &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;
@@ -66,6 +102,8 @@ int main(int argc, char **argv) {
"lampoon:national", GRPC_STATUS_UNKNOWN, "Rpc sent on a lame channel.");
GPR_ASSERT(chan);
+ test_transport_op(chan);
+
GPR_ASSERT(GRPC_CHANNEL_FATAL_FAILURE ==
grpc_channel_check_connectivity_state(chan, 0));