aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2018-01-24 10:58:25 -0800
committerGravatar Yash Tibrewal <yashkt@google.com>2018-01-24 10:58:25 -0800
commitea8027a0b1b5ca2ba2e29f9924d5c164cc75aba1 (patch)
treea8409e75cbf9966c0aad4fc5df5d8af33dc59fa6 /test
parent7cbbee745e84d714f826e54fdbc93499341e7fa3 (diff)
parent5e7eed29ed747a24a91c3d202066e64d0478d5db (diff)
Merge branch 'master' into badclient
Diffstat (limited to 'test')
-rw-r--r--test/core/backoff/backoff_test.cc34
-rw-r--r--test/core/bad_client/bad_client.cc4
-rw-r--r--test/core/bad_client/tests/large_metadata.cc2
-rw-r--r--test/core/bad_ssl/bad_ssl_test.cc4
-rw-r--r--test/core/channel/minimal_stack_is_minimal_test.cc2
-rw-r--r--test/core/client_channel/lb_policies_test.cc2
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.cc4
-rw-r--r--test/core/compression/message_compress_test.cc2
-rw-r--r--test/core/end2end/bad_server_response_test.cc2
-rw-r--r--test/core/end2end/cq_verifier.cc2
-rw-r--r--test/core/end2end/dualstack_socket_test.cc13
-rw-r--r--test/core/end2end/fixtures/h2_full+trace.cc2
-rw-r--r--test/core/end2end/fixtures/h2_http_proxy.cc2
-rw-r--r--test/core/end2end/fixtures/h2_sockpair+trace.cc2
-rw-r--r--test/core/end2end/fixtures/h2_ssl.cc6
-rw-r--r--test/core/end2end/fixtures/h2_ssl_proxy.cc6
-rw-r--r--test/core/end2end/fixtures/h2_uds.cc2
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc2
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.cc15
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer_corpus/fuzz-input-d2ab5bin0 -> 48866 bytes
-rw-r--r--test/core/end2end/goaway_server_test.cc4
-rw-r--r--test/core/end2end/h2_ssl_cert_test.cc6
-rw-r--r--test/core/end2end/tests/bad_hostname.cc2
-rw-r--r--test/core/end2end/tests/call_creds.cc2
-rw-r--r--test/core/end2end/tests/cancel_with_status.cc2
-rw-r--r--test/core/end2end/tests/default_host.cc2
-rw-r--r--test/core/end2end/tests/empty_batch.cc2
-rw-r--r--test/core/end2end/tests/filter_status_code.cc53
-rw-r--r--test/core/end2end/tests/high_initial_seqno.cc2
-rw-r--r--test/core/end2end/tests/hpack_size.cc2
-rw-r--r--test/core/end2end/tests/idempotent_request.cc2
-rw-r--r--test/core/end2end/tests/keepalive_timeout.cc2
-rw-r--r--test/core/end2end/tests/negative_deadline.cc2
-rw-r--r--test/core/end2end/tests/no_logging.cc2
-rw-r--r--test/core/end2end/tests/proxy_auth.cc2
-rw-r--r--test/core/end2end/tests/registered_call.cc2
-rw-r--r--test/core/end2end/tests/server_finishes_request.cc2
-rw-r--r--test/core/end2end/tests/simple_request.cc2
-rw-r--r--test/core/fling/client.cc2
-rw-r--r--test/core/fling/fling_stream_test.cc2
-rw-r--r--test/core/fling/fling_test.cc2
-rw-r--r--test/core/gpr/BUILD (renamed from test/core/support/BUILD)65
-rw-r--r--test/core/gpr/alloc_test.cc (renamed from test/core/support/alloc_test.cc)14
-rw-r--r--test/core/gpr/arena_test.cc (renamed from test/core/support/arena_test.cc)6
-rw-r--r--test/core/gpr/avl_test.cc (renamed from test/core/support/avl_test.cc)0
-rw-r--r--test/core/gpr/cmdline_test.cc (renamed from test/core/support/cmdline_test.cc)0
-rw-r--r--test/core/gpr/cpu_test.cc (renamed from test/core/support/cpu_test.cc)3
-rw-r--r--test/core/gpr/env_test.cc (renamed from test/core/support/env_test.cc)4
-rw-r--r--test/core/gpr/host_port_test.cc (renamed from test/core/support/host_port_test.cc)0
-rw-r--r--test/core/gpr/log_test.cc (renamed from test/core/support/log_test.cc)2
-rw-r--r--test/core/gpr/mpscq_test.cc (renamed from test/core/support/mpscq_test.cc)2
-rw-r--r--test/core/gpr/murmur_hash_test.cc (renamed from test/core/support/murmur_hash_test.cc)2
-rw-r--r--test/core/gpr/spinlock_test.cc (renamed from test/core/support/spinlock_test.cc)6
-rw-r--r--test/core/gpr/string_test.cc (renamed from test/core/support/string_test.cc)2
-rw-r--r--test/core/gpr/sync_test.cc (renamed from test/core/support/sync_test.cc)8
-rw-r--r--test/core/gpr/thd_test.cc (renamed from test/core/support/thd_test.cc)0
-rw-r--r--test/core/gpr/time_test.cc (renamed from test/core/support/time_test.cc)11
-rw-r--r--test/core/gpr/tls_test.cc (renamed from test/core/support/tls_test.cc)0
-rw-r--r--test/core/gpr/useful_test.cc (renamed from test/core/support/useful_test.cc)0
-rw-r--r--test/core/gprpp/BUILD96
-rw-r--r--test/core/gprpp/inlined_vector_test.cc74
-rw-r--r--test/core/gprpp/manual_constructor_test.cc (renamed from test/core/support/manual_constructor_test.cc)4
-rw-r--r--test/core/gprpp/memory_test.cc (renamed from test/core/support/memory_test.cc)2
-rw-r--r--test/core/gprpp/orphanable_test.cc114
-rw-r--r--test/core/gprpp/ref_counted_ptr_test.cc (renamed from test/core/support/ref_counted_ptr_test.cc)19
-rw-r--r--test/core/gprpp/ref_counted_test.cc (renamed from test/core/support/ref_counted_test.cc)8
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.cc6
-rw-r--r--test/core/iomgr/fd_conservation_posix_test.cc2
-rw-r--r--test/core/iomgr/load_file_test.cc4
-rw-r--r--test/core/iomgr/pollset_set_test.cc6
-rw-r--r--test/core/iomgr/resource_quota_test.cc14
-rw-r--r--test/core/iomgr/udp_server_test.cc23
-rw-r--r--test/core/iomgr/wakeup_fd_cv_test.cc2
-rw-r--r--test/core/json/json_test.cc2
-rw-r--r--test/core/memory_usage/client.cc4
-rw-r--r--test/core/memory_usage/memory_usage_test.cc2
-rw-r--r--test/core/network_benchmarks/low_level_ping_pong.cc4
-rw-r--r--test/core/security/auth_context_test.cc2
-rw-r--r--test/core/security/create_jwt.cc5
-rw-r--r--test/core/security/credentials_test.cc6
-rw-r--r--test/core/security/print_google_default_creds_token.cc4
-rw-r--r--test/core/security/security_connector_test.cc6
-rw-r--r--test/core/security/verify_jwt.cc2
-rw-r--r--test/core/slice/percent_encoding_test.cc2
-rw-r--r--test/core/slice/slice_string_helpers_test.cc2
-rw-r--r--test/core/support/vector_test.cc42
-rw-r--r--test/core/surface/alarm_test.cc11
-rw-r--r--test/core/surface/public_headers_must_be_c89.c1
-rw-r--r--test/core/transport/bdp_estimator_test.cc2
-rw-r--r--test/core/transport/chttp2/bin_decoder_test.cc2
-rw-r--r--test/core/transport/chttp2/bin_encoder_test.cc2
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.cc2
-rw-r--r--test/core/transport/chttp2/hpack_table_test.cc2
-rw-r--r--test/core/transport/metadata_test.cc2
-rw-r--r--test/core/transport/pid_controller_test.cc2
-rw-r--r--test/core/transport/timeout_encoding_test.cc4
-rw-r--r--test/core/tsi/transport_security_test.cc2
-rw-r--r--test/core/util/debugger_macros.cc2
-rw-r--r--test/core/util/test_config.cc4
-rw-r--r--test/cpp/client/client_channel_stress_test.cc8
-rw-r--r--test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj533
-rw-r--r--test/cpp/cocoapods/Podfile71
-rw-r--r--test/cpp/cocoapods/generic/Info.plist22
-rw-r--r--test/cpp/cocoapods/generic/generic.mm244
-rw-r--r--test/cpp/cocoapods/test/Info.plist22
-rw-r--r--test/cpp/cocoapods/test/server_context_test_spouse_test.mm100
-rw-r--r--test/cpp/end2end/BUILD171
-rw-r--r--test/cpp/end2end/async_end2end_test.cc2
-rw-r--r--test/cpp/end2end/client_lb_end2end_test.cc45
-rw-r--r--test/cpp/end2end/end2end_test.cc35
-rw-r--r--test/cpp/end2end/exception_test.cc119
-rw-r--r--test/cpp/end2end/grpclb_end2end_test.cc49
-rw-r--r--test/cpp/end2end/server_early_return_test.cc233
-rw-r--r--test/cpp/end2end/shutdown_test.cc2
-rw-r--r--test/cpp/end2end/test_service_impl.cc13
-rw-r--r--test/cpp/end2end/test_service_impl.h1
-rw-r--r--test/cpp/grpclb/grpclb_test.cc6
-rw-r--r--test/cpp/interop/client.cc2
-rw-r--r--test/cpp/interop/http2_client.cc2
-rw-r--r--test/cpp/interop/interop_server.cc2
-rw-r--r--test/cpp/interop/interop_test.cc2
-rw-r--r--test/cpp/microbenchmarks/bm_arena.cc2
-rw-r--r--test/cpp/microbenchmarks/bm_closure.cc2
-rw-r--r--test/cpp/naming/resolver_component_test.cc4
-rw-r--r--test/cpp/naming/resolver_component_tests_runner_invoker.cc2
-rw-r--r--test/cpp/qps/driver.cc3
-rw-r--r--test/cpp/qps/json_run_localhost.cc2
-rw-r--r--test/distrib/cpp/run_distrib_test_cmake.bat4
128 files changed, 2103 insertions, 427 deletions
diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc
index 7bc4d14ce6..2e61243831 100644
--- a/test/core/backoff/backoff_test.cc
+++ b/test/core/backoff/backoff_test.cc
@@ -45,11 +45,11 @@ TEST(BackOffTest, ConstantBackOff) {
.set_max_backoff(max_backoff);
BackOff backoff(options);
- grpc_millis next_attempt_start_time = backoff.Begin();
+ grpc_millis next_attempt_start_time = backoff.NextAttemptTime();
EXPECT_EQ(next_attempt_start_time - grpc_core::ExecCtx::Get()->Now(),
initial_backoff);
for (int i = 0; i < 10000; i++) {
- next_attempt_start_time = backoff.Step();
+ next_attempt_start_time = backoff.NextAttemptTime();
EXPECT_EQ(next_attempt_start_time - grpc_core::ExecCtx::Get()->Now(),
initial_backoff);
}
@@ -67,7 +67,7 @@ TEST(BackOffTest, MinConnect) {
.set_jitter(jitter)
.set_max_backoff(max_backoff);
BackOff backoff(options);
- grpc_millis next = backoff.Begin();
+ grpc_millis next = backoff.NextAttemptTime();
EXPECT_EQ(next - grpc_core::ExecCtx::Get()->Now(), initial_backoff);
}
@@ -86,42 +86,42 @@ TEST(BackOffTest, NoJitterBackOff) {
// x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
grpc_core::ExecCtx exec_ctx;
grpc_core::ExecCtx::Get()->TestOnlySetNow(0);
- grpc_millis next = backoff.Begin();
+ grpc_millis next = backoff.NextAttemptTime();
EXPECT_EQ(next, 2);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 6);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 14);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 30);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 62);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 126);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 254);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 510);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 1022);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
// Hit the maximum timeout. From this point onwards, retries will increase
// only by max timeout.
EXPECT_EQ(next, 1535);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 2048);
grpc_core::ExecCtx::Get()->TestOnlySetNow(next);
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
EXPECT_EQ(next, 2561);
}
@@ -141,7 +141,7 @@ TEST(BackOffTest, JitterBackOff) {
backoff.SetRandomSeed(0); // force consistent PRNG
grpc_core::ExecCtx exec_ctx;
- grpc_millis next = backoff.Begin();
+ grpc_millis next = backoff.NextAttemptTime();
EXPECT_EQ(next - grpc_core::ExecCtx::Get()->Now(), initial_backoff);
grpc_millis expected_next_lower_bound =
@@ -150,7 +150,7 @@ TEST(BackOffTest, JitterBackOff) {
(grpc_millis)((double)current_backoff * (1 + jitter));
for (int i = 0; i < 10000; i++) {
- next = backoff.Step();
+ next = backoff.NextAttemptTime();
// next-now must be within (jitter*100)% of the current backoff (which
// increases by * multiplier up to max_backoff).
const grpc_millis timeout_millis = next - grpc_core::ExecCtx::Get()->Now();
diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc
index 140c43fec9..0f586f14f1 100644
--- a/test/core/bad_client/bad_client.cc
+++ b/test/core/bad_client/bad_client.cc
@@ -28,10 +28,10 @@
#include "src/core/ext/filters/http/server/http_server_filter.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/channel_stack.h"
+#include "src/core/lib/gpr/murmur_hash.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/endpoint_pair.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/murmur_hash.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
diff --git a/test/core/bad_client/tests/large_metadata.cc b/test/core/bad_client/tests/large_metadata.cc
index 429af8c955..d534753f53 100644
--- a/test/core/bad_client/tests/large_metadata.cc
+++ b/test/core/bad_client/tests/large_metadata.cc
@@ -22,7 +22,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc
index 0e74a62f19..8a7960b5ed 100644
--- a/test/core/bad_ssl/bad_ssl_test.cc
+++ b/test/core/bad_ssl/bad_ssl_test.cc
@@ -26,8 +26,8 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/subprocess.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/channel/minimal_stack_is_minimal_test.cc b/test/core/channel/minimal_stack_is_minimal_test.cc
index 3495f603e4..f02c8180f2 100644
--- a/test/core/channel/minimal_stack_is_minimal_test.cc
+++ b/test/core/channel/minimal_stack_is_minimal_test.cc
@@ -35,7 +35,7 @@
#include <string.h>
#include "src/core/lib/channel/channel_stack_builder.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/transport_impl.h"
diff --git a/test/core/client_channel/lb_policies_test.cc b/test/core/client_channel/lb_policies_test.cc
index 847ea0066b..716c63b9d0 100644
--- a/test/core/client_channel/lb_policies_test.cc
+++ b/test/core/client_channel/lb_policies_test.cc
@@ -30,7 +30,7 @@
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
index 4d16a77924..07ee133ee3 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
@@ -63,8 +63,10 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
-
grpc_uri_destroy(uri);
+ /* Flush ExecCtx to avoid stack-use-after-scope on on_res_arg which is
+ * accessed in the closure on_resolution_cb */
+ grpc_core::ExecCtx::Get()->Flush();
}
static void test_fails(grpc_resolver_factory* factory, const char* string) {
diff --git a/test/core/compression/message_compress_test.cc b/test/core/compression/message_compress_test.cc
index 6ca07b70c4..b03ca4c4cb 100644
--- a/test/core/compression/message_compress_test.cc
+++ b/test/core/compression/message_compress_test.cc
@@ -25,8 +25,8 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/murmur_hash.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/support/murmur_hash.h"
#include "test/core/util/slice_splitter.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc
index 93809ac37a..a8e5e291c8 100644
--- a/test/core/end2end/bad_server_response_test.cc
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -31,10 +31,10 @@
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/end2end/cq_verifier.cc b/test/core/end2end/cq_verifier.cc
index 8686f4e7b7..7bf8ae0f6e 100644
--- a/test/core/end2end/cq_verifier.cc
+++ b/test/core/end2end/cq_verifier.cc
@@ -29,7 +29,7 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/event_string.h"
#define ROOT_EXPECTATION 1000
diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc
index 2ba1c17c2c..bb30547cd2 100644
--- a/test/core/end2end/dualstack_socket_test.cc
+++ b/test/core/end2end/dualstack_socket_test.cc
@@ -29,12 +29,12 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -43,14 +43,11 @@
static void* tag(intptr_t i) { return (void*)i; }
-static gpr_timespec ms_from_now(int ms) {
- return grpc_timeout_milliseconds_to_deadline(ms);
-}
-
static void drain_cq(grpc_completion_queue* cq) {
grpc_event ev;
do {
- ev = grpc_completion_queue_next(cq, ms_from_now(5000), nullptr);
+ ev = grpc_completion_queue_next(
+ cq, grpc_timeout_milliseconds_to_deadline(5000), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
@@ -165,11 +162,11 @@ void test_connect(const char* server_host, const char* client_host, int port,
if (expect_ok) {
/* Normal deadline, shouldn't be reached. */
- deadline = ms_from_now(60000);
+ deadline = grpc_timeout_milliseconds_to_deadline(60000);
} else {
/* Give up faster when failure is expected.
BUG: Setting this to 1000 reveals a memory leak (b/18608927). */
- deadline = ms_from_now(1500);
+ deadline = grpc_timeout_milliseconds_to_deadline(3000);
}
/* Send a trivial request. */
diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc
index a49de96009..7104fbc581 100644
--- a/test/core/end2end/fixtures/h2_full+trace.cc
+++ b/test/core/end2end/fixtures/h2_full+trace.cc
@@ -35,7 +35,7 @@
#include "src/core/ext/filters/http/server/http_server_filter.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/connected_channel.h"
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/util/port.h"
diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc
index 099367d91b..e8e81f0930 100644
--- a/test/core/end2end/fixtures/h2_http_proxy.cc
+++ b/test/core/end2end/fixtures/h2_http_proxy.cc
@@ -31,7 +31,7 @@
#include "src/core/ext/filters/http/server/http_server_filter.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/connected_channel.h"
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/fixtures/http_proxy_fixture.h"
diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc
index 9807e929af..236780b8d3 100644
--- a/test/core/end2end/fixtures/h2_sockpair+trace.cc
+++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc
@@ -36,9 +36,9 @@
#include "src/core/ext/filters/http/server/http_server_filter.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/connected_channel.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/endpoint_pair.h"
#include "src/core/lib/iomgr/iomgr.h"
-#include "src/core/lib/support/env.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc
index 9a0680c40e..8c5c8a2f3f 100644
--- a/test/core/end2end/fixtures/h2_ssl.cc
+++ b/test/core/end2end/fixtures/h2_ssl.cc
@@ -26,10 +26,10 @@
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc
index 5ddbdefc8c..3f0646cf0f 100644
--- a/test/core/end2end/fixtures/h2_ssl_proxy.cc
+++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc
@@ -26,10 +26,10 @@
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/end2end/fixtures/proxy.h"
#include "test/core/util/port.h"
diff --git a/test/core/end2end/fixtures/h2_uds.cc b/test/core/end2end/fixtures/h2_uds.cc
index 28f0a50e15..1944dd84a3 100644
--- a/test/core/end2end/fixtures/h2_uds.cc
+++ b/test/core/end2end/fixtures/h2_uds.cc
@@ -33,7 +33,7 @@
#include "src/core/ext/filters/http/server/http_server_filter.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/connected_channel.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/util/port.h"
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc
index 137f7c9fa3..8ec97df3e4 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -34,6 +34,7 @@
#include <grpc/support/useful.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/combiner.h"
@@ -49,7 +50,6 @@
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/slice/b64.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/port.h"
struct grpc_end2end_http_proxy {
diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc
index 967a6d560f..14c155502a 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.cc
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -28,13 +28,13 @@
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/iomgr/timer_manager.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/env.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/metadata.h"
#include "test/core/end2end/data/ssl_test_data.h"
@@ -280,7 +280,12 @@ static grpc_channel_credentials* read_ssl_channel_creds(input_stream* inp) {
return creds;
}
-static grpc_call_credentials* read_call_creds(input_stream* inp) {
+static grpc_call_credentials* read_call_creds(input_stream* inp, int depth) {
+ if (depth > 64) {
+ // prevent creating infinitely deep call creds
+ end(inp);
+ return nullptr;
+ }
switch (next_byte(inp)) {
default:
end(inp);
@@ -288,8 +293,8 @@ static grpc_call_credentials* read_call_creds(input_stream* inp) {
case 0:
return nullptr;
case 1: {
- grpc_call_credentials* c1 = read_call_creds(inp);
- grpc_call_credentials* c2 = read_call_creds(inp);
+ grpc_call_credentials* c1 = read_call_creds(inp, depth + 1);
+ grpc_call_credentials* c2 = read_call_creds(inp, depth + 1);
if (c1 != nullptr && c2 != nullptr) {
grpc_call_credentials* out =
grpc_composite_call_credentials_create(c1, c2, nullptr);
@@ -338,7 +343,7 @@ static grpc_channel_credentials* read_channel_creds(input_stream* inp) {
break;
case 1: {
grpc_channel_credentials* c1 = read_channel_creds(inp);
- grpc_call_credentials* c2 = read_call_creds(inp);
+ grpc_call_credentials* c2 = read_call_creds(inp, 0);
if (c1 != nullptr && c2 != nullptr) {
grpc_channel_credentials* out =
grpc_composite_channel_credentials_create(c1, c2, nullptr);
diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/fuzz-input-d2ab5 b/test/core/end2end/fuzzers/api_fuzzer_corpus/fuzz-input-d2ab5
new file mode 100644
index 0000000000..1745798b68
--- /dev/null
+++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/fuzz-input-d2ab5
Binary files differ
diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc
index 94cfbdda7e..f23d87ea68 100644
--- a/test/core/end2end/goaway_server_test.cc
+++ b/test/core/end2end/goaway_server_test.cc
@@ -187,7 +187,7 @@ int main(int argc, char** argv) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->flags = 0;
+ op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call1, ops,
@@ -263,7 +263,7 @@ int main(int argc, char** argv) {
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
- op->flags = 0;
+ op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
op->reserved = nullptr;
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call2, ops,
diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc
index d50d1f4d81..3383d6d5d1 100644
--- a/test/core/end2end/h2_ssl_cert_test.cc
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -26,10 +26,10 @@
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
diff --git a/test/core/end2end/tests/bad_hostname.cc b/test/core/end2end/tests/bad_hostname.cc
index 97ef62b5e3..85e9ba1307 100644
--- a/test/core/end2end/tests/bad_hostname.cc
+++ b/test/core/end2end/tests/bad_hostname.cc
@@ -27,7 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/call_creds.cc b/test/core/end2end/tests/call_creds.cc
index e1c868232c..c5ea101c53 100644
--- a/test/core/end2end/tests/call_creds.cc
+++ b/test/core/end2end/tests/call_creds.cc
@@ -27,8 +27,8 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/string.h"
#include "test/core/end2end/cq_verifier.h"
static const char iam_token[] = "token";
diff --git a/test/core/end2end/tests/cancel_with_status.cc b/test/core/end2end/tests/cancel_with_status.cc
index c867751d53..7937fd161f 100644
--- a/test/core/end2end/tests/cancel_with_status.cc
+++ b/test/core/end2end/tests/cancel_with_status.cc
@@ -28,7 +28,7 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/default_host.cc b/test/core/end2end/tests/default_host.cc
index 85f92b0ab0..7c94420540 100644
--- a/test/core/end2end/tests/default_host.cc
+++ b/test/core/end2end/tests/default_host.cc
@@ -27,7 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/empty_batch.cc b/test/core/end2end/tests/empty_batch.cc
index b249c141de..c41e65ddd2 100644
--- a/test/core/end2end/tests/empty_batch.cc
+++ b/test/core/end2end/tests/empty_batch.cc
@@ -27,7 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/filter_status_code.cc b/test/core/end2end/tests/filter_status_code.cc
index 261ddd93ec..61c658b95a 100644
--- a/test/core/end2end/tests/filter_status_code.cc
+++ b/test/core/end2end/tests/filter_status_code.cc
@@ -30,11 +30,14 @@
#include <grpc/support/useful.h>
#include "src/core/lib/channel/channel_stack_builder.h"
+#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel_init.h"
#include "test/core/end2end/cq_verifier.h"
static bool g_enable_filter = false;
static gpr_mu g_mu;
+static grpc_call_stack* g_client_call_stack;
+static grpc_call_stack* g_server_call_stack;
static bool g_client_code_recv;
static bool g_server_code_recv;
static gpr_cv g_client_code_cv;
@@ -117,6 +120,8 @@ static void test_request(grpc_end2end_test_config config) {
int was_cancelled = 2;
gpr_mu_lock(&g_mu);
+ g_client_call_stack = nullptr;
+ g_server_call_stack = nullptr;
g_client_status_code = GRPC_STATUS_OK;
g_server_status_code = GRPC_STATUS_OK;
gpr_mu_unlock(&g_mu);
@@ -127,6 +132,9 @@ static void test_request(grpc_end2end_test_config config) {
grpc_slice_from_static_string("/foo"),
get_host_override_slice("foo.test.google.fr", config), deadline, nullptr);
GPR_ASSERT(c);
+ gpr_mu_lock(&g_mu);
+ g_client_call_stack = grpc_call_get_call_stack(c);
+ gpr_mu_unlock(&g_mu);
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
@@ -168,6 +176,10 @@ static void test_request(grpc_end2end_test_config config) {
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
cq_verify(cqv);
+ gpr_mu_lock(&g_mu);
+ g_server_call_stack = grpc_call_get_call_stack(s);
+ gpr_mu_unlock(&g_mu);
+
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -215,49 +227,62 @@ static void test_request(grpc_end2end_test_config config) {
// Perform checks after test tear-down
// Guards against the case that there's outstanding channel-related work on a
// call prior to verification
- // TODO(https://github.com/grpc/grpc/issues/13915) enable this for windows
-#ifndef GPR_WINDOWS
gpr_mu_lock(&g_mu);
if (!g_client_code_recv) {
GPR_ASSERT(gpr_cv_wait(&g_client_code_cv, &g_mu,
- grpc_timeout_seconds_to_deadline(3)));
+ grpc_timeout_seconds_to_deadline(3)) == 0);
}
if (!g_server_code_recv) {
- GPR_ASSERT(gpr_cv_wait(&g_client_code_cv, &g_mu,
- grpc_timeout_seconds_to_deadline(3)));
+ GPR_ASSERT(gpr_cv_wait(&g_server_code_cv, &g_mu,
+ grpc_timeout_seconds_to_deadline(3)) == 0);
}
GPR_ASSERT(g_client_status_code == GRPC_STATUS_UNIMPLEMENTED);
GPR_ASSERT(g_server_status_code == GRPC_STATUS_UNIMPLEMENTED);
gpr_mu_unlock(&g_mu);
-#endif // GPR_WINDOWS
}
/*******************************************************************************
* Test status_code filter
*/
+typedef struct final_status_data {
+ grpc_call_stack* call;
+} final_status_data;
+
static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
+ final_status_data* data = (final_status_data*)elem->call_data;
+ data->call = args->call_stack;
return GRPC_ERROR_NONE;
}
static void client_destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
+ final_status_data* data = (final_status_data*)elem->call_data;
gpr_mu_lock(&g_mu);
- g_client_status_code = final_info->final_status;
- g_client_code_recv = true;
- gpr_cv_signal(&g_client_code_cv);
+ // Some fixtures, like proxies, will spawn intermidiate calls
+ // We only want the results from our explicit calls
+ if (data->call == g_client_call_stack) {
+ g_client_status_code = final_info->final_status;
+ g_client_code_recv = true;
+ gpr_cv_signal(&g_client_code_cv);
+ }
gpr_mu_unlock(&g_mu);
}
static void server_destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
+ final_status_data* data = (final_status_data*)elem->call_data;
gpr_mu_lock(&g_mu);
- g_server_status_code = final_info->final_status;
- g_server_code_recv = true;
- gpr_cv_signal(&g_server_code_cv);
+ // Some fixtures, like proxies, will spawn intermidiate calls
+ // We only want the results from our explicit calls
+ if (data->call == g_server_call_stack) {
+ g_server_status_code = final_info->final_status;
+ g_server_code_recv = true;
+ gpr_cv_signal(&g_server_code_cv);
+ }
gpr_mu_unlock(&g_mu);
}
@@ -271,7 +296,7 @@ static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_client_filter = {
grpc_call_next_op,
grpc_channel_next_op,
- 0,
+ sizeof(final_status_data),
init_call_elem,
grpc_call_stack_ignore_set_pollset_or_pollset_set,
client_destroy_call_elem,
@@ -284,7 +309,7 @@ static const grpc_channel_filter test_client_filter = {
static const grpc_channel_filter test_server_filter = {
grpc_call_next_op,
grpc_channel_next_op,
- 0,
+ sizeof(final_status_data),
init_call_elem,
grpc_call_stack_ignore_set_pollset_or_pollset_set,
server_destroy_call_elem,
diff --git a/test/core/end2end/tests/high_initial_seqno.cc b/test/core/end2end/tests/high_initial_seqno.cc
index d390a954e5..d4d4f5a817 100644
--- a/test/core/end2end/tests/high_initial_seqno.cc
+++ b/test/core/end2end/tests/high_initial_seqno.cc
@@ -29,7 +29,7 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/hpack_size.cc b/test/core/end2end/tests/hpack_size.cc
index 7ac5fefa22..0d6ec01e36 100644
--- a/test/core/end2end/tests/hpack_size.cc
+++ b/test/core/end2end/tests/hpack_size.cc
@@ -29,7 +29,7 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/idempotent_request.cc b/test/core/end2end/tests/idempotent_request.cc
index e39975382a..7487e4d83d 100644
--- a/test/core/end2end/tests/idempotent_request.cc
+++ b/test/core/end2end/tests/idempotent_request.cc
@@ -27,7 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc
index 822565510f..6482b86825 100644
--- a/test/core/end2end/tests/keepalive_timeout.cc
+++ b/test/core/end2end/tests/keepalive_timeout.cc
@@ -28,8 +28,8 @@
#include <grpc/support/useful.h>
#include "src/core/ext/transport/chttp2/transport/frame_ping.h"
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/support/env.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/negative_deadline.cc b/test/core/end2end/tests/negative_deadline.cc
index b793964b48..b752bf9482 100644
--- a/test/core/end2end/tests/negative_deadline.cc
+++ b/test/core/end2end/tests/negative_deadline.cc
@@ -27,7 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/no_logging.cc b/test/core/end2end/tests/no_logging.cc
index bf8651221a..d89918bd3e 100644
--- a/test/core/end2end/tests/no_logging.cc
+++ b/test/core/end2end/tests/no_logging.cc
@@ -28,8 +28,8 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/error.h"
-#include "src/core/lib/support/string.h"
#include "test/core/end2end/cq_verifier.h"
enum { TIMEOUT = 200000 };
diff --git a/test/core/end2end/tests/proxy_auth.cc b/test/core/end2end/tests/proxy_auth.cc
index e4b91ab879..495151b592 100644
--- a/test/core/end2end/tests/proxy_auth.cc
+++ b/test/core/end2end/tests/proxy_auth.cc
@@ -32,7 +32,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/registered_call.cc b/test/core/end2end/tests/registered_call.cc
index 440d817cf1..cefa89db4d 100644
--- a/test/core/end2end/tests/registered_call.cc
+++ b/test/core/end2end/tests/registered_call.cc
@@ -27,7 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/server_finishes_request.cc b/test/core/end2end/tests/server_finishes_request.cc
index 46b874b569..743b3aeb91 100644
--- a/test/core/end2end/tests/server_finishes_request.cc
+++ b/test/core/end2end/tests/server_finishes_request.cc
@@ -27,7 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc
index 7eb7467981..ae93f79c9d 100644
--- a/test/core/end2end/tests/simple_request.cc
+++ b/test/core/end2end/tests/simple_request.cc
@@ -28,7 +28,7 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "src/core/lib/debug/stats.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
static void* tag(intptr_t t) { return (void*)t; }
diff --git a/test/core/fling/client.cc b/test/core/fling/client.cc
index 69fb6dc7c7..28e62e0e83 100644
--- a/test/core/fling/client.cc
+++ b/test/core/fling/client.cc
@@ -186,8 +186,10 @@ int main(int argc, char** argv) {
}
if (!sc.name) {
fprintf(stderr, "unsupported scenario '%s'. Valid are:", scenario_name);
+ fflush(stderr);
for (i = 0; i < GPR_ARRAY_SIZE(scenarios); i++) {
fprintf(stderr, " %s", scenarios[i].name);
+ fflush(stderr);
}
return 1;
}
diff --git a/test/core/fling/fling_stream_test.cc b/test/core/fling/fling_stream_test.cc
index b476f2e128..b5a5ce816e 100644
--- a/test/core/fling/fling_stream_test.cc
+++ b/test/core/fling/fling_stream_test.cc
@@ -23,7 +23,7 @@
#include <grpc/support/host_port.h>
#include <grpc/support/string_util.h>
#include <grpc/support/subprocess.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/port.h"
int main(int argc, char** argv) {
diff --git a/test/core/fling/fling_test.cc b/test/core/fling/fling_test.cc
index 0e8b3c1028..3792e45c42 100644
--- a/test/core/fling/fling_test.cc
+++ b/test/core/fling/fling_test.cc
@@ -23,7 +23,7 @@
#include <grpc/support/host_port.h>
#include <grpc/support/string_util.h>
#include <grpc/support/subprocess.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/port.h"
int main(int argc, const char** argv) {
diff --git a/test/core/support/BUILD b/test/core/gpr/BUILD
index 4372b49b54..1be1036d04 100644
--- a/test/core/support/BUILD
+++ b/test/core/gpr/BUILD
@@ -16,7 +16,7 @@ load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_c
licenses(["notice"]) # Apache v2
-grpc_package(name = "test/core/support")
+grpc_package(name = "test/core/gpr")
grpc_cc_test(
name = "alloc_test",
@@ -119,16 +119,6 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "manual_constructor_test",
- srcs = ["manual_constructor_test.cc"],
- language = "C++",
- deps = [
- "//:gpr",
- "//test/core/util:gpr_test_util",
- ],
-)
-
-grpc_cc_test(
name = "spinlock_test",
srcs = ["spinlock_test.cc"],
language = "C++",
@@ -187,56 +177,3 @@ grpc_cc_test(
"//test/core/util:gpr_test_util",
],
)
-
-grpc_cc_test(
- name = "memory_test",
- srcs = ["memory_test.cc"],
- external_deps = [
- "gtest",
- ],
- language = "C++",
- deps = [
- "//:grpc",
- "//test/core/util:gpr_test_util",
- ],
-)
-
-grpc_cc_test(
- name = "vector_test",
- srcs = ["vector_test.cc"],
- external_deps = [
- "gtest",
- ],
- language = "C++",
- deps = [
- "//:grpc",
- "//test/core/util:gpr_test_util",
- ],
-)
-
-grpc_cc_test(
- name = "ref_counted_test",
- srcs = ["ref_counted_test.cc"],
- language = "C++",
- deps = [
- "//:ref_counted",
- "//test/core/util:gpr_test_util",
- ],
- external_deps = [
- "gtest",
- ],
-)
-
-grpc_cc_test(
- name = "ref_counted_ptr_test",
- srcs = ["ref_counted_ptr_test.cc"],
- language = "C++",
- deps = [
- "//:ref_counted",
- "//:ref_counted_ptr",
- "//test/core/util:gpr_test_util",
- ],
- external_deps = [
- "gtest",
- ],
-)
diff --git a/test/core/support/alloc_test.cc b/test/core/gpr/alloc_test.cc
index 6074c6e6e7..bf4471c36f 100644
--- a/test/core/support/alloc_test.cc
+++ b/test/core/gpr/alloc_test.cc
@@ -16,8 +16,11 @@
*
*/
+#include <string.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+
#include "test/core/util/test_config.h"
static void* fake_malloc(size_t size) { return (void*)size; }
@@ -48,8 +51,19 @@ static void test_custom_allocs() {
gpr_free(i);
}
+static void test_malloc_aligned() {
+ for (size_t size = 1; size <= 256; ++size) {
+ void* ptr = gpr_malloc_aligned(size, 16);
+ GPR_ASSERT(ptr != nullptr);
+ GPR_ASSERT(((intptr_t)ptr & 0xf) == 0);
+ memset(ptr, 0, size);
+ gpr_free_aligned(ptr);
+ }
+}
+
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_custom_allocs();
+ test_malloc_aligned();
return 0;
}
diff --git a/test/core/support/arena_test.cc b/test/core/gpr/arena_test.cc
index ada0f43854..62a3f8bf50 100644
--- a/test/core/support/arena_test.cc
+++ b/test/core/gpr/arena_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/arena.h"
+#include "src/core/lib/gpr/arena.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -27,7 +27,7 @@
#include <inttypes.h>
#include <string.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
static void test_noop(void) { gpr_arena_destroy(gpr_arena_create(1)); }
@@ -53,6 +53,8 @@ static void test(const char* name, size_t init_size, const size_t* allocs,
void** ps = static_cast<void**>(gpr_zalloc(sizeof(*ps) * nallocs));
for (size_t i = 0; i < nallocs; i++) {
ps[i] = gpr_arena_alloc(a, allocs[i]);
+ // ensure the returned address is aligned
+ GPR_ASSERT(((intptr_t)ps[i] & 0xf) == 0);
// ensure no duplicate results
for (size_t j = 0; j < i; j++) {
GPR_ASSERT(ps[i] != ps[j]);
diff --git a/test/core/support/avl_test.cc b/test/core/gpr/avl_test.cc
index 345db557b9..345db557b9 100644
--- a/test/core/support/avl_test.cc
+++ b/test/core/gpr/avl_test.cc
diff --git a/test/core/support/cmdline_test.cc b/test/core/gpr/cmdline_test.cc
index 172efda8a0..172efda8a0 100644
--- a/test/core/support/cmdline_test.cc
+++ b/test/core/gpr/cmdline_test.cc
diff --git a/test/core/support/cpu_test.cc b/test/core/gpr/cpu_test.cc
index 334c4318e1..87cdc0fb50 100644
--- a/test/core/support/cpu_test.cc
+++ b/test/core/gpr/cpu_test.cc
@@ -119,13 +119,16 @@ static void cpu_test(void) {
}
gpr_mu_unlock(&ct.mu);
fprintf(stderr, "Saw cores [");
+ fflush(stderr);
for (i = 0; i < ct.ncores; i++) {
if (ct.used[i]) {
fprintf(stderr, "%d,", i);
+ fflush(stderr);
cores_seen++;
}
}
fprintf(stderr, "] (%d/%d)\n", cores_seen, ct.ncores);
+ fflush(stderr);
gpr_free(ct.used);
}
diff --git a/test/core/support/env_test.cc b/test/core/gpr/env_test.cc
index b12c04d06f..3f4b493239 100644
--- a/test/core/support/env_test.cc
+++ b/test/core/gpr/env_test.cc
@@ -22,8 +22,8 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
diff --git a/test/core/support/host_port_test.cc b/test/core/gpr/host_port_test.cc
index 42dd56524f..42dd56524f 100644
--- a/test/core/support/host_port_test.cc
+++ b/test/core/gpr/host_port_test.cc
diff --git a/test/core/support/log_test.cc b/test/core/gpr/log_test.cc
index 7dba35c13e..839ff0aef9 100644
--- a/test/core/support/log_test.cc
+++ b/test/core/gpr/log_test.cc
@@ -21,7 +21,7 @@
#include <stdbool.h>
#include <string.h>
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "test/core/util/test_config.h"
static bool log_func_reached = false;
diff --git a/test/core/support/mpscq_test.cc b/test/core/gpr/mpscq_test.cc
index 1b83f7d5be..5a8177543c 100644
--- a/test/core/support/mpscq_test.cc
+++ b/test/core/gpr/mpscq_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/mpscq.h"
+#include "src/core/lib/gpr/mpscq.h"
#include <stdlib.h>
diff --git a/test/core/support/murmur_hash_test.cc b/test/core/gpr/murmur_hash_test.cc
index 461c728951..d920dd3f95 100644
--- a/test/core/support/murmur_hash_test.cc
+++ b/test/core/gpr/murmur_hash_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/murmur_hash.h"
+#include "src/core/lib/gpr/murmur_hash.h"
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "test/core/util/test_config.h"
diff --git a/test/core/support/spinlock_test.cc b/test/core/gpr/spinlock_test.cc
index 58d5fcd42b..77e3dfbede 100644
--- a/test/core/support/spinlock_test.cc
+++ b/test/core/gpr/spinlock_test.cc
@@ -18,7 +18,7 @@
/* Test of gpr synchronization support. */
-#include "src/core/lib/support/spinlock.h"
+#include "src/core/lib/gpr/spinlock.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -95,15 +95,18 @@ static void test(const char* name, void (*body)(void* m), int timeout_s,
gpr_timespec deadline = gpr_time_add(
start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN));
fprintf(stderr, "%s:", name);
+ fflush(stderr);
while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
if (iterations < INT64_MAX / 2) iterations <<= 1;
fprintf(stderr, " %ld", (long)iterations);
+ fflush(stderr);
m = test_new(10, iterations, incr_step);
test_create_threads(m, body);
test_wait(m);
if (m->counter != m->thread_count * m->iterations * m->incr_step) {
fprintf(stderr, "counter %ld threads %d iterations %ld\n",
(long)m->counter, m->thread_count, (long)m->iterations);
+ fflush(stderr);
GPR_ASSERT(0);
}
test_destroy(m);
@@ -111,6 +114,7 @@ static void test(const char* name, void (*body)(void* m), int timeout_s,
time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec,
(int)time_taken.tv_nsec);
+ fflush(stderr);
}
/* Increment m->counter on each iteration; then mark thread as done. */
diff --git a/test/core/support/string_test.cc b/test/core/gpr/string_test.cc
index fd7f7cde59..57068eb2c9 100644
--- a/test/core/support/string_test.cc
+++ b/test/core/gpr/string_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include <limits.h>
#include <stddef.h>
diff --git a/test/core/support/sync_test.cc b/test/core/gpr/sync_test.cc
index fb7ec44754..768f96d093 100644
--- a/test/core/support/sync_test.cc
+++ b/test/core/gpr/sync_test.cc
@@ -231,16 +231,17 @@ static void mark_thread_done(struct test* m) {
*/
static void test(const char* name, void (*body)(void* m),
void (*extra)(void* m), int timeout_s, int incr_step) {
- int64_t iterations = 1024;
+ int64_t iterations = 256;
struct test* m;
gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
gpr_timespec time_taken;
gpr_timespec deadline = gpr_time_add(
start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN));
fprintf(stderr, "%s:", name);
+ fflush(stderr);
while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
- iterations <<= 1;
fprintf(stderr, " %ld", (long)iterations);
+ fflush(stderr);
m = test_new(10, iterations, incr_step);
if (extra != nullptr) {
gpr_thd_id id;
@@ -252,13 +253,16 @@ static void test(const char* name, void (*body)(void* m),
if (m->counter != m->threads * m->iterations * m->incr_step) {
fprintf(stderr, "counter %ld threads %d iterations %ld\n",
(long)m->counter, m->threads, (long)m->iterations);
+ fflush(stderr);
GPR_ASSERT(0);
}
test_destroy(m);
+ iterations <<= 1;
}
time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec,
(int)time_taken.tv_nsec);
+ fflush(stderr);
}
/* Increment m->counter on each iteration; then mark thread as done. */
diff --git a/test/core/support/thd_test.cc b/test/core/gpr/thd_test.cc
index b755bf18f3..b755bf18f3 100644
--- a/test/core/support/thd_test.cc
+++ b/test/core/gpr/thd_test.cc
diff --git a/test/core/support/time_test.cc b/test/core/gpr/time_test.cc
index 608169274f..b2b4dce58e 100644
--- a/test/core/support/time_test.cc
+++ b/test/core/gpr/time_test.cc
@@ -66,21 +66,28 @@ static void test_values(void) {
x = gpr_inf_future(GPR_CLOCK_REALTIME);
fprintf(stderr, "far future ");
+ fflush(stderr);
i_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
fprintf(stderr, "\n");
GPR_ASSERT(x.tv_sec == INT64_MAX);
fprintf(stderr, "far future ");
+ fflush(stderr);
ts_to_s(x, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
x = gpr_inf_past(GPR_CLOCK_REALTIME);
fprintf(stderr, "far past ");
+ fflush(stderr);
i_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
GPR_ASSERT(x.tv_sec == INT64_MIN);
fprintf(stderr, "far past ");
+ fflush(stderr);
ts_to_s(x, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
for (i = 1; i != 1000 * 1000 * 1000; i *= 10) {
x = gpr_time_from_micros(i, GPR_TIMESPAN);
@@ -135,15 +142,19 @@ static void test_add_sub(void) {
if (gpr_time_cmp(gpr_time_from_micros(sum * k, GPR_TIMESPAN), sumt) !=
0) {
fprintf(stderr, "i %d j %d sum %d sumt ", i, j, sum);
+ fflush(stderr);
ts_to_s(sumt, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
GPR_ASSERT(0);
}
if (gpr_time_cmp(gpr_time_from_micros(diff * k, GPR_TIMESPAN), difft) !=
0) {
fprintf(stderr, "i %d j %d diff %d diff ", i, j, diff);
+ fflush(stderr);
ts_to_s(sumt, &to_fp, stderr);
fprintf(stderr, "\n");
+ fflush(stderr);
GPR_ASSERT(0);
}
}
diff --git a/test/core/support/tls_test.cc b/test/core/gpr/tls_test.cc
index 743b10f090..743b10f090 100644
--- a/test/core/support/tls_test.cc
+++ b/test/core/gpr/tls_test.cc
diff --git a/test/core/support/useful_test.cc b/test/core/gpr/useful_test.cc
index 2f86010d77..2f86010d77 100644
--- a/test/core/support/useful_test.cc
+++ b/test/core/gpr/useful_test.cc
diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD
new file mode 100644
index 0000000000..1c11e0bdb5
--- /dev/null
+++ b/test/core/gprpp/BUILD
@@ -0,0 +1,96 @@
+# Copyright 2016 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary", "grpc_package")
+
+licenses(["notice"]) # Apache v2
+
+grpc_package(name = "test/core/gprpp")
+
+grpc_cc_test(
+ name = "manual_constructor_test",
+ srcs = ["manual_constructor_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:gpr++_base",
+ "//test/core/util:gpr_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "memory_test",
+ srcs = ["memory_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ language = "C++",
+ deps = [
+ "//:gpr++_base",
+ "//test/core/util:gpr_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "inlined_vector_test",
+ srcs = ["inlined_vector_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ language = "C++",
+ deps = [
+ "//:inlined_vector",
+ "//test/core/util:gpr_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "orphanable_test",
+ srcs = ["orphanable_test.cc"],
+ language = "C++",
+ deps = [
+ "//:orphanable",
+ "//test/core/util:gpr_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "ref_counted_test",
+ srcs = ["ref_counted_test.cc"],
+ language = "C++",
+ deps = [
+ "//:ref_counted",
+ "//test/core/util:gpr_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "ref_counted_ptr_test",
+ srcs = ["ref_counted_ptr_test.cc"],
+ language = "C++",
+ deps = [
+ "//:ref_counted",
+ "//:ref_counted_ptr",
+ "//test/core/util:gpr_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
diff --git a/test/core/gprpp/inlined_vector_test.cc b/test/core/gprpp/inlined_vector_test.cc
new file mode 100644
index 0000000000..0e712dafe4
--- /dev/null
+++ b/test/core/gprpp/inlined_vector_test.cc
@@ -0,0 +1,74 @@
+/*
+ *
+ * Copyright 2017 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "src/core/lib/gprpp/inlined_vector.h"
+#include <gtest/gtest.h>
+#include "src/core/lib/gprpp/memory.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc_core {
+namespace testing {
+
+TEST(InlinedVectorTest, CreateAndIterate) {
+ const int kNumElements = 9;
+ InlinedVector<int, 2> v;
+ for (int i = 0; i < kNumElements; ++i) {
+ v.push_back(i);
+ }
+ EXPECT_EQ(static_cast<size_t>(kNumElements), v.size());
+ for (int i = 0; i < kNumElements; ++i) {
+ EXPECT_EQ(i, v[i]);
+ }
+}
+
+TEST(InlinedVectorTest, ValuesAreInlined) {
+ const int kNumElements = 5;
+ InlinedVector<int, 10> v;
+ for (int i = 0; i < kNumElements; ++i) {
+ v.push_back(i);
+ }
+ EXPECT_EQ(static_cast<size_t>(kNumElements), v.size());
+ for (int i = 0; i < kNumElements; ++i) {
+ EXPECT_EQ(i, v[i]);
+ }
+}
+
+TEST(InlinedVectorTest, PushBackWithMove) {
+ InlinedVector<UniquePtr<int>, 1> v;
+ UniquePtr<int> i = MakeUnique<int>(3);
+ v.push_back(std::move(i));
+ EXPECT_EQ(nullptr, i.get());
+ EXPECT_EQ(1UL, v.size());
+ EXPECT_EQ(3, *v[0]);
+}
+
+TEST(InlinedVectorTest, EmplaceBack) {
+ InlinedVector<UniquePtr<int>, 1> v;
+ v.emplace_back(New<int>(3));
+ EXPECT_EQ(1UL, v.size());
+ EXPECT_EQ(3, *v[0]);
+}
+
+} // 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/support/manual_constructor_test.cc b/test/core/gprpp/manual_constructor_test.cc
index 714f8b21a0..f06c3cab06 100644
--- a/test/core/support/manual_constructor_test.cc
+++ b/test/core/gprpp/manual_constructor_test.cc
@@ -18,7 +18,7 @@
/* Test of gpr synchronization support. */
-#include "src/core/lib/support/manual_constructor.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -26,7 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
-#include "src/core/lib/support/abstract.h"
+#include "src/core/lib/gprpp/abstract.h"
#include "test/core/util/test_config.h"
class A {
diff --git a/test/core/support/memory_test.cc b/test/core/gprpp/memory_test.cc
index 79ab631a78..180c36fad7 100644
--- a/test/core/support/memory_test.cc
+++ b/test/core/gprpp/memory_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/lib/support/memory.h"
+#include "src/core/lib/gprpp/memory.h"
#include <gtest/gtest.h>
#include "test/core/util/test_config.h"
diff --git a/test/core/gprpp/orphanable_test.cc b/test/core/gprpp/orphanable_test.cc
new file mode 100644
index 0000000000..ff2f6d8bc2
--- /dev/null
+++ b/test/core/gprpp/orphanable_test.cc
@@ -0,0 +1,114 @@
+/*
+ *
+ * Copyright 2017 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "src/core/lib/gprpp/orphanable.h"
+
+#include <gtest/gtest.h>
+
+#include "src/core/lib/gprpp/memory.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc_core {
+namespace testing {
+namespace {
+
+class Foo : public Orphanable {
+ public:
+ Foo() : Foo(0) {}
+ explicit Foo(int value) : value_(value) {}
+ void Orphan() override { Delete(this); }
+ int value() const { return value_; }
+
+ private:
+ int value_;
+};
+
+TEST(Orphanable, Basic) {
+ Foo* foo = New<Foo>();
+ foo->Orphan();
+}
+
+TEST(OrphanablePtr, Basic) {
+ OrphanablePtr<Foo> foo(New<Foo>());
+ EXPECT_EQ(0, foo->value());
+}
+
+TEST(MakeOrphanable, DefaultConstructor) {
+ auto foo = MakeOrphanable<Foo>();
+ EXPECT_EQ(0, foo->value());
+}
+
+TEST(MakeOrphanable, WithParameters) {
+ auto foo = MakeOrphanable<Foo>(5);
+ EXPECT_EQ(5, foo->value());
+}
+
+class Bar : public InternallyRefCounted {
+ public:
+ Bar() : Bar(0) {}
+ explicit Bar(int value) : value_(value) {}
+ void Orphan() override { Unref(); }
+ int value() const { return value_; }
+
+ void StartWork() { Ref(); }
+ void FinishWork() { Unref(); }
+
+ private:
+ int value_;
+};
+
+TEST(OrphanablePtr, InternallyRefCounted) {
+ auto bar = MakeOrphanable<Bar>();
+ bar->StartWork();
+ bar->FinishWork();
+}
+
+// Note: We use DebugOnlyTraceFlag instead of TraceFlag to ensure that
+// things build properly in both debug and non-debug cases.
+DebugOnlyTraceFlag baz_tracer(true, "baz");
+
+class Baz : public InternallyRefCountedWithTracing {
+ public:
+ Baz() : Baz(0) {}
+ explicit Baz(int value)
+ : InternallyRefCountedWithTracing(&baz_tracer), value_(value) {}
+ void Orphan() override { Unref(); }
+ int value() const { return value_; }
+
+ void StartWork() { Ref(DEBUG_LOCATION, "work"); }
+ void FinishWork() { Unref(DEBUG_LOCATION, "work"); }
+
+ private:
+ int value_;
+};
+
+TEST(OrphanablePtr, InternallyRefCountedWithTracing) {
+ auto baz = MakeOrphanable<Baz>();
+ baz->StartWork();
+ baz->FinishWork();
+}
+
+} // namespace
+} // 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/support/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc
index 1830edc4e5..f1f13f3183 100644
--- a/test/core/support/ref_counted_ptr_test.cc
+++ b/test/core/gprpp/ref_counted_ptr_test.cc
@@ -16,14 +16,14 @@
*
*/
-#include "src/core/lib/support/ref_counted_ptr.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include <gtest/gtest.h>
#include <grpc/support/log.h>
-#include "src/core/lib/support/memory.h"
-#include "src/core/lib/support/ref_counted.h"
+#include "src/core/lib/gprpp/memory.h"
+#include "src/core/lib/gprpp/ref_counted.h"
#include "test/core/util/test_config.h"
namespace grpc_core {
@@ -138,6 +138,19 @@ TEST(RefCountedPtr, DerefernceOperators) {
foo_ref.value();
}
+TEST(RefCountedPtr, EqualityOperators) {
+ RefCountedPtr<Foo> foo(New<Foo>());
+ RefCountedPtr<Foo> bar = foo;
+ RefCountedPtr<Foo> empty;
+ // Test equality between RefCountedPtrs.
+ EXPECT_EQ(foo, bar);
+ EXPECT_NE(foo, empty);
+ // Test equality with bare pointers.
+ EXPECT_EQ(foo, foo.get());
+ EXPECT_EQ(empty, nullptr);
+ EXPECT_NE(foo, nullptr);
+}
+
TEST(MakeRefCounted, NoArgs) {
RefCountedPtr<Foo> foo = MakeRefCounted<Foo>();
EXPECT_EQ(0, foo->value());
diff --git a/test/core/support/ref_counted_test.cc b/test/core/gprpp/ref_counted_test.cc
index be9b6ff7c2..b1b0fee5c0 100644
--- a/test/core/support/ref_counted_test.cc
+++ b/test/core/gprpp/ref_counted_test.cc
@@ -16,11 +16,11 @@
*
*/
-#include "src/core/lib/support/ref_counted.h"
+#include "src/core/lib/gprpp/ref_counted.h"
#include <gtest/gtest.h>
-#include "src/core/lib/support/memory.h"
+#include "src/core/lib/gprpp/memory.h"
#include "test/core/util/test_config.h"
namespace grpc_core {
@@ -44,7 +44,9 @@ TEST(RefCounted, ExtraRef) {
foo->Unref();
}
-TraceFlag foo_tracer(true, "foo");
+// Note: We use DebugOnlyTraceFlag instead of TraceFlag to ensure that
+// things build properly in both debug and non-debug cases.
+DebugOnlyTraceFlag foo_tracer(true, "foo");
class FooWithTracing : public RefCountedWithTracing {
public:
diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc
index e767e01f21..262470300e 100644
--- a/test/core/iomgr/ev_epollsig_linux_test.cc
+++ b/test/core/iomgr/ev_epollsig_linux_test.cc
@@ -18,7 +18,7 @@
#include "src/core/lib/iomgr/port.h"
/* This test only relevant on linux systems where epoll() is available */
-#ifdef GRPC_LINUX_EPOLL
+#ifdef GRPC_LINUX_EPOLL_CREATE1
#include "src/core/lib/iomgr/ev_epollsig_linux.h"
#include "src/core/lib/iomgr/ev_posix.h"
@@ -319,6 +319,6 @@ int main(int argc, char** argv) {
grpc_shutdown();
return 0;
}
-#else /* defined(GRPC_LINUX_EPOLL) */
+#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */
int main(int argc, char** argv) { return 0; }
-#endif /* !defined(GRPC_LINUX_EPOLL) */
+#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */
diff --git a/test/core/iomgr/fd_conservation_posix_test.cc b/test/core/iomgr/fd_conservation_posix_test.cc
index aaa14010f8..4866e350d5 100644
--- a/test/core/iomgr/fd_conservation_posix_test.cc
+++ b/test/core/iomgr/fd_conservation_posix_test.cc
@@ -43,7 +43,7 @@ int main(int argc, char** argv) {
grpc_resource_quota_create("fd_conservation_posix_test");
for (i = 0; i < 100; i++) {
- p = grpc_iomgr_create_endpoint_pair("test", NULL);
+ p = grpc_iomgr_create_endpoint_pair("test", nullptr);
grpc_endpoint_destroy(p.client);
grpc_endpoint_destroy(p.server);
grpc_core::ExecCtx::Get()->Flush();
diff --git a/test/core/iomgr/load_file_test.cc b/test/core/iomgr/load_file_test.cc
index 797d0ef1a4..38c8710535 100644
--- a/test/core/iomgr/load_file_test.cc
+++ b/test/core/iomgr/load_file_test.cc
@@ -24,9 +24,9 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/iomgr/load_file.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "test/core/util/test_config.h"
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc
index f27079134b..7d2f59bed4 100644
--- a/test/core/iomgr/pollset_set_test.cc
+++ b/test/core/iomgr/pollset_set_test.cc
@@ -18,7 +18,7 @@
#include "src/core/lib/iomgr/port.h"
/* This test only relevant on linux systems where epoll is available */
-#ifdef GRPC_LINUX_EPOLL
+#ifdef GRPC_LINUX_EPOLL_CREATE1
#include <errno.h>
#include <string.h>
@@ -443,6 +443,6 @@ int main(int argc, char** argv) {
grpc_shutdown();
return 0;
}
-#else /* defined(GRPC_LINUX_EPOLL) */
+#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */
int main(int argc, char** argv) { return 0; }
-#endif /* !defined(GRPC_LINUX_EPOLL) */
+#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */
diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc
index ae26f72701..07682d2630 100644
--- a/test/core/iomgr/resource_quota_test.cc
+++ b/test/core/iomgr/resource_quota_test.cc
@@ -118,7 +118,7 @@ static void test_instant_alloc_then_free(void) {
grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
grpc_core::ExecCtx exec_ctx;
- grpc_resource_user_alloc(usr, 1024, NULL);
+ grpc_resource_user_alloc(usr, 1024, nullptr);
}
{
grpc_core::ExecCtx exec_ctx;
@@ -136,7 +136,7 @@ static void test_instant_alloc_free_pair(void) {
grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
grpc_core::ExecCtx exec_ctx;
- grpc_resource_user_alloc(usr, 1024, NULL);
+ grpc_resource_user_alloc(usr, 1024, nullptr);
grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
@@ -565,7 +565,7 @@ static void test_resource_user_stays_allocated_until_memory_released(void) {
grpc_resource_user* usr = grpc_resource_user_create(q, "usr");
{
grpc_core::ExecCtx exec_ctx;
- grpc_resource_user_alloc(usr, 1024, NULL);
+ grpc_resource_user_alloc(usr, 1024, nullptr);
}
{
grpc_core::ExecCtx exec_ctx;
@@ -608,8 +608,8 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
grpc_core::ExecCtx exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
grpc_core::ExecCtx::Get()->Flush();
- GPR_ASSERT(gpr_event_wait(&allocated,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline(
+ 5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -667,8 +667,8 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
grpc_core::ExecCtx exec_ctx;
grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
grpc_core::ExecCtx::Get()->Flush();
- GPR_ASSERT(gpr_event_wait(&allocated,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline(
+ 5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc
index dc1248bc1c..09f0283013 100644
--- a/test/core/iomgr/udp_server_test.cc
+++ b/test/core/iomgr/udp_server_test.cc
@@ -51,6 +51,9 @@ static int g_number_of_bytes_read = 0;
static int g_number_of_orphan_calls = 0;
static int g_number_of_starts = 0;
+int rcv_buf_size = 1024;
+int snd_buf_size = 1024;
+
static void on_start(grpc_fd* emfd, void* user_data) { g_number_of_starts++; }
static bool on_read(grpc_fd* emfd) {
@@ -177,8 +180,9 @@ static void test_no_op_with_port(void) {
memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_in);
addr->sin_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_start, on_read,
- on_write, on_fd_orphaned));
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size,
+ snd_buf_size, on_start, on_read, on_write,
+ on_fd_orphaned));
grpc_udp_server_destroy(s, nullptr);
@@ -207,8 +211,9 @@ static void test_no_op_with_port_and_socket_factory(void) {
memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_in);
addr->sin_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_start, on_read,
- on_write, on_fd_orphaned));
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size,
+ snd_buf_size, on_start, on_read, on_write,
+ on_fd_orphaned));
GPR_ASSERT(socket_factory->number_of_socket_calls == 1);
GPR_ASSERT(socket_factory->number_of_bind_calls == 1);
@@ -233,8 +238,9 @@ static void test_no_op_with_port_and_start(void) {
memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_in);
addr->sin_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_start, on_read,
- on_write, on_fd_orphaned));
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size,
+ snd_buf_size, on_start, on_read, on_write,
+ on_fd_orphaned));
grpc_udp_server_start(s, nullptr, 0, nullptr);
GPR_ASSERT(g_number_of_starts == 1);
@@ -265,8 +271,9 @@ static void test_receive(int number_of_clients) {
memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_storage);
addr->ss_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_start, on_read,
- on_write, on_fd_orphaned));
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size,
+ snd_buf_size, on_start, on_read, on_write,
+ on_fd_orphaned));
svrfd = grpc_udp_server_get_fd(s, 0);
GPR_ASSERT(svrfd >= 0);
diff --git a/test/core/iomgr/wakeup_fd_cv_test.cc b/test/core/iomgr/wakeup_fd_cv_test.cc
index d4e05bd7ef..c092a8f3bf 100644
--- a/test/core/iomgr/wakeup_fd_cv_test.cc
+++ b/test/core/iomgr/wakeup_fd_cv_test.cc
@@ -27,9 +27,9 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr_posix.h"
-#include "src/core/lib/support/env.h"
typedef struct poll_args {
struct pollfd* fds;
diff --git a/test/core/json/json_test.cc b/test/core/json/json_test.cc
index 18b9c55ee7..902f1cd90e 100644
--- a/test/core/json/json_test.cc
+++ b/test/core/json/json_test.cc
@@ -22,8 +22,8 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/json/json.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/memory_usage/client.cc b/test/core/memory_usage/client.cc
index eb90067970..ca841434aa 100644
--- a/test/core/memory_usage/client.cc
+++ b/test/core/memory_usage/client.cc
@@ -28,8 +28,8 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/memory_counters.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc
index 58e31c9531..fb6d290130 100644
--- a/test/core/memory_usage/memory_usage_test.cc
+++ b/test/core/memory_usage/memory_usage_test.cc
@@ -23,7 +23,7 @@
#include <grpc/support/host_port.h>
#include <grpc/support/string_util.h>
#include <grpc/support/subprocess.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/port.h"
int main(int argc, char** argv) {
diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc
index 96b0745f52..fb982a10fd 100644
--- a/test/core/network_benchmarks/low_level_ping_pong.cc
+++ b/test/core/network_benchmarks/low_level_ping_pong.cc
@@ -535,6 +535,7 @@ void print_usage(char* argv0) {
fprintf(stderr, " tcp: fds are endpoints of a TCP connection\n");
fprintf(stderr, " socketpair: fds come from socketpair()\n");
fprintf(stderr, " pipe: fds come from pipe()\n");
+ fflush(stderr);
}
typedef struct test_strategy {
@@ -565,6 +566,7 @@ int create_socket(const char* socket_type, fd_pair* client_fds,
create_sockets_pipe(client_fds, server_fds);
} else {
fprintf(stderr, "Invalid socket type %s\n", socket_type);
+ fflush(stderr);
return -1;
}
return 0;
@@ -657,6 +659,7 @@ int main(int argc, char** argv) {
}
if (msg_size <= 0) {
fprintf(stderr, "msg_size must be > 0\n");
+ fflush(stderr);
print_usage(argv[0]);
return -1;
}
@@ -668,6 +671,7 @@ int main(int argc, char** argv) {
}
if (strategy == nullptr) {
fprintf(stderr, "Invalid read strategy %s\n", read_strategy);
+ fflush(stderr);
return -1;
}
diff --git a/test/core/security/auth_context_test.cc b/test/core/security/auth_context_test.cc
index d8e41326c0..58f0d8e1c2 100644
--- a/test/core/security/auth_context_test.cc
+++ b/test/core/security/auth_context_test.cc
@@ -18,8 +18,8 @@
#include <string.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/security/context/security_context.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
#include <grpc/support/log.h>
diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc
index 867a8ba575..56ae9c891c 100644
--- a/test/core/security/create_jwt.cc
+++ b/test/core/security/create_jwt.cc
@@ -39,6 +39,7 @@ void create_jwt(const char* json_key_file_path, const char* service_url,
grpc_slice_unref(json_key_data);
if (!grpc_auth_json_key_is_valid(&key)) {
fprintf(stderr, "Could not parse json key.\n");
+ fflush(stderr);
exit(1);
}
jwt = grpc_jwt_encode_and_sign(
@@ -47,6 +48,7 @@ void create_jwt(const char* json_key_file_path, const char* service_url,
grpc_auth_json_key_destruct(&key);
if (jwt == nullptr) {
fprintf(stderr, "Could not create JWT.\n");
+ fflush(stderr);
exit(1);
}
fprintf(stdout, "%s\n", jwt);
@@ -72,16 +74,19 @@ int main(int argc, char** argv) {
if (json_key_file_path == nullptr) {
fprintf(stderr, "Missing --json_key option.\n");
+ fflush(stderr);
exit(1);
}
if (scope != nullptr) {
if (service_url != nullptr) {
fprintf(stderr,
"Options --scope and --service_url are mutually exclusive.\n");
+ fflush(stderr);
exit(1);
}
} else if (service_url == nullptr) {
fprintf(stderr, "Need one of --service_url or --scope options.\n");
+ fflush(stderr);
exit(1);
}
diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc
index ecc61928f5..90310469aa 100644
--- a/test/core/security/credentials_test.cc
+++ b/test/core/security/credentials_test.cc
@@ -31,6 +31,9 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/http/httpcli.h"
#include "src/core/lib/security/credentials/composite/composite_credentials.h"
#include "src/core/lib/security/credentials/fake/fake_credentials.h"
@@ -38,9 +41,6 @@
#include "src/core/lib/security/credentials/jwt/jwt_credentials.h"
#include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h"
#include "src/core/lib/security/transport/auth_filters.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "test/core/util/test_config.h"
/* -- Mock channel credentials. -- */
diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc
index b3742f58a8..a90f997bda 100644
--- a/test/core/security/print_google_default_creds_token.cc
+++ b/test/core/security/print_google_default_creds_token.cc
@@ -27,10 +27,10 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/security/credentials/composite/composite_credentials.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
typedef struct {
gpr_mu* mu;
@@ -45,6 +45,7 @@ static void on_metadata_response(void* arg, grpc_error* error) {
synchronizer* sync = static_cast<synchronizer*>(arg);
if (error != GRPC_ERROR_NONE) {
fprintf(stderr, "Fetching token failed: %s\n", grpc_error_string(error));
+ fflush(stderr);
} else {
char* token;
GPR_ASSERT(sync->md_array.size == 1);
@@ -81,6 +82,7 @@ int main(int argc, char** argv) {
creds = grpc_google_default_credentials_create();
if (creds == nullptr) {
fprintf(stderr, "\nCould not find default credentials.\n\n");
+ fflush(stderr);
result = 1;
goto end;
}
diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc
index 9a68e176db..6eaef2bf49 100644
--- a/test/core/security/security_connector_test.cc
+++ b/test/core/security/security_connector_test.cc
@@ -25,12 +25,12 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/transport/security_connector.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
-#include "src/core/lib/support/tmpfile.h"
#include "src/core/tsi/ssl_transport_security.h"
#include "src/core/tsi/transport_security.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc
index e039970c67..5d32ce0cdb 100644
--- a/test/core/security/verify_jwt.cc
+++ b/test/core/security/verify_jwt.cc
@@ -39,6 +39,7 @@ typedef struct {
static void print_usage_and_exit(gpr_cmdline* cl, const char* argv0) {
char* usage = gpr_cmdline_usage_string(cl, argv0);
fprintf(stderr, "%s", usage);
+ fflush(stderr);
gpr_free(usage);
gpr_cmdline_destroy(cl);
exit(1);
@@ -62,6 +63,7 @@ static void on_jwt_verification_done(void* user_data,
GPR_ASSERT(claims == nullptr);
fprintf(stderr, "Verification failed with error %s\n",
grpc_jwt_verifier_status_to_string(status));
+ fflush(stderr);
}
gpr_mu_lock(sync->mu);
diff --git a/test/core/slice/percent_encoding_test.cc b/test/core/slice/percent_encoding_test.cc
index 11f3995f98..e8d04fcc83 100644
--- a/test/core/slice/percent_encoding_test.cc
+++ b/test/core/slice/percent_encoding_test.cc
@@ -22,8 +22,8 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
#define TEST_VECTOR(raw, encoded, dict) \
diff --git a/test/core/slice/slice_string_helpers_test.cc b/test/core/slice/slice_string_helpers_test.cc
index f1d470461a..a443f17c69 100644
--- a/test/core/slice/slice_string_helpers_test.cc
+++ b/test/core/slice/slice_string_helpers_test.cc
@@ -29,7 +29,7 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
diff --git a/test/core/support/vector_test.cc b/test/core/support/vector_test.cc
deleted file mode 100644
index aad9f3be90..0000000000
--- a/test/core/support/vector_test.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * Copyright 2017 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "src/core/lib/support/vector.h"
-#include <gtest/gtest.h>
-#include "test/core/util/test_config.h"
-
-namespace grpc_core {
-namespace testing {
-
-TEST(InlinedVectorTest, CreateAndIterate) {
- InlinedVector<int, 1> v{1, 2, 3};
- int sum = 0;
- for (auto i : v) {
- sum += i;
- }
- EXPECT_EQ(6, sum);
-}
-
-} // 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/surface/alarm_test.cc b/test/core/surface/alarm_test.cc
index 8950603b41..67fc6833a5 100644
--- a/test/core/surface/alarm_test.cc
+++ b/test/core/surface/alarm_test.cc
@@ -34,8 +34,15 @@ static void* create_test_tag(void) {
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), nullptr);
+ /* By the time grpc_completion_queue_shutdown runs, the cq's internal
+ pending event counter might not have been updated yet by a previous
+ cq_end_op_for_next (which releases a completed event first and only later
+ updates the pending event counter), so we can't rely on a no-polling
+ cq_next to never return GRPC_QUEUE_TIMEOUT. Using a deadline in the future
+ solves the problem. See https://github.com/grpc/grpc/issues/13693.
+ */
+ ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(2),
+ nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index 8d2384ba61..7fd36a241a 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -29,7 +29,6 @@
#include <grpc/impl/codegen/byte_buffer_reader.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/connectivity_state.h>
-#include <grpc/impl/codegen/exec_ctx_fwd.h>
#include <grpc/impl/codegen/fork.h>
#include <grpc/impl/codegen/gpr_slice.h>
#include <grpc/impl/codegen/gpr_types.h>
diff --git a/test/core/transport/bdp_estimator_test.cc b/test/core/transport/bdp_estimator_test.cc
index 445823b628..3afcad7f17 100644
--- a/test/core/transport/bdp_estimator_test.cc
+++ b/test/core/transport/bdp_estimator_test.cc
@@ -25,8 +25,8 @@
#include <grpc/support/useful.h>
#include <gtest/gtest.h>
#include <limits.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/timer_manager.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
diff --git a/test/core/transport/chttp2/bin_decoder_test.cc b/test/core/transport/chttp2/bin_decoder_test.cc
index 6d70a4261b..283eebbacf 100644
--- a/test/core/transport/chttp2/bin_decoder_test.cc
+++ b/test/core/transport/chttp2/bin_decoder_test.cc
@@ -24,9 +24,9 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
static int all_ok = 1;
diff --git a/test/core/transport/chttp2/bin_encoder_test.cc b/test/core/transport/chttp2/bin_encoder_test.cc
index 44f5de8a50..bd62b0e479 100644
--- a/test/core/transport/chttp2/bin_encoder_test.cc
+++ b/test/core/transport/chttp2/bin_encoder_test.cc
@@ -26,8 +26,8 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
static int all_ok = 1;
diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc
index d2dbd4a798..a40bd643ec 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.cc
+++ b/test/core/transport/chttp2/hpack_encoder_test.cc
@@ -26,9 +26,9 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/metadata.h"
#include "test/core/util/parse_hexstring.h"
#include "test/core/util/slice_splitter.h"
diff --git a/test/core/transport/chttp2/hpack_table_test.cc b/test/core/transport/chttp2/hpack_table_test.cc
index 3f3cb2ee9d..e316cf63a0 100644
--- a/test/core/transport/chttp2/hpack_table_test.cc
+++ b/test/core/transport/chttp2/hpack_table_test.cc
@@ -26,7 +26,7 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc
index 5c52ae8d5f..7d943fd5c7 100644
--- a/test/core/transport/metadata_test.cc
+++ b/test/core/transport/metadata_test.cc
@@ -27,8 +27,8 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/static_metadata.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/transport/pid_controller_test.cc b/test/core/transport/pid_controller_test.cc
index 081d03472a..1a499c2fb7 100644
--- a/test/core/transport/pid_controller_test.cc
+++ b/test/core/transport/pid_controller_test.cc
@@ -26,7 +26,7 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
#include <gtest/gtest.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
namespace grpc_core {
diff --git a/test/core/transport/timeout_encoding_test.cc b/test/core/transport/timeout_encoding_test.cc
index 0930bc836d..e94be138dd 100644
--- a/test/core/transport/timeout_encoding_test.cc
+++ b/test/core/transport/timeout_encoding_test.cc
@@ -25,8 +25,8 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/murmur_hash.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/murmur_hash.h"
+#include "src/core/lib/gpr/string.h"
#include "test/core/util/test_config.h"
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
diff --git a/test/core/tsi/transport_security_test.cc b/test/core/tsi/transport_security_test.cc
index c788ad96ad..42e17df25d 100644
--- a/test/core/tsi/transport_security_test.cc
+++ b/test/core/tsi/transport_security_test.cc
@@ -27,7 +27,7 @@
#include <openssl/crypto.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/tsi/fake_transport_security.h"
#include "src/core/tsi/ssl_transport_security.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/util/debugger_macros.cc b/test/core/util/debugger_macros.cc
index f1e4ffd3af..bb96fc7054 100644
--- a/test/core/util/debugger_macros.cc
+++ b/test/core/util/debugger_macros.cc
@@ -39,6 +39,7 @@ grpc_stream* grpc_transport_stream_from_call(grpc_call* call) {
grpc_subchannel_call* scc = grpc_client_channel_get_subchannel_call(el);
if (scc == nullptr) {
fprintf(stderr, "No subchannel-call");
+ fflush(stderr);
return nullptr;
}
cs = grpc_subchannel_call_get_call_stack(scc);
@@ -46,6 +47,7 @@ grpc_stream* grpc_transport_stream_from_call(grpc_call* call) {
return grpc_connected_channel_get_stream(el);
} else {
fprintf(stderr, "Unrecognized filter: %s", el->filter->name);
+ fflush(stderr);
return nullptr;
}
}
diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc
index 9ebb52d83e..6b410440c2 100644
--- a/test/core/util/test_config.cc
+++ b/test/core/util/test_config.cc
@@ -27,8 +27,8 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
int64_t g_fixture_slowdown_factor = 1;
int64_t g_poller_slowdown_factor = 1;
diff --git a/test/cpp/client/client_channel_stress_test.cc b/test/cpp/client/client_channel_stress_test.cc
index e829d5278b..80d1583333 100644
--- a/test/cpp/client/client_channel_stress_test.cc
+++ b/test/cpp/client/client_channel_stress_test.cc
@@ -19,6 +19,7 @@
#include <atomic>
#include <memory>
#include <mutex>
+#include <random>
#include <sstream>
#include <thread>
@@ -104,8 +105,8 @@ class BalancerServiceImpl : public LoadBalancer::Service {
for (size_t i = 0; i < num_drop_entry; ++i) {
random_backend_indices.push_back(-1);
}
- std::random_shuffle(random_backend_indices.begin(),
- random_backend_indices.end());
+ std::shuffle(random_backend_indices.begin(), random_backend_indices.end(),
+ std::mt19937(std::random_device()()));
// Build the response according to the random list generated above.
LoadBalanceResponse response;
for (int index : random_backend_indices) {
@@ -149,7 +150,8 @@ class ClientChannelStressTest {
addresses.emplace_back(AddressData{balancer_server.port_, true, ""});
}
}
- std::random_shuffle(addresses.begin(), addresses.end());
+ std::shuffle(addresses.begin(), addresses.end(),
+ std::mt19937(std::random_device()()));
SetNextResolution(addresses);
std::this_thread::sleep_for(wait_duration);
}
diff --git a/test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj b/test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj
new file mode 100644
index 0000000000..1d332ba7ce
--- /dev/null
+++ b/test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj
@@ -0,0 +1,533 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 48;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 2D3F2189E2CDF493639A17C5 /* libPods-test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 99B1FD20127AB0F23D6AB570 /* libPods-test.a */; };
+ 5E63948A1FDB64B50051E9AA /* server_context_test_spouse_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E6394891FDB64B50051E9AA /* server_context_test_spouse_test.mm */; };
+ 5EFA5F731FEDB36700EBF4B7 /* generic.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EFA5F721FEDB36700EBF4B7 /* generic.mm */; };
+ D0F8FABF3ECF587C207C12F3 /* libPods-generic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D0872BAEE90C8A149743DB7 /* libPods-generic.a */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 3D0872BAEE90C8A149743DB7 /* libPods-generic.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-generic.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5E63947F1FDB5EA10051E9AA /* test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = test.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5E6394831FDB5EA10051E9AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 5E6394891FDB64B50051E9AA /* server_context_test_spouse_test.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = server_context_test_spouse_test.mm; sourceTree = "<group>"; };
+ 5EFA5F701FEDB36700EBF4B7 /* generic.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = generic.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5EFA5F721FEDB36700EBF4B7 /* generic.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = generic.mm; sourceTree = "<group>"; };
+ 5EFA5F741FEDB36700EBF4B7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 8682448F311EDE94C14D551D /* Pods-test.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-test.release.xcconfig"; path = "Pods/Target Support Files/Pods-test/Pods-test.release.xcconfig"; sourceTree = "<group>"; };
+ 91EDF22ADDE71926C7BC1AF1 /* Pods-test.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-test.debug.xcconfig"; path = "Pods/Target Support Files/Pods-test/Pods-test.debug.xcconfig"; sourceTree = "<group>"; };
+ 99B1FD20127AB0F23D6AB570 /* libPods-test.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-test.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ B357AF2DC912B224C026D114 /* Pods-generic.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-generic.release.xcconfig"; path = "Pods/Target Support Files/Pods-generic/Pods-generic.release.xcconfig"; sourceTree = "<group>"; };
+ D9B4F77163CB9089C4436BF4 /* Pods-generic.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-generic.debug.xcconfig"; path = "Pods/Target Support Files/Pods-generic/Pods-generic.debug.xcconfig"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 5E63947C1FDB5EA10051E9AA /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 2D3F2189E2CDF493639A17C5 /* libPods-test.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5EFA5F6D1FEDB36700EBF4B7 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D0F8FABF3ECF587C207C12F3 /* libPods-generic.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 4439BD4D56FD5738BF780F8E /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ 91EDF22ADDE71926C7BC1AF1 /* Pods-test.debug.xcconfig */,
+ 8682448F311EDE94C14D551D /* Pods-test.release.xcconfig */,
+ D9B4F77163CB9089C4436BF4 /* Pods-generic.debug.xcconfig */,
+ B357AF2DC912B224C026D114 /* Pods-generic.release.xcconfig */,
+ );
+ name = Pods;
+ sourceTree = "<group>";
+ };
+ 5E63944B1FDB5D9B0051E9AA = {
+ isa = PBXGroup;
+ children = (
+ 5E63947F1FDB5EA10051E9AA /* test.xctest */,
+ 5E6394801FDB5EA10051E9AA /* test */,
+ 4439BD4D56FD5738BF780F8E /* Pods */,
+ 5EFA5F711FEDB36700EBF4B7 /* generic */,
+ C2E6603B58413BD724AFB400 /* Frameworks */,
+ 5EFA5F701FEDB36700EBF4B7 /* generic.xctest */,
+ );
+ sourceTree = "<group>";
+ };
+ 5E6394801FDB5EA10051E9AA /* test */ = {
+ isa = PBXGroup;
+ children = (
+ 5E6394891FDB64B50051E9AA /* server_context_test_spouse_test.mm */,
+ 5E6394831FDB5EA10051E9AA /* Info.plist */,
+ );
+ path = test;
+ sourceTree = "<group>";
+ };
+ 5EFA5F711FEDB36700EBF4B7 /* generic */ = {
+ isa = PBXGroup;
+ children = (
+ 5EFA5F721FEDB36700EBF4B7 /* generic.mm */,
+ 5EFA5F741FEDB36700EBF4B7 /* Info.plist */,
+ );
+ path = generic;
+ sourceTree = "<group>";
+ };
+ C2E6603B58413BD724AFB400 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 99B1FD20127AB0F23D6AB570 /* libPods-test.a */,
+ 3D0872BAEE90C8A149743DB7 /* libPods-generic.a */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 5E63947E1FDB5EA10051E9AA /* test */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5E6394841FDB5EA10051E9AA /* Build configuration list for PBXNativeTarget "test" */;
+ buildPhases = (
+ 6D8317CF72F9E252442662F8 /* [CP] Check Pods Manifest.lock */,
+ 5E63947B1FDB5EA10051E9AA /* Sources */,
+ 5E63947C1FDB5EA10051E9AA /* Frameworks */,
+ 5E63947D1FDB5EA10051E9AA /* Resources */,
+ B972D278DA2A2BF12386177C /* [CP] Embed Pods Frameworks */,
+ 3C2FE7A8DBA8BBCB2923B173 /* [CP] Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = test;
+ productName = test;
+ productReference = 5E63947F1FDB5EA10051E9AA /* test.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+ 5EFA5F6F1FEDB36700EBF4B7 /* generic */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5EFA5F751FEDB36700EBF4B7 /* Build configuration list for PBXNativeTarget "generic" */;
+ buildPhases = (
+ 4844599DC62113265AB660B3 /* [CP] Check Pods Manifest.lock */,
+ 5EFA5F6C1FEDB36700EBF4B7 /* Sources */,
+ 5EFA5F6D1FEDB36700EBF4B7 /* Frameworks */,
+ 5EFA5F6E1FEDB36700EBF4B7 /* Resources */,
+ 11E4716E0919C734CC6AA8C2 /* [CP] Embed Pods Frameworks */,
+ 9E149E84C3AA06289FE1F244 /* [CP] Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = generic;
+ productName = generic;
+ productReference = 5EFA5F701FEDB36700EBF4B7 /* generic.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 5E63944C1FDB5D9B0051E9AA /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0910;
+ ORGANIZATIONNAME = gRPC;
+ TargetAttributes = {
+ 5E63947E1FDB5EA10051E9AA = {
+ CreatedOnToolsVersion = 9.1;
+ ProvisioningStyle = Automatic;
+ };
+ 5EFA5F6F1FEDB36700EBF4B7 = {
+ CreatedOnToolsVersion = 9.2;
+ ProvisioningStyle = Automatic;
+ };
+ };
+ };
+ buildConfigurationList = 5E63944F1FDB5D9B0051E9AA /* Build configuration list for PBXProject "GRPCCppTests" */;
+ compatibilityVersion = "Xcode 8.0";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 5E63944B1FDB5D9B0051E9AA;
+ productRefGroup = 5E63944B1FDB5D9B0051E9AA;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 5E63947E1FDB5EA10051E9AA /* test */,
+ 5EFA5F6F1FEDB36700EBF4B7 /* generic */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 5E63947D1FDB5EA10051E9AA /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5EFA5F6E1FEDB36700EBF4B7 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 11E4716E0919C734CC6AA8C2 /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-generic/Pods-generic-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 3C2FE7A8DBA8BBCB2923B173 /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Copy Pods Resources";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-test/Pods-test-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 4844599DC62113265AB660B3 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-generic-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 6D8317CF72F9E252442662F8 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-test-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 9E149E84C3AA06289FE1F244 /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Copy Pods Resources";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-generic/Pods-generic-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ B972D278DA2A2BF12386177C /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-test/Pods-test-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 5E63947B1FDB5EA10051E9AA /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E63948A1FDB64B50051E9AA /* server_context_test_spouse_test.mm in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5EFA5F6C1FEDB36700EBF4B7 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5EFA5F731FEDB36700EBF4B7 /* generic.mm in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 5E6394731FDB5D9B0051E9AA /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = ../../../include;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.1;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ USER_HEADER_SEARCH_PATHS = ../../..;
+ };
+ name = Debug;
+ };
+ 5E6394741FDB5D9B0051E9AA /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = ../../../include;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.1;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ USER_HEADER_SEARCH_PATHS = ../../..;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 5E6394851FDB5EA10051E9AA /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 91EDF22ADDE71926C7BC1AF1 /* Pods-test.debug.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"${PODS_ROOT}/Headers/Public\"",
+ "\"${PODS_ROOT}/Headers/Public/BoringSSL\"",
+ "\"${PODS_ROOT}/Headers/Public/gRPC-C++\"",
+ "\"${PODS_ROOT}/Headers/Public/gRPC-Core\"",
+ "\"${PODS_ROOT}/Headers/Public/nanopb\"",
+ );
+ INFOPLIST_FILE = test/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.test;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 5E6394861FDB5EA10051E9AA /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 8682448F311EDE94C14D551D /* Pods-test.release.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"${PODS_ROOT}/Headers/Public\"",
+ "\"${PODS_ROOT}/Headers/Public/BoringSSL\"",
+ "\"${PODS_ROOT}/Headers/Public/gRPC-C++\"",
+ "\"${PODS_ROOT}/Headers/Public/gRPC-Core\"",
+ "\"${PODS_ROOT}/Headers/Public/nanopb\"",
+ );
+ INFOPLIST_FILE = test/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.test;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+ 5EFA5F761FEDB36700EBF4B7 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = D9B4F77163CB9089C4436BF4 /* Pods-generic.debug.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ INFOPLIST_FILE = generic/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.generic;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 5EFA5F771FEDB36700EBF4B7 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = B357AF2DC912B224C026D114 /* Pods-generic.release.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ DEVELOPMENT_TEAM = EQHXZ8M8AV;
+ INFOPLIST_FILE = generic/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.generic;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 5E63944F1FDB5D9B0051E9AA /* Build configuration list for PBXProject "GRPCCppTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E6394731FDB5D9B0051E9AA /* Debug */,
+ 5E6394741FDB5D9B0051E9AA /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 5E6394841FDB5EA10051E9AA /* Build configuration list for PBXNativeTarget "test" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E6394851FDB5EA10051E9AA /* Debug */,
+ 5E6394861FDB5EA10051E9AA /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 5EFA5F751FEDB36700EBF4B7 /* Build configuration list for PBXNativeTarget "generic" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5EFA5F761FEDB36700EBF4B7 /* Debug */,
+ 5EFA5F771FEDB36700EBF4B7 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 5E63944C1FDB5D9B0051E9AA /* Project object */;
+}
diff --git a/test/cpp/cocoapods/Podfile b/test/cpp/cocoapods/Podfile
new file mode 100644
index 0000000000..8d8cdaaadd
--- /dev/null
+++ b/test/cpp/cocoapods/Podfile
@@ -0,0 +1,71 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+# Location of gRPC's repo root relative to this file.
+GRPC_LOCAL_SRC = '../../..'
+
+%w(
+ test
+ generic
+).each do |target_name|
+ target target_name do
+ pod 'gRPC-Core', :path => GRPC_LOCAL_SRC
+ pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC
+ pod 'gRPC-C++', :path => GRPC_LOCAL_SRC
+ pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true
+ end
+end
+
+# gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's
+# pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded
+# and before they are installed in the user project.
+#
+# This podspec searches for the gRPC core library headers under "$(PODS_ROOT)/gRPC-Core", where
+# Cocoapods normally places the downloaded sources. When doing local development of the libraries,
+# though, Cocoapods just takes the sources from whatever directory was specified using `:path`, and
+# doesn't copy them under $(PODS_ROOT). When using static libraries, one can sometimes rely on the
+# symbolic links to the pods headers that Cocoapods creates under "$(PODS_ROOT)/Headers". But those
+# aren't created when using dynamic frameworks. So our solution is to modify the podspec on the fly
+# to point at the local directory where the sources are.
+#
+# TODO(jcanizales): Send a PR to Cocoapods to get rid of this need.
+pre_install do |installer|
+ # This is the gRPC-Core podspec object, as initialized by its podspec file.
+ grpc_core_spec = installer.pod_targets.find{|t| t.name == 'gRPC-Core'}.root_spec
+
+ # Copied from gRPC-Core.podspec, except for the adjusted src_root:
+ src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}"
+ grpc_core_spec.pod_target_xcconfig = {
+ 'GRPC_SRC_ROOT' => src_root,
+ 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
+ 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
+ # If we don't set these two settings, `include/grpc/support/time.h` and
+ # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # build.
+ 'USE_HEADERMAP' => 'NO',
+ 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
+ }
+end
+
+post_install do |installer|
+ installer.pods_project.targets.each do |target|
+ target.build_configurations.each do |config|
+ config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES'
+ end
+
+ # CocoaPods creates duplicated library targets of gRPC-Core when the test targets include
+ # non-default subspecs of gRPC-Core. All of these library targets start with prefix 'gRPC-Core'
+ # and require the same error suppresion.
+ if target.name.start_with?('gRPC-Core')
+ target.build_configurations.each do |config|
+ # TODO(zyc): Remove this setting after the issue is resolved
+ # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
+ # function" warning
+ config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
+ config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1'
+ end
+ end
+ end
+end
diff --git a/test/cpp/cocoapods/generic/Info.plist b/test/cpp/cocoapods/generic/Info.plist
new file mode 100644
index 0000000000..6c40a6cd0c
--- /dev/null
+++ b/test/cpp/cocoapods/generic/Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/test/cpp/cocoapods/generic/generic.mm b/test/cpp/cocoapods/generic/generic.mm
new file mode 100644
index 0000000000..30b43ec375
--- /dev/null
+++ b/test/cpp/cocoapods/generic/generic.mm
@@ -0,0 +1,244 @@
+/*
+ *
+ * Copyright 2017 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <XCTest/XCTest.h>
+
+#include <sstream>
+
+#include <grpc++/channel.h>
+#include <grpc++/client_context.h>
+#include <grpc++/create_channel.h>
+#include <grpc++/generic/async_generic_service.h>
+#include <grpc++/generic/generic_stub.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpc++/support/slice.h>
+#include <grpc/grpc.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+using std::chrono::system_clock;
+using namespace grpc;
+
+void* tag(int i) { return (void*)(intptr_t)i; }
+
+static grpc_slice merge_slices(grpc_slice* slices, size_t nslices) {
+ size_t i;
+ size_t len = 0;
+ uint8_t* cursor;
+ grpc_slice out;
+
+ for (i = 0; i < nslices; i++) {
+ len += GRPC_SLICE_LENGTH(slices[i]);
+ }
+
+ out = grpc_slice_malloc(len);
+ cursor = GRPC_SLICE_START_PTR(out);
+
+ for (i = 0; i < nslices; i++) {
+ memcpy(cursor, GRPC_SLICE_START_PTR(slices[i]),
+ GRPC_SLICE_LENGTH(slices[i]));
+ cursor += GRPC_SLICE_LENGTH(slices[i]);
+ }
+
+ return out;
+}
+
+int byte_buffer_eq_string(ByteBuffer* bb, const char* str) {
+ int res;
+
+ std::vector<Slice> slices;
+ bb->Dump(&slices);
+ grpc_slice* c_slices = new grpc_slice[slices.size()];
+ for (int i = 0; i < slices.size(); i++) {
+ c_slices[i] = slices[i].c_slice();
+ }
+ grpc_slice a = merge_slices(c_slices, slices.size());
+ grpc_slice b = grpc_slice_from_copied_string(str);
+ res =
+ (GRPC_SLICE_LENGTH(a) == GRPC_SLICE_LENGTH(b)) &&
+ (0 == memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b),
+ GRPC_SLICE_LENGTH(a)));
+ grpc_slice_unref(a);
+ grpc_slice_unref(b);
+ for (int i = 0; i < slices.size(); i++) {
+ grpc_slice_unref(c_slices[i]);
+ }
+ delete [] c_slices;
+
+ return res;
+}
+
+@interface GenericTest : XCTestCase
+
+@end
+
+@implementation GenericTest {
+ grpc::string server_host_;
+ CompletionQueue cli_cq_;
+ std::unique_ptr<ServerCompletionQueue> srv_cq_;
+ std::unique_ptr<GenericStub> generic_stub_;
+ std::unique_ptr<Server> server_;
+ AsyncGenericService generic_service_;
+ std::ostringstream server_address_;
+}
+
+- (void)verify_ok:(grpc::CompletionQueue*)cq
+ i:(int)i
+ expect_ok:(bool)expect_ok {
+ bool ok;
+ void* got_tag;
+ XCTAssertTrue(cq->Next(&got_tag, &ok));
+ XCTAssertEqual(expect_ok, ok);
+ XCTAssertEqual(tag(i), got_tag);
+}
+
+- (void)server_ok:(int)i { [self verify_ok:srv_cq_.get() i:i expect_ok:true]; }
+- (void)client_ok:(int)i { [self verify_ok:&cli_cq_ i:i expect_ok:true]; }
+- (void)server_fail:(int)i { [self verify_ok:srv_cq_.get() i:i expect_ok:false]; }
+- (void)client_fail:(int)i { [self verify_ok:&cli_cq_ i:i expect_ok:false]; }
+
+- (void)setUp {
+ [super setUp];
+
+ server_host_ = "localhost";
+ int port = grpc_pick_unused_port_or_die();
+ server_address_ << server_host_ << ":" << port;
+ // Setup server
+ ServerBuilder builder;
+ builder.AddListeningPort(server_address_.str(),
+ InsecureServerCredentials());
+ builder.RegisterAsyncGenericService(&generic_service_);
+ // Include a second call to RegisterAsyncGenericService to make sure that
+ // we get an error in the log, since it is not allowed to have 2 async
+ // generic services
+ builder.RegisterAsyncGenericService(&generic_service_);
+ srv_cq_ = builder.AddCompletionQueue();
+ server_ = builder.BuildAndStart();
+}
+
+- (void)tearDown {
+ // Put teardown code here. This method is called after the invocation of each test method in the class.
+ server_->Shutdown();
+ void* ignored_tag;
+ bool ignored_ok;
+ cli_cq_.Shutdown();
+ srv_cq_->Shutdown();
+ while (cli_cq_.Next(&ignored_tag, &ignored_ok));
+ while (srv_cq_->Next(&ignored_tag, &ignored_ok));
+ [super tearDown];
+}
+
+- (void)ResetStub {
+ std::shared_ptr<Channel> channel =
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
+ generic_stub_.reset(new GenericStub(channel));
+}
+
+- (void)SendRpc:(int)num_rpcs {
+ [self SendRpc:num_rpcs check_deadline:false deadline:gpr_inf_future(GPR_CLOCK_MONOTONIC)];
+ }
+
+- (void)SendRpc:(int)num_rpcs
+ check_deadline:(bool)check_deadline
+ deadline:(gpr_timespec)deadline {
+ const grpc::string kMethodName("/grpc.cpp.test.util.EchoTestService/Echo");
+ for (int i = 0; i < num_rpcs; i++) {
+ Status recv_status;
+
+ ClientContext cli_ctx;
+ GenericServerContext srv_ctx;
+ GenericServerAsyncReaderWriter stream(&srv_ctx);
+
+ // The string needs to be long enough to test heap-based slice.
+ /*send_request.set_message("Hello world. Hello world. Hello world.");*/
+
+ if (check_deadline) {
+ cli_ctx.set_deadline(deadline);
+ }
+
+ std::unique_ptr<GenericClientAsyncReaderWriter> call =
+ generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1));
+ [self client_ok:1];
+ Slice send_slice = Slice("hello world", 11);
+ std::unique_ptr<ByteBuffer> send_buffer =
+ std::unique_ptr<ByteBuffer>(new ByteBuffer(&send_slice, 1));
+ call->Write(*send_buffer, tag(2));
+ // Send ByteBuffer can be destroyed after calling Write.
+ send_buffer.reset();
+ [self client_ok:2];
+ call->WritesDone(tag(3));
+ [self client_ok:3];
+
+ generic_service_.RequestCall(&srv_ctx, &stream, srv_cq_.get(),
+ srv_cq_.get(), tag(4));
+
+ [self verify_ok:srv_cq_.get() i:4 expect_ok:true];
+ XCTAssertEqual(server_host_, srv_ctx.host().substr(0, server_host_.length()));
+ XCTAssertEqual(kMethodName, srv_ctx.method());
+
+ if (check_deadline) {
+ XCTAssertTrue(gpr_time_similar(deadline, srv_ctx.raw_deadline(),
+ gpr_time_from_millis(1000, GPR_TIMESPAN)));
+ }
+
+ ByteBuffer recv_buffer;
+ stream.Read(&recv_buffer, tag(5));
+ [self server_ok:5];
+ XCTAssertTrue(byte_buffer_eq_string(&recv_buffer, "hello world"));
+
+ send_buffer = std::unique_ptr<ByteBuffer>(new ByteBuffer(recv_buffer));
+ stream.Write(*send_buffer, tag(6));
+ send_buffer.reset();
+ [self server_ok:6];
+
+ stream.Finish(Status::OK, tag(7));
+ [self server_ok:7];
+
+ recv_buffer.Clear();
+ call->Read(&recv_buffer, tag(8));
+ [self client_ok:8];
+ XCTAssertTrue(byte_buffer_eq_string(&recv_buffer, "hello world"));
+
+ call->Finish(&recv_status, tag(9));
+ [self client_ok:9];
+
+ XCTAssertTrue(recv_status.ok());
+ }
+}
+
+- (void)testSimpleRpc {
+ [self ResetStub];
+ [self SendRpc:1];
+}
+
+- (void)testSequentialRpcs {
+ [self ResetStub];
+ [self SendRpc:10];
+}
+
++ (void)setUp {
+ grpc_test_init(0, NULL);
+}
+
+@end
+
diff --git a/test/cpp/cocoapods/test/Info.plist b/test/cpp/cocoapods/test/Info.plist
new file mode 100644
index 0000000000..6c40a6cd0c
--- /dev/null
+++ b/test/cpp/cocoapods/test/Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/test/cpp/cocoapods/test/server_context_test_spouse_test.mm b/test/cpp/cocoapods/test/server_context_test_spouse_test.mm
new file mode 100644
index 0000000000..fd6878efbf
--- /dev/null
+++ b/test/cpp/cocoapods/test/server_context_test_spouse_test.mm
@@ -0,0 +1,100 @@
+/*
+ *
+ * Copyright 2016 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// Hack TEST macro of gTest and make they conform XCTest style. We only
+// need test name (b), not test case name (a).
+#define TEST(a,b) - (void)test ## b
+#define ASSERT_TRUE XCTAssert
+#define ASSERT_EQ XCTAssertEqual
+
+#import <XCTest/XCTest.h>
+
+#include <grpc++/test/server_context_test_spouse.h>
+
+#include <cstring>
+#include <vector>
+
+#include <grpc++/impl/grpc_library.h>
+
+static grpc::internal::GrpcLibraryInitializer g_initializer;
+
+const char key1[] = "metadata-key1";
+const char key2[] = "metadata-key2";
+const char val1[] = "metadata-val1";
+const char val2[] = "metadata-val2";
+
+bool ClientMetadataContains(const grpc::ServerContext& context,
+ const grpc::string_ref& key,
+ const grpc::string_ref& value) {
+ const auto& client_metadata = context.client_metadata();
+ for (auto iter = client_metadata.begin(); iter != client_metadata.end();
+ ++iter) {
+ if (iter->first == key && iter->second == value) {
+ return true;
+ }
+ }
+ return false;
+}
+
+@interface ServerContextTestSpouseTest : XCTestCase
+
+@end
+
+@implementation ServerContextTestSpouseTest
+
+TEST(ServerContextTestSpouseTest, ClientMetadata) {
+ grpc::ServerContext context;
+ grpc::testing::ServerContextTestSpouse spouse(&context);
+
+ spouse.AddClientMetadata(key1, val1);
+ ASSERT_TRUE(ClientMetadataContains(context, key1, val1));
+
+ spouse.AddClientMetadata(key2, val2);
+ ASSERT_TRUE(ClientMetadataContains(context, key1, val1));
+ ASSERT_TRUE(ClientMetadataContains(context, key2, val2));
+}
+
+TEST(ServerContextTestSpouseTest, InitialMetadata) {
+ grpc::ServerContext context;
+ grpc::testing::ServerContextTestSpouse spouse(&context);
+ std::multimap<grpc::string, grpc::string> metadata;
+
+ context.AddInitialMetadata(key1, val1);
+ metadata.insert(std::pair<grpc::string, grpc::string>(key1, val1));
+ ASSERT_EQ(metadata, spouse.GetInitialMetadata());
+
+ context.AddInitialMetadata(key2, val2);
+ metadata.insert(std::pair<grpc::string, grpc::string>(key2, val2));
+ ASSERT_EQ(metadata, spouse.GetInitialMetadata());
+}
+
+TEST(ServerContextTestSpouseTest, TrailingMetadata) {
+ grpc::ServerContext context;
+ grpc::testing::ServerContextTestSpouse spouse(&context);
+ std::multimap<grpc::string, grpc::string> metadata;
+
+ context.AddTrailingMetadata(key1, val1);
+ metadata.insert(std::pair<grpc::string, grpc::string>(key1, val1));
+ ASSERT_EQ(metadata, spouse.GetTrailingMetadata());
+
+ context.AddTrailingMetadata(key2, val2);
+ metadata.insert(std::pair<grpc::string, grpc::string>(key2, val2));
+ ASSERT_EQ(metadata, spouse.GetTrailingMetadata());
+}
+
+@end
diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD
index fa77c30aca..27e8da1ff1 100644
--- a/test/cpp/end2end/BUILD
+++ b/test/cpp/end2end/BUILD
@@ -16,25 +16,31 @@ licenses(["notice"]) # Apache v2
load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package", "grpc_cc_binary")
-grpc_package(name = "test/cpp/end2end", visibility = "public") # Allows external users to implement end2end tests.
+grpc_package(
+ name = "test/cpp/end2end",
+ visibility = "public",
+) # Allows external users to implement end2end tests.
grpc_cc_library(
name = "test_service_impl",
testonly = True,
srcs = ["test_service_impl.cc"],
hdrs = ["test_service_impl.h"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//src/proto/grpc/testing:echo_proto",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "async_end2end_test",
srcs = ["async_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -47,14 +53,17 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "client_crash_test",
srcs = ["client_crash_test.cc"],
+ data = [
+ ":client_crash_test_server",
+ ],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -66,18 +75,16 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- data = [
- ":client_crash_test_server",
- ],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_binary(
name = "client_crash_test_server",
testonly = True,
srcs = ["client_crash_test_server.cc"],
+ external_deps = [
+ "gflags",
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -89,16 +96,15 @@ grpc_cc_binary(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gflags",
- "gtest",
- ],
)
grpc_cc_library(
name = "end2end_test_lib",
- srcs = ["end2end_test.cc"],
testonly = True,
+ srcs = ["end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -111,40 +117,76 @@ grpc_cc_library(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+)
+
+grpc_cc_test(
+ name = "server_early_return_test",
+ srcs = ["server_early_return_test.cc"],
external_deps = [
"gtest",
],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//src/proto/grpc/testing:echo_messages_proto",
+ "//src/proto/grpc/testing:echo_proto",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_util",
+ ],
)
grpc_cc_test(
name = "end2end_test",
deps = [
- ":end2end_test_lib"
+ ":end2end_test_lib",
],
)
grpc_cc_test(
- name = "filter_end2end_test",
- srcs = ["filter_end2end_test.cc"],
+ name = "exception_test",
+ srcs = ["exception_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
- "//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+)
+
+grpc_cc_test(
+ name = "filter_end2end_test",
+ srcs = ["filter_end2end_test.cc"],
external_deps = [
"gtest",
],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//src/proto/grpc/testing:echo_messages_proto",
+ "//src/proto/grpc/testing:echo_proto",
+ "//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_util",
+ ],
)
grpc_cc_test(
name = "generic_end2end_test",
srcs = ["generic_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -156,14 +198,14 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "hybrid_end2end_test",
srcs = ["hybrid_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -176,14 +218,15 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "mock_test",
srcs = ["mock_test.cc"],
+ external_deps = [
+ "gmock",
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -196,15 +239,14 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gmock",
- "gtest",
- ],
)
grpc_cc_test(
name = "client_lb_end2end_test",
srcs = ["client_lb_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -217,37 +259,38 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "grpclb_end2end_test",
srcs = ["grpclb_end2end_test.cc"],
+ external_deps = [
+ "gmock",
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
"//:grpc",
"//:grpc++",
+ "//:grpc_resolver_fake",
"//src/proto/grpc/lb/v1:load_balancer_proto",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
- "//:grpc_resolver_fake",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gmock",
- "gtest",
- ],
)
grpc_cc_test(
name = "proto_server_reflection_test",
srcs = ["proto_server_reflection_test.cc"],
+ external_deps = [
+ "gtest",
+ "gflags",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -262,15 +305,14 @@ grpc_cc_test(
"//test/cpp/util:grpc++_proto_reflection_desc_db",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- "gflags",
- ],
)
grpc_cc_test(
name = "server_builder_plugin_test",
srcs = ["server_builder_plugin_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
":test_service_impl",
"//:gpr",
@@ -283,14 +325,17 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "server_crash_test",
srcs = ["server_crash_test.cc"],
+ data = [
+ ":server_crash_test_client",
+ ],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -302,18 +347,16 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
- data = [
- ":server_crash_test_client",
- ],
)
grpc_cc_binary(
name = "server_crash_test_client",
testonly = True,
srcs = ["server_crash_test_client.cc"],
+ external_deps = [
+ "gflags",
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -325,15 +368,14 @@ grpc_cc_binary(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gflags",
- "gtest",
- ],
)
grpc_cc_test(
name = "shutdown_test",
srcs = ["shutdown_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -345,14 +387,14 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "streaming_throughput_test",
srcs = ["streaming_throughput_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -364,14 +406,14 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "thread_stress_test",
srcs = ["thread_stress_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
deps = [
"//:gpr",
"//:grpc",
@@ -383,7 +425,4 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
- external_deps = [
- "gtest",
- ],
)
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 1ea087e706..44cd81a6a4 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -34,8 +34,8 @@
#include <grpc/support/time.h>
#include <grpc/support/tls.h>
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/port.h"
-#include "src/core/lib/support/env.h"
#include "src/proto/grpc/health/v1/health.grpc.pb.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc
index c6e9577f0c..328ad86061 100644
--- a/test/cpp/end2end/client_lb_end2end_test.cc
+++ b/test/cpp/end2end/client_lb_end2end_test.cc
@@ -19,6 +19,7 @@
#include <algorithm>
#include <memory>
#include <mutex>
+#include <random>
#include <thread>
#include <grpc++/channel.h>
@@ -37,7 +38,7 @@
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
#include "src/core/ext/filters/client_channel/subchannel_index.h"
#include "src/core/lib/backoff/backoff.h"
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@@ -456,7 +457,8 @@ TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) {
grpc_subchannel_index_test_only_set_force_creation(force_creation);
gpr_log(GPR_INFO, "Force subchannel creation: %d", force_creation);
for (size_t i = 0; i < 1000; ++i) {
- std::random_shuffle(ports.begin(), ports.end());
+ std::shuffle(ports.begin(), ports.end(),
+ std::mt19937(std::random_device()()));
SetNextResolution(ports);
if (i % 10 == 0) CheckRpcSendOk();
}
@@ -621,7 +623,8 @@ TEST_F(ClientLbEnd2endTest, RoundRobinManyUpdates) {
ports.emplace_back(servers_[i]->port_);
}
for (size_t i = 0; i < 1000; ++i) {
- std::random_shuffle(ports.begin(), ports.end());
+ std::shuffle(ports.begin(), ports.end(),
+ std::mt19937(std::random_device()()));
SetNextResolution(ports);
if (i % 10 == 0) CheckRpcSendOk();
}
@@ -673,6 +676,42 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) {
GPR_ASSERT(gpr_time_cmp(deadline, now) > 0);
}
+TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) {
+ const int kNumServers = 3;
+ StartServers(kNumServers);
+ const auto ports = GetServersPorts();
+ ResetStub(ports, "round_robin");
+ SetNextResolution(ports);
+ for (size_t i = 0; i < kNumServers; ++i) WaitForServer(i);
+ for (size_t i = 0; i < servers_.size(); ++i) {
+ CheckRpcSendOk();
+ EXPECT_EQ(1, servers_[i]->service_.request_count()) << "for backend #" << i;
+ }
+ // One request should have gone to each server.
+ for (size_t i = 0; i < servers_.size(); ++i) {
+ EXPECT_EQ(1, servers_[i]->service_.request_count());
+ }
+ const auto pre_death = servers_[0]->service_.request_count();
+ // Kill the first server.
+ servers_[0]->Shutdown(true);
+ // Client request still succeed. May need retrying if RR had returned a pick
+ // before noticing the change in the server's connectivity.
+ while (!SendRpc())
+ ; // Retry until success.
+ // Send a bunch of RPCs that should succeed.
+ for (int i = 0; i < 10 * kNumServers; ++i) CheckRpcSendOk();
+ const auto post_death = servers_[0]->service_.request_count();
+ // No requests have gone to the deceased server.
+ EXPECT_EQ(pre_death, post_death);
+ // Bring the first server back up.
+ servers_[0].reset(new ServerData(server_host_, ports[0]));
+ // Requests should start arriving at the first server either right away (if
+ // the server managed to start before the RR policy retried the subchannel) or
+ // after the subchannel retry delay otherwise (RR's subchannel retried before
+ // the server was fully back up).
+ WaitForServer(0);
+}
+
} // namespace
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 4c8dfe0f40..b1b0b5d0e8 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -35,8 +35,8 @@
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/security/credentials/credentials.h"
-#include "src/core/lib/support/env.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@@ -1087,31 +1087,6 @@ TEST_P(End2endTest, RpcMaxMessageSize) {
EXPECT_FALSE(s.ok());
}
-// Client sends 20 requests and the server returns CANCELLED status after
-// reading 10 requests.
-TEST_P(End2endTest, RequestStreamServerEarlyCancelTest) {
- ResetStub();
- EchoRequest request;
- EchoResponse response;
- ClientContext context;
-
- context.AddMetadata(kServerCancelAfterReads, "10");
- auto stream = stub_->RequestStream(&context, &response);
- request.set_message("hello");
- int send_messages = 20;
- while (send_messages > 10) {
- EXPECT_TRUE(stream->Write(request));
- send_messages--;
- }
- while (send_messages > 0) {
- stream->Write(request);
- send_messages--;
- }
- stream->WritesDone();
- Status s = stream->Finish();
- EXPECT_EQ(s.error_code(), StatusCode::CANCELLED);
-}
-
void ReaderThreadFunc(ClientReaderWriter<EchoRequest, EchoResponse>* stream,
gpr_event* ev) {
EchoResponse resp;
@@ -1609,7 +1584,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginKeyFailure) {
Status s = stub_->Echo(&context, request, &response);
EXPECT_FALSE(s.ok());
- EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED);
+ EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE);
}
TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) {
@@ -1626,7 +1601,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) {
Status s = stub_->Echo(&context, request, &response);
EXPECT_FALSE(s.ok());
- EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED);
+ EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE);
}
TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) {
@@ -1644,7 +1619,7 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) {
Status s = stub_->Echo(&context, request, &response);
EXPECT_FALSE(s.ok());
- EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED);
+ EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE);
EXPECT_EQ(s.error_message(),
grpc::string("Getting metadata from plugin failed with error: ") +
kTestCredsPluginErrorMsg);
@@ -1705,7 +1680,7 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) {
Status s = stub_->Echo(&context, request, &response);
EXPECT_FALSE(s.ok());
- EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED);
+ EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE);
EXPECT_EQ(s.error_message(),
grpc::string("Getting metadata from plugin failed with error: ") +
kTestCredsPluginErrorMsg);
diff --git a/test/cpp/end2end/exception_test.cc b/test/cpp/end2end/exception_test.cc
new file mode 100644
index 0000000000..76272ad08a
--- /dev/null
+++ b/test/cpp/end2end/exception_test.cc
@@ -0,0 +1,119 @@
+/*
+ *
+ * Copyright 2017 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <exception>
+#include <memory>
+
+#include <grpc++/channel.h>
+#include <grpc++/client_context.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpc/impl/codegen/port_platform.h>
+
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/test_config.h"
+
+#include <gtest/gtest.h>
+
+namespace grpc {
+namespace testing {
+
+const char* kErrorMessage = "This service caused an exception";
+
+#if GRPC_ALLOW_EXCEPTIONS
+class ExceptingServiceImpl : public ::grpc::testing::EchoTestService::Service {
+ public:
+ Status Echo(ServerContext* server_context, const EchoRequest* request,
+ EchoResponse* response) override {
+ throw - 1;
+ }
+ Status RequestStream(ServerContext* context,
+ ServerReader<EchoRequest>* reader,
+ EchoResponse* response) override {
+ throw ServiceException();
+ }
+
+ private:
+ class ServiceException final : public std::exception {
+ public:
+ ServiceException() {}
+
+ private:
+ const char* what() const noexcept override { return kErrorMessage; }
+ };
+};
+
+class ExceptionTest : public ::testing::Test {
+ protected:
+ ExceptionTest() {}
+
+ void SetUp() override {
+ ServerBuilder builder;
+ builder.RegisterService(&service_);
+ server_ = builder.BuildAndStart();
+ }
+
+ void TearDown() override { server_->Shutdown(); }
+
+ void ResetStub() {
+ channel_ = server_->InProcessChannel(ChannelArguments());
+ stub_ = grpc::testing::EchoTestService::NewStub(channel_);
+ }
+
+ std::shared_ptr<Channel> channel_;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
+ std::unique_ptr<Server> server_;
+ ExceptingServiceImpl service_;
+};
+
+TEST_F(ExceptionTest, Unary) {
+ ResetStub();
+ EchoRequest request;
+ EchoResponse response;
+ request.set_message("test");
+ ClientContext context;
+
+ Status s = stub_->Echo(&context, request, &response);
+ EXPECT_FALSE(s.ok());
+ EXPECT_EQ(s.error_code(), StatusCode::UNKNOWN);
+}
+
+TEST_F(ExceptionTest, RequestStream) {
+ ResetStub();
+ EchoResponse response;
+ ClientContext context;
+
+ auto stream = stub_->RequestStream(&context, &response);
+ stream->WritesDone();
+ Status s = stream->Finish();
+
+ EXPECT_FALSE(s.ok());
+ EXPECT_EQ(s.error_code(), StatusCode::UNKNOWN);
+}
+
+#endif // GRPC_ALLOW_EXCEPTIONS
+
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc
index d4ee6b429f..78527587cf 100644
--- a/test/cpp/end2end/grpclb_end2end_test.cc
+++ b/test/cpp/end2end/grpclb_end2end_test.cc
@@ -34,8 +34,8 @@
#include <grpc/support/time.h>
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/sockaddr.h"
-#include "src/core/lib/support/env.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -220,30 +220,31 @@ class BalancerServiceImpl : public BalancerService {
if (client_load_reporting_interval_seconds_ > 0) {
request.Clear();
- stream->Read(&request);
- gpr_log(GPR_INFO, "LB[%p]: recv client load report msg: '%s'", this,
- request.DebugString().c_str());
- GPR_ASSERT(request.has_client_stats());
- // We need to acquire the lock here in order to prevent the notify_one
- // below from firing before its corresponding wait is executed.
- std::lock_guard<std::mutex> lock(mu_);
- client_stats_.num_calls_started +=
- request.client_stats().num_calls_started();
- client_stats_.num_calls_finished +=
- request.client_stats().num_calls_finished();
- client_stats_.num_calls_finished_with_client_failed_to_send +=
- request.client_stats()
- .num_calls_finished_with_client_failed_to_send();
- client_stats_.num_calls_finished_known_received +=
- request.client_stats().num_calls_finished_known_received();
- for (const auto& drop_token_count :
- request.client_stats().calls_finished_with_drop()) {
- client_stats_
- .drop_token_counts[drop_token_count.load_balance_token()] +=
- drop_token_count.num_calls();
+ if (stream->Read(&request)) {
+ gpr_log(GPR_INFO, "LB[%p]: recv client load report msg: '%s'", this,
+ request.DebugString().c_str());
+ GPR_ASSERT(request.has_client_stats());
+ // We need to acquire the lock here in order to prevent the notify_one
+ // below from firing before its corresponding wait is executed.
+ std::lock_guard<std::mutex> lock(mu_);
+ client_stats_.num_calls_started +=
+ request.client_stats().num_calls_started();
+ client_stats_.num_calls_finished +=
+ request.client_stats().num_calls_finished();
+ client_stats_.num_calls_finished_with_client_failed_to_send +=
+ request.client_stats()
+ .num_calls_finished_with_client_failed_to_send();
+ client_stats_.num_calls_finished_known_received +=
+ request.client_stats().num_calls_finished_known_received();
+ for (const auto& drop_token_count :
+ request.client_stats().calls_finished_with_drop()) {
+ client_stats_
+ .drop_token_counts[drop_token_count.load_balance_token()] +=
+ drop_token_count.num_calls();
+ }
+ load_report_ready_ = true;
+ load_report_cond_.notify_one();
}
- load_report_ready_ = true;
- load_report_cond_.notify_one();
}
done:
gpr_log(GPR_INFO, "LB[%p]: done", this);
diff --git a/test/cpp/end2end/server_early_return_test.cc b/test/cpp/end2end/server_early_return_test.cc
new file mode 100644
index 0000000000..6fd26fcdb6
--- /dev/null
+++ b/test/cpp/end2end/server_early_return_test.cc
@@ -0,0 +1,233 @@
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc++/channel.h>
+#include <grpc++/client_context.h>
+#include <grpc++/create_channel.h>
+#include <grpc++/security/credentials.h>
+#include <grpc++/security/server_credentials.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+#include "test/cpp/util/string_ref_helper.h"
+
+#include <gtest/gtest.h>
+
+namespace grpc {
+namespace testing {
+namespace {
+
+const char kServerReturnStatusCode[] = "server_return_status_code";
+const char kServerDelayBeforeReturnUs[] = "server_delay_before_return_us";
+const char kServerReturnAfterNReads[] = "server_return_after_n_reads";
+
+class TestServiceImpl : public ::grpc::testing::EchoTestService::Service {
+ public:
+ // Unused methods are not implemented.
+
+ Status RequestStream(ServerContext* context,
+ ServerReader<EchoRequest>* reader,
+ EchoResponse* response) override {
+ int server_return_status_code =
+ GetIntValueFromMetadata(context, kServerReturnStatusCode, 0);
+ int server_delay_before_return_us =
+ GetIntValueFromMetadata(context, kServerDelayBeforeReturnUs, 0);
+ int server_return_after_n_reads =
+ GetIntValueFromMetadata(context, kServerReturnAfterNReads, 0);
+
+ EchoRequest request;
+ while (server_return_after_n_reads--) {
+ EXPECT_TRUE(reader->Read(&request));
+ }
+
+ response->set_message("response msg");
+
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_micros(server_delay_before_return_us, GPR_TIMESPAN)));
+
+ return Status(static_cast<StatusCode>(server_return_status_code), "");
+ }
+
+ Status BidiStream(
+ ServerContext* context,
+ ServerReaderWriter<EchoResponse, EchoRequest>* stream) override {
+ int server_return_status_code =
+ GetIntValueFromMetadata(context, kServerReturnStatusCode, 0);
+ int server_delay_before_return_us =
+ GetIntValueFromMetadata(context, kServerDelayBeforeReturnUs, 0);
+ int server_return_after_n_reads =
+ GetIntValueFromMetadata(context, kServerReturnAfterNReads, 0);
+
+ EchoRequest request;
+ EchoResponse response;
+ while (server_return_after_n_reads--) {
+ EXPECT_TRUE(stream->Read(&request));
+ response.set_message(request.message());
+ EXPECT_TRUE(stream->Write(response));
+ }
+
+ gpr_sleep_until(gpr_time_add(
+ gpr_now(GPR_CLOCK_MONOTONIC),
+ gpr_time_from_micros(server_delay_before_return_us, GPR_TIMESPAN)));
+
+ return Status(static_cast<StatusCode>(server_return_status_code), "");
+ }
+
+ int GetIntValueFromMetadata(ServerContext* context, const char* key,
+ int default_value) {
+ auto metadata = context->client_metadata();
+ if (metadata.find(key) != metadata.end()) {
+ std::istringstream iss(ToString(metadata.find(key)->second));
+ iss >> default_value;
+ }
+ return default_value;
+ }
+};
+
+class ServerEarlyReturnTest : public ::testing::Test {
+ protected:
+ ServerEarlyReturnTest() : picked_port_(0) {}
+
+ void SetUp() override {
+ int port = grpc_pick_unused_port_or_die();
+ picked_port_ = port;
+ server_address_ << "127.0.0.1:" << port;
+ ServerBuilder builder;
+ builder.AddListeningPort(server_address_.str(),
+ InsecureServerCredentials());
+ builder.RegisterService(&service_);
+ server_ = builder.BuildAndStart();
+
+ channel_ =
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
+ stub_ = grpc::testing::EchoTestService::NewStub(channel_);
+ }
+
+ void TearDown() override {
+ server_->Shutdown();
+ if (picked_port_ > 0) {
+ grpc_recycle_unused_port(picked_port_);
+ }
+ }
+
+ // Client sends 20 requests and the server returns after reading 10 requests.
+ // If return_cancel is true, server returns CANCELLED status. Otherwise it
+ // returns OK.
+ void DoBidiStream(bool return_cancelled) {
+ EchoRequest request;
+ EchoResponse response;
+ ClientContext context;
+
+ context.AddMetadata(kServerReturnAfterNReads, "10");
+ if (return_cancelled) {
+ // "1" means CANCELLED
+ context.AddMetadata(kServerReturnStatusCode, "1");
+ }
+ context.AddMetadata(kServerDelayBeforeReturnUs, "10000");
+
+ auto stream = stub_->BidiStream(&context);
+
+ for (int i = 0; i < 20; i++) {
+ request.set_message(grpc::string("hello") + grpc::to_string(i));
+ bool write_ok = stream->Write(request);
+ bool read_ok = stream->Read(&response);
+ if (i < 10) {
+ EXPECT_TRUE(write_ok);
+ EXPECT_TRUE(read_ok);
+ EXPECT_EQ(response.message(), request.message());
+ } else {
+ EXPECT_FALSE(read_ok);
+ }
+ }
+
+ stream->WritesDone();
+ EXPECT_FALSE(stream->Read(&response));
+
+ Status s = stream->Finish();
+ if (return_cancelled) {
+ EXPECT_EQ(s.error_code(), StatusCode::CANCELLED);
+ } else {
+ EXPECT_TRUE(s.ok());
+ }
+ }
+
+ void DoRequestStream(bool return_cancelled) {
+ EchoRequest request;
+ EchoResponse response;
+ ClientContext context;
+
+ context.AddMetadata(kServerReturnAfterNReads, "10");
+ if (return_cancelled) {
+ // "1" means CANCELLED
+ context.AddMetadata(kServerReturnStatusCode, "1");
+ }
+ context.AddMetadata(kServerDelayBeforeReturnUs, "10000");
+
+ auto stream = stub_->RequestStream(&context, &response);
+ for (int i = 0; i < 20; i++) {
+ request.set_message(grpc::string("hello") + grpc::to_string(i));
+ bool written = stream->Write(request);
+ if (i < 10) {
+ EXPECT_TRUE(written);
+ }
+ }
+ stream->WritesDone();
+ Status s = stream->Finish();
+ if (return_cancelled) {
+ EXPECT_EQ(s.error_code(), StatusCode::CANCELLED);
+ } else {
+ EXPECT_TRUE(s.ok());
+ }
+ }
+
+ std::shared_ptr<Channel> channel_;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
+ std::unique_ptr<Server> server_;
+ std::ostringstream server_address_;
+ TestServiceImpl service_;
+ int picked_port_;
+};
+
+TEST_F(ServerEarlyReturnTest, BidiStreamEarlyOk) { DoBidiStream(false); }
+
+TEST_F(ServerEarlyReturnTest, BidiStreamEarlyCancel) { DoBidiStream(true); }
+
+TEST_F(ServerEarlyReturnTest, RequestStreamEarlyOK) { DoRequestStream(false); }
+TEST_F(ServerEarlyReturnTest, RequestStreamEarlyCancel) {
+ DoRequestStream(true);
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc
index 14ba7c96cc..9119102f7a 100644
--- a/test/cpp/end2end/shutdown_test.cc
+++ b/test/cpp/end2end/shutdown_test.cc
@@ -28,7 +28,7 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
diff --git a/test/cpp/end2end/test_service_impl.cc b/test/cpp/end2end/test_service_impl.cc
index e4f7c08f25..875a27b5f5 100644
--- a/test/cpp/end2end/test_service_impl.cc
+++ b/test/cpp/end2end/test_service_impl.cc
@@ -181,13 +181,6 @@ Status TestServiceImpl::RequestStream(ServerContext* context,
int server_try_cancel = GetIntValueFromMetadata(
kServerTryCancelRequest, context->client_metadata(), DO_NOT_CANCEL);
- // If 'cancel_after_reads' is set in the metadata AND non-zero, the server
- // will cancel the RPC (by just returning Status::CANCELLED - doesn't call
- // ServerContext::TryCancel()) after reading the number of records specified
- // by the 'cancel_after_reads' value set in the metadata.
- int cancel_after_reads = GetIntValueFromMetadata(
- kServerCancelAfterReads, context->client_metadata(), 0);
-
EchoRequest request;
response->set_message("");
@@ -204,12 +197,6 @@ Status TestServiceImpl::RequestStream(ServerContext* context,
int num_msgs_read = 0;
while (reader->Read(&request)) {
- if (cancel_after_reads == 1) {
- gpr_log(GPR_INFO, "return cancel status");
- return Status::CANCELLED;
- } else if (cancel_after_reads > 0) {
- cancel_after_reads--;
- }
response->mutable_message()->append(request.message());
}
gpr_log(GPR_INFO, "Read: %d messages", num_msgs_read);
diff --git a/test/cpp/end2end/test_service_impl.h b/test/cpp/end2end/test_service_impl.h
index e485769bb2..070f357139 100644
--- a/test/cpp/end2end/test_service_impl.h
+++ b/test/cpp/end2end/test_service_impl.h
@@ -31,7 +31,6 @@ namespace testing {
const int kServerDefaultResponseStreamsToSend = 3;
const char* const kServerResponseStreamsToSend = "server_responses_to_send";
-const char* const kServerCancelAfterReads = "cancel_after_reads";
const char* const kServerTryCancelRequest = "server_try_cancel";
const char* const kDebugInfoTrailerKey = "debug-info-bin";
const char* const kServerFinishAfterNReads = "server_finish_after_n_reads";
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index 38b65fbc78..d241594af1 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -40,11 +40,11 @@
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/security/credentials/fake/fake_credentials.h"
-#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/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "test/core/end2end/cq_verifier.h"
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index 716fb96382..8958b9884d 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -27,7 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/cpp/interop/client_helper.h"
#include "test/cpp/interop/interop_client.h"
#include "test/cpp/util/test_config.h"
diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc
index 2de7abcf17..7a9e3ced6a 100644
--- a/test/cpp/interop/http2_client.cc
+++ b/test/cpp/interop/http2_client.cc
@@ -30,7 +30,7 @@
#include "src/proto/grpc/testing/test.grpc.pb.h"
#include "test/cpp/interop/http2_client.h"
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "test/cpp/util/create_test_channel.h"
#include "test/cpp/util/test_config.h"
diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc
index 30bd8bfef8..7cfdb2f9e9 100644
--- a/test/cpp/interop/interop_server.cc
+++ b/test/cpp/interop/interop_server.cc
@@ -31,7 +31,7 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
-#include "src/core/lib/support/string.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/transport/byte_stream.h"
#include "src/proto/grpc/testing/empty.pb.h"
#include "src/proto/grpc/testing/messages.pb.h"
diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc
index 1bf0d8d10f..563b7abb5e 100644
--- a/test/cpp/interop/interop_test.cc
+++ b/test/cpp/interop/interop_test.cc
@@ -37,8 +37,8 @@
#include "test/core/util/port.h"
#include "test/cpp/util/test_config.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
-#include "src/core/lib/support/string.h"
DEFINE_string(extra_server_flags, "", "Extra flags to pass to server.");
diff --git a/test/cpp/microbenchmarks/bm_arena.cc b/test/cpp/microbenchmarks/bm_arena.cc
index 5b7c611919..69c8c1c029 100644
--- a/test/cpp/microbenchmarks/bm_arena.cc
+++ b/test/cpp/microbenchmarks/bm_arena.cc
@@ -18,7 +18,7 @@
/* Benchmark arenas */
-#include "src/core/lib/support/arena.h"
+#include "src/core/lib/gpr/arena.h"
#include "test/cpp/microbenchmarks/helpers.h"
#include "third_party/benchmark/include/benchmark/benchmark.h"
diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc
index 4d5a82c3f6..6d88faecc0 100644
--- a/test/cpp/microbenchmarks/bm_closure.cc
+++ b/test/cpp/microbenchmarks/bm_closure.cc
@@ -22,10 +22,10 @@
#include <grpc/grpc.h>
#include <sstream>
+#include "src/core/lib/gpr/spinlock.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#include "src/core/lib/support/spinlock.h"
#include "test/cpp/microbenchmarks/helpers.h"
diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc
index 3481d9d1aa..8b5523f01a 100644
--- a/test/cpp/naming/resolver_component_test.cc
+++ b/test/cpp/naming/resolver_component_test.cc
@@ -37,13 +37,13 @@
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/ext/filters/client_channel/resolver_registry.h"
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
-#include "src/core/lib/support/env.h"
-#include "src/core/lib/support/string.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
diff --git a/test/cpp/naming/resolver_component_tests_runner_invoker.cc b/test/cpp/naming/resolver_component_tests_runner_invoker.cc
index 0beb27de1b..65f11243fe 100644
--- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc
+++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc
@@ -32,7 +32,7 @@
#include "test/cpp/util/subprocess.h"
#include "test/cpp/util/test_config.h"
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "test/core/util/port.h"
DEFINE_bool(
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index 22d039d4b7..a809a27e3c 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -31,9 +31,8 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include "src/core/lib/gpr/env.h"
#include "src/core/lib/profiling/timers.h"
-#include "src/core/lib/support/env.h"
-#include "src/proto/grpc/testing/services.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#include "test/cpp/qps/client.h"
diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc
index db8b2a3943..948c3088e6 100644
--- a/test/cpp/qps/json_run_localhost.cc
+++ b/test/cpp/qps/json_run_localhost.cc
@@ -26,7 +26,7 @@
#include <grpc/support/log.h>
-#include "src/core/lib/support/env.h"
+#include "src/core/lib/gpr/env.h"
#include "test/core/util/port.h"
#include "test/cpp/util/subprocess.h"
diff --git a/test/distrib/cpp/run_distrib_test_cmake.bat b/test/distrib/cpp/run_distrib_test_cmake.bat
index 047846b0f1..f920768ae3 100644
--- a/test/distrib/cpp/run_distrib_test_cmake.bat
+++ b/test/distrib/cpp/run_distrib_test_cmake.bat
@@ -58,13 +58,13 @@ cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DOP
cmake --build . --config Release --target install || goto :error
cd ../..
-# Build helloworld example using cmake
+@rem Build helloworld example using cmake
cd examples/cpp/helloworld
mkdir cmake
cd cmake
mkdir build
cd build
-cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ../.. || goto :error
+cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DOPENSSL_INCLUDE_DIR=%OPENSSL_DIR%/include ../.. || goto :error
cmake --build . --config Release || goto :error
cd ../../../../..