aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
Diffstat (limited to 'test/core')
-rw-r--r--test/core/client_config/uri_parser_test.c1
-rw-r--r--test/core/end2end/cq_verifier.c3
-rw-r--r--test/core/end2end/multiple_server_queues_test.c7
-rw-r--r--test/core/end2end/no_server_test.c4
-rw-r--r--test/core/end2end/tests/max_message_length.c3
-rw-r--r--test/core/fling/client.c22
-rw-r--r--test/core/fling/server.c3
-rw-r--r--test/core/httpcli/httpcli_test.c3
-rw-r--r--test/core/iomgr/alarm_heap_test.c3
-rw-r--r--test/core/iomgr/alarm_list_test.c70
-rw-r--r--test/core/iomgr/alarm_test.c4
-rw-r--r--test/core/iomgr/endpoint_tests.c6
-rw-r--r--test/core/iomgr/fd_posix_test.c8
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c27
-rw-r--r--test/core/iomgr/tcp_server_posix_test.c4
-rw-r--r--test/core/network_benchmarks/low_level_ping_pong.c2
-rw-r--r--test/core/security/json_token_test.c4
-rw-r--r--test/core/security/jwt_verifier_test.c70
-rw-r--r--test/core/security/oauth2_utils.c3
-rw-r--r--test/core/security/print_google_default_creds_token.c3
-rw-r--r--test/core/security/verify_jwt.c3
-rw-r--r--test/core/statistics/census_log_tests.c11
-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/small_log_test.c2
-rw-r--r--test/core/statistics/trace_test.c2
-rw-r--r--test/core/statistics/window_stats_test.c10
-rw-r--r--test/core/support/cancellable_test.c62
-rw-r--r--test/core/support/stack_lockfree_test.c154
-rw-r--r--test/core/support/sync_test.c33
-rw-r--r--test/core/support/thd_test.c2
-rw-r--r--test/core/support/time_test.c126
-rw-r--r--test/core/support/useful_test.c14
-rw-r--r--test/core/surface/completion_queue_test.c48
-rw-r--r--test/core/transport/chttp2/timeout_encoding_test.c71
-rw-r--r--test/core/util/test_config.c38
-rw-r--r--test/core/util/test_config.h16
39 files changed, 569 insertions, 281 deletions
diff --git a/test/core/client_config/uri_parser_test.c b/test/core/client_config/uri_parser_test.c
index e5f9017ce0..3451ca1e8c 100644
--- a/test/core/client_config/uri_parser_test.c
+++ b/test/core/client_config/uri_parser_test.c
@@ -60,6 +60,7 @@ int main(int argc, char **argv) {
test_succeeds("http://www.google.com:90", "http", "www.google.com:90", "");
test_succeeds("a192.4-df:foo.coom", "a192.4-df", "", "foo.coom");
test_succeeds("a+b:foo.coom", "a+b", "", "foo.coom");
+ test_succeeds("zookeeper://127.0.0.1:2181/foo/bar", "zookeeper", "127.0.0.1:2181", "/foo/bar");
test_fails("xyz");
test_fails("http://www.google.com?why-are-you-using-queries");
test_fails("dns:foo.com#fragments-arent-supported-here");
diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c
index 33f7c02b61..81e158e969 100644
--- a/test/core/end2end/cq_verifier.c
+++ b/test/core/end2end/cq_verifier.c
@@ -248,7 +248,8 @@ void cq_verify(cq_verifier *v) {
}
void cq_verify_empty(cq_verifier *v) {
- gpr_timespec deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(1));
+ gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(1, GPR_TIMESPAN));
grpc_event ev;
GPR_ASSERT(v->expect.next == &v->expect && "expectation queue must be empty");
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 ee5e390c39..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,12 +121,12 @@ 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);
}
static double now(void) {
- gpr_timespec tv = gpr_now();
+ gpr_timespec tv = gpr_now(GPR_CLOCK_REALTIME);
return 1e9 * tv.tv_sec + tv.tv_nsec;
}
@@ -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/fling/server.c b/test/core/fling/server.c
index 9542e15ad0..082bbd368a 100644
--- a/test/core/fling/server.c
+++ b/test/core/fling/server.c
@@ -241,7 +241,8 @@ int main(int argc, char **argv) {
shutdown_started = 1;
}
ev = grpc_completion_queue_next(
- cq, gpr_time_add(gpr_now(), gpr_time_from_micros(1000000)));
+ cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)));
s = ev.tag;
switch (ev.type) {
case GRPC_OP_COMPLETE:
diff --git a/test/core/httpcli/httpcli_test.c b/test/core/httpcli/httpcli_test.c
index 6e579bc045..4801eb3e39 100644
--- a/test/core/httpcli/httpcli_test.c
+++ b/test/core/httpcli/httpcli_test.c
@@ -145,7 +145,8 @@ int main(int argc, char **argv) {
gpr_free(args[0]);
gpr_free(args[2]);
- gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5)));
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(5, GPR_TIMESPAN)));
grpc_test_init(argc, argv);
grpc_init();
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 684e3f579a..56d662e61a 100644
--- a/test/core/iomgr/alarm_list_test.c
+++ b/test/core/iomgr/alarm_list_test.c
@@ -51,7 +51,7 @@ static void cb(void *arg, int success) {
}
static void add_test(void) {
- gpr_timespec start = gpr_now();
+ gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
int i;
grpc_alarm alarms[20];
@@ -60,45 +60,51 @@ static void add_test(void) {
/* 10 ms alarms. will expire in the current epoch */
for (i = 0; i < 10; i++) {
- grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(10)),
- cb, (void *)(gpr_intptr) i, start);
+ grpc_alarm_init(&alarms[i],
+ gpr_time_add(start, gpr_time_from_millis(10, GPR_TIMESPAN)),
+ cb, (void *)(gpr_intptr)i, start);
}
/* 1010 ms alarms. will expire in the next epoch */
for (i = 10; i < 20; i++) {
- grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(1010)),
- cb, (void *)(gpr_intptr) i, start);
+ grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(
+ 1010, GPR_TIMESPAN)),
+ cb, (void *)(gpr_intptr)i, start);
}
/* collect alarms. Only the first batch should be ready. */
- GPR_ASSERT(10 ==
- grpc_alarm_check(
- NULL, gpr_time_add(start, gpr_time_from_millis(500)), NULL));
+ GPR_ASSERT(10 == grpc_alarm_check(NULL,
+ gpr_time_add(start, gpr_time_from_millis(
+ 500, GPR_TIMESPAN)),
+ NULL));
for (i = 0; i < 20; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 10));
GPR_ASSERT(cb_called[i][0] == 0);
}
- GPR_ASSERT(0 ==
- grpc_alarm_check(
- NULL, gpr_time_add(start, gpr_time_from_millis(600)), NULL));
+ GPR_ASSERT(0 == grpc_alarm_check(
+ NULL, gpr_time_add(
+ start, gpr_time_from_millis(600, GPR_TIMESPAN)),
+ NULL));
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 10));
GPR_ASSERT(cb_called[i][0] == 0);
}
/* collect the rest of the alarms */
- GPR_ASSERT(10 ==
- grpc_alarm_check(
- NULL, gpr_time_add(start, gpr_time_from_millis(1500)), NULL));
+ GPR_ASSERT(
+ 10 == grpc_alarm_check(NULL, gpr_time_add(start, gpr_time_from_millis(
+ 1500, GPR_TIMESPAN)),
+ NULL));
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
GPR_ASSERT(cb_called[i][0] == 0);
}
- GPR_ASSERT(0 ==
- grpc_alarm_check(
- NULL, gpr_time_add(start, gpr_time_from_millis(1600)), NULL));
+ GPR_ASSERT(0 == grpc_alarm_check(NULL,
+ gpr_time_add(start, gpr_time_from_millis(
+ 1600, GPR_TIMESPAN)),
+ NULL));
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
GPR_ASSERT(cb_called[i][0] == 0);
@@ -107,24 +113,30 @@ static void add_test(void) {
grpc_alarm_list_shutdown();
}
+static gpr_timespec tfm(int m) {
+ gpr_timespec t = gpr_time_from_millis(m, GPR_TIMESPAN);
+ 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/alarm_test.c b/test/core/iomgr/alarm_test.c
index 0ccec435e6..362eb5fe63 100644
--- a/test/core/iomgr/alarm_test.c
+++ b/test/core/iomgr/alarm_test.c
@@ -113,7 +113,7 @@ static void test_grpc_alarm(void) {
gpr_event_init(&arg.fcb_arg);
grpc_alarm_init(&alarm, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100), alarm_cb, &arg,
- gpr_now());
+ gpr_now(GPR_CLOCK_REALTIME));
alarm_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1);
gpr_mu_lock(&arg.mu);
@@ -165,7 +165,7 @@ static void test_grpc_alarm(void) {
gpr_event_init(&arg2.fcb_arg);
grpc_alarm_init(&alarm_to_cancel, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100),
- alarm_cb, &arg2, gpr_now());
+ alarm_cb, &arg2, gpr_now(GPR_CLOCK_REALTIME));
grpc_alarm_cancel(&alarm_to_cancel);
alarm_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1);
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c
index 8198c24752..0cfba5fac8 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.c
@@ -254,7 +254,7 @@ static void read_and_write_test(grpc_endpoint_test_config config,
gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
while (!state.read_done || !state.write_done) {
- GPR_ASSERT(gpr_time_cmp(gpr_now(), deadline) < 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0);
grpc_pollset_work(g_pollset, deadline);
}
gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
@@ -350,14 +350,14 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config,
deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10);
gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
while (!write_st.done) {
- GPR_ASSERT(gpr_time_cmp(gpr_now(), deadline) < 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0);
grpc_pollset_work(g_pollset, deadline);
}
gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
grpc_endpoint_destroy(write_st.ep);
gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
while (!read_st.done) {
- GPR_ASSERT(gpr_time_cmp(gpr_now(), deadline) < 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0);
grpc_pollset_work(g_pollset, deadline);
}
gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
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 b673c032b2..637886a738 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -79,6 +79,8 @@ void test_succeeds(void) {
int r;
int connections_complete_before;
+ gpr_log(GPR_DEBUG, "test_succeeds");
+
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
@@ -95,7 +97,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 {
@@ -119,6 +122,8 @@ void test_fails(void) {
socklen_t addr_len = sizeof(addr);
int connections_complete_before;
+ gpr_log(GPR_DEBUG, "test_fails");
+
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
@@ -128,7 +133,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));
@@ -144,13 +150,15 @@ void test_times_out(void) {
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
int svr_fd;
-#define NUM_CLIENT_CONNECTS 10
+#define NUM_CLIENT_CONNECTS 100
int client_fd[NUM_CLIENT_CONNECTS];
int i;
int r;
int connections_complete_before;
gpr_timespec connect_deadline;
+ gpr_log(GPR_DEBUG, "test_times_out");
+
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
@@ -186,12 +194,15 @@ void test_times_out(void) {
/* Make sure the event doesn't trigger early */
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
- while (gpr_time_cmp(gpr_time_add(connect_deadline, gpr_time_from_seconds(2)),
- gpr_now()) > 0) {
- int is_after_deadline = gpr_time_cmp(connect_deadline, gpr_now()) <= 0;
+ while (gpr_time_cmp(gpr_time_add(connect_deadline,
+ gpr_time_from_seconds(2, GPR_TIMESPAN)),
+ gpr_now(GPR_CLOCK_REALTIME)) > 0) {
+ int is_after_deadline =
+ gpr_time_cmp(connect_deadline, gpr_now(GPR_CLOCK_REALTIME)) <= 0;
if (is_after_deadline &&
- gpr_time_cmp(gpr_time_add(connect_deadline, gpr_time_from_seconds(1)),
- gpr_now()) > 0) {
+ gpr_time_cmp(gpr_time_add(connect_deadline,
+ gpr_time_from_seconds(1, GPR_TIMESPAN)),
+ gpr_now(GPR_CLOCK_REALTIME)) > 0) {
/* allow some slack before insisting that things be done */
} else {
GPR_ASSERT(g_connections_complete ==
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c
index fb262711c0..83252a889b 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.c
@@ -125,7 +125,7 @@ static void test_connect(int n) {
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
for (i = 0; i < n; i++) {
- deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(4000);
+ deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10);
nconnects_before = g_nconnects;
clifd = socket(addr.ss_family, SOCK_STREAM, 0);
@@ -135,7 +135,7 @@ static void test_connect(int n) {
gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before &&
- gpr_time_cmp(deadline, gpr_now()) > 0) {
+ gpr_time_cmp(deadline, gpr_now(GPR_CLOCK_REALTIME)) > 0) {
grpc_pollset_work(&g_pollset, deadline);
}
gpr_log(GPR_DEBUG, "wait done");
diff --git a/test/core/network_benchmarks/low_level_ping_pong.c b/test/core/network_benchmarks/low_level_ping_pong.c
index 78a0eef1a2..0ce4bd4b25 100644
--- a/test/core/network_benchmarks/low_level_ping_pong.c
+++ b/test/core/network_benchmarks/low_level_ping_pong.c
@@ -296,7 +296,7 @@ static void print_histogram(gpr_histogram *histogram) {
}
static double now(void) {
- gpr_timespec tv = gpr_now();
+ gpr_timespec tv = gpr_now(GPR_CLOCK_REALTIME);
return 1e9 * tv.tv_sec + tv.tv_nsec;
}
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/oauth2_utils.c b/test/core/security/oauth2_utils.c
index 3e4285256a..ecd04fd9e1 100644
--- a/test/core/security/oauth2_utils.c
+++ b/test/core/security/oauth2_utils.c
@@ -83,7 +83,8 @@ char *grpc_test_fetch_oauth2_token_with_credentials(grpc_credentials *creds) {
on_oauth2_response, &request);
gpr_mu_lock(GRPC_POLLSET_MU(&request.pollset));
- while (!request.is_done) grpc_pollset_work(&request.pollset, gpr_inf_future);
+ while (!request.is_done)
+ grpc_pollset_work(&request.pollset, gpr_inf_future(GPR_CLOCK_REALTIME));
gpr_mu_unlock(GRPC_POLLSET_MU(&request.pollset));
grpc_pollset_shutdown(&request.pollset, do_nothing, 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 241ec1ce4f..3292f8a64d 100644
--- a/test/core/statistics/census_log_tests.c
+++ b/test/core/statistics/census_log_tests.c
@@ -237,7 +237,8 @@ static void reader_thread(void* arg) {
gpr_timespec interval;
int counter = 0;
printf(" Reader starting\n");
- interval = gpr_time_from_micros(args->read_iteration_interval_in_msec * 1000);
+ interval = gpr_time_from_micros(args->read_iteration_interval_in_msec * 1000,
+ GPR_TIMESPAN);
gpr_mu_lock(args->mu);
while (!args->stop_flag && records_read < args->total_records) {
gpr_cv_wait(&args->stop, args->mu, interval);
@@ -310,7 +311,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 +324,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. */
@@ -568,7 +569,7 @@ void test_performance(void) {
double write_time_micro = 0.0;
int nrecords = 0;
setup_test(0);
- start_time = gpr_now();
+ start_time = gpr_now(GPR_CLOCK_REALTIME);
while (1) {
void* record = census_log_start_write(write_size);
if (record == NULL) {
@@ -577,7 +578,7 @@ void test_performance(void) {
census_log_end_write(record, write_size);
nrecords++;
}
- write_time = gpr_time_sub(gpr_now(), start_time);
+ write_time = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start_time);
write_time_micro = write_time.tv_sec * 1000000 + write_time.tv_nsec / 1000;
census_log_shutdown();
printf(
diff --git a/test/core/statistics/multiple_writers_circular_buffer_test.c b/test/core/statistics/multiple_writers_circular_buffer_test.c
index a645e15918..56ada893ef 100644
--- a/test/core/statistics/multiple_writers_circular_buffer_test.c
+++ b/test/core/statistics/multiple_writers_circular_buffer_test.c
@@ -40,7 +40,7 @@
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
- srand(gpr_now().tv_nsec);
+ srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_multiple_writers_circular_log();
return 0;
}
diff --git a/test/core/statistics/multiple_writers_test.c b/test/core/statistics/multiple_writers_test.c
index 84aef15c1a..e524927da6 100644
--- a/test/core/statistics/multiple_writers_test.c
+++ b/test/core/statistics/multiple_writers_test.c
@@ -40,7 +40,7 @@
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
- srand(gpr_now().tv_nsec);
+ srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_multiple_writers();
return 0;
}
diff --git a/test/core/statistics/performance_test.c b/test/core/statistics/performance_test.c
index 3c1e28241e..3f0e080093 100644
--- a/test/core/statistics/performance_test.c
+++ b/test/core/statistics/performance_test.c
@@ -40,7 +40,7 @@
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
- srand(gpr_now().tv_nsec);
+ srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_performance();
return 0;
}
diff --git a/test/core/statistics/quick_test.c b/test/core/statistics/quick_test.c
index 0e432314bb..c72ae77b98 100644
--- a/test/core/statistics/quick_test.c
+++ b/test/core/statistics/quick_test.c
@@ -40,7 +40,7 @@
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
- srand(gpr_now().tv_nsec);
+ srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_invalid_record_size();
test_end_write_with_different_size();
test_read_pending_record();
diff --git a/test/core/statistics/small_log_test.c b/test/core/statistics/small_log_test.c
index c151b77f63..b26b95f639 100644
--- a/test/core/statistics/small_log_test.c
+++ b/test/core/statistics/small_log_test.c
@@ -40,7 +40,7 @@
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
- srand(gpr_now().tv_nsec);
+ srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
test_small_log();
return 0;
}
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 d893f7f792..9e637ccce9 100644
--- a/test/core/statistics/window_stats_test.c
+++ b/test/core/statistics/window_stats_test.c
@@ -83,7 +83,7 @@ void empty_test(void) {
result.statistic = &sum;
census_window_stats_get_sums(stats, zero, &result);
GPR_ASSERT(result.count == 0 && sum.value1 == 0 && sum.value2 == 0);
- census_window_stats_get_sums(stats, gpr_now(), &result);
+ census_window_stats_get_sums(stats, gpr_now(GPR_CLOCK_REALTIME), &result);
GPR_ASSERT(result.count == 0 && sum.value1 == 0 && sum.value2 == 0);
census_window_stats_destroy(stats);
}
@@ -268,7 +268,7 @@ void rolling_time_test(void) {
struct census_window_stats* stats =
census_window_stats_create(1, &kMinInterval, 7, &kMyStatInfo);
GPR_ASSERT(stats != NULL);
- srand(gpr_now().tv_nsec);
+ srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
for (i = 0; i < 100000; i++) {
increment.tv_nsec = rand() % 100000000; /* up to 1/10th second */
when = gpr_time_add(when, increment);
@@ -290,9 +290,9 @@ 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);
- srand(gpr_now().tv_nsec);
+ 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 */
when = gpr_time_add(when, increment);
diff --git a/test/core/support/cancellable_test.c b/test/core/support/cancellable_test.c
index b2db1afc76..9b321d388e 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) {
@@ -81,24 +82,30 @@ static void test(void) {
GPR_ASSERT(!gpr_cancellable_is_cancelled(&t.cancel));
/* Test timeout on event wait for uncancelled gpr_cancellable */
- interval = gpr_now();
+ interval = gpr_now(GPR_CLOCK_REALTIME);
gpr_event_cancellable_wait(
- &t.ev, gpr_time_add(gpr_now(), gpr_time_from_micros(1000000)), &t.cancel);
- interval = gpr_time_sub(gpr_now(), interval);
- GPR_ASSERT(gpr_time_cmp(interval, gpr_time_from_micros(500000)) >= 0);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_micros(2000000), interval) >= 0);
+ &t.ev, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)),
+ &t.cancel);
+ interval = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), interval);
+ GPR_ASSERT(
+ gpr_time_cmp(interval, gpr_time_from_micros(500000, GPR_TIMESPAN)) >= 0);
+ GPR_ASSERT(
+ gpr_time_cmp(gpr_time_from_micros(2000000, GPR_TIMESPAN), interval) >= 0);
/* Test timeout on cv wait for uncancelled gpr_cancellable */
gpr_mu_lock(&t.mu);
- interval = gpr_now();
+ interval = gpr_now(GPR_CLOCK_REALTIME);
while (!gpr_cv_cancellable_wait(
- &t.cv, &t.mu,
- gpr_time_add(gpr_now(), gpr_time_from_micros(1000000)),
- &t.cancel)) {
+ &t.cv, &t.mu, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)),
+ &t.cancel)) {
}
- interval = gpr_time_sub(gpr_now(), interval);
- GPR_ASSERT(gpr_time_cmp(interval, gpr_time_from_micros(500000)) >= 0);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_micros(2000000), interval) >= 0);
+ interval = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), interval);
+ GPR_ASSERT(
+ gpr_time_cmp(interval, gpr_time_from_micros(500000, GPR_TIMESPAN)) >= 0);
+ GPR_ASSERT(
+ gpr_time_cmp(gpr_time_from_micros(2000000, GPR_TIMESPAN), interval) >= 0);
gpr_mu_unlock(&t.mu);
/* Create some threads. They all wait until cancelled; the last to finish
@@ -113,7 +120,8 @@ static void test(void) {
/* Wait a second, and check that no threads have finished waiting. */
gpr_mu_lock(&t.mu);
gpr_cv_wait(&t.cv, &t.mu,
- gpr_time_add(gpr_now(), gpr_time_from_micros(1000000)));
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)));
GPR_ASSERT(t.n == n);
gpr_mu_unlock(&t.mu);
@@ -124,27 +132,31 @@ 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 */
gpr_mu_lock(&t.mu);
- interval = gpr_now();
+ interval = gpr_now(GPR_CLOCK_REALTIME);
while (!gpr_cv_cancellable_wait(
- &t.cv, &t.mu,
- gpr_time_add(gpr_now(), gpr_time_from_micros(1000000)),
- &t.cancel)) {
+ &t.cv, &t.mu, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)),
+ &t.cancel)) {
}
- interval = gpr_time_sub(gpr_now(), interval);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_micros(100000), interval) >= 0);
+ interval = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), interval);
+ GPR_ASSERT(
+ gpr_time_cmp(gpr_time_from_micros(100000, GPR_TIMESPAN), interval) >= 0);
gpr_mu_unlock(&t.mu);
/* Test timeout on event wait for cancelled gpr_cancellable */
- interval = gpr_now();
+ interval = gpr_now(GPR_CLOCK_REALTIME);
gpr_event_cancellable_wait(
- &t.ev, gpr_time_add(gpr_now(), gpr_time_from_micros(1000000)), &t.cancel);
- interval = gpr_time_sub(gpr_now(), interval);
- GPR_ASSERT(gpr_time_cmp(gpr_time_from_micros(100000), interval) >= 0);
+ &t.ev, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN)),
+ &t.cancel);
+ interval = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), interval);
+ GPR_ASSERT(
+ gpr_time_cmp(gpr_time_from_micros(100000, GPR_TIMESPAN), interval) >= 0);
gpr_mu_destroy(&t.mu);
gpr_cv_destroy(&t.cv);
diff --git a/test/core/support/stack_lockfree_test.c b/test/core/support/stack_lockfree_test.c
new file mode 100644
index 0000000000..02ec3154d5
--- /dev/null
+++ b/test/core/support/stack_lockfree_test.c
@@ -0,0 +1,154 @@
+/*
+ *
+ * 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/support/stack_lockfree.h"
+
+#include <stdlib.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include "test/core/util/test_config.h"
+
+/* max stack size supported */
+#define MAX_STACK_SIZE 65534
+
+#define MAX_THREADS 32
+
+static void test_serial_sized(int size) {
+ gpr_stack_lockfree *stack = gpr_stack_lockfree_create(size);
+ int i;
+
+ /* First try popping empty */
+ GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
+
+ /* Now add one item and check it */
+ gpr_stack_lockfree_push(stack, 3);
+ GPR_ASSERT(gpr_stack_lockfree_pop(stack) == 3);
+ GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
+
+ /* Now add repeatedly more items and check them */
+ for (i = 1; i < size; i *= 2) {
+ int j;
+ for (j = 0; j <= i; j++) {
+ GPR_ASSERT(gpr_stack_lockfree_push(stack, j) == (j == 0));
+ }
+ for (j = 0; j <= i; j++) {
+ GPR_ASSERT(gpr_stack_lockfree_pop(stack) == i - j);
+ }
+ GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
+ }
+
+ gpr_stack_lockfree_destroy(stack);
+}
+
+static void test_serial() {
+ int i;
+ for (i = 128; i < MAX_STACK_SIZE; i *= 2) {
+ test_serial_sized(i);
+ }
+ test_serial_sized(MAX_STACK_SIZE);
+}
+
+struct test_arg {
+ gpr_stack_lockfree *stack;
+ int stack_size;
+ int nthreads;
+ int rank;
+ int sum;
+};
+
+static void test_mt_body(void *v) {
+ struct test_arg *arg = (struct test_arg *)v;
+ int lo, hi;
+ int i;
+ int res;
+ lo = arg->rank * arg->stack_size / arg->nthreads;
+ hi = (arg->rank + 1) * arg->stack_size / arg->nthreads;
+ for (i = lo; i < hi; i++) {
+ gpr_stack_lockfree_push(arg->stack, i);
+ if ((res = gpr_stack_lockfree_pop(arg->stack)) != -1) {
+ arg->sum += res;
+ }
+ }
+ while ((res = gpr_stack_lockfree_pop(arg->stack)) != -1) {
+ arg->sum += res;
+ }
+}
+
+static void test_mt_sized(int size, int nth) {
+ gpr_stack_lockfree *stack;
+ struct test_arg args[MAX_THREADS];
+ gpr_thd_id thds[MAX_THREADS];
+ int sum;
+ int i;
+ gpr_thd_options options = gpr_thd_options_default();
+
+ stack = gpr_stack_lockfree_create(size);
+ for (i = 0; i < nth; i++) {
+ args[i].stack = stack;
+ args[i].stack_size = size;
+ args[i].nthreads = nth;
+ args[i].rank = i;
+ args[i].sum = 0;
+ }
+ gpr_thd_options_set_joinable(&options);
+ for (i = 0; i < nth; i++) {
+ GPR_ASSERT(gpr_thd_new(&thds[i], test_mt_body, &args[i], &options));
+ }
+ sum = 0;
+ for (i = 0; i < nth; i++) {
+ gpr_thd_join(thds[i]);
+ sum = sum + args[i].sum;
+ }
+ GPR_ASSERT((unsigned)sum == ((unsigned)size * (size - 1)) / 2);
+ gpr_stack_lockfree_destroy(stack);
+}
+
+static void test_mt() {
+ int size, nth;
+ for (nth = 1; nth < MAX_THREADS; nth++) {
+ for (size = 128; size < MAX_STACK_SIZE; size *= 2) {
+ test_mt_sized(size, nth);
+ }
+ test_mt_sized(MAX_STACK_SIZE, nth);
+ }
+}
+
+int main(int argc, char **argv) {
+ grpc_test_init(argc, argv);
+ test_serial();
+ test_mt();
+ return 0;
+}
diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c
index 44bc6ba471..f729eb0b92 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);
}
@@ -242,12 +243,12 @@ static void test(const char *name, void (*body)(void *m),
void (*extra)(void *m), int timeout_s) {
gpr_int64 iterations = 1024;
struct test *m;
- gpr_timespec start = gpr_now();
+ gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
gpr_timespec time_taken;
- gpr_timespec deadline =
- gpr_time_add(start, gpr_time_from_micros(timeout_s * 1000000));
+ gpr_timespec deadline = gpr_time_add(
+ start, gpr_time_from_micros(timeout_s * 1000000, GPR_TIMESPAN));
fprintf(stderr, "%s:", name);
- while (gpr_time_cmp(gpr_now(), deadline) < 0) {
+ while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
iterations <<= 1;
fprintf(stderr, " %ld", (long)iterations);
m = test_new(10, iterations);
@@ -265,7 +266,7 @@ static void test(const char *name, void (*body)(void *m),
}
test_destroy(m);
}
- time_taken = gpr_time_sub(gpr_now(), start);
+ time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
fprintf(stderr, " done %ld.%09d s\n", (long)time_taken.tv_sec,
(int)time_taken.tv_nsec);
}
@@ -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);
@@ -323,7 +324,8 @@ static void inc_with_1ms_delay(void *v /*=m*/) {
for (i = 0; i != m->iterations; i++) {
gpr_timespec deadline;
gpr_mu_lock(&m->mu);
- deadline = gpr_time_add(gpr_now(), gpr_time_from_micros(1000));
+ deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000, GPR_TIMESPAN));
while (!gpr_cv_wait(&m->cv, &m->mu, deadline)) {
}
m->counter++;
@@ -339,7 +341,8 @@ static void inc_with_1ms_delay_event(void *v /*=m*/) {
gpr_int64 i;
for (i = 0; i != m->iterations; i++) {
gpr_timespec deadline;
- deadline = gpr_time_add(gpr_now(), gpr_time_from_micros(1000));
+ deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000, GPR_TIMESPAN));
GPR_ASSERT(gpr_event_wait(&m->event, deadline) == NULL);
gpr_mu_lock(&m->mu);
m->counter++;
@@ -377,14 +380,15 @@ 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;
gpr_mu_unlock(&m->mu);
GPR_ASSERT(
!queue_remove(&m->q, &value,
- gpr_time_add(gpr_now(), gpr_time_from_micros(1000000))));
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(1000000, GPR_TIMESPAN))));
mark_thread_done(m);
}
@@ -424,7 +428,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..594863c278 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");
@@ -113,37 +113,37 @@ static void test_values(void) {
fprintf(stderr, "\n");
for (i = 1; i != 1000 * 1000 * 1000; i *= 10) {
- x = gpr_time_from_micros(i);
+ x = gpr_time_from_micros(i, GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec == i / GPR_US_PER_SEC &&
x.tv_nsec == (i % GPR_US_PER_SEC) * GPR_NS_PER_US);
- x = gpr_time_from_nanos(i);
+ x = gpr_time_from_nanos(i, GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec == i / GPR_NS_PER_SEC &&
x.tv_nsec == (i % GPR_NS_PER_SEC));
- x = gpr_time_from_millis(i);
+ x = gpr_time_from_millis(i, GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec == i / GPR_MS_PER_SEC &&
x.tv_nsec == (i % GPR_MS_PER_SEC) * GPR_NS_PER_MS);
}
/* Test possible overflow in conversion of -ve values. */
- x = gpr_time_from_micros(-(LONG_MAX - 999997));
+ x = gpr_time_from_micros(-(LONG_MAX - 999997), GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec < 0);
GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC);
- x = gpr_time_from_nanos(-(LONG_MAX - 999999997));
+ x = gpr_time_from_nanos(-(LONG_MAX - 999999997), GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec < 0);
GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC);
- x = gpr_time_from_millis(-(LONG_MAX - 997));
+ x = gpr_time_from_millis(-(LONG_MAX - 997), GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec < 0);
GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC);
/* Test general -ve values. */
for (i = -1; i > -1000 * 1000 * 1000; i *= 7) {
- x = gpr_time_from_micros(i);
+ x = gpr_time_from_micros(i, GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec * GPR_US_PER_SEC + x.tv_nsec / GPR_NS_PER_US == i);
- x = gpr_time_from_nanos(i);
+ x = gpr_time_from_nanos(i, GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec * GPR_NS_PER_SEC + x.tv_nsec == i);
- x = gpr_time_from_millis(i);
+ x = gpr_time_from_millis(i, GPR_TIMESPAN);
GPR_ASSERT(x.tv_sec * GPR_MS_PER_SEC + x.tv_nsec / GPR_NS_PER_MS == i);
}
}
@@ -158,17 +158,19 @@ static void test_add_sub(void) {
for (k = 1; k <= 10000000; k *= 10) {
int sum = i + j;
int diff = i - j;
- gpr_timespec it = gpr_time_from_micros(i * k);
- gpr_timespec jt = gpr_time_from_micros(j * k);
+ gpr_timespec it = gpr_time_from_micros(i * k, GPR_TIMESPAN);
+ gpr_timespec jt = gpr_time_from_micros(j * k, GPR_TIMESPAN);
gpr_timespec sumt = gpr_time_add(it, jt);
gpr_timespec difft = gpr_time_sub(it, jt);
- if (gpr_time_cmp(gpr_time_from_micros(sum * k), sumt) != 0) {
+ if (gpr_time_cmp(gpr_time_from_micros(sum * k, GPR_TIMESPAN), sumt) !=
+ 0) {
fprintf(stderr, "i %d j %d sum %d sumt ", i, j, sum);
ts_to_s(sumt, &to_fp, stderr);
fprintf(stderr, "\n");
GPR_ASSERT(0);
}
- if (gpr_time_cmp(gpr_time_from_micros(diff * k), difft) != 0) {
+ if (gpr_time_cmp(gpr_time_from_micros(diff * k, GPR_TIMESPAN), difft) !=
+ 0) {
fprintf(stderr, "i %d j %d diff %d diff ", i, j, diff);
ts_to_s(sumt, &to_fp, stderr);
fprintf(stderr, "\n");
@@ -181,66 +183,76 @@ static void test_add_sub(void) {
static void test_overflow(void) {
/* overflow */
- gpr_timespec x = gpr_time_from_micros(1);
+ gpr_timespec x = gpr_time_from_micros(1, GPR_TIMESPAN);
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);
- x = gpr_time_from_micros(-1);
+ } 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, GPR_TIMESPAN);
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_TIMESPAN);
+ 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_time_from_micros(10),
- gpr_time_from_micros(10), gpr_time_0));
- GPR_ASSERT(1 == gpr_time_similar(gpr_time_from_micros(10),
- gpr_time_from_micros(15),
- gpr_time_from_micros(10)));
- GPR_ASSERT(1 == gpr_time_similar(gpr_time_from_micros(15),
- gpr_time_from_micros(10),
- gpr_time_from_micros(10)));
- GPR_ASSERT(0 == gpr_time_similar(gpr_time_from_micros(10),
- gpr_time_from_micros(25),
- gpr_time_from_micros(10)));
- GPR_ASSERT(0 == gpr_time_similar(gpr_time_from_micros(25),
- gpr_time_from_micros(10),
- gpr_time_from_micros(10)));
+ 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_TIMESPAN),
+ gpr_time_from_micros(10, GPR_TIMESPAN),
+ gpr_time_0(GPR_TIMESPAN)));
+ GPR_ASSERT(1 == gpr_time_similar(gpr_time_from_micros(10, GPR_TIMESPAN),
+ gpr_time_from_micros(15, GPR_TIMESPAN),
+ gpr_time_from_micros(10, GPR_TIMESPAN)));
+ GPR_ASSERT(1 == gpr_time_similar(gpr_time_from_micros(15, GPR_TIMESPAN),
+ gpr_time_from_micros(10, GPR_TIMESPAN),
+ gpr_time_from_micros(10, GPR_TIMESPAN)));
+ GPR_ASSERT(0 == gpr_time_similar(gpr_time_from_micros(10, GPR_TIMESPAN),
+ gpr_time_from_micros(25, GPR_TIMESPAN),
+ gpr_time_from_micros(10, GPR_TIMESPAN)));
+ GPR_ASSERT(0 == gpr_time_similar(gpr_time_from_micros(25, GPR_TIMESPAN),
+ gpr_time_from_micros(10, GPR_TIMESPAN),
+ gpr_time_from_micros(10, GPR_TIMESPAN)));
}
int main(int argc, char *argv[]) {
diff --git a/test/core/support/useful_test.c b/test/core/support/useful_test.c
index feaf436379..cbf4f02e26 100644
--- a/test/core/support/useful_test.c
+++ b/test/core/support/useful_test.c
@@ -39,6 +39,7 @@
int main(int argc, char **argv) {
int four[4];
int five[5];
+ gpr_uint32 bitset = 0;
grpc_test_init(argc, argv);
GPR_ASSERT(GPR_MIN(1, 2) == 1);
@@ -55,5 +56,18 @@ int main(int argc, char **argv) {
GPR_ASSERT(GPR_ARRAY_SIZE(four) == 4);
GPR_ASSERT(GPR_ARRAY_SIZE(five) == 5);
+ GPR_ASSERT(GPR_BITCOUNT((1u << 31) - 1) == 31);
+ GPR_ASSERT(GPR_BITCOUNT(1u << 3) == 1);
+ GPR_ASSERT(GPR_BITCOUNT(0) == 0);
+
+ GPR_ASSERT(GPR_BITSET(&bitset, 3) == 8);
+ GPR_ASSERT(GPR_BITCOUNT(bitset) == 1);
+ GPR_ASSERT(GPR_BITGET(bitset, 3) == 1);
+ GPR_ASSERT(GPR_BITSET(&bitset, 1) == 10);
+ GPR_ASSERT(GPR_BITCOUNT(bitset) == 2);
+ GPR_ASSERT(GPR_BITCLEAR(&bitset, 3) == 2);
+ GPR_ASSERT(GPR_BITCOUNT(bitset) == 1);
+ GPR_ASSERT(GPR_BITGET(bitset, 3) == 0);
+
return 0;
}
diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c
index eba24f5c6e..0e59ea4b22 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);
}
@@ -69,24 +69,27 @@ static void test_wait_empty(void) {
LOG_TEST("test_wait_empty");
cc = grpc_completion_queue_create();
- GPR_ASSERT(grpc_completion_queue_next(cc, gpr_now()).type ==
+ GPR_ASSERT(grpc_completion_queue_next(cc, gpr_now(GPR_CLOCK_REALTIME)).type ==
GRPC_QUEUE_TIMEOUT);
shutdown_and_destroy(cc);
}
+static void do_nothing_end_completion(void *arg, grpc_cq_completion *c) {}
+
static void test_cq_end_op(void) {
grpc_event ev;
grpc_completion_queue *cc;
+ grpc_cq_completion completion;
void *tag = create_test_tag();
LOG_TEST("test_cq_end_op");
cc = grpc_completion_queue_create();
- grpc_cq_begin_op(cc, NULL);
- grpc_cq_end_op(cc, tag, NULL, 1);
+ grpc_cq_begin_op(cc);
+ grpc_cq_end_op(cc, tag, 1, do_nothing_end_completion, NULL, &completion);
- 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 +103,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 +114,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);
}
@@ -120,6 +123,7 @@ static void test_pluck(void) {
grpc_event ev;
grpc_completion_queue *cc;
void *tags[128];
+ grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)];
unsigned i, j;
LOG_TEST("test_pluck");
@@ -134,23 +138,26 @@ static void test_pluck(void) {
cc = grpc_completion_queue_create();
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
- grpc_cq_begin_op(cc, NULL);
- grpc_cq_end_op(cc, tags[i], NULL, 1);
+ grpc_cq_begin_op(cc);
+ grpc_cq_end_op(cc, tags[i], 1, do_nothing_end_completion, NULL,
+ &completions[i]);
}
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]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
- grpc_cq_begin_op(cc, NULL);
- grpc_cq_end_op(cc, tags[i], NULL, 1);
+ grpc_cq_begin_op(cc);
+ grpc_cq_end_op(cc, tags[i], 1, do_nothing_end_completion, NULL,
+ &completions[i]);
}
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]);
}
@@ -171,7 +178,11 @@ typedef struct test_thread_options {
} test_thread_options;
gpr_timespec ten_seconds_time(void) {
- return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1);
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10);
+}
+
+static void free_completion(void *arg, grpc_cq_completion *completion) {
+ gpr_free(completion);
}
static void producer_thread(void *arg) {
@@ -184,7 +195,7 @@ static void producer_thread(void *arg) {
gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- grpc_cq_begin_op(opt->cc, NULL);
+ grpc_cq_begin_op(opt->cc);
}
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
@@ -193,7 +204,8 @@ static void producer_thread(void *arg) {
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- grpc_cq_end_op(opt->cc, (void *)(gpr_intptr)1, NULL, 1);
+ grpc_cq_end_op(opt->cc, (void *)(gpr_intptr)1, 1, free_completion, NULL,
+ gpr_malloc(sizeof(grpc_cq_completion)));
opt->events_triggered++;
}
diff --git a/test/core/transport/chttp2/timeout_encoding_test.c b/test/core/transport/chttp2/timeout_encoding_test.c
index 5bfb9cf0ec..ba6c3191f1 100644
--- a/test/core/transport/chttp2/timeout_encoding_test.c
+++ b/test/core/transport/chttp2/timeout_encoding_test.c
@@ -54,34 +54,35 @@ static void assert_encodes_as(gpr_timespec ts, const char *s) {
void test_encoding(void) {
LOG_TEST("test_encoding");
- assert_encodes_as(gpr_time_from_micros(-1), "1n");
- assert_encodes_as(gpr_time_from_seconds(-10), "1n");
- assert_encodes_as(gpr_time_from_nanos(10), "10n");
- assert_encodes_as(gpr_time_from_nanos(999999999), "1S");
- assert_encodes_as(gpr_time_from_micros(1), "1u");
- assert_encodes_as(gpr_time_from_micros(10), "10u");
- assert_encodes_as(gpr_time_from_micros(100), "100u");
- assert_encodes_as(gpr_time_from_micros(890), "890u");
- assert_encodes_as(gpr_time_from_micros(900), "900u");
- assert_encodes_as(gpr_time_from_micros(901), "901u");
- assert_encodes_as(gpr_time_from_millis(1), "1m");
- assert_encodes_as(gpr_time_from_millis(2), "2m");
- assert_encodes_as(gpr_time_from_micros(10001), "10100u");
- assert_encodes_as(gpr_time_from_micros(999999), "1S");
- assert_encodes_as(gpr_time_from_millis(1000), "1S");
- assert_encodes_as(gpr_time_from_millis(2000), "2S");
- assert_encodes_as(gpr_time_from_millis(2500), "2500m");
- assert_encodes_as(gpr_time_from_millis(59900), "59900m");
- assert_encodes_as(gpr_time_from_seconds(50), "50S");
- assert_encodes_as(gpr_time_from_seconds(59), "59S");
- assert_encodes_as(gpr_time_from_seconds(60), "1M");
- assert_encodes_as(gpr_time_from_seconds(80), "80S");
- assert_encodes_as(gpr_time_from_seconds(90), "90S");
- assert_encodes_as(gpr_time_from_minutes(2), "2M");
- assert_encodes_as(gpr_time_from_minutes(20), "20M");
- assert_encodes_as(gpr_time_from_hours(1), "1H");
- assert_encodes_as(gpr_time_from_hours(10), "10H");
- assert_encodes_as(gpr_time_from_seconds(1000000000), "1000000000S");
+ assert_encodes_as(gpr_time_from_micros(-1, GPR_TIMESPAN), "1n");
+ assert_encodes_as(gpr_time_from_seconds(-10, GPR_TIMESPAN), "1n");
+ assert_encodes_as(gpr_time_from_nanos(10, GPR_TIMESPAN), "10n");
+ assert_encodes_as(gpr_time_from_nanos(999999999, GPR_TIMESPAN), "1S");
+ assert_encodes_as(gpr_time_from_micros(1, GPR_TIMESPAN), "1u");
+ assert_encodes_as(gpr_time_from_micros(10, GPR_TIMESPAN), "10u");
+ assert_encodes_as(gpr_time_from_micros(100, GPR_TIMESPAN), "100u");
+ assert_encodes_as(gpr_time_from_micros(890, GPR_TIMESPAN), "890u");
+ assert_encodes_as(gpr_time_from_micros(900, GPR_TIMESPAN), "900u");
+ assert_encodes_as(gpr_time_from_micros(901, GPR_TIMESPAN), "901u");
+ assert_encodes_as(gpr_time_from_millis(1, GPR_TIMESPAN), "1m");
+ assert_encodes_as(gpr_time_from_millis(2, GPR_TIMESPAN), "2m");
+ assert_encodes_as(gpr_time_from_micros(10001, GPR_TIMESPAN), "10100u");
+ assert_encodes_as(gpr_time_from_micros(999999, GPR_TIMESPAN), "1S");
+ assert_encodes_as(gpr_time_from_millis(1000, GPR_TIMESPAN), "1S");
+ assert_encodes_as(gpr_time_from_millis(2000, GPR_TIMESPAN), "2S");
+ assert_encodes_as(gpr_time_from_millis(2500, GPR_TIMESPAN), "2500m");
+ assert_encodes_as(gpr_time_from_millis(59900, GPR_TIMESPAN), "59900m");
+ assert_encodes_as(gpr_time_from_seconds(50, GPR_TIMESPAN), "50S");
+ assert_encodes_as(gpr_time_from_seconds(59, GPR_TIMESPAN), "59S");
+ assert_encodes_as(gpr_time_from_seconds(60, GPR_TIMESPAN), "1M");
+ assert_encodes_as(gpr_time_from_seconds(80, GPR_TIMESPAN), "80S");
+ assert_encodes_as(gpr_time_from_seconds(90, GPR_TIMESPAN), "90S");
+ assert_encodes_as(gpr_time_from_minutes(2, GPR_TIMESPAN), "2M");
+ assert_encodes_as(gpr_time_from_minutes(20, GPR_TIMESPAN), "20M");
+ assert_encodes_as(gpr_time_from_hours(1, GPR_TIMESPAN), "1H");
+ assert_encodes_as(gpr_time_from_hours(10, GPR_TIMESPAN), "10H");
+ assert_encodes_as(gpr_time_from_seconds(1000000000, GPR_TIMESPAN),
+ "1000000000S");
}
static void assert_decodes_as(const char *buffer, gpr_timespec expected) {
@@ -91,7 +92,8 @@ static void assert_decodes_as(const char *buffer, gpr_timespec expected) {
GPR_ASSERT(0 == gpr_time_cmp(got, expected));
}
-void decode_suite(char ext, gpr_timespec (*answer)(long x)) {
+void decode_suite(char ext,
+ gpr_timespec (*answer)(long x, gpr_clock_type clock)) {
long test_vals[] = {1, 12, 123, 1234, 12345, 123456,
1234567, 12345678, 123456789, 98765432, 9876543, 987654,
98765, 9876, 987, 98, 9};
@@ -99,19 +101,19 @@ void decode_suite(char ext, gpr_timespec (*answer)(long x)) {
char *input;
for (i = 0; i < GPR_ARRAY_SIZE(test_vals); i++) {
gpr_asprintf(&input, "%ld%c", test_vals[i], ext);
- assert_decodes_as(input, answer(test_vals[i]));
+ assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN));
gpr_free(input);
gpr_asprintf(&input, " %ld%c", test_vals[i], ext);
- assert_decodes_as(input, answer(test_vals[i]));
+ assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN));
gpr_free(input);
gpr_asprintf(&input, "%ld %c", test_vals[i], ext);
- assert_decodes_as(input, answer(test_vals[i]));
+ assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN));
gpr_free(input);
gpr_asprintf(&input, "%ld %c ", test_vals[i], ext);
- assert_decodes_as(input, answer(test_vals[i]));
+ assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN));
gpr_free(input);
}
}
@@ -124,7 +126,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) {
diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c
index 20ab67ec15..225658f5e2 100644
--- a/test/core/util/test_config.c
+++ b/test/core/util/test_config.c
@@ -48,7 +48,45 @@ static int seed(void) { return getpid(); }
static int seed(void) { return _getpid(); }
#endif
+#if GPR_WINDOWS_CRASH_HANDLER
+LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) {
+ gpr_log(GPR_DEBUG, "Exception handler called, dumping information");
+ while (ex_info->ExceptionRecord) {
+ DWORD code = ex_info->ExceptionRecord->ExceptionCode;
+ DWORD flgs = ex_info->ExceptionRecord->ExceptionFlags;
+ PVOID addr = ex_info->ExceptionRecord->ExceptionAddress;
+ gpr_log("code: %x - flags: %d - address: %p", code, flgs, addr);
+ ex_info->ExceptionRecord = ex_info->ExceptionRecord->ExceptionRecord;
+ }
+ if (IsDebuggerPresent()) {
+ __debugbreak();
+ } else {
+ _exit(1);
+ }
+ return EXCEPTION_EXECUTE_HANDLER;
+}
+
+void abort_handler(int sig) {
+ gpr_log(GPR_DEBUG, "Abort handler called.");
+ if (IsDebuggerPresent()) {
+ __debugbreak();
+ } else {
+ _exit(1);
+ }
+}
+
+static void install_crash_handler() {
+ SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) crash_handler);
+ _set_abort_behavior(0, _WRITE_ABORT_MSG);
+ _set_abort_behavior(0, _CALL_REPORTFAULT);
+ signal(SIGABRT, abort_handler);
+}
+#else
+static void install_crash_handler() { }
+#endif
+
void grpc_test_init(int argc, char **argv) {
+ install_crash_handler();
gpr_log(GPR_DEBUG, "test slowdown: machine=%f build=%f total=%f",
(double)GRPC_TEST_SLOWDOWN_MACHINE_FACTOR,
(double)GRPC_TEST_SLOWDOWN_BUILD_FACTOR,
diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h
index 0b3c54373d..063c797ce9 100644
--- a/test/core/util/test_config.h
+++ b/test/core/util/test_config.h
@@ -51,13 +51,15 @@ extern "C" {
#define GRPC_TEST_SLOWDOWN_FACTOR \
(GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR)
-#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \
- gpr_time_add(gpr_now(), \
- gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e6 * (x)))
+#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), \
+ gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e6 * (x), \
+ GPR_TIMESPAN))
-#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \
- gpr_time_add(gpr_now(), \
- gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)))
+#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), \
+ gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x), \
+ GPR_TIMESPAN))
#ifndef GRPC_TEST_CUSTOM_PICK_PORT
#define GRPC_TEST_PICK_PORT
@@ -69,4 +71,4 @@ void grpc_test_init(int argc, char **argv);
}
#endif /* __cplusplus */
-#endif /* GRPC_TEST_CORE_UTIL_TEST_CONFIG_H */
+#endif /* GRPC_TEST_CORE_UTIL_TEST_CONFIG_H */