diff options
author | Craig Tiller <ctiller@google.com> | 2016-02-22 22:23:43 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-02-22 22:23:43 -0800 |
commit | c866f7281f2797fd662c7ba8db555e073aa4db2d (patch) | |
tree | 1fc1d5618a0039f21e37bafe331b3b2ba23927c6 /test/core | |
parent | 521423c8cf471bfdc4c7e1294890252220518416 (diff) | |
parent | 914a2e7217e3376dfbd69fa37008d6d60f797689 (diff) |
Merge github.com:grpc/grpc into naming-crisis
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/iomgr/tcp_client_posix_test.c | 26 | ||||
-rw-r--r-- | test/core/iomgr/timer_list_test.c | 31 |
2 files changed, 32 insertions, 25 deletions
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c index 9725d8a3b6..b57478059f 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.c @@ -45,6 +45,7 @@ #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/socket_utils_posix.h" +#include "src/core/iomgr/timer.h" #include "test/core/util/test_config.h" static grpc_pollset_set g_pollset_set; @@ -125,11 +126,13 @@ void test_succeeds(void) { gpr_now(GPR_CLOCK_MONOTONIC), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)); gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); } gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); + + grpc_exec_ctx_finish(&exec_ctx); } void test_fails(void) { @@ -159,14 +162,18 @@ void test_fails(void) { /* wait for the connection callback to finish */ while (g_connections_complete == connections_complete_before) { grpc_pollset_worker worker; - grpc_pollset_work(&exec_ctx, &g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), test_deadline()); + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_timespec polling_deadline = test_deadline(); + if (!grpc_timer_check(&exec_ctx, now, &polling_deadline)) { + grpc_pollset_work(&exec_ctx, &g_pollset, &worker, now, polling_deadline); + } gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); } gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); + grpc_exec_ctx_finish(&exec_ctx); } void test_times_out(void) { @@ -243,15 +250,18 @@ void test_times_out(void) { GPR_ASSERT(g_connections_complete == connections_complete_before + is_after_deadline); } - grpc_pollset_work(&exec_ctx, &g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10)); + gpr_timespec polling_deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10); + if (!grpc_timer_check(&exec_ctx, now, &polling_deadline)) { + grpc_pollset_work(&exec_ctx, &g_pollset, &worker, now, polling_deadline); + } gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); } gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); + grpc_exec_ctx_finish(&exec_ctx); + close(svr_fd); for (i = 0; i < NUM_CLIENT_CONNECTS; ++i) { close(client_fd[i]); diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c index 15de87c5a1..7a21fdd5c1 100644 --- a/test/core/iomgr/timer_list_test.c +++ b/test/core/iomgr/timer_list_test.c @@ -35,7 +35,6 @@ #include <string.h> -#include "src/core/iomgr/timer_internal.h" #include <grpc/support/log.h> #include "test/core/util/test_config.h" @@ -72,20 +71,19 @@ static void add_test(void) { } /* collect timers. Only the first batch should be ready. */ - GPR_ASSERT(10 == grpc_timer_check(&exec_ctx, - gpr_time_add(start, gpr_time_from_millis( - 500, GPR_TIMESPAN)), - NULL)); + GPR_ASSERT(grpc_timer_check( + &exec_ctx, gpr_time_add(start, gpr_time_from_millis(500, GPR_TIMESPAN)), + NULL)); 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(0 == 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_exec_ctx_finish(&exec_ctx); for (i = 0; i < 30; i++) { GPR_ASSERT(cb_called[i][1] == (i < 10)); @@ -93,20 +91,19 @@ static void add_test(void) { } /* collect the rest of the timers */ - GPR_ASSERT(10 == grpc_timer_check( - &exec_ctx, gpr_time_add(start, gpr_time_from_millis( - 1500, GPR_TIMESPAN)), - NULL)); + GPR_ASSERT(grpc_timer_check( + &exec_ctx, gpr_time_add(start, gpr_time_from_millis(1500, GPR_TIMESPAN)), + NULL)); 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(0 == 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)); for (i = 0; i < 30; i++) { GPR_ASSERT(cb_called[i][1] == (i < 20)); GPR_ASSERT(cb_called[i][0] == 0); |