From b2ef1cf67fc894343a7bf5579605049fbffabfa2 Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Tue, 30 May 2017 09:25:48 -0700
Subject: Get rid of zero-length poll case now that timer pool exists

---
 test/core/iomgr/tcp_client_posix_test.c | 15 +++++++++++----
 test/core/iomgr/tcp_client_uv_test.c    | 15 +++++++++++----
 test/core/iomgr/timer_list_test.c       | 26 +++++++++++++++-----------
 3 files changed, 37 insertions(+), 19 deletions(-)

(limited to 'test/core')

diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index 6e1bb43eb5..276684e855 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -181,10 +181,17 @@ void test_fails(void) {
     grpc_pollset_worker *worker = NULL;
     gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
     gpr_timespec polling_deadline = test_deadline();
-    if (!grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
-      GPR_ASSERT(GRPC_LOG_IF_ERROR(
-          "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, now,
-                                            polling_deadline)));
+    switch (grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
+      case GRPC_TIMERS_FIRED:
+        break;
+      case GRPC_TIMERS_NOT_CHECKED:
+        polling_deadline = now;
+      /* fall through */
+      case GRPC_TIMERS_CHECKED_AND_EMPTY:
+        GPR_ASSERT(GRPC_LOG_IF_ERROR(
+            "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
+                                              now, polling_deadline)));
+        break;
     }
     gpr_mu_unlock(g_mu);
     grpc_exec_ctx_flush(&exec_ctx);
diff --git a/test/core/iomgr/tcp_client_uv_test.c b/test/core/iomgr/tcp_client_uv_test.c
index 3a8458df86..4ec05cff12 100644
--- a/test/core/iomgr/tcp_client_uv_test.c
+++ b/test/core/iomgr/tcp_client_uv_test.c
@@ -178,10 +178,17 @@ void test_fails(void) {
     grpc_pollset_worker *worker = NULL;
     gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
     gpr_timespec polling_deadline = test_deadline();
-    if (!grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
-      GPR_ASSERT(GRPC_LOG_IF_ERROR(
-          "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, now,
-                                            polling_deadline)));
+    switch (grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
+      case GRPC_TIMERS_FIRED:
+        break;
+      case GRPC_TIMERS_NOT_CHECKED:
+        polling_deadline = now;
+      /* fall through */
+      case GRPC_TIMERS_CHECKED_AND_EMPTY:
+        GPR_ASSERT(GRPC_LOG_IF_ERROR(
+            "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
+                                              now, polling_deadline)));
+        break;
     }
     gpr_mu_unlock(g_mu);
     grpc_exec_ctx_flush(&exec_ctx);
diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c
index 88a9f6b855..2a3a47ccf9 100644
--- a/test/core/iomgr/timer_list_test.c
+++ b/test/core/iomgr/timer_list_test.c
@@ -88,17 +88,19 @@ static void add_test(void) {
 
   /* collect timers.  Only the first batch should be ready. */
   GPR_ASSERT(grpc_timer_check(
-      &exec_ctx, gpr_time_add(start, gpr_time_from_millis(500, GPR_TIMESPAN)),
-      NULL));
+                 &exec_ctx,
+                 gpr_time_add(start, gpr_time_from_millis(500, GPR_TIMESPAN)),
+                 NULL) == GRPC_TIMERS_FIRED);
   grpc_exec_ctx_finish(&exec_ctx);
   for (i = 0; i < 20; i++) {
     GPR_ASSERT(cb_called[i][1] == (i < 10));
     GPR_ASSERT(cb_called[i][0] == 0);
   }
 
-  GPR_ASSERT(!grpc_timer_check(
-      &exec_ctx, gpr_time_add(start, gpr_time_from_millis(600, GPR_TIMESPAN)),
-      NULL));
+  GPR_ASSERT(grpc_timer_check(
+                 &exec_ctx,
+                 gpr_time_add(start, gpr_time_from_millis(600, GPR_TIMESPAN)),
+                 NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY);
   grpc_exec_ctx_finish(&exec_ctx);
   for (i = 0; i < 30; i++) {
     GPR_ASSERT(cb_called[i][1] == (i < 10));
@@ -107,17 +109,19 @@ static void add_test(void) {
 
   /* collect the rest of the timers */
   GPR_ASSERT(grpc_timer_check(
-      &exec_ctx, gpr_time_add(start, gpr_time_from_millis(1500, GPR_TIMESPAN)),
-      NULL));
+                 &exec_ctx,
+                 gpr_time_add(start, gpr_time_from_millis(1500, GPR_TIMESPAN)),
+                 NULL) == GRPC_TIMERS_FIRED);
   grpc_exec_ctx_finish(&exec_ctx);
   for (i = 0; i < 30; i++) {
     GPR_ASSERT(cb_called[i][1] == (i < 20));
     GPR_ASSERT(cb_called[i][0] == 0);
   }
 
-  GPR_ASSERT(!grpc_timer_check(
-      &exec_ctx, gpr_time_add(start, gpr_time_from_millis(1600, GPR_TIMESPAN)),
-      NULL));
+  GPR_ASSERT(grpc_timer_check(
+                 &exec_ctx,
+                 gpr_time_add(start, gpr_time_from_millis(1600, GPR_TIMESPAN)),
+                 NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY);
   for (i = 0; i < 30; i++) {
     GPR_ASSERT(cb_called[i][1] == (i < 20));
     GPR_ASSERT(cb_called[i][0] == 0);
@@ -163,7 +167,7 @@ void destruction_test(void) {
       &exec_ctx, &timers[4], tfm(1),
       grpc_closure_create(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx),
       gpr_time_0(GPR_CLOCK_REALTIME));
-  GPR_ASSERT(1 == grpc_timer_check(&exec_ctx, tfm(2), NULL));
+  GPR_ASSERT(grpc_timer_check(&exec_ctx, tfm(2), NULL) == GRPC_TIMERS_FIRED);
   grpc_exec_ctx_finish(&exec_ctx);
   GPR_ASSERT(1 == cb_called[4][1]);
   grpc_timer_cancel(&exec_ctx, &timers[0]);
-- 
cgit v1.2.3