aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2016-01-05 15:53:30 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2016-01-05 15:53:30 -0800
commitd3917ab79003013d33f456a5c63ce868d6ea3072 (patch)
tree2062026e9b336e98a6aef9a1bfdcedccba5ead3d /test
parent383ffacb00c33115af4509937d0733d0badeac6a (diff)
Add an early out to gpr_cpu_test
This test consumes a huge amount of CPU. On Windows, it additionally starves other tests from getting scheduled - for long enough that those tests time out and fail. Historically tests starting shortly after this test are the most likely to fail. Once we've seen all CPU's, we will no longer do anything useful - so check for that, and finish up early whenever possible.
Diffstat (limited to 'test')
-rw-r--r--test/core/support/cpu_test.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/core/support/cpu_test.c b/test/core/support/cpu_test.c
index fa83878a15..138ad6a19e 100644
--- a/test/core/support/cpu_test.c
+++ b/test/core/support/cpu_test.c
@@ -80,7 +80,7 @@ static void worker_thread(void *arg) {
struct cpu_test *ct = (struct cpu_test *)arg;
gpr_uint32 cpu;
int r = 12345678;
- int i, j;
+ 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... */