Merge pull request #12885 from yashykt/timeouttestfix

Fixing Linux Portability Build
pull/12909/head
Yash Tibrewal 7 years ago committed by GitHub
commit ebf117531f
  1. 19
      src/core/ext/transport/chttp2/transport/flow_control.cc
  2. 2
      src/core/lib/iomgr/timer_uv.cc
  3. 5
      test/core/backoff/backoff_test.c
  4. 20
      test/core/iomgr/tcp_client_uv_test.c
  5. 4
      test/core/iomgr/tcp_server_uv_test.c
  6. 14
      test/core/transport/timeout_encoding_test.c

@ -399,15 +399,16 @@ static double get_pid_controller_guess(grpc_exec_ctx* exec_ctx,
if (!tfc->pid_controller_initialized) { if (!tfc->pid_controller_initialized) {
tfc->last_pid_update = now; tfc->last_pid_update = now;
tfc->pid_controller_initialized = true; tfc->pid_controller_initialized = true;
grpc_pid_controller_init( grpc_pid_controller_args args;
&tfc->pid_controller, memset(&args, 0, sizeof(args));
(grpc_pid_controller_args){.gain_p = 4, args.gain_p = 4;
.gain_i = 8, args.gain_i = 8;
.gain_d = 0, args.gain_d = 0;
.initial_control_value = target, args.initial_control_value = target;
.min_control_value = -1, args.min_control_value = -1;
.max_control_value = 25, args.max_control_value = 25;
.integral_range = 10}); args.integral_range = 10;
grpc_pid_controller_init(&tfc->pid_controller, args);
return pow(2, target); return pow(2, target);
} }
double bdp_error = target - grpc_pid_controller_last(&tfc->pid_controller); double bdp_error = target - grpc_pid_controller_last(&tfc->pid_controller);

@ -94,7 +94,7 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx *exec_ctx,
return GRPC_TIMERS_NOT_CHECKED; return GRPC_TIMERS_NOT_CHECKED;
} }
void grpc_timer_list_init(gpr_timespec now) {} void grpc_timer_list_init(grpc_exec_ctx *exec_ctx) {}
void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {} void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {}
void grpc_timer_consume_kick(void) {} void grpc_timer_consume_kick(void) {}

@ -105,8 +105,9 @@ static void test_jitter_backoff(void) {
const int64_t initial_timeout = 500; const int64_t initial_timeout = 500;
const double jitter = 0.1; const double jitter = 0.1;
grpc_backoff backoff; grpc_backoff backoff;
grpc_backoff_init(&backoff, initial_timeout, 1.0 /* multiplier */, jitter, grpc_backoff_init(&backoff, (grpc_millis)initial_timeout,
100 /* min timeout */, 1000 /* max timeout */); 1.0 /* multiplier */, jitter, 100 /* min timeout */,
1000 /* max timeout */);
backoff.rng_state = 0; // force consistent PRNG backoff.rng_state = 0; // force consistent PRNG

@ -42,8 +42,8 @@ static grpc_pollset *g_pollset;
static int g_connections_complete = 0; static int g_connections_complete = 0;
static grpc_endpoint *g_connecting = NULL; static grpc_endpoint *g_connecting = NULL;
static gpr_timespec test_deadline(void) { static grpc_millis test_deadline(void) {
return grpc_timeout_seconds_to_deadline(10); return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
} }
static void finish_connection(grpc_exec_ctx *exec_ctx) { static void finish_connection(grpc_exec_ctx *exec_ctx) {
@ -110,7 +110,7 @@ void test_succeeds(void) {
(int *)&resolved_addr.len) == 0); (int *)&resolved_addr.len) == 0);
GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx);
grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL, grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL,
&resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME)); &resolved_addr, GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu); gpr_mu_lock(g_mu);
@ -119,8 +119,8 @@ void test_succeeds(void) {
GPR_ASSERT(GRPC_LOG_IF_ERROR( GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", "pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker, grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(5)))); grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_flush(&exec_ctx); grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(g_mu); gpr_mu_lock(g_mu);
@ -154,7 +154,7 @@ void test_fails(void) {
/* connect to a broken address */ /* connect to a broken address */
GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx);
grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL, grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL,
&resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME)); &resolved_addr, GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu); gpr_mu_lock(g_mu);
@ -162,17 +162,17 @@ void test_fails(void) {
while (g_connections_complete == connections_complete_before) { while (g_connections_complete == connections_complete_before) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec polling_deadline = test_deadline(); grpc_millis polling_deadline = test_deadline();
switch (grpc_timer_check(&exec_ctx, now, &polling_deadline)) { switch (grpc_timer_check(&exec_ctx, &polling_deadline)) {
case GRPC_TIMERS_FIRED: case GRPC_TIMERS_FIRED:
break; break;
case GRPC_TIMERS_NOT_CHECKED: case GRPC_TIMERS_NOT_CHECKED:
polling_deadline = now; polling_deadline = grpc_timespec_to_millis_round_up(now);
/* fall through */ /* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY: case GRPC_TIMERS_CHECKED_AND_EMPTY:
GPR_ASSERT(GRPC_LOG_IF_ERROR( GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
now, polling_deadline))); polling_deadline)));
break; break;
} }
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);

@ -207,7 +207,7 @@ static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote,
GPR_ASSERT(GRPC_LOG_IF_ERROR( GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", "pollset_work",
grpc_pollset_work(exec_ctx, g_pollset, &worker, grpc_pollset_work(exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline))); grpc_timespec_to_millis_round_up(deadline))));
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(exec_ctx); grpc_exec_ctx_finish(exec_ctx);
gpr_mu_lock(g_mu); gpr_mu_lock(g_mu);
@ -246,7 +246,7 @@ static void test_connect(unsigned n) {
GPR_ASSERT(GRPC_ERROR_NONE == GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_tcp_server_add_port(s, &resolved_addr, &svr_port)); grpc_tcp_server_add_port(s, &resolved_addr, &svr_port));
GPR_ASSERT(svr_port > 0); GPR_ASSERT(svr_port > 0);
GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr) == 0); GPR_ASSERT((uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr)) == 0);
/* Cannot use wildcard (port==0), because add_port() will try to reuse the /* Cannot use wildcard (port==0), because add_port() will try to reuse the
same port as a previous add_port(). */ same port as a previous add_port(). */
svr1_port = grpc_pick_unused_port_or_die(); svr1_port = grpc_pick_unused_port_or_die();

@ -102,18 +102,20 @@ void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) {
} }
static grpc_millis millis_from_nanos(int64_t x) { static grpc_millis millis_from_nanos(int64_t x) {
return x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); return (grpc_millis)(x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0));
} }
static grpc_millis millis_from_micros(int64_t x) { static grpc_millis millis_from_micros(int64_t x) {
return x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); return (grpc_millis)(x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0));
}
static grpc_millis millis_from_millis(int64_t x) { return (grpc_millis)x; }
static grpc_millis millis_from_seconds(int64_t x) {
return (grpc_millis)(x * GPR_MS_PER_SEC);
} }
static grpc_millis millis_from_millis(int64_t x) { return x; }
static grpc_millis millis_from_seconds(int64_t x) { return x * GPR_MS_PER_SEC; }
static grpc_millis millis_from_minutes(int64_t x) { static grpc_millis millis_from_minutes(int64_t x) {
return x * 60 * GPR_MS_PER_SEC; return (grpc_millis)(x * 60 * GPR_MS_PER_SEC);
} }
static grpc_millis millis_from_hours(int64_t x) { static grpc_millis millis_from_hours(int64_t x) {
return x * 3600 * GPR_MS_PER_SEC; return (grpc_millis)(x * 3600 * GPR_MS_PER_SEC);
} }
void test_decoding(void) { void test_decoding(void) {

Loading…
Cancel
Save