diff options
author | Craig Tiller <ctiller@google.com> | 2017-06-07 16:45:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 16:45:59 -0700 |
commit | 6b19d3b408903a9a91727d1dfd4cd1704433cfe7 (patch) | |
tree | ef53e1954a3b6c4160a3ffe4169726267140d361 /test/core | |
parent | 2f6715d49b04163a9006c4c93b5ef8a1a1e4e98c (diff) | |
parent | 6d7c49f97bc8d4498f33310368fbb54dbcd82b52 (diff) |
Merge pull request #11333 from ctiller/faster_timer_pool
Get rid of zero-length poll case now that timer pool exists
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/iomgr/tcp_client_posix_test.c | 15 | ||||
-rw-r--r-- | test/core/iomgr/tcp_client_uv_test.c | 15 | ||||
-rw-r--r-- | test/core/iomgr/timer_list_test.c | 26 |
3 files changed, 37 insertions, 19 deletions
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]); |