aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/support
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2016-01-07 16:37:03 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2016-01-07 16:37:03 -0800
commit7cc0f464d12696b0f5c26d3ad248215c9ff63c27 (patch)
treec572b7fc730350ebd7ff3201ded323cfee9dad3f /test/core/support
parent54ed674d406e43a9c54ad103b5ea454d73a64c3b (diff)
parentabf85d96481a35d26ecfd16575f0a13846d3b8e5 (diff)
Merge github.com:grpc/grpc into proto_names
Diffstat (limited to 'test/core/support')
-rw-r--r--test/core/support/alloc_test.c2
-rw-r--r--test/core/support/cpu_test.c14
2 files changed, 11 insertions, 5 deletions
diff --git a/test/core/support/alloc_test.c b/test/core/support/alloc_test.c
index ea6306c1f9..a7051a46a1 100644
--- a/test/core/support/alloc_test.c
+++ b/test/core/support/alloc_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/test/core/support/cpu_test.c b/test/core/support/cpu_test.c
index f041166d08..a5c52442ad 100644
--- a/test/core/support/cpu_test.c
+++ b/test/core/support/cpu_test.c
@@ -72,15 +72,15 @@ struct cpu_test {
uint32_t ncores;
int is_done;
gpr_cv done_cv;
- int *used; /* is this core used? */
- int r; /* random number */
+ int *used; /* is this core used? */
+ unsigned r; /* random number */
};
static void worker_thread(void *arg) {
struct cpu_test *ct = (struct cpu_test *)arg;
uint32_t cpu;
- int r = 12345678;
- int i, j;
+ unsigned r = 12345678;
+ unsigned i, j;
for (i = 0; i < 1000 / GRPC_TEST_SLOWDOWN_FACTOR; i++) {
/* run for a bit - just calculate something random. */
for (j = 0; j < 1000000 / GRPC_TEST_SLOWDOWN_FACTOR; j++) {
@@ -90,7 +90,13 @@ static void worker_thread(void *arg) {
GPR_ASSERT(cpu < ct->ncores);
gpr_mu_lock(&ct->mu);
ct->used[cpu] = 1;
+ for (j = 0; j < ct->ncores; j++) {
+ if (!ct->used[j]) break;
+ }
gpr_mu_unlock(&ct->mu);
+ if (j == ct->ncores) {
+ break; /* all cpus have been used - no further use in running this test */
+ }
}
gpr_mu_lock(&ct->mu);
ct->r = r; /* make it look like we care about r's value... */