diff options
Diffstat (limited to 'test')
22 files changed, 157 insertions, 126 deletions
diff --git a/test/core/end2end/multiple_server_queues_test.c b/test/core/end2end/multiple_server_queues_test.c index e291e4e6d3..208d42e6e7 100644 --- a/test/core/end2end/multiple_server_queues_test.c +++ b/test/core/end2end/multiple_server_queues_test.c @@ -49,11 +49,12 @@ int main(int argc, char **argv) { grpc_server_register_completion_queue(server, cq2); grpc_server_start(server); grpc_server_shutdown_and_notify(server, cq2, NULL); - grpc_completion_queue_next(cq2, gpr_inf_future); /* cue queue hang */ + grpc_completion_queue_next( + cq2, gpr_inf_future(GPR_CLOCK_REALTIME)); /* cue queue hang */ grpc_completion_queue_shutdown(cq1); grpc_completion_queue_shutdown(cq2); - grpc_completion_queue_next(cq1, gpr_inf_future); - grpc_completion_queue_next(cq2, gpr_inf_future); + grpc_completion_queue_next(cq1, gpr_inf_future(GPR_CLOCK_REALTIME)); + grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME)); grpc_server_destroy(server); grpc_completion_queue_destroy(cq1); grpc_completion_queue_destroy(cq2); diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index 35b837b7b5..79797f9375 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -85,8 +85,8 @@ int main(int argc, char **argv) { GPR_ASSERT(status == GRPC_STATUS_DEADLINE_EXCEEDED); grpc_completion_queue_shutdown(cq); - while (grpc_completion_queue_next(cq, gpr_inf_future).type != - GRPC_QUEUE_SHUTDOWN) + while (grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME)) + .type != GRPC_QUEUE_SHUTDOWN) ; grpc_completion_queue_destroy(cq); grpc_call_destroy(call); diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 9d716f1135..ea59a9385f 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -129,7 +129,8 @@ static void test_max_message_length(grpc_end2end_test_config config) { cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, f.cq, "/foo", - "foo.test.google.fr:1234", gpr_inf_future); + "foo.test.google.fr:1234", + gpr_inf_future(GPR_CLOCK_REALTIME)); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/fling/client.c b/test/core/fling/client.c index 6741a9dec8..2b19654379 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.c @@ -89,24 +89,26 @@ static void init_ping_pong_request(void) { } static void step_ping_pong_request(void) { - call = grpc_channel_create_call(channel, cq, "/Reflector/reflectUnary", - "localhost", gpr_inf_future); + call = + grpc_channel_create_call(channel, cq, "/Reflector/reflectUnary", + "localhost", gpr_inf_future(GPR_CLOCK_REALTIME)); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, op - ops, (void *)1)); - grpc_completion_queue_next(cq, gpr_inf_future); + grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME)); grpc_call_destroy(call); grpc_byte_buffer_destroy(response_payload_recv); call = NULL; } static void init_ping_pong_stream(void) { - call = grpc_channel_create_call(channel, cq, "/Reflector/reflectStream", - "localhost", gpr_inf_future); + call = + grpc_channel_create_call(channel, cq, "/Reflector/reflectStream", + "localhost", gpr_inf_future(GPR_CLOCK_REALTIME)); stream_init_op.op = GRPC_OP_SEND_INITIAL_METADATA; stream_init_op.data.send_initial_metadata.count = 0; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, &stream_init_op, 1, (void *)1)); - grpc_completion_queue_next(cq, gpr_inf_future); + grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME)); grpc_metadata_array_init(&initial_metadata_recv); @@ -119,7 +121,7 @@ static void init_ping_pong_stream(void) { static void step_ping_pong_stream(void) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, stream_step_ops, 2, (void *)1)); - grpc_completion_queue_next(cq, gpr_inf_future); + grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME)); grpc_byte_buffer_destroy(response_payload_recv); } @@ -208,8 +210,8 @@ int main(int argc, char **argv) { grpc_channel_destroy(channel); grpc_completion_queue_shutdown(cq); - while (grpc_completion_queue_next(cq, gpr_inf_future).type != - GRPC_QUEUE_SHUTDOWN) + while (grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME)) + .type != GRPC_QUEUE_SHUTDOWN) ; grpc_completion_queue_destroy(cq); grpc_byte_buffer_destroy(the_buffer); diff --git a/test/core/iomgr/alarm_heap_test.c b/test/core/iomgr/alarm_heap_test.c index b3e1e64d0f..66b6e4cb64 100644 --- a/test/core/iomgr/alarm_heap_test.c +++ b/test/core/iomgr/alarm_heap_test.c @@ -44,6 +44,7 @@ static gpr_timespec random_deadline(void) { gpr_timespec ts; ts.tv_sec = rand(); ts.tv_nsec = rand(); + ts.clock_type = GPR_CLOCK_REALTIME; return ts; } @@ -101,7 +102,7 @@ static int *all_top(grpc_alarm_heap *pq, int *n) { static void check_pq_top(grpc_alarm *elements, grpc_alarm_heap *pq, gpr_uint8 *inpq, int num_elements) { - gpr_timespec max_deadline = gpr_inf_past; + gpr_timespec max_deadline = gpr_inf_past(GPR_CLOCK_REALTIME); int *max_deadline_indices = gpr_malloc(num_elements * sizeof(int)); int *top_elements; int num_max_deadline_indices = 0; diff --git a/test/core/iomgr/alarm_list_test.c b/test/core/iomgr/alarm_list_test.c index 225c449d4b..2d7cf6c3ec 100644 --- a/test/core/iomgr/alarm_list_test.c +++ b/test/core/iomgr/alarm_list_test.c @@ -107,24 +107,30 @@ static void add_test(void) { grpc_alarm_list_shutdown(); } +static gpr_timespec tfm(int m) { + gpr_timespec t = gpr_time_from_millis(m); + t.clock_type = GPR_CLOCK_REALTIME; + return t; +} + /* Cleaning up a list with pending alarms. */ void destruction_test(void) { grpc_alarm alarms[5]; - grpc_alarm_list_init(gpr_time_0); + grpc_alarm_list_init(gpr_time_0(GPR_CLOCK_REALTIME)); memset(cb_called, 0, sizeof(cb_called)); - grpc_alarm_init(&alarms[0], gpr_time_from_millis(100), cb, - (void *)(gpr_intptr)0, gpr_time_0); - grpc_alarm_init(&alarms[1], gpr_time_from_millis(3), cb, - (void *)(gpr_intptr)1, gpr_time_0); - grpc_alarm_init(&alarms[2], gpr_time_from_millis(100), cb, - (void *)(gpr_intptr)2, gpr_time_0); - grpc_alarm_init(&alarms[3], gpr_time_from_millis(3), cb, - (void *)(gpr_intptr)3, gpr_time_0); - grpc_alarm_init(&alarms[4], gpr_time_from_millis(1), cb, - (void *)(gpr_intptr)4, gpr_time_0); - GPR_ASSERT(1 == grpc_alarm_check(NULL, gpr_time_from_millis(2), NULL)); + grpc_alarm_init(&alarms[0], tfm(100), cb, (void *)(gpr_intptr)0, + gpr_time_0(GPR_CLOCK_REALTIME)); + grpc_alarm_init(&alarms[1], tfm(3), cb, (void *)(gpr_intptr)1, + gpr_time_0(GPR_CLOCK_REALTIME)); + grpc_alarm_init(&alarms[2], tfm(100), cb, (void *)(gpr_intptr)2, + gpr_time_0(GPR_CLOCK_REALTIME)); + grpc_alarm_init(&alarms[3], tfm(3), cb, (void *)(gpr_intptr)3, + gpr_time_0(GPR_CLOCK_REALTIME)); + grpc_alarm_init(&alarms[4], tfm(1), cb, (void *)(gpr_intptr)4, + gpr_time_0(GPR_CLOCK_REALTIME)); + GPR_ASSERT(1 == grpc_alarm_check(NULL, tfm(2), NULL)); GPR_ASSERT(1 == cb_called[4][1]); grpc_alarm_cancel(&alarms[0]); grpc_alarm_cancel(&alarms[3]); diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c index fe08ec495f..cd268661db 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.c @@ -249,7 +249,7 @@ static int server_start(server *sv) { static void server_wait_and_shutdown(server *sv) { gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); while (!sv->done) { - grpc_pollset_work(&g_pollset, gpr_inf_future); + grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); } @@ -356,7 +356,7 @@ static void client_start(client *cl, int port) { static void client_wait_and_shutdown(client *cl) { gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); while (!cl->done) { - grpc_pollset_work(&g_pollset, gpr_inf_future); + grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); } @@ -445,7 +445,7 @@ static void test_grpc_fd_change(void) { /* And now wait for it to run. */ gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); while (a.cb_that_ran == NULL) { - grpc_pollset_work(&g_pollset, gpr_inf_future); + grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_REALTIME)); } GPR_ASSERT(a.cb_that_ran == first_read_callback); gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); @@ -463,7 +463,7 @@ static void test_grpc_fd_change(void) { gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); while (b.cb_that_ran == NULL) { - grpc_pollset_work(&g_pollset, gpr_inf_future); + grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_REALTIME)); } /* Except now we verify that second_read_callback ran instead */ GPR_ASSERT(b.cb_that_ran == second_read_callback); diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c index 710cd725df..36b1d6c939 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.c @@ -95,7 +95,8 @@ void test_succeeds(void) { /* connect to it */ GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)&addr, &addr_len) == 0); grpc_tcp_client_connect(must_succeed, NULL, &g_pollset_set, - (struct sockaddr *)&addr, addr_len, gpr_inf_future); + (struct sockaddr *)&addr, addr_len, + gpr_inf_future(GPR_CLOCK_REALTIME)); /* await the connection */ do { @@ -128,7 +129,8 @@ void test_fails(void) { /* connect to a broken address */ grpc_tcp_client_connect(must_fail, NULL, &g_pollset_set, - (struct sockaddr *)&addr, addr_len, gpr_inf_future); + (struct sockaddr *)&addr, addr_len, + gpr_inf_future(GPR_CLOCK_REALTIME)); gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.c index 767f724b62..e4d422ccc2 100644 --- a/test/core/security/fetch_oauth2.c +++ b/test/core/security/fetch_oauth2.c @@ -181,7 +181,8 @@ int main(int argc, char **argv) { grpc_credentials_get_request_metadata(creds, &sync.pollset, "", on_oauth2_response, &sync); gpr_mu_lock(GRPC_POLLSET_MU(&sync.pollset)); - while (!sync.is_done) grpc_pollset_work(&sync.pollset, gpr_inf_future); + while (!sync.is_done) + grpc_pollset_work(&sync.pollset, gpr_inf_future(GPR_CLOCK_REALTIME)); gpr_mu_unlock(GRPC_POLLSET_MU(&sync.pollset)); grpc_pollset_destroy(&sync.pollset); diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c index b43e0425ee..da57cef15c 100644 --- a/test/core/security/json_token_test.c +++ b/test/core/security/json_token_test.c @@ -269,8 +269,8 @@ static void check_jwt_header(grpc_json *header) { static void check_jwt_claim(grpc_json *claim, const char *expected_audience, const char *expected_scope) { - gpr_timespec expiration = {0, 0}; - gpr_timespec issue_time = {0, 0}; + gpr_timespec expiration = gpr_time_0(GPR_CLOCK_REALTIME); + gpr_timespec issue_time = gpr_time_0(GPR_CLOCK_REALTIME); gpr_timespec parsed_lifetime; grpc_json *iss = NULL; grpc_json *scope = NULL; diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index 46b96d9ecb..98db56c0ef 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -1,35 +1,35 @@ /* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ +* +*Copyright 2015, Google Inc. +*All rights reserved. +* +*Redistribution and use in source and binary forms, with or without +*modification, are permitted provided that the following conditions are +*met: +* +* * Redistributions of source code must retain the above copyright +*notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +*copyright notice, this list of conditions and the following disclaimer +*in the documentation and/or other materials provided with the +*distribution. +* * Neither the name of Google Inc. nor the names of its +*contributors may be used to endorse or promote products derived from +*this software without specific prior written permission. +* +*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +*A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +*OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +*SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +*LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +*DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +*THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +*(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +*OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ #include "src/core/security/jwt_verifier.h" @@ -115,7 +115,7 @@ static const char good_jwk_set[] = " ]" "}"; -static gpr_timespec expected_lifetime = {3600, 0}; +static gpr_timespec expected_lifetime = {3600, 0, GPR_TIMESPAN}; static const char good_google_email_keys_part1[] = "{\"e6b5137873db8d2ef81e06a47289e6434ec8a165\": \"-----BEGIN " @@ -201,9 +201,9 @@ static void test_expired_claims_failure(void) { gpr_slice s = gpr_slice_from_copied_string(expired_claims); grpc_json *json = grpc_json_parse_string_with_len( (char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s)); - gpr_timespec exp_iat = {100, 0}; - gpr_timespec exp_exp = {120, 0}; - gpr_timespec exp_nbf = {60, 0}; + gpr_timespec exp_iat = {100, 0, GPR_CLOCK_REALTIME}; + gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME}; + gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME}; GPR_ASSERT(json != NULL); claims = grpc_jwt_claims_from_json(json, s); GPR_ASSERT(claims != NULL); diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c index 5b55a4da13..0875cfb4fb 100644 --- a/test/core/security/print_google_default_creds_token.c +++ b/test/core/security/print_google_default_creds_token.c @@ -95,7 +95,8 @@ int main(int argc, char **argv) { on_metadata_response, &sync); gpr_mu_lock(GRPC_POLLSET_MU(&sync.pollset)); - while (!sync.is_done) grpc_pollset_work(&sync.pollset, gpr_inf_future); + while (!sync.is_done) + grpc_pollset_work(&sync.pollset, gpr_inf_future(GPR_CLOCK_REALTIME)); gpr_mu_unlock(GRPC_POLLSET_MU(&sync.pollset)); grpc_credentials_release(creds); diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.c index e90be5de98..cb073f19c7 100644 --- a/test/core/security/verify_jwt.c +++ b/test/core/security/verify_jwt.c @@ -109,7 +109,8 @@ int main(int argc, char **argv) { on_jwt_verification_done, &sync); gpr_mu_lock(GRPC_POLLSET_MU(&sync.pollset)); - while (!sync.is_done) grpc_pollset_work(&sync.pollset, gpr_inf_future); + while (!sync.is_done) + grpc_pollset_work(&sync.pollset, gpr_inf_future(GPR_CLOCK_REALTIME)); gpr_mu_unlock(GRPC_POLLSET_MU(&sync.pollset)); grpc_jwt_verifier_destroy(verifier); diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c index a34dcf07c4..0f326d28e2 100644 --- a/test/core/statistics/census_log_tests.c +++ b/test/core/statistics/census_log_tests.c @@ -310,7 +310,7 @@ static void multiple_writers_single_reader(int circular_log) { /* Wait for writers to finish. */ gpr_mu_lock(&writers_mu); while (writers_count != 0) { - gpr_cv_wait(&writers_done, &writers_mu, gpr_inf_future); + gpr_cv_wait(&writers_done, &writers_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_unlock(&writers_mu); gpr_mu_destroy(&writers_mu); @@ -323,7 +323,7 @@ static void multiple_writers_single_reader(int circular_log) { } /* wait for reader to finish */ while (reader.running) { - gpr_cv_wait(&reader_done, &reader_mu, gpr_inf_future); + gpr_cv_wait(&reader_done, &reader_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } if (circular_log) { /* Assert that there were no out-of-space errors. */ diff --git a/test/core/statistics/trace_test.c b/test/core/statistics/trace_test.c index b13fd03f70..187884d90f 100644 --- a/test/core/statistics/trace_test.c +++ b/test/core/statistics/trace_test.c @@ -136,7 +136,7 @@ static void test_concurrency(void) { gpr_mu_lock(&arg.mu); while (arg.num_done < NUM_THREADS) { gpr_log(GPR_INFO, "num done %d", arg.num_done); - gpr_cv_wait(&arg.done, &arg.mu, gpr_inf_future); + gpr_cv_wait(&arg.done, &arg.mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_unlock(&arg.mu); census_tracing_shutdown(); diff --git a/test/core/statistics/window_stats_test.c b/test/core/statistics/window_stats_test.c index 1c66a87407..9e637ccce9 100644 --- a/test/core/statistics/window_stats_test.c +++ b/test/core/statistics/window_stats_test.c @@ -290,8 +290,8 @@ 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(1, &gpr_inf_future, 10, &kMyStatInfo); + 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++) { increment.tv_sec = rand() % 21600; /* 6 hours */ diff --git a/test/core/support/cancellable_test.c b/test/core/support/cancellable_test.c index 2f4b67a785..ca206bd839 100644 --- a/test/core/support/cancellable_test.c +++ b/test/core/support/cancellable_test.c @@ -55,7 +55,8 @@ struct test { static void thd_body(void *v) { struct test *t = v; gpr_mu_lock(&t->mu); - while (!gpr_cv_cancellable_wait(&t->cv, &t->mu, gpr_inf_future, &t->cancel)) { + while (!gpr_cv_cancellable_wait( + &t->cv, &t->mu, gpr_inf_future(GPR_CLOCK_REALTIME), &t->cancel)) { } t->n--; if (t->n == 0) { @@ -125,7 +126,7 @@ static void test(void) { GPR_ASSERT(gpr_cancellable_is_cancelled(&t.cancel)); /* Wait for threads to finish. */ - gpr_event_wait(&t.done, gpr_inf_future); + gpr_event_wait(&t.done, gpr_inf_future(GPR_CLOCK_REALTIME)); GPR_ASSERT(t.n == 0); /* Test timeout on cv wait for cancelled gpr_cancellable */ diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c index 99be5cdc90..73dd06c96f 100644 --- a/test/core/support/sync_test.c +++ b/test/core/support/sync_test.c @@ -81,13 +81,14 @@ void queue_destroy(queue *q) { void queue_append(queue *q, int x) { gpr_mu_lock(&q->mu); /* To wait for a predicate without a deadline, loop on the negation of the - predicate, and use gpr_cv_wait(..., gpr_inf_future) inside the loop + predicate, and use gpr_cv_wait(..., gpr_inf_future(GPR_CLOCK_REALTIME)) + inside the loop to release the lock, wait, and reacquire on each iteration. Code that makes the condition true should use gpr_cv_broadcast() on the corresponding condition variable. The predicate must be on state protected by the lock. */ while (q->length == N) { - gpr_cv_wait(&q->non_full, &q->mu, gpr_inf_future); + gpr_cv_wait(&q->non_full, &q->mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } if (q->length == 0) { /* Wake threads blocked in queue_remove(). */ /* It's normal to use gpr_cv_broadcast() or gpr_signal() while @@ -209,7 +210,7 @@ static void test_create_threads(struct test *m, void (*body)(void *arg)) { static void test_wait(struct test *m) { gpr_mu_lock(&m->mu); while (m->done != 0) { - gpr_cv_wait(&m->done_cv, &m->mu, gpr_inf_future); + gpr_cv_wait(&m->done_cv, &m->mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_unlock(&m->mu); } @@ -306,7 +307,7 @@ static void inc_by_turns(void *v /*=m*/) { for (i = 0; i != m->iterations; i++) { gpr_mu_lock(&m->mu); while ((m->counter % m->threads) != id) { - gpr_cv_wait(&m->cv, &m->mu, gpr_inf_future); + gpr_cv_wait(&m->cv, &m->mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } m->counter++; gpr_cv_broadcast(&m->cv); @@ -379,7 +380,7 @@ static void consumer(void *v /*=m*/) { gpr_int64 i; int value; for (i = 0; i != n; i++) { - queue_remove(&m->q, &value, gpr_inf_future); + queue_remove(&m->q, &value, gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_lock(&m->mu); m->counter = n; @@ -426,7 +427,8 @@ static void refcheck(void *v /*=m*/) { struct test *m = v; gpr_int64 n = m->iterations * m->threads; gpr_int64 i; - GPR_ASSERT(gpr_event_wait(&m->event, gpr_inf_future) == (void *)1); + GPR_ASSERT(gpr_event_wait(&m->event, gpr_inf_future(GPR_CLOCK_REALTIME)) == + (void *)1); GPR_ASSERT(gpr_event_get(&m->event) == (void *)1); for (i = 1; i != n; i++) { GPR_ASSERT(!gpr_unref(&m->refcount)); diff --git a/test/core/support/thd_test.c b/test/core/support/thd_test.c index bb3d54a262..7232cd9f5b 100644 --- a/test/core/support/thd_test.c +++ b/test/core/support/thd_test.c @@ -79,7 +79,7 @@ static void test(void) { } gpr_mu_lock(&t.mu); while (!t.is_done) { - gpr_cv_wait(&t.done_cv, &t.mu, gpr_inf_future); + gpr_cv_wait(&t.done_cv, &t.mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } gpr_mu_unlock(&t.mu); GPR_ASSERT(t.n == 0); diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c index c1dce777b0..29908744ae 100644 --- a/test/core/support/time_test.c +++ b/test/core/support/time_test.c @@ -91,10 +91,10 @@ static void ts_to_s(gpr_timespec t, static void test_values(void) { int i; - gpr_timespec x = gpr_time_0; + gpr_timespec x = gpr_time_0(GPR_CLOCK_REALTIME); GPR_ASSERT(x.tv_sec == 0 && x.tv_nsec == 0); - x = gpr_inf_future; + x = gpr_inf_future(GPR_CLOCK_REALTIME); fprintf(stderr, "far future "); u_to_s(x.tv_sec, 16, 16, &to_fp, stderr); fprintf(stderr, "\n"); @@ -103,7 +103,7 @@ static void test_values(void) { ts_to_s(x, &to_fp, stderr); fprintf(stderr, "\n"); - x = gpr_inf_past; + x = gpr_inf_past(GPR_CLOCK_REALTIME); fprintf(stderr, "far past "); u_to_s(x.tv_sec, 16, 16, &to_fp, stderr); fprintf(stderr, "\n"); @@ -184,51 +184,61 @@ static void test_overflow(void) { gpr_timespec x = gpr_time_from_micros(1); do { x = gpr_time_add(x, x); - } while (gpr_time_cmp(x, gpr_inf_future) < 0); - GPR_ASSERT(gpr_time_cmp(x, gpr_inf_future) == 0); + } while (gpr_time_cmp(x, gpr_inf_future(GPR_TIMESPAN)) < 0); + GPR_ASSERT(gpr_time_cmp(x, gpr_inf_future(GPR_TIMESPAN)) == 0); x = gpr_time_from_micros(-1); do { x = gpr_time_add(x, x); - } while (gpr_time_cmp(x, gpr_inf_past) > 0); - GPR_ASSERT(gpr_time_cmp(x, gpr_inf_past) == 0); + } while (gpr_time_cmp(x, gpr_inf_past(GPR_TIMESPAN)) > 0); + GPR_ASSERT(gpr_time_cmp(x, gpr_inf_past(GPR_TIMESPAN)) == 0); } static void test_sticky_infinities(void) { int i; int j; int k; - static const gpr_timespec *infinity[] = {&gpr_inf_future, &gpr_inf_past}; - static const gpr_timespec *addend[] = {&gpr_inf_future, &gpr_inf_past, - &gpr_time_0, NULL}; + gpr_timespec infinity[2]; + gpr_timespec addend[3]; + infinity[0] = gpr_inf_future(GPR_TIMESPAN); + infinity[1] = gpr_inf_past(GPR_TIMESPAN); + addend[0] = gpr_inf_future(GPR_TIMESPAN); + addend[1] = gpr_inf_past(GPR_TIMESPAN); + addend[2] = gpr_time_0(GPR_TIMESPAN); /* Infinities are sticky */ for (i = 0; i != sizeof(infinity) / sizeof(infinity[0]); i++) { for (j = 0; j != sizeof(addend) / sizeof(addend[0]); j++) { - if (addend[j] == NULL) { - for (k = -200; k <= 200; k++) { - gpr_timespec y = gpr_time_from_micros(k * 100000); - gpr_timespec x = gpr_time_add(*infinity[i], y); - GPR_ASSERT(gpr_time_cmp(x, *infinity[i]) == 0); - x = gpr_time_sub(*infinity[i], y); - GPR_ASSERT(gpr_time_cmp(x, *infinity[i]) == 0); - } - } else { - gpr_timespec x = gpr_time_add(*infinity[i], *addend[j]); - GPR_ASSERT(gpr_time_cmp(x, *infinity[i]) == 0); - x = gpr_time_sub(*infinity[i], *addend[j]); - GPR_ASSERT(gpr_time_cmp(x, *infinity[i]) == 0); - } + gpr_timespec x = gpr_time_add(infinity[i], addend[j]); + GPR_ASSERT(gpr_time_cmp(x, infinity[i]) == 0); + x = gpr_time_sub(infinity[i], addend[j]); + GPR_ASSERT(gpr_time_cmp(x, infinity[i]) == 0); + } + for (k = -200; k <= 200; k++) { + gpr_timespec y = gpr_time_from_micros(k * 100000); + gpr_timespec x = gpr_time_add(infinity[i], y); + GPR_ASSERT(gpr_time_cmp(x, infinity[i]) == 0); + x = gpr_time_sub(infinity[i], y); + GPR_ASSERT(gpr_time_cmp(x, infinity[i]) == 0); } } } static void test_similar(void) { - GPR_ASSERT(1 == gpr_time_similar(gpr_inf_future, gpr_inf_future, gpr_time_0)); - GPR_ASSERT(1 == gpr_time_similar(gpr_inf_past, gpr_inf_past, gpr_time_0)); - GPR_ASSERT(0 == gpr_time_similar(gpr_inf_past, gpr_inf_future, gpr_time_0)); - GPR_ASSERT(0 == gpr_time_similar(gpr_inf_future, gpr_inf_past, gpr_time_0)); + GPR_ASSERT(1 == gpr_time_similar(gpr_inf_future(GPR_TIMESPAN), + gpr_inf_future(GPR_TIMESPAN), + gpr_time_0(GPR_TIMESPAN))); + GPR_ASSERT(1 == gpr_time_similar(gpr_inf_past(GPR_TIMESPAN), + gpr_inf_past(GPR_TIMESPAN), + gpr_time_0(GPR_TIMESPAN))); + GPR_ASSERT(0 == gpr_time_similar(gpr_inf_past(GPR_TIMESPAN), + gpr_inf_future(GPR_TIMESPAN), + gpr_time_0(GPR_TIMESPAN))); + GPR_ASSERT(0 == gpr_time_similar(gpr_inf_future(GPR_TIMESPAN), + gpr_inf_past(GPR_TIMESPAN), + gpr_time_0(GPR_TIMESPAN))); GPR_ASSERT(1 == gpr_time_similar(gpr_time_from_micros(10), - gpr_time_from_micros(10), gpr_time_0)); + gpr_time_from_micros(10), + gpr_time_0(GPR_TIMESPAN))); GPR_ASSERT(1 == gpr_time_similar(gpr_time_from_micros(10), gpr_time_from_micros(15), gpr_time_from_micros(10))); diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index 66136cfe5e..a00e1efb4c 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -52,7 +52,7 @@ static void *create_test_tag(void) { static void shutdown_and_destroy(grpc_completion_queue *cc) { grpc_event ev; grpc_completion_queue_shutdown(cc); - ev = grpc_completion_queue_next(cc, gpr_inf_past); + ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME)); GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(cc); } @@ -86,7 +86,7 @@ static void test_cq_end_op(void) { grpc_cq_begin_op(cc, NULL); grpc_cq_end_op(cc, tag, NULL, 1); - ev = grpc_completion_queue_next(cc, gpr_inf_past); + ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME)); GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); GPR_ASSERT(ev.tag == tag); GPR_ASSERT(ev.success); @@ -100,8 +100,8 @@ static void test_shutdown_then_next_polling(void) { cc = grpc_completion_queue_create(); grpc_completion_queue_shutdown(cc); - GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_past).type == - GRPC_QUEUE_SHUTDOWN); + GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME)) + .type == GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(cc); } @@ -111,8 +111,8 @@ static void test_shutdown_then_next_with_timeout(void) { cc = grpc_completion_queue_create(); grpc_completion_queue_shutdown(cc); - GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_future).type == - GRPC_QUEUE_SHUTDOWN); + GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_future(GPR_CLOCK_REALTIME)) + .type == GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(cc); } @@ -139,7 +139,8 @@ static void test_pluck(void) { } for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - ev = grpc_completion_queue_pluck(cc, tags[i], gpr_inf_past); + ev = grpc_completion_queue_pluck(cc, tags[i], + gpr_inf_past(GPR_CLOCK_REALTIME)); GPR_ASSERT(ev.tag == tags[i]); } @@ -150,7 +151,7 @@ static void test_pluck(void) { for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { ev = grpc_completion_queue_pluck(cc, tags[GPR_ARRAY_SIZE(tags) - i - 1], - gpr_inf_past); + gpr_inf_past(GPR_CLOCK_REALTIME)); GPR_ASSERT(ev.tag == tags[GPR_ARRAY_SIZE(tags) - i - 1]); } diff --git a/test/core/transport/chttp2/timeout_encoding_test.c b/test/core/transport/chttp2/timeout_encoding_test.c index 5bfb9cf0ec..b5ab26768b 100644 --- a/test/core/transport/chttp2/timeout_encoding_test.c +++ b/test/core/transport/chttp2/timeout_encoding_test.c @@ -124,7 +124,8 @@ void test_decoding(void) { decode_suite('S', gpr_time_from_seconds); decode_suite('M', gpr_time_from_minutes); decode_suite('H', gpr_time_from_hours); - assert_decodes_as("1000000000000000000000u", gpr_inf_future); + assert_decodes_as("1000000000000000000000u", + gpr_inf_future(GPR_CLOCK_REALTIME)); } void test_decoding_fails(void) { |