diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2016-01-06 17:28:40 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2016-01-06 17:28:40 -0800 |
commit | 04b3cf6f1964fb66a025a2b974973374b26387be (patch) | |
tree | d69e98b1b74a766afec6ee7ccabe343912b8c888 /test/core/support | |
parent | e8f9ba6b7f904a5b4376093ae631654f97f17e91 (diff) | |
parent | fc5281f66d9bd134d893e23bb45757677b1096c2 (diff) |
Merge github.com:grpc/grpc into wtfwin
Diffstat (limited to 'test/core/support')
-rw-r--r-- | test/core/support/alloc_test.c | 8 | ||||
-rw-r--r-- | test/core/support/cpu_test.c | 6 | ||||
-rw-r--r-- | test/core/support/murmur_hash_test.c | 14 | ||||
-rw-r--r-- | test/core/support/slice_test.c | 14 | ||||
-rw-r--r-- | test/core/support/string_test.c | 18 | ||||
-rw-r--r-- | test/core/support/sync_test.c | 32 | ||||
-rw-r--r-- | test/core/support/time_test.c | 8 | ||||
-rw-r--r-- | test/core/support/tls_test.c | 2 | ||||
-rw-r--r-- | test/core/support/useful_test.c | 6 |
9 files changed, 54 insertions, 54 deletions
diff --git a/test/core/support/alloc_test.c b/test/core/support/alloc_test.c index dc0a2acfa5..ea6306c1f9 100644 --- a/test/core/support/alloc_test.c +++ b/test/core/support/alloc_test.c @@ -39,17 +39,17 @@ static void *fake_malloc(size_t size) { return (void *)size; } static void *fake_realloc(void *addr, size_t size) { return (void *)size; } -static void fake_free(void *addr) { *((gpr_intptr *)addr) = 0xdeadd00d; } +static void fake_free(void *addr) { *((intptr_t *)addr) = 0xdeadd00d; } static void test_custom_allocs() { const gpr_allocation_functions default_fns = gpr_get_allocation_functions(); - gpr_intptr addr_to_free = 0; + intptr_t addr_to_free = 0; int *i; gpr_allocation_functions fns = {fake_malloc, fake_realloc, fake_free}; gpr_set_allocation_functions(fns); - GPR_ASSERT((void*)(size_t)0xdeadbeef == gpr_malloc(0xdeadbeef)); - GPR_ASSERT((void*)(size_t)0xcafed00d == gpr_realloc(0, 0xcafed00d)); + GPR_ASSERT((void *)(size_t)0xdeadbeef == gpr_malloc(0xdeadbeef)); + GPR_ASSERT((void *)(size_t)0xcafed00d == gpr_realloc(0, 0xcafed00d)); gpr_free(&addr_to_free); GPR_ASSERT(addr_to_free == 0xdeadd00d); diff --git a/test/core/support/cpu_test.c b/test/core/support/cpu_test.c index 010a96bbcb..d0b78f19d5 100644 --- a/test/core/support/cpu_test.c +++ b/test/core/support/cpu_test.c @@ -69,7 +69,7 @@ struct cpu_test { gpr_mu mu; int nthreads; - gpr_uint32 ncores; + uint32_t ncores; int is_done; gpr_cv done_cv; int *used; /* is this core used? */ @@ -78,7 +78,7 @@ struct cpu_test { static void worker_thread(void *arg) { struct cpu_test *ct = (struct cpu_test *)arg; - gpr_uint32 cpu; + uint32_t cpu; unsigned r = 12345678; unsigned i, j; for (i = 0; i < 1000 / GRPC_TEST_SLOWDOWN_FACTOR; i++) { @@ -109,7 +109,7 @@ static void worker_thread(void *arg) { } static void cpu_test(void) { - gpr_uint32 i; + uint32_t i; int cores_seen = 0; struct cpu_test ct; gpr_thd_id thd; diff --git a/test/core/support/murmur_hash_test.c b/test/core/support/murmur_hash_test.c index 1762486776..562b9567e7 100644 --- a/test/core/support/murmur_hash_test.c +++ b/test/core/support/murmur_hash_test.c @@ -38,16 +38,16 @@ #include <string.h> -typedef gpr_uint32 (*hash_func)(const void *key, size_t len, gpr_uint32 seed); +typedef uint32_t (*hash_func)(const void *key, size_t len, uint32_t seed); /* From smhasher: This should hopefully be a thorough and uambiguous test of whether a hash is correctly implemented on a given platform */ -static void verification_test(hash_func hash, gpr_uint32 expected) { - gpr_uint8 key[256]; - gpr_uint32 hashes[256]; - gpr_uint32 final = 0; +static void verification_test(hash_func hash, uint32_t expected) { + uint8_t key[256]; + uint32_t hashes[256]; + uint32_t final = 0; size_t i; memset(key, 0, sizeof(key)); @@ -57,8 +57,8 @@ static void verification_test(hash_func hash, gpr_uint32 expected) { the seed */ for (i = 0; i < 256; i++) { - key[i] = (gpr_uint8)i; - hashes[i] = hash(key, i, (gpr_uint32)(256u - i)); + key[i] = (uint8_t)i; + hashes[i] = hash(key, i, (uint32_t)(256u - i)); } /* Then hash the result array */ diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c index 9e0e22c24b..2df38376a9 100644 --- a/test/core/support/slice_test.c +++ b/test/core/support/slice_test.c @@ -66,7 +66,7 @@ static void test_slice_malloc_returns_something_sensible(void) { } /* We must be able to write to every byte of the data */ for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* And finally we must succeed in destroying the slice */ gpr_slice_unref(slice); @@ -76,7 +76,7 @@ static void test_slice_malloc_returns_something_sensible(void) { static void do_nothing(void *ignored) {} static void test_slice_new_returns_something_sensible(void) { - gpr_uint8 x; + uint8_t x; gpr_slice slice = gpr_slice_new(&x, 1, do_nothing); GPR_ASSERT(slice.refcount); @@ -93,7 +93,7 @@ static void do_nothing_with_len_1(void *ignored, size_t len) { } static void test_slice_new_with_len_returns_something_sensible(void) { - gpr_uint8 x; + uint8_t x; int num_refs = 5; /* To test adding/removing an arbitrary number of refs */ int i; @@ -131,7 +131,7 @@ static void test_slice_sub_works(unsigned length) { beginning of the slice. */ slice = gpr_slice_malloc(length); for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* Ensure that for all subsets length is correct and that we start on the @@ -141,7 +141,7 @@ static void test_slice_sub_works(unsigned length) { sub = gpr_slice_sub(slice, i, j); GPR_ASSERT(GPR_SLICE_LENGTH(sub) == j - i); for (k = 0; k < j - i; k++) { - GPR_ASSERT(GPR_SLICE_START_PTR(sub)[k] == (gpr_uint8)(i + k)); + GPR_ASSERT(GPR_SLICE_START_PTR(sub)[k] == (uint8_t)(i + k)); } gpr_slice_unref(sub); } @@ -170,7 +170,7 @@ static void test_slice_split_head_works(size_t length) { beginning of the slice. */ slice = gpr_slice_malloc(length); for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* Ensure that for all subsets length is correct and that we start on the @@ -198,7 +198,7 @@ static void test_slice_split_tail_works(size_t length) { beginning of the slice. */ slice = gpr_slice_malloc(length); for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* Ensure that for all subsets length is correct and that we start on the diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c index c97d3176c5..c1d0f12250 100644 --- a/test/core/support/string_test.c +++ b/test/core/support/string_test.c @@ -59,7 +59,7 @@ static void test_strdup(void) { GPR_ASSERT(NULL == gpr_strdup(NULL)); } -static void expect_dump(const char *buf, size_t len, gpr_uint32 flags, +static void expect_dump(const char *buf, size_t len, uint32_t flags, const char *result) { char *got = gpr_dump(buf, len, flags); GPR_ASSERT(0 == strcmp(got, result)); @@ -76,7 +76,7 @@ static void test_dump(void) { expect_dump("ab", 2, GPR_DUMP_HEX | GPR_DUMP_ASCII, "61 62 'ab'"); } -static void expect_slice_dump(gpr_slice slice, gpr_uint32 flags, +static void expect_slice_dump(gpr_slice slice, uint32_t flags, const char *result) { char *got = gpr_dump_slice(slice, flags); GPR_ASSERT(0 == strcmp(got, result)); @@ -105,12 +105,12 @@ static void test_dump_slice(void) { } static void test_pu32_fail(const char *s) { - gpr_uint32 out; + uint32_t out; GPR_ASSERT(!gpr_parse_bytes_to_uint32(s, strlen(s), &out)); } -static void test_pu32_succeed(const char *s, gpr_uint32 want) { - gpr_uint32 out; +static void test_pu32_succeed(const char *s, uint32_t want) { + uint32_t out; GPR_ASSERT(gpr_parse_bytes_to_uint32(s, strlen(s), &out)); GPR_ASSERT(out == want); } @@ -318,19 +318,19 @@ static void test_int64toa() { LOG_TEST_NAME("test_int64toa"); /* zero */ - GPR_ASSERT(1 == gpr_int64toa(0, buf)); + GPR_ASSERT(1 == int64_ttoa(0, buf)); GPR_ASSERT(0 == strcmp("0", buf)); /* positive */ - GPR_ASSERT(3 == gpr_int64toa(123, buf)); + GPR_ASSERT(3 == int64_ttoa(123, buf)); GPR_ASSERT(0 == strcmp("123", buf)); /* large positive */ - GPR_ASSERT(19 == gpr_int64toa(9223372036854775807LL, buf)); + GPR_ASSERT(19 == int64_ttoa(9223372036854775807LL, buf)); GPR_ASSERT(0 == strcmp("9223372036854775807", buf)); /* large negative */ - GPR_ASSERT(20 == gpr_int64toa(-9223372036854775807LL - 1, buf)); + GPR_ASSERT(20 == int64_ttoa(-9223372036854775807LL - 1, buf)); GPR_ASSERT(0 == strcmp("-9223372036854775808", buf)); } diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c index 73f68e4dbd..0149bc3afd 100644 --- a/test/core/support/sync_test.c +++ b/test/core/support/sync_test.c @@ -149,8 +149,8 @@ int queue_remove(queue *q, int *head, gpr_timespec abs_deadline) { struct test { int threads; /* number of threads */ - gpr_int64 iterations; /* number of iterations per thread */ - gpr_int64 counter; + int64_t iterations; /* number of iterations per thread */ + int64_t counter; int thread_count; /* used to allocate thread ids */ int done; /* threads not yet completed */ int incr_step; /* how much to increment/decrement refcount each time */ @@ -171,7 +171,7 @@ struct test { }; /* Return pointer to a new struct test. */ -static struct test *test_new(int threads, gpr_int64 iterations, int incr_step) { +static struct test *test_new(int threads, int64_t iterations, int incr_step) { struct test *m = gpr_malloc(sizeof(*m)); m->threads = threads; m->iterations = iterations; @@ -246,7 +246,7 @@ static void mark_thread_done(struct test *m) { */ static void test(const char *name, void (*body)(void *m), void (*extra)(void *m), int timeout_s, int incr_step) { - gpr_int64 iterations = 1024; + int64_t iterations = 1024; struct test *m; gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec time_taken; @@ -279,7 +279,7 @@ static void test(const char *name, void (*body)(void *m), /* Increment m->counter on each iteration; then mark thread as done. */ static void inc(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { gpr_mu_lock(&m->mu); m->counter++; @@ -292,7 +292,7 @@ static void inc(void *v /*=m*/) { then mark thread as done. */ static void inctry(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations;) { if (gpr_mu_trylock(&m->mu)) { m->counter++; @@ -307,7 +307,7 @@ static void inctry(void *v /*=m*/) { thread as done. */ static void inc_by_turns(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; int id = thread_id(m); for (i = 0; i != m->iterations; i++) { gpr_mu_lock(&m->mu); @@ -325,7 +325,7 @@ static void inc_by_turns(void *v /*=m*/) { then mark thread as done. */ static void inc_with_1ms_delay(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { gpr_timespec deadline; gpr_mu_lock(&m->mu); @@ -343,7 +343,7 @@ static void inc_with_1ms_delay(void *v /*=m*/) { for timing; then mark thread as done. */ static void inc_with_1ms_delay_event(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { gpr_timespec deadline; deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), @@ -361,7 +361,7 @@ static void inc_with_1ms_delay_event(void *v /*=m*/) { until it succeeds. */ static void many_producers(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; int x = thread_id(m); if ((x & 1) == 0) { for (i = 0; i != m->iterations; i++) { @@ -381,8 +381,8 @@ static void many_producers(void *v /*=m*/) { then mark thread as done. */ static void consumer(void *v /*=m*/) { struct test *m = v; - gpr_int64 n = m->iterations * m->threads; - gpr_int64 i; + int64_t n = m->iterations * m->threads; + int64_t i; int value; for (i = 0; i != n; i++) { queue_remove(&m->q, &value, gpr_inf_future(GPR_CLOCK_REALTIME)); @@ -401,7 +401,7 @@ static void consumer(void *v /*=m*/) { m->counter, then mark thread as done. */ static void statsinc(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { gpr_stats_inc(&m->stats_counter, 1); } @@ -416,7 +416,7 @@ static void statsinc(void *v /*=m*/) { then mark thread as done. */ static void refinc(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { if (m->incr_step == 1) { gpr_ref(&m->refcount); @@ -435,8 +435,8 @@ static void refinc(void *v /*=m*/) { decrement caused the counter to reach zero, then mark thread as done. */ static void refcheck(void *v /*=m*/) { struct test *m = v; - gpr_int64 n = m->iterations * m->threads * m->incr_step; - gpr_int64 i; + int64_t n = m->iterations * m->threads * m->incr_step; + int64_t i; GPR_ASSERT(gpr_event_wait(&m->event, gpr_inf_future(GPR_CLOCK_REALTIME)) == (void *)1); GPR_ASSERT(gpr_event_get(&m->event) == (void *)1); diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c index b921052e7b..fc26f94d29 100644 --- a/test/core/support/time_test.c +++ b/test/core/support/time_test.c @@ -49,7 +49,7 @@ static void to_fp(void *arg, const char *buf, size_t len) { /* Convert gpr_uintmax x to ascii base b (2..16), and write with (*writer)(arg, ...), zero padding to "chars" digits). */ -static void u_to_s(gpr_uintmax x, unsigned base, int chars, +static void u_to_s(uintmax_t x, unsigned base, int chars, void (*writer)(void *arg, const char *buf, size_t len), void *arg) { char buf[64]; @@ -64,14 +64,14 @@ static void u_to_s(gpr_uintmax x, unsigned base, int chars, /* Convert gpr_intmax x to ascii base b (2..16), and write with (*writer)(arg, ...), zero padding to "chars" digits). */ -static void i_to_s(gpr_intmax x, unsigned base, int chars, +static void i_to_s(intmax_t x, unsigned base, int chars, void (*writer)(void *arg, const char *buf, size_t len), void *arg) { if (x < 0) { (*writer)(arg, "-", 1); - u_to_s((gpr_uintmax)-x, base, chars - 1, writer, arg); + u_to_s((uintmax_t)-x, base, chars - 1, writer, arg); } else { - u_to_s((gpr_uintmax)x, base, chars, writer, arg); + u_to_s((uintmax_t)x, base, chars, writer, arg); } } diff --git a/test/core/support/tls_test.c b/test/core/support/tls_test.c index 0a3c28417f..c6fb1a4a26 100644 --- a/test/core/support/tls_test.c +++ b/test/core/support/tls_test.c @@ -46,7 +46,7 @@ GPR_TLS_DECL(test_var); static void thd_body(void *arg) { - gpr_intptr i; + intptr_t i; GPR_ASSERT(gpr_tls_get(&test_var) == 0); diff --git a/test/core/support/useful_test.c b/test/core/support/useful_test.c index cbf4f02e26..3665bbf972 100644 --- a/test/core/support/useful_test.c +++ b/test/core/support/useful_test.c @@ -39,7 +39,7 @@ int main(int argc, char **argv) { int four[4]; int five[5]; - gpr_uint32 bitset = 0; + uint32_t bitset = 0; grpc_test_init(argc, argv); GPR_ASSERT(GPR_MIN(1, 2) == 1); @@ -51,8 +51,8 @@ int main(int argc, char **argv) { GPR_ASSERT(GPR_CLAMP(2, 0, 2) == 2); GPR_ASSERT(GPR_CLAMP(-1, 0, 2) == 0); GPR_ASSERT(GPR_CLAMP(3, 0, 2) == 2); - GPR_ASSERT(GPR_ROTL((gpr_uint32)0x80000001, 1) == 3); - GPR_ASSERT(GPR_ROTR((gpr_uint32)0x80000001, 1) == 0xc0000000); + GPR_ASSERT(GPR_ROTL((uint32_t)0x80000001, 1) == 3); + GPR_ASSERT(GPR_ROTR((uint32_t)0x80000001, 1) == 0xc0000000); GPR_ASSERT(GPR_ARRAY_SIZE(four) == 4); GPR_ASSERT(GPR_ARRAY_SIZE(five) == 5); |