diff options
author | 2015-02-26 09:30:36 -0800 | |
---|---|---|
committer | 2015-02-26 09:30:36 -0800 | |
commit | 0e32857bfdab7422b22508fac833d7c651470691 (patch) | |
tree | 3bc397d6f1bf3c47639900df482cb72876626809 /test/core/statistics | |
parent | c33731aea655720293576e77ec4d5f04e1f7d545 (diff) | |
parent | c1f1162787a84abdbc6cbe1717909692fad41261 (diff) |
Merge pull request #784 from ctiller/timeout
Introduce slowdown factor for unit test deadlines
Diffstat (limited to 'test/core/statistics')
-rw-r--r-- | test/core/statistics/census_log_tests.c | 7 | ||||
-rw-r--r-- | test/core/statistics/hash_table_test.c | 4 | ||||
-rw-r--r-- | test/core/statistics/trace_test.c | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c index fbc96bbde6..241ec1ce4f 100644 --- a/test/core/statistics/census_log_tests.c +++ b/test/core/statistics/census_log_tests.c @@ -42,6 +42,7 @@ #include <grpc/support/thd.h> #include <grpc/support/time.h> #include <grpc/support/useful.h> +#include "test/core/util/test_config.h" /* Fills in 'record' of size 'size'. Each byte in record is filled in with the same value. The value is extracted from 'record' pointer. */ @@ -123,8 +124,8 @@ static void assert_log_empty(void) { /* Given log size and record size, computes the minimum usable space. */ static gpr_int32 min_usable_space(size_t log_size, size_t record_size) { gpr_int32 usable_space; - gpr_int32 num_blocks = GPR_MAX(log_size / CENSUS_LOG_MAX_RECORD_SIZE, - gpr_cpu_num_cores()); + gpr_int32 num_blocks = + GPR_MAX(log_size / CENSUS_LOG_MAX_RECORD_SIZE, gpr_cpu_num_cores()); gpr_int32 waste_per_block = CENSUS_LOG_MAX_RECORD_SIZE % record_size; /* In the worst case, all except one core-local block is full. */ gpr_int32 num_full_blocks = num_blocks - 1; @@ -198,7 +199,7 @@ static void writer_thread(void* arg) { This should never happen for circular logs. */ printf(" Writer stalled due to out-of-space: %d out of %d written\n", records_written, args->num_records); - gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_micros(10000))); + gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10)); } } /* Done. Decrement count and signal. */ diff --git a/test/core/statistics/hash_table_test.c b/test/core/statistics/hash_table_test.c index 2752d6d89d..1e9e1c8d23 100644 --- a/test/core/statistics/hash_table_test.c +++ b/test/core/statistics/hash_table_test.c @@ -97,7 +97,7 @@ static void test_table_with_int_key(void) { for (i = 0; i < 20; ++i) { census_ht_key key; key.val = i; - census_ht_insert(ht, key, (void*)(gpr_intptr)i); + census_ht_insert(ht, key, (void*)(gpr_intptr) i); GPR_ASSERT(census_ht_get_size(ht) == i + 1); } for (i = 0; i < 20; i++) { @@ -105,7 +105,7 @@ static void test_table_with_int_key(void) { census_ht_key key; key.val = i; val = census_ht_find(ht, key); - GPR_ASSERT(val == (void*)(gpr_intptr)i); + GPR_ASSERT(val == (void*)(gpr_intptr) i); } elements = census_ht_get_all_elements(ht, &num_elements); GPR_ASSERT(elements != NULL); diff --git a/test/core/statistics/trace_test.c b/test/core/statistics/trace_test.c index 65b70e1006..b13fd03f70 100644 --- a/test/core/statistics/trace_test.c +++ b/test/core/statistics/trace_test.c @@ -111,7 +111,7 @@ static void mimic_trace_op_sequences(void* arg) { id = census_tracing_start_op(); census_add_method_tag(id, method_name); /* pretend doing 1us work. */ - gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_micros(1))); + gpr_sleep_until(GRPC_TIMEOUT_MICROS_TO_DEADLINE(1)); census_tracing_end_op(id); } gpr_log(GPR_INFO, "End trace op sequence thread."); |