From c430c84f84bec9c97cb48b0ccfd212f52e10de93 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 30 Oct 2017 17:38:50 -0700 Subject: more changes --- test/core/client_channel/lb_policies_test.cc | 2 +- .../core/network_benchmarks/low_level_ping_pong.cc | 22 +++++++++---------- test/core/statistics/hash_table_test.cc | 18 ++++++++-------- test/core/statistics/window_stats_test.cc | 25 +++++++++++----------- 4 files changed, 34 insertions(+), 33 deletions(-) (limited to 'test') diff --git a/test/core/client_channel/lb_policies_test.cc b/test/core/client_channel/lb_policies_test.cc index 1f0d310380..aa0e1ba14d 100644 --- a/test/core/client_channel/lb_policies_test.cc +++ b/test/core/client_channel/lb_policies_test.cc @@ -235,7 +235,7 @@ static request_sequences request_sequences_create(size_t n) { res.connections = static_cast(gpr_malloc(sizeof(*res.connections) * n)); res.connectivity_states = - static_cast(gpr_malloc(sizeof(*res.connectivity_states) * n)); + static_cast(gpr_malloc(sizeof(*res.connectivity_states) * n)); memset(res.connections, 0, sizeof(*res.connections) * n); memset(res.connectivity_states, 0, sizeof(*res.connectivity_states) * n); return res; diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc index 1550003eb9..acd84aaa09 100644 --- a/test/core/network_benchmarks/low_level_ping_pong.cc +++ b/test/core/network_benchmarks/low_level_ping_pong.cc @@ -252,7 +252,7 @@ static int epoll_setup(thread_args *args) { #endif static void server_thread(thread_args *args) { - char *buf = gpr_malloc(args->msg_size); + char *buf = static_cast(gpr_malloc(args->msg_size)); if (args->setup(args) < 0) { gpr_log(GPR_ERROR, "Setup failed"); } @@ -271,7 +271,7 @@ static void server_thread(thread_args *args) { } static void server_thread_wrap(void *arg) { - thread_args *args = arg; + thread_args *args = static_cast(arg); server_thread(args); } @@ -291,7 +291,7 @@ static double now(void) { } static void client_thread(thread_args *args) { - char *buf = gpr_malloc(args->msg_size * sizeof(char)); + char *buf = static_cast(gpr_malloc(args->msg_size * sizeof(char))); memset(buf, 0, args->msg_size * sizeof(char)); gpr_histogram *histogram = gpr_histogram_create(0.01, 60e9); double start_time; @@ -538,7 +538,7 @@ void print_usage(char *argv0) { } typedef struct test_strategy { - char *name; + const char *name; int (*read_strategy)(struct thread_args *args, char *buf); int (*setup)(struct thread_args *args); } test_strategy; @@ -553,7 +553,7 @@ static test_strategy test_strategies[] = { {"spin_read", spin_read_bytes, set_socket_nonblocking}, {"spin_poll", poll_read_bytes_spin, set_socket_nonblocking}}; -static char *socket_types[] = {"tcp", "socketpair", "pipe"}; +static const char *socket_types[] = {"tcp", "socketpair", "pipe"}; int create_socket(char *socket_type, fd_pair *client_fds, fd_pair *server_fds) { if (strcmp(socket_type, "tcp") == 0) { @@ -594,8 +594,8 @@ static int run_all_benchmarks(size_t msg_size) { test_strategy *strategy = &test_strategies[i]; size_t j; for (j = 0; j < GPR_ARRAY_SIZE(socket_types); ++j) { - thread_args *client_args = gpr_malloc(sizeof(thread_args)); - thread_args *server_args = gpr_malloc(sizeof(thread_args)); + thread_args *client_args = static_cast(gpr_malloc(sizeof(thread_args))); + thread_args *server_args = static_cast(gpr_malloc(sizeof(thread_args))); char *socket_type = socket_types[j]; client_args->read_bytes = strategy->read_strategy; @@ -618,11 +618,11 @@ static int run_all_benchmarks(size_t msg_size) { } int main(int argc, char **argv) { - thread_args *client_args = gpr_malloc(sizeof(thread_args)); - thread_args *server_args = gpr_malloc(sizeof(thread_args)); + thread_args *client_args = static_cast(gpr_malloc(sizeof(thread_args))); + thread_args *server_args = static_cast(gpr_malloc(sizeof(thread_args))); int msg_size = -1; - char *read_strategy = NULL; - char *socket_type = NULL; + const char *read_strategy = NULL; + const char *socket_type = NULL; size_t i; const test_strategy *strategy = NULL; int error = 0; diff --git a/test/core/statistics/hash_table_test.cc b/test/core/statistics/hash_table_test.cc index d714e15091..72ea0d8066 100644 --- a/test/core/statistics/hash_table_test.cc +++ b/test/core/statistics/hash_table_test.cc @@ -89,7 +89,7 @@ static void test_table_with_int_key(void) { uint64_t *val = NULL; census_ht_key key; key.val = i; - val = census_ht_find(ht, key); + val = static_cast(census_ht_find(ht, key)); GPR_ASSERT(val == (void *)(intptr_t)i); } elements = census_ht_get_all_elements(ht, &num_elements); @@ -112,22 +112,22 @@ static void test_value_and_key_deleter(void) { char *val = NULL; char *val2 = NULL; key.ptr = gpr_malloc(100); - val = gpr_malloc(10); + val = static_cast(gpr_malloc(10)); strcpy(val, "value"); strcpy(key.ptr, "some string as a key"); GPR_ASSERT(ht != NULL); GPR_ASSERT(census_ht_get_size(ht) == 0); census_ht_insert(ht, key, val); GPR_ASSERT(census_ht_get_size(ht) == 1); - val = census_ht_find(ht, key); + val = static_cast(census_ht_find(ht, key)); GPR_ASSERT(val != NULL); GPR_ASSERT(strcmp(val, "value") == 0); /* Insert same key different value, old value is overwritten. */ - val2 = gpr_malloc(10); + val2 = static_cast(gpr_malloc(10)); strcpy(val2, "v2"); census_ht_insert(ht, key, val2); GPR_ASSERT(census_ht_get_size(ht) == 1); - val2 = census_ht_find(ht, key); + val2 = static_cast(census_ht_find(ht, key)); GPR_ASSERT(val2 != NULL); GPR_ASSERT(strcmp(val2, "v2") == 0); census_ht_destroy(ht); @@ -214,7 +214,7 @@ static void test_table_with_string_key(void) { census_ht_key key; int *val_ptr; key.ptr = (void *)(keys[i]); - val_ptr = census_ht_find(ht, key); + val_ptr = static_cast(census_ht_find(ht, key)); GPR_ASSERT(*val_ptr == vals[i]); } { @@ -225,7 +225,7 @@ static void test_table_with_string_key(void) { census_ht_insert(ht, key, (void *)(vals + 8)); /* expect value to be over written by new insertion */ GPR_ASSERT(census_ht_get_size(ht) == 9); - val_ptr = census_ht_find(ht, key); + val_ptr = static_cast(census_ht_find(ht, key)); GPR_ASSERT(*val_ptr == vals[8]); } for (i = 0; i < 9; i++) { @@ -234,11 +234,11 @@ static void test_table_with_string_key(void) { uint32_t expected_tbl_sz = 9 - i; GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz); key.ptr = (void *)(keys[i]); - val_ptr = census_ht_find(ht, key); + val_ptr = static_cast(census_ht_find(ht, key)); GPR_ASSERT(val_ptr != NULL); census_ht_erase(ht, key); GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz - 1); - val_ptr = census_ht_find(ht, key); + val_ptr = static_cast(census_ht_find(ht, key)); GPR_ASSERT(val_ptr == NULL); } census_ht_destroy(ht); diff --git a/test/core/statistics/window_stats_test.cc b/test/core/statistics/window_stats_test.cc index 254c14a6a8..91eafd5724 100644 --- a/test/core/statistics/window_stats_test.cc +++ b/test/core/statistics/window_stats_test.cc @@ -44,11 +44,11 @@ void add_proportion_test_stat(double p, void *base, const void *addme) { const struct census_window_stats_stat_info kMyStatInfo = { sizeof(test_stat), NULL, add_test_stat, add_proportion_test_stat}; -const gpr_timespec kMilliSecInterval = {0, 1000000}; -const gpr_timespec kSecInterval = {1, 0}; -const gpr_timespec kMinInterval = {60, 0}; -const gpr_timespec kHourInterval = {3600, 0}; -const gpr_timespec kPrimeInterval = {0, 101}; +const gpr_timespec kMilliSecInterval = {0, 1000000, GPR_CLOCK_MONOTONIC}; +const gpr_timespec kSecInterval = {1, 0, GPR_CLOCK_MONOTONIC}; +const gpr_timespec kMinInterval = {60, 0 GPR_CLOCK_MONOTONIC}; +const gpr_timespec kHourInterval = {3600, 0, GPR_CLOCK_MONOTONIC}; +const gpr_timespec kPrimeInterval = {0, 101, GPR_CLOCK_MONOTONIC}; static int compare_double(double a, double b, double epsilon) { if (a >= b) { @@ -60,7 +60,7 @@ static int compare_double(double a, double b, double epsilon) { void empty_test(void) { census_window_stats_sums result; - const gpr_timespec zero = {0, 0}; + const gpr_timespec zero = {0, 0, GPR_CLOCK_MONOTONIC}; test_stat sum; struct census_window_stats *stats = census_window_stats_create(1, &kMinInterval, 5, &kMyStatInfo); @@ -76,7 +76,7 @@ void empty_test(void) { void one_interval_test(void) { const test_stat value = {0.1, 4}; const double epsilon = 1e10 - 11; - gpr_timespec when = {0, 0}; + gpr_timespec when = {0, 0, GPR_CLOCK_MONOTONIC}; census_window_stats_sums result; test_stat sum; /* granularity == 5 so width of internal windows should be 12s */ @@ -186,7 +186,7 @@ void many_interval_test(void) { gpr_timespec intervals[4]; const test_stat value = {123.45, 8}; const double epsilon = 1e10 - 11; - gpr_timespec when = {3600, 0}; /* one hour */ + gpr_timespec when = {3600, 0, GPR_CLOCK_MONOTONIC}; /* one hour */ census_window_stats_sums result[4]; test_stat sums[4]; int i; @@ -245,11 +245,11 @@ void many_interval_test(void) { void rolling_time_test(void) { const test_stat value = {0.1, 4}; - gpr_timespec when = {0, 0}; + gpr_timespec when = {0, 0, GPR_CLOCK_MONOTONIC}; census_window_stats_sums result; test_stat sum; int i; - gpr_timespec increment = {0, 0}; + gpr_timespec increment = {0, 0, GPR_CLOCK_MONOTONIC}; struct census_window_stats *stats = census_window_stats_create(1, &kMinInterval, 7, &kMyStatInfo); GPR_ASSERT(stats != NULL); @@ -270,12 +270,13 @@ void rolling_time_test(void) { #include void infinite_interval_test(void) { const test_stat value = {0.1, 4}; - gpr_timespec when = {0, 0}; + gpr_timespec when = {0, 0, GPR_CLOCK_MONOTONIC}; census_window_stats_sums result; test_stat sum; int i; const int count = 100000; - gpr_timespec increment = {0, 0}; + gpr_timespec increment = {0, 0, GPR_CLOCK_MONOTONIC}; + gpr_timespec temp = gpr_inf_future(GPR_CLOCK_REALTIME); struct census_window_stats *stats = census_window_stats_create( 1, &gpr_inf_future(GPR_CLOCK_REALTIME), 10, &kMyStatInfo); srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); -- cgit v1.2.3