aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-04-27 14:56:56 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-04-27 14:56:56 -0700
commitf7283e01ddefff3d57e30e80a0e1b3530458f400 (patch)
tree3d5fd7816155142b982d4cfa2a187f05efa1df65 /test
parent1939744de5ac47225fa36586dff342b000d08ddc (diff)
parent4865c79548d4f83ebae4e10fbaf4c3ba10535c97 (diff)
Merge github.com:grpc/grpc into trickle_stall
Diffstat (limited to 'test')
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-minimized-5175380371570688bin0 -> 48 bytes
-rw-r--r--test/core/end2end/tests/resource_quota_server.c8
-rw-r--r--test/core/support/memory_test.cc89
-rw-r--r--test/core/tsi/transport_security_test.c2
-rw-r--r--test/core/util/passthru_endpoint.c5
-rw-r--r--test/core/util/trickle_endpoint.c8
-rwxr-xr-xtest/distrib/cpp/run_distrib_test.sh9
7 files changed, 106 insertions, 15 deletions
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-minimized-5175380371570688 b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-minimized-5175380371570688
new file mode 100644
index 0000000000..9c7aebc63a
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-minimized-5175380371570688
Binary files differ
diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c
index 2453ca1b89..6418f5d01a 100644
--- a/test/core/end2end/tests/resource_quota_server.c
+++ b/test/core/end2end/tests/resource_quota_server.c
@@ -169,6 +169,7 @@ void resource_quota_server(grpc_end2end_test_config config) {
int cancelled_calls_on_client = 0;
int cancelled_calls_on_server = 0;
int deadline_exceeded = 0;
+ int unavailable = 0;
grpc_byte_buffer *request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
@@ -260,6 +261,9 @@ void resource_quota_server(grpc_end2end_test_config config) {
case GRPC_STATUS_DEADLINE_EXCEEDED:
deadline_exceeded++;
break;
+ case GRPC_STATUS_UNAVAILABLE:
+ unavailable++;
+ break;
case GRPC_STATUS_OK:
break;
default:
@@ -358,9 +362,9 @@ void resource_quota_server(grpc_end2end_test_config config) {
gpr_log(GPR_INFO,
"Done. %d total calls: %d cancelled at server, %d cancelled at "
- "client, %d timed out.",
+ "client, %d timed out, %d unavailable.",
NUM_CALLS, cancelled_calls_on_server, cancelled_calls_on_client,
- deadline_exceeded);
+ deadline_exceeded, unavailable);
grpc_byte_buffer_destroy(request_payload);
grpc_slice_unref(request_payload_slice);
diff --git a/test/core/support/memory_test.cc b/test/core/support/memory_test.cc
new file mode 100644
index 0000000000..8db316a423
--- /dev/null
+++ b/test/core/support/memory_test.cc
@@ -0,0 +1,89 @@
+/*
+ *
+ * Copyright 2017, 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/lib/support/memory.h"
+#include <gtest/gtest.h>
+#include "test/core/util/test_config.h"
+
+namespace grpc_core {
+namespace testing {
+
+struct Foo {
+ Foo(int p, int q) : a(p), b(q) {}
+ int a;
+ int b;
+};
+
+TEST(MemoryTest, NewDeleteTest) { Delete(New<int>()); }
+
+TEST(MemoryTest, NewDeleteWithArgTest) {
+ int* i = New<int>(42);
+ EXPECT_EQ(42, *i);
+ Delete(i);
+}
+
+TEST(MemoryTest, NewDeleteWithArgsTest) {
+ Foo* p = New<Foo>(1, 2);
+ EXPECT_EQ(1, p->a);
+ EXPECT_EQ(2, p->b);
+ Delete(p);
+}
+
+TEST(MemoryTest, MakeUniqueTest) { MakeUnique<int>(); }
+
+TEST(MemoryTest, MakeUniqueWithArgTest) {
+ auto i = MakeUnique<int>(42);
+ EXPECT_EQ(42, *i);
+}
+
+TEST(MemoryTest, UniquePtrWithCustomDeleter) {
+ int n = 0;
+ class IncrementingDeleter {
+ public:
+ void operator()(int* p) { ++*p; }
+ };
+ {
+ UniquePtr<int, IncrementingDeleter> p(&n);
+ EXPECT_EQ(0, n);
+ }
+ EXPECT_EQ(1, n);
+}
+
+} // namespace testing
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/core/tsi/transport_security_test.c b/test/core/tsi/transport_security_test.c
index ee4a37c314..4214407823 100644
--- a/test/core/tsi/transport_security_test.c
+++ b/test/core/tsi/transport_security_test.c
@@ -376,6 +376,8 @@ static void test_handshaker_invalid_args(void) {
TSI_INVALID_ARGUMENT);
GPR_ASSERT(tsi_handshaker_get_bytes_to_send_to_peer(NULL, NULL, NULL) ==
TSI_INVALID_ARGUMENT);
+ GPR_ASSERT(tsi_handshaker_next(NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL) ==
+ TSI_INVALID_ARGUMENT);
}
static void test_handshaker_invalid_state(void) {
diff --git a/test/core/util/passthru_endpoint.c b/test/core/util/passthru_endpoint.c
index 121567fc0d..6400845d23 100644
--- a/test/core/util/passthru_endpoint.c
+++ b/test/core/util/passthru_endpoint.c
@@ -102,13 +102,14 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown");
} else if (m->on_read != NULL) {
for (size_t i = 0; i < slices->count; i++) {
- grpc_slice_buffer_add(m->on_read_out, grpc_slice_ref(slices->slices[i]));
+ grpc_slice_buffer_add(m->on_read_out, grpc_slice_copy(slices->slices[i]));
}
grpc_closure_sched(exec_ctx, m->on_read, GRPC_ERROR_NONE);
m->on_read = NULL;
} else {
for (size_t i = 0; i < slices->count; i++) {
- grpc_slice_buffer_add(&m->read_buffer, grpc_slice_ref(slices->slices[i]));
+ grpc_slice_buffer_add(&m->read_buffer,
+ grpc_slice_copy(slices->slices[i]));
}
}
gpr_mu_unlock(&m->parent->mu);
diff --git a/test/core/util/trickle_endpoint.c b/test/core/util/trickle_endpoint.c
index 02ba257abe..69386a0718 100644
--- a/test/core/util/trickle_endpoint.c
+++ b/test/core/util/trickle_endpoint.c
@@ -78,15 +78,15 @@ static void maybe_call_write_cb_locked(grpc_exec_ctx *exec_ctx,
static void te_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
grpc_slice_buffer *slices, grpc_closure *cb) {
trickle_endpoint *te = (trickle_endpoint *)ep;
- for (size_t i = 0; i < slices->count; i++) {
- grpc_slice_ref_internal(slices->slices[i]);
- }
gpr_mu_lock(&te->mu);
GPR_ASSERT(te->write_cb == NULL);
if (te->write_buffer.length == 0) {
te->last_write = gpr_now(GPR_CLOCK_MONOTONIC);
}
- grpc_slice_buffer_addn(&te->write_buffer, slices->slices, slices->count);
+ for (size_t i = 0; i < slices->count; i++) {
+ grpc_slice_buffer_add(&te->write_buffer,
+ grpc_slice_copy(slices->slices[i]));
+ }
te->write_cb = cb;
maybe_call_write_cb_locked(exec_ctx, te);
gpr_mu_unlock(&te->mu);
diff --git a/test/distrib/cpp/run_distrib_test.sh b/test/distrib/cpp/run_distrib_test.sh
index 15fbf28107..4728e32f06 100755
--- a/test/distrib/cpp/run_distrib_test.sh
+++ b/test/distrib/cpp/run_distrib_test.sh
@@ -30,13 +30,8 @@
set -ex
-git clone $EXTERNAL_GIT_ROOT
-# clone gRPC submodules, use data from locally cloned submodules where possible
-(cd ${EXTERNAL_GIT_ROOT} && git submodule foreach 'cd /var/local/git/grpc \
-&& git submodule update --init --reference ${EXTERNAL_GIT_ROOT}/${name} \
-${name}')
-
-cd grpc
+# change to grpc repo root
+cd $(dirname $0)/../../..
cd third_party/protobuf && ./autogen.sh && \
./configure && make -j4 && make check && make install && ldconfig