Imported Upstream version 1.41.0
[platform/upstream/grpc.git] / test / core / end2end / tests / keepalive_timeout.cc
index c4025e9..6db92f2 100644 (file)
@@ -16,8 +16,6 @@
  *
  */
 
-#include "test/core/end2end/end2end_tests.h"
-
 #include <stdio.h>
 #include <string.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/gpr/useful.h"
 #include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/iomgr/iomgr.h"
 #include "test/core/end2end/cq_verifier.h"
+#include "test/core/end2end/end2end_tests.h"
+
+#ifdef GRPC_POSIX_SOCKET
+#include "src/core/lib/iomgr/ev_posix.h"
+#endif  // GRPC_POSIX_SOCKET
 
-static void* tag(intptr_t t) { return (void*)t; }
+static void* tag(intptr_t t) { return reinterpret_cast<void*>(t); }
 
 static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
                                             const char* test_name,
@@ -225,15 +228,13 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
  * 200ms. In the success case, each ping ack should reset the keepalive timer so
  * that the keepalive ping is never sent. */
 static void test_read_delays_keepalive(grpc_end2end_test_config config) {
-  char* poller = gpr_getenv("GRPC_POLL_STRATEGY");
-  /* It is hard to get the timing right for the polling engines poll and poll-cv
-   */
-  if (poller != nullptr &&
-      (0 == strcmp(poller, "poll-cv") || 0 == strcmp(poller, "poll"))) {
-    gpr_free(poller);
+#ifdef GRPC_POSIX_SOCKET
+  grpc_core::UniquePtr<char> poller = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy);
+  /* It is hard to get the timing right for the polling engine poll. */
+  if ((0 == strcmp(poller.get(), "poll"))) {
     return;
   }
-  gpr_free(poller);
+#endif  // GRPC_POSIX_SOCKET
   const int kPingIntervalMS = 100;
   grpc_arg keepalive_arg_elems[3];
   keepalive_arg_elems[0].type = GRPC_ARG_INTEGER;