diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-11-13 15:37:58 -0800 |
---|---|---|
committer | Yash Tibrewal <yashkt@google.com> | 2017-11-14 01:36:28 -0800 |
commit | 75122c23578e24417dcf64081c737571a9fc2dbc (patch) | |
tree | f4b8491964ec0508a5826490628c9f87b82c3326 /test/core/iomgr/timer_list_test.cc | |
parent | 36cd68f0d543b9024c84eff82319890a791de7f6 (diff) |
Address some PR comments
Diffstat (limited to 'test/core/iomgr/timer_list_test.cc')
-rw-r--r-- | test/core/iomgr/timer_list_test.cc | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/test/core/iomgr/timer_list_test.cc b/test/core/iomgr/timer_list_test.cc index 07dfec168c..7281f55b85 100644 --- a/test/core/iomgr/timer_list_test.cc +++ b/test/core/iomgr/timer_list_test.cc @@ -52,7 +52,7 @@ static void add_test(void) { grpc_timer_check_trace.value = 1; memset(cb_called, 0, sizeof(cb_called)); - grpc_millis start = grpc_exec_ctx_now(); + grpc_millis start = ExecCtx::Get()->Now(); /* 10 ms timers. will expire in the current epoch */ for (i = 0; i < 10; i++) { @@ -69,32 +69,32 @@ static void add_test(void) { } /* collect timers. Only the first batch should be ready. */ - exec_ctx->now = start + 500; + ExecCtx::Get()->SetNow(start + 500); GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_FIRED); - grpc_exec_ctx_finish(); + for (i = 0; i < 20; i++) { GPR_ASSERT(cb_called[i][1] == (i < 10)); GPR_ASSERT(cb_called[i][0] == 0); } - exec_ctx->now = start + 600; + ExecCtx::Get()->SetNow(start + 600); GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY); - grpc_exec_ctx_finish(); + for (i = 0; i < 30; i++) { GPR_ASSERT(cb_called[i][1] == (i < 10)); GPR_ASSERT(cb_called[i][0] == 0); } /* collect the rest of the timers */ - exec_ctx->now = start + 1500; + ExecCtx::Get()->SetNow(start + 1500); GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_FIRED); - grpc_exec_ctx_finish(); + for (i = 0; i < 30; i++) { GPR_ASSERT(cb_called[i][1] == (i < 20)); GPR_ASSERT(cb_called[i][0] == 0); } - exec_ctx->now = start + 1600; + ExecCtx::Get()->SetNow(start + 1600); GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY); for (i = 0; i < 30; i++) { GPR_ASSERT(cb_called[i][1] == (i < 20)); @@ -102,7 +102,6 @@ static void add_test(void) { } grpc_timer_list_shutdown(); - grpc_exec_ctx_finish(); } /* Cleaning up a list with pending timers. */ @@ -112,8 +111,7 @@ void destruction_test(void) { gpr_log(GPR_INFO, "destruction_test"); - exec_ctx->now_is_valid = true; - exec_ctx->now = 0; + ExecCtx::Get()->SetNow(0); grpc_timer_list_init(); grpc_timer_trace.value = 1; grpc_timer_check_trace.value = 1; @@ -134,18 +132,18 @@ void destruction_test(void) { grpc_timer_init( &timers[4], 1, GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)4, grpc_schedule_on_exec_ctx)); - exec_ctx->now = 2; + ExecCtx::Get()->SetNow(2); GPR_ASSERT(grpc_timer_check(NULL) == GRPC_TIMERS_FIRED); - grpc_exec_ctx_finish(); + GPR_ASSERT(1 == cb_called[4][1]); grpc_timer_cancel(&timers[0]); grpc_timer_cancel(&timers[3]); - grpc_exec_ctx_finish(); + GPR_ASSERT(1 == cb_called[0][0]); GPR_ASSERT(1 == cb_called[3][0]); grpc_timer_list_shutdown(); - grpc_exec_ctx_finish(); + GPR_ASSERT(1 == cb_called[1][0]); GPR_ASSERT(1 == cb_called[2][0]); } |