aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/surface
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-02-25 08:36:40 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-02-25 08:36:40 -0800
commit8ad8a41a84bf7e17c6e9a5fd8d975370a222c0fe (patch)
tree257d00e77bda0bc5e53b770ba9fa7cc300c449bb /test/core/surface
parent517aa0c5358f860582e6143a29522699f61fba15 (diff)
Introduce slowdown factor for unit test deadlines
Dramatically lowers (eliminates maybe?) false negatives from ?SAN runs.
Diffstat (limited to 'test/core/surface')
-rw-r--r--test/core/surface/completion_queue_benchmark.c14
-rw-r--r--test/core/surface/completion_queue_test.c22
-rw-r--r--test/core/surface/lame_client_test.c5
3 files changed, 20 insertions, 21 deletions
diff --git a/test/core/surface/completion_queue_benchmark.c b/test/core/surface/completion_queue_benchmark.c
index 9116fd0fe4..81ebe15415 100644
--- a/test/core/surface/completion_queue_benchmark.c
+++ b/test/core/surface/completion_queue_benchmark.c
@@ -53,23 +53,23 @@ static void producer_thread(void *arg) {
test_thread_options *opt = arg;
int i;
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future));
for (i = 0; i < opt->iterations; i++) {
grpc_cq_begin_op(opt->cc, NULL, GRPC_WRITE_ACCEPTED);
- grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL,
- GRPC_OP_OK);
+ grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL,
+ NULL, GRPC_OP_OK);
}
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
}
static void consumer_thread(void *arg) {
test_thread_options *opt = arg;
grpc_event *ev;
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future));
for (;;) {
@@ -78,7 +78,7 @@ static void consumer_thread(void *arg) {
case GRPC_WRITE_ACCEPTED:
break;
case GRPC_QUEUE_SHUTDOWN:
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
return;
default:
gpr_log(GPR_ERROR, "Invalid event received: %d", ev->type);
@@ -112,7 +112,7 @@ double ops_per_second(int consumers, int producers, int iterations) {
/* start the benchmark */
t_start = gpr_now();
- gpr_event_set(&start, (void *)(gpr_intptr)1);
+ gpr_event_set(&start, (void *)(gpr_intptr) 1);
/* wait for producers to finish */
for (i = 0; i < producers; i++) {
diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c
index 35f150c781..414ca2eac9 100644
--- a/test/core/surface/completion_queue_test.c
+++ b/test/core/surface/completion_queue_test.c
@@ -248,7 +248,7 @@ typedef struct test_thread_options {
} test_thread_options;
gpr_timespec ten_seconds_time(void) {
- return gpr_time_add(gpr_now(), gpr_time_from_micros(10 * 1000000));
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1);
}
static void producer_thread(void *arg) {
@@ -256,7 +256,7 @@ static void producer_thread(void *arg) {
int i;
gpr_log(GPR_INFO, "producer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
@@ -265,18 +265,18 @@ static void producer_thread(void *arg) {
}
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
- grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL,
- GRPC_OP_OK);
+ grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL,
+ NULL, GRPC_OP_OK);
opt->events_triggered++;
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
}
static void consumer_thread(void *arg) {
@@ -284,13 +284,13 @@ static void consumer_thread(void *arg) {
grpc_event *ev;
gpr_log(GPR_INFO, "consumer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 1", opt->id);
gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 2", opt->id);
@@ -305,7 +305,7 @@ static void consumer_thread(void *arg) {
break;
case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
+ gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
grpc_event_finish(ev);
return;
default:
@@ -350,7 +350,7 @@ static void test_threading(int producers, int consumers) {
/* start phase1: producers will pre-declare all operations they will
complete */
gpr_log(GPR_INFO, "start phase 1");
- gpr_event_set(&phase1, (void *)(gpr_intptr)1);
+ gpr_event_set(&phase1, (void *)(gpr_intptr) 1);
gpr_log(GPR_INFO, "wait phase 1");
for (i = 0; i < producers + consumers; i++) {
@@ -360,7 +360,7 @@ static void test_threading(int producers, int consumers) {
/* start phase2: operations will complete, and consumers will consume them */
gpr_log(GPR_INFO, "start phase 2");
- gpr_event_set(&phase2, (void *)(gpr_intptr)1);
+ gpr_event_set(&phase2, (void *)(gpr_intptr) 1);
/* in parallel, we shutdown the completion channel - all events should still
be consumed */
diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c
index 0142768261..3653c5a1b0 100644
--- a/test/core/surface/lame_client_test.c
+++ b/test/core/surface/lame_client_test.c
@@ -51,9 +51,8 @@ int main(int argc, char **argv) {
chan = grpc_lame_client_channel_create();
GPR_ASSERT(chan);
- call = grpc_channel_create_call_old(
- chan, "/Foo", "anywhere",
- gpr_time_add(gpr_now(), gpr_time_from_seconds(100)));
+ call = grpc_channel_create_call_old(chan, "/Foo", "anywhere",
+ GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100));
GPR_ASSERT(call);
cq = grpc_completion_queue_create();
cqv = cq_verifier_create(cq);