aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/statistics
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-11-03 09:09:36 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-11-03 09:09:36 -0700
commitbaa14a975ef92ee6fb301f0e684f56f18f2c55a7 (patch)
tree9a6cb2df58fe175e8abfccf2cbd40349726e46f3 /test/core/statistics
parentef68fe7239a89095f1eaa89c1dd28b2b7be2a3c7 (diff)
Update clang-format to 5.0
Diffstat (limited to 'test/core/statistics')
-rw-r--r--test/core/statistics/census_log_tests.c58
-rw-r--r--test/core/statistics/census_stub_test.c4
-rw-r--r--test/core/statistics/hash_table_test.c88
-rw-r--r--test/core/statistics/multiple_writers_circular_buffer_test.c2
-rw-r--r--test/core/statistics/multiple_writers_test.c2
-rw-r--r--test/core/statistics/performance_test.c2
-rw-r--r--test/core/statistics/quick_test.c2
-rw-r--r--test/core/statistics/rpc_stats_test.c6
-rw-r--r--test/core/statistics/small_log_test.c2
-rw-r--r--test/core/statistics/trace_test.c17
-rw-r--r--test/core/statistics/window_stats_test.c24
11 files changed, 103 insertions, 104 deletions
diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c
index 229a5e55f9..e6eda5486c 100644
--- a/test/core/statistics/census_log_tests.c
+++ b/test/core/statistics/census_log_tests.c
@@ -16,7 +16,6 @@
*
*/
-#include "src/core/ext/census/census_log.h"
#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@@ -27,26 +26,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "src/core/ext/census/census_log.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. */
-static void write_record(char *record, size_t size) {
+static void write_record(char* record, size_t size) {
char data = (uintptr_t)record % 255;
memset(record, data, size);
}
/* Reads fixed size records. Returns the number of records read in
'num_records'. */
-static void read_records(size_t record_size, const char *buffer,
- size_t buffer_size, int32_t *num_records) {
+static void read_records(size_t record_size, const char* buffer,
+ size_t buffer_size, int32_t* num_records) {
int32_t ix;
GPR_ASSERT(buffer_size >= record_size);
GPR_ASSERT(buffer_size % record_size == 0);
*num_records = buffer_size / record_size;
for (ix = 0; ix < *num_records; ++ix) {
size_t jx;
- const char *record = buffer + (record_size * ix);
+ const char* record = buffer + (record_size * ix);
char data = (uintptr_t)record % 255;
for (jx = 0; jx < record_size; ++jx) {
GPR_ASSERT(data == record[jx]);
@@ -65,13 +65,13 @@ static size_t write_records_to_log(int writer_id, int32_t record_size,
for (ix = 0; ix < num_records; ++ix) {
int32_t jx;
int32_t spin_count = max_spin_count ? rand() % max_spin_count : 0;
- char *record;
+ char* record;
if (counter++ == num_records / 10) {
printf(" Writer %d: %d out of %d written\n", writer_id, ix,
num_records);
counter = 0;
}
- record = (char *)(census_log_start_write(record_size));
+ record = (char*)(census_log_start_write(record_size));
if (record == NULL) {
return ix;
}
@@ -86,13 +86,13 @@ static size_t write_records_to_log(int writer_id, int32_t record_size,
/* Performs a single read iteration. Returns the number of records read. */
static size_t perform_read_iteration(size_t record_size) {
- const void *read_buffer = NULL;
+ const void* read_buffer = NULL;
size_t bytes_available;
size_t records_read = 0;
census_log_init_reader();
while ((read_buffer = census_log_read_next(&bytes_available))) {
int32_t num_records = 0;
- read_records(record_size, (const char *)read_buffer, bytes_available,
+ read_records(record_size, (const char*)read_buffer, bytes_available,
&num_records);
records_read += num_records;
}
@@ -162,15 +162,15 @@ typedef struct writer_thread_args {
/* Number of records to write. */
int32_t num_records;
/* Used to signal when writer is complete */
- gpr_cv *done;
- gpr_mu *mu;
- int *count;
+ gpr_cv* done;
+ gpr_mu* mu;
+ int* count;
} writer_thread_args;
/* Writes the given number of records of random size (up to kMaxRecordSize) and
random data to the specified log. */
-static void writer_thread(void *arg) {
- writer_thread_args *args = (writer_thread_args *)arg;
+static void writer_thread(void* arg) {
+ writer_thread_args* args = (writer_thread_args*)arg;
/* Maximum number of times to spin between writes. */
static const int32_t MAX_SPIN_COUNT = 50;
int records_written = 0;
@@ -207,17 +207,17 @@ typedef struct reader_thread_args {
gpr_cv stop;
int stop_flag;
/* Used to signal when reader has finished */
- gpr_cv *done;
- gpr_mu *mu;
+ gpr_cv* done;
+ gpr_mu* mu;
int running;
} reader_thread_args;
/* Reads and verifies the specified number of records. Reader can also be
stopped via gpr_cv_signal(&args->stop). Sleeps for 'read_interval_in_msec'
between read iterations. */
-static void reader_thread(void *arg) {
+static void reader_thread(void* arg) {
int32_t records_read = 0;
- reader_thread_args *args = (reader_thread_args *)arg;
+ reader_thread_args* args = (reader_thread_args*)arg;
int32_t num_iterations = 0;
gpr_timespec interval;
int counter = 0;
@@ -335,7 +335,7 @@ static void setup_test(int circular_log) {
void test_invalid_record_size(void) {
static const size_t INVALID_SIZE = CENSUS_LOG_MAX_RECORD_SIZE + 1;
static const size_t VALID_SIZE = 1;
- void *record;
+ void* record;
printf("Starting test: invalid record size\n");
setup_test(0);
record = census_log_start_write(INVALID_SIZE);
@@ -358,8 +358,8 @@ void test_invalid_record_size(void) {
void test_end_write_with_different_size(void) {
static const size_t START_WRITE_SIZE = 10;
static const size_t END_WRITE_SIZE = 7;
- void *record_written;
- const void *record_read;
+ void* record_written;
+ const void* record_read;
size_t bytes_available;
printf("Starting test: end write with different size\n");
setup_test(0);
@@ -378,8 +378,8 @@ void test_end_write_with_different_size(void) {
void test_read_pending_record(void) {
static const size_t PR_RECORD_SIZE = 1024;
size_t bytes_available;
- const void *record_read;
- void *record_written;
+ const void* record_read;
+ void* record_written;
printf("Starting test: read pending record\n");
setup_test(0);
/* Start a write. */
@@ -405,9 +405,9 @@ void test_read_beyond_pending_record(void) {
uint32_t incomplete_record_size = 10;
uint32_t complete_record_size = 20;
size_t bytes_available;
- void *complete_record;
- const void *record_read;
- void *incomplete_record;
+ void* complete_record;
+ const void* record_read;
+ void* incomplete_record;
printf("Starting test: read beyond pending record\n");
setup_test(0);
incomplete_record = census_log_start_write(incomplete_record_size);
@@ -442,8 +442,8 @@ void test_read_beyond_pending_record(void) {
void test_detached_while_reading(void) {
static const size_t DWR_RECORD_SIZE = 10;
size_t bytes_available;
- const void *record_read;
- void *record_written;
+ const void* record_read;
+ void* record_written;
uint32_t block_read = 0;
printf("Starting test: detached while reading\n");
setup_test(0);
@@ -556,7 +556,7 @@ void test_performance(void) {
setup_test(0);
start_time = gpr_now(GPR_CLOCK_REALTIME);
while (1) {
- void *record = census_log_start_write(write_size);
+ void* record = census_log_start_write(write_size);
if (record == NULL) {
break;
}
diff --git a/test/core/statistics/census_stub_test.c b/test/core/statistics/census_stub_test.c
index f38d571abd..507ae0a9fa 100644
--- a/test/core/statistics/census_stub_test.c
+++ b/test/core/statistics/census_stub_test.c
@@ -28,7 +28,7 @@
/* Tests census noop stubs in a simulated rpc flow */
void test_census_stubs(void) {
census_op_id op_id;
- census_rpc_stats *stats = census_rpc_stats_create_empty();
+ census_rpc_stats* stats = census_rpc_stats_create_empty();
census_aggregated_rpc_stats data_map = {0, NULL};
/* Initializes census library at server start up time. */
@@ -55,7 +55,7 @@ void test_census_stubs(void) {
census_shutdown();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_census_stubs();
return 0;
diff --git a/test/core/statistics/hash_table_test.c b/test/core/statistics/hash_table_test.c
index d714e15091..0f6147a095 100644
--- a/test/core/statistics/hash_table_test.c
+++ b/test/core/statistics/hash_table_test.c
@@ -29,27 +29,27 @@
#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
-static uint64_t hash64(const void *k) {
+static uint64_t hash64(const void* k) {
size_t len = strlen(k);
- uint64_t higher = gpr_murmur_hash3((const char *)k, len / 2, 0);
+ uint64_t higher = gpr_murmur_hash3((const char*)k, len / 2, 0);
return higher << 32 |
- gpr_murmur_hash3((const char *)(k) + len / 2, len - len / 2, 0);
+ gpr_murmur_hash3((const char*)(k) + len / 2, len - len / 2, 0);
}
-static int cmp_str_keys(const void *k1, const void *k2) {
- return strcmp((const char *)k1, (const char *)k2);
+static int cmp_str_keys(const void* k1, const void* k2) {
+ return strcmp((const char*)k1, (const char*)k2);
}
-static uint64_t force_collision(const void *k) {
+static uint64_t force_collision(const void* k) {
return (1997 + hash64(k) % 3);
}
-static void free_data(void *data) { gpr_free(data); }
+static void free_data(void* data) { gpr_free(data); }
/* Basic tests that empty hash table can be created and destroyed. */
static void test_create_table(void) {
/* Create table with uint64 key type */
- census_ht *ht = NULL;
+ census_ht* ht = NULL;
census_ht_option ht_options = {
CENSUS_HT_UINT64, 1999, NULL, NULL, NULL, NULL};
ht = census_ht_create(&ht_options);
@@ -69,11 +69,11 @@ static void test_create_table(void) {
static void test_table_with_int_key(void) {
census_ht_option opt = {CENSUS_HT_UINT64, 7, NULL, NULL, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
+ census_ht* ht = census_ht_create(&opt);
uint64_t i = 0;
uint64_t sum_of_keys = 0;
size_t num_elements;
- census_ht_kv *elements = NULL;
+ census_ht_kv* elements = NULL;
GPR_ASSERT(ht != NULL);
GPR_ASSERT(census_ht_get_size(ht) == 0);
elements = census_ht_get_all_elements(ht, &num_elements);
@@ -82,15 +82,15 @@ 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 *)(intptr_t)i);
+ census_ht_insert(ht, key, (void*)(intptr_t)i);
GPR_ASSERT(census_ht_get_size(ht) == i + 1);
}
for (i = 0; i < 20; i++) {
- uint64_t *val = NULL;
+ uint64_t* val = NULL;
census_ht_key key;
key.val = i;
val = census_ht_find(ht, key);
- GPR_ASSERT(val == (void *)(intptr_t)i);
+ GPR_ASSERT(val == (void*)(intptr_t)i);
}
elements = census_ht_get_all_elements(ht, &num_elements);
GPR_ASSERT(elements != NULL);
@@ -107,10 +107,10 @@ static void test_table_with_int_key(void) {
static void test_value_and_key_deleter(void) {
census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64,
&cmp_str_keys, &free_data, &free_data};
- census_ht *ht = census_ht_create(&opt);
+ census_ht* ht = census_ht_create(&opt);
census_ht_key key;
- char *val = NULL;
- char *val2 = NULL;
+ char* val = NULL;
+ char* val2 = NULL;
key.ptr = gpr_malloc(100);
val = gpr_malloc(10);
strcpy(val, "value");
@@ -136,14 +136,14 @@ static void test_value_and_key_deleter(void) {
/* Test simple insert and erase operations. */
static void test_simple_add_and_erase(void) {
census_ht_option opt = {CENSUS_HT_UINT64, 7, NULL, NULL, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
+ census_ht* ht = census_ht_create(&opt);
GPR_ASSERT(ht != NULL);
GPR_ASSERT(census_ht_get_size(ht) == 0);
{
census_ht_key key;
int val = 3;
key.val = 2;
- census_ht_insert(ht, key, (void *)&val);
+ census_ht_insert(ht, key, (void*)&val);
GPR_ASSERT(census_ht_get_size(ht) == 1);
census_ht_erase(ht, key);
GPR_ASSERT(census_ht_get_size(ht) == 0);
@@ -151,11 +151,11 @@ static void test_simple_add_and_erase(void) {
census_ht_erase(ht, key);
GPR_ASSERT(census_ht_get_size(ht) == 0);
/* Erasing a non-existant key from a table should be noop. */
- census_ht_insert(ht, key, (void *)&val);
+ census_ht_insert(ht, key, (void*)&val);
key.val = 3;
- census_ht_insert(ht, key, (void *)&val);
+ census_ht_insert(ht, key, (void*)&val);
key.val = 9;
- census_ht_insert(ht, key, (void *)&val);
+ census_ht_insert(ht, key, (void*)&val);
GPR_ASSERT(census_ht_get_size(ht) == 3);
key.val = 1;
census_ht_erase(ht, key);
@@ -172,7 +172,7 @@ static void test_simple_add_and_erase(void) {
static void test_insertion_and_deletion_with_high_collision_rate(void) {
census_ht_option opt = {CENSUS_HT_POINTER, 13, &force_collision,
&cmp_str_keys, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
+ census_ht* ht = census_ht_create(&opt);
char key_str[1000][GPR_LTOA_MIN_BUFSIZE];
uint64_t val = 0;
unsigned i = 0;
@@ -180,7 +180,7 @@ static void test_insertion_and_deletion_with_high_collision_rate(void) {
census_ht_key key;
key.ptr = key_str[i];
gpr_ltoa(i, key_str[i]);
- census_ht_insert(ht, key, (void *)(&val));
+ census_ht_insert(ht, key, (void*)(&val));
gpr_log(GPR_INFO, "%d\n", i);
GPR_ASSERT(census_ht_get_size(ht) == (i + 1));
}
@@ -196,8 +196,8 @@ static void test_insertion_and_deletion_with_high_collision_rate(void) {
static void test_table_with_string_key(void) {
census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64,
&cmp_str_keys, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
- const char *keys[] = {
+ census_ht* ht = census_ht_create(&opt);
+ const char* keys[] = {
"k1", "a", "000", "apple", "banana_a_long_long_long_banana",
"%$", "111", "foo", "b"};
const int vals[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
@@ -206,23 +206,23 @@ static void test_table_with_string_key(void) {
GPR_ASSERT(census_ht_get_size(ht) == 0);
for (i = 0; i < 9; i++) {
census_ht_key key;
- key.ptr = (void *)(keys[i]);
- census_ht_insert(ht, key, (void *)(vals + i));
+ key.ptr = (void*)(keys[i]);
+ census_ht_insert(ht, key, (void*)(vals + i));
}
GPR_ASSERT(census_ht_get_size(ht) == 9);
for (i = 0; i < 9; i++) {
census_ht_key key;
- int *val_ptr;
- key.ptr = (void *)(keys[i]);
+ int* val_ptr;
+ key.ptr = (void*)(keys[i]);
val_ptr = census_ht_find(ht, key);
GPR_ASSERT(*val_ptr == vals[i]);
}
{
/* inserts duplicate keys */
census_ht_key key;
- int *val_ptr = NULL;
- key.ptr = (void *)(keys[2]);
- census_ht_insert(ht, key, (void *)(vals + 8));
+ int* val_ptr = NULL;
+ key.ptr = (void*)(keys[2]);
+ 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);
@@ -230,10 +230,10 @@ static void test_table_with_string_key(void) {
}
for (i = 0; i < 9; i++) {
census_ht_key key;
- int *val_ptr;
+ int* val_ptr;
uint32_t expected_tbl_sz = 9 - i;
GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz);
- key.ptr = (void *)(keys[i]);
+ key.ptr = (void*)(keys[i]);
val_ptr = census_ht_find(ht, key);
GPR_ASSERT(val_ptr != NULL);
census_ht_erase(ht, key);
@@ -246,34 +246,34 @@ static void test_table_with_string_key(void) {
static void test_insertion_with_same_key(void) {
census_ht_option opt = {CENSUS_HT_UINT64, 11, NULL, NULL, NULL, NULL};
- census_ht *ht = census_ht_create(&opt);
+ census_ht* ht = census_ht_create(&opt);
census_ht_key key;
const char vals[] = {'a', 'b', 'c'};
- char *val_ptr;
+ char* val_ptr;
key.val = 3;
- census_ht_insert(ht, key, (void *)&(vals[0]));
+ census_ht_insert(ht, key, (void*)&(vals[0]));
GPR_ASSERT(census_ht_get_size(ht) == 1);
- val_ptr = (char *)census_ht_find(ht, key);
+ val_ptr = (char*)census_ht_find(ht, key);
GPR_ASSERT(val_ptr != NULL);
GPR_ASSERT(*val_ptr == 'a');
key.val = 4;
- val_ptr = (char *)census_ht_find(ht, key);
+ val_ptr = (char*)census_ht_find(ht, key);
GPR_ASSERT(val_ptr == NULL);
key.val = 3;
- census_ht_insert(ht, key, (void *)&(vals[1]));
+ census_ht_insert(ht, key, (void*)&(vals[1]));
GPR_ASSERT(census_ht_get_size(ht) == 1);
- val_ptr = (char *)census_ht_find(ht, key);
+ val_ptr = (char*)census_ht_find(ht, key);
GPR_ASSERT(val_ptr != NULL);
GPR_ASSERT(*val_ptr == 'b');
- census_ht_insert(ht, key, (void *)&(vals[2]));
+ census_ht_insert(ht, key, (void*)&(vals[2]));
GPR_ASSERT(census_ht_get_size(ht) == 1);
- val_ptr = (char *)census_ht_find(ht, key);
+ val_ptr = (char*)census_ht_find(ht, key);
GPR_ASSERT(val_ptr != NULL);
GPR_ASSERT(*val_ptr == 'c');
census_ht_destroy(ht);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_create_table();
test_simple_add_and_erase();
diff --git a/test/core/statistics/multiple_writers_circular_buffer_test.c b/test/core/statistics/multiple_writers_circular_buffer_test.c
index 8abd76c3d1..6d3411289e 100644
--- a/test/core/statistics/multiple_writers_circular_buffer_test.c
+++ b/test/core/statistics/multiple_writers_circular_buffer_test.c
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_multiple_writers_circular_log();
diff --git a/test/core/statistics/multiple_writers_test.c b/test/core/statistics/multiple_writers_test.c
index de800e0d8a..47410ab105 100644
--- a/test/core/statistics/multiple_writers_test.c
+++ b/test/core/statistics/multiple_writers_test.c
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_multiple_writers();
diff --git a/test/core/statistics/performance_test.c b/test/core/statistics/performance_test.c
index 6104acb612..9d4fd6ef90 100644
--- a/test/core/statistics/performance_test.c
+++ b/test/core/statistics/performance_test.c
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_performance();
diff --git a/test/core/statistics/quick_test.c b/test/core/statistics/quick_test.c
index 1e044b6b59..91ecdde818 100644
--- a/test/core/statistics/quick_test.c
+++ b/test/core/statistics/quick_test.c
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_invalid_record_size();
diff --git a/test/core/statistics/rpc_stats_test.c b/test/core/statistics/rpc_stats_test.c
index 01ac5a19ab..aead5cfdca 100644
--- a/test/core/statistics/rpc_stats_test.c
+++ b/test/core/statistics/rpc_stats_test.c
@@ -39,7 +39,7 @@ static void test_init_shutdown(void) {
}
static void test_create_and_destroy(void) {
- census_rpc_stats *stats = NULL;
+ census_rpc_stats* stats = NULL;
census_aggregated_rpc_stats agg_stats = {0, NULL};
stats = census_rpc_stats_create_empty();
@@ -54,7 +54,7 @@ static void test_create_and_destroy(void) {
GPR_ASSERT(agg_stats.num_entries == 0);
GPR_ASSERT(agg_stats.stats == NULL);
agg_stats.num_entries = 1;
- agg_stats.stats = (census_per_method_rpc_stats *)gpr_malloc(
+ agg_stats.stats = (census_per_method_rpc_stats*)gpr_malloc(
sizeof(census_per_method_rpc_stats));
agg_stats.stats[0].method = gpr_strdup("foo");
census_aggregated_rpc_stats_set_empty(&agg_stats);
@@ -172,7 +172,7 @@ static void test_record_stats_with_trace_store_uninitialized(void) {
census_stats_store_shutdown();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_init_shutdown();
test_create_and_destroy();
diff --git a/test/core/statistics/small_log_test.c b/test/core/statistics/small_log_test.c
index 4bcc35c37e..fb8dfc9988 100644
--- a/test/core/statistics/small_log_test.c
+++ b/test/core/statistics/small_log_test.c
@@ -23,7 +23,7 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_small_log();
diff --git a/test/core/statistics/trace_test.c b/test/core/statistics/trace_test.c
index 63da9f71d3..ecbfed09ee 100644
--- a/test/core/statistics/trace_test.c
+++ b/test/core/statistics/trace_test.c
@@ -28,7 +28,6 @@
#include <grpc/support/useful.h>
#include "src/core/ext/census/census_interface.h"
#include "src/core/ext/census/census_tracing.h"
-#include "src/core/ext/census/census_tracing.h"
#include "test/core/util/test_config.h"
/* Ensure all possible state transitions are called without causing problem */
@@ -70,7 +69,7 @@ static void test_get_trace_method_name(void) {
census_add_method_tag(id, write_name);
census_internal_lock_trace_store();
{
- const char *read_name =
+ const char* read_name =
census_get_trace_method_name(census_get_trace_obj_locked(id));
GPR_ASSERT(strcmp(read_name, write_name) == 0);
}
@@ -84,12 +83,12 @@ typedef struct thd_arg {
gpr_mu mu;
} thd_arg;
-static void mimic_trace_op_sequences(void *arg) {
+static void mimic_trace_op_sequences(void* arg) {
census_op_id id;
- const char *method_name = "service_foo/method_bar";
+ const char* method_name = "service_foo/method_bar";
int i = 0;
const int num_iter = 200;
- thd_arg *args = (thd_arg *)arg;
+ thd_arg* args = (thd_arg*)arg;
GPR_ASSERT(args != NULL);
gpr_log(GPR_INFO, "Start trace op sequence thread.");
for (i = 0; i < num_iter; i++) {
@@ -140,7 +139,7 @@ static void test_add_method_tag_to_unknown_op_id(void) {
static void test_trace_print(void) {
census_op_id id;
int i;
- const char *annotation_txt[4] = {"abc", "", "$%^ *()_"};
+ const char* annotation_txt[4] = {"abc", "", "$%^ *()_"};
char long_txt[CENSUS_MAX_ANNOTATION_LENGTH + 10];
memset(long_txt, 'a', GPR_ARRAY_SIZE(long_txt));
@@ -166,8 +165,8 @@ static int ids_equal(census_op_id id1, census_op_id id2) {
static void test_get_active_ops(void) {
census_op_id id_1, id_2, id_3;
- census_trace_obj **active_ops;
- const char *annotation_txt[] = {"annotation 1", "a2"};
+ census_trace_obj** active_ops;
+ const char* annotation_txt[] = {"annotation 1", "a2"};
int i = 0;
int n = 0;
@@ -227,7 +226,7 @@ static void test_get_active_ops(void) {
census_tracing_shutdown();
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_init_shutdown();
test_start_op_generates_locally_unique_ids();
diff --git a/test/core/statistics/window_stats_test.c b/test/core/statistics/window_stats_test.c
index 254c14a6a8..457004bbd0 100644
--- a/test/core/statistics/window_stats_test.c
+++ b/test/core/statistics/window_stats_test.c
@@ -27,16 +27,16 @@ typedef struct test_stat {
int value2;
} test_stat;
-void add_test_stat(void *base, const void *addme) {
- test_stat *b = (test_stat *)base;
- const test_stat *a = (const test_stat *)addme;
+void add_test_stat(void* base, const void* addme) {
+ test_stat* b = (test_stat*)base;
+ const test_stat* a = (const test_stat*)addme;
b->value1 += a->value1;
b->value2 += a->value2;
}
-void add_proportion_test_stat(double p, void *base, const void *addme) {
- test_stat *b = (test_stat *)base;
- const test_stat *a = (const test_stat *)addme;
+void add_proportion_test_stat(double p, void* base, const void* addme) {
+ test_stat* b = (test_stat*)base;
+ const test_stat* a = (const test_stat*)addme;
b->value1 += p * a->value1;
b->value2 += p * a->value2 + 0.5; /* +0.5 is poor mans (no c99) round() */
}
@@ -62,7 +62,7 @@ void empty_test(void) {
census_window_stats_sums result;
const gpr_timespec zero = {0, 0};
test_stat sum;
- struct census_window_stats *stats =
+ struct census_window_stats* stats =
census_window_stats_create(1, &kMinInterval, 5, &kMyStatInfo);
GPR_ASSERT(stats != NULL);
result.statistic = &sum;
@@ -80,7 +80,7 @@ void one_interval_test(void) {
census_window_stats_sums result;
test_stat sum;
/* granularity == 5 so width of internal windows should be 12s */
- struct census_window_stats *stats =
+ struct census_window_stats* stats =
census_window_stats_create(1, &kMinInterval, 5, &kMyStatInfo);
GPR_ASSERT(stats != NULL);
/* phase 1: insert a single value at t=0s, and check that various measurement
@@ -190,7 +190,7 @@ void many_interval_test(void) {
census_window_stats_sums result[4];
test_stat sums[4];
int i;
- struct census_window_stats *stats;
+ struct census_window_stats* stats;
intervals[0] = kMilliSecInterval;
intervals[1] = kSecInterval;
intervals[2] = kMinInterval;
@@ -250,7 +250,7 @@ void rolling_time_test(void) {
test_stat sum;
int i;
gpr_timespec increment = {0, 0};
- struct census_window_stats *stats =
+ struct census_window_stats* stats =
census_window_stats_create(1, &kMinInterval, 7, &kMyStatInfo);
GPR_ASSERT(stats != NULL);
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
@@ -276,7 +276,7 @@ void infinite_interval_test(void) {
int i;
const int count = 100000;
gpr_timespec increment = {0, 0};
- struct census_window_stats *stats = census_window_stats_create(
+ 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);
for (i = 0; i < count; i++) {
@@ -292,7 +292,7 @@ void infinite_interval_test(void) {
census_window_stats_destroy(stats);
}
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
grpc_test_init(argc, argv);
empty_test();
one_interval_test();