diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/core/iomgr/timer_heap_test.c | 21 | ||||
-rw-r--r-- | test/core/iomgr/timer_list_test.c | 8 |
2 files changed, 11 insertions, 18 deletions
diff --git a/test/core/iomgr/timer_heap_test.c b/test/core/iomgr/timer_heap_test.c index 410d972313..153304fa7b 100644 --- a/test/core/iomgr/timer_heap_test.c +++ b/test/core/iomgr/timer_heap_test.c @@ -47,13 +47,7 @@ #include "test/core/util/test_config.h" -static gpr_timespec random_deadline(void) { - gpr_timespec ts; - ts.tv_sec = rand(); - ts.tv_nsec = rand(); - ts.clock_type = GPR_CLOCK_REALTIME; - return ts; -} +static gpr_atm random_deadline(void) { return rand(); } static grpc_timer *create_test_elements(size_t num_elements) { grpc_timer *elems = gpr_malloc(num_elements * sizeof(grpc_timer)); @@ -78,12 +72,10 @@ static void check_valid(grpc_timer_heap *pq) { size_t left_child = 1u + 2u * i; size_t right_child = left_child + 1u; if (left_child < pq->timer_count) { - GPR_ASSERT(gpr_time_cmp(pq->timers[i]->deadline, - pq->timers[left_child]->deadline) <= 0); + GPR_ASSERT(pq->timers[i]->deadline <= pq->timers[left_child]->deadline); } if (right_child < pq->timer_count) { - GPR_ASSERT(gpr_time_cmp(pq->timers[i]->deadline, - pq->timers[right_child]->deadline) <= 0); + GPR_ASSERT(pq->timers[i]->deadline <= pq->timers[right_child]->deadline); } } } @@ -227,20 +219,19 @@ static void test2(void) { } if (num_inserted) { - gpr_timespec *min_deadline = NULL; + gpr_atm *min_deadline = NULL; for (size_t i = 0; i < elems_size; i++) { if (elems[i].inserted) { if (min_deadline == NULL) { min_deadline = &elems[i].elem.deadline; } else { - if (gpr_time_cmp(elems[i].elem.deadline, *min_deadline) < 0) { + if (elems[i].elem.deadline < *min_deadline) { min_deadline = &elems[i].elem.deadline; } } } } - GPR_ASSERT( - 0 == gpr_time_cmp(grpc_timer_heap_top(&pq)->deadline, *min_deadline)); + GPR_ASSERT(grpc_timer_heap_top(&pq)->deadline == *min_deadline); } } diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c index 85ad5277cc..5c397b32cb 100644 --- a/test/core/iomgr/timer_list_test.c +++ b/test/core/iomgr/timer_list_test.c @@ -57,6 +57,8 @@ static void add_test(void) { grpc_timer timers[20]; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + gpr_log(GPR_INFO, "add_test"); + grpc_timer_list_init(start); memset(cb_called, 0, sizeof(cb_called)); @@ -120,9 +122,7 @@ static void add_test(void) { } static gpr_timespec tfm(int m) { - gpr_timespec t = gpr_time_from_millis(m, GPR_TIMESPAN); - t.clock_type = GPR_CLOCK_REALTIME; - return t; + return gpr_time_from_millis(m, GPR_CLOCK_REALTIME); } /* Cleaning up a list with pending timers. */ @@ -130,6 +130,8 @@ void destruction_test(void) { grpc_timer timers[5]; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + gpr_log(GPR_INFO, "destruction_test"); + grpc_timer_list_init(gpr_time_0(GPR_CLOCK_REALTIME)); memset(cb_called, 0, sizeof(cb_called)); |