Skip to content
Snippets Groups Projects
Commit d719d6e1 authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

Merge pull request #5750 from sreecha/gpr_thd_test

Reduce the number of threads so that this test works on x86 systems
parents 85b460fb f7cea976
No related branches found
No related tags found
No related merge requests found
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -41,6 +41,8 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
#define NUM_THREADS 300
struct test {
gpr_mu mu;
int n;
......@@ -79,15 +81,14 @@ static void test_options(void) {
static void test(void) {
int i;
gpr_thd_id thd;
gpr_thd_id thds[1000];
gpr_thd_id thds[NUM_THREADS];
struct test t;
int n = 1000;
gpr_thd_options options = gpr_thd_options_default();
gpr_mu_init(&t.mu);
gpr_cv_init(&t.done_cv);
t.n = n;
t.n = NUM_THREADS;
t.is_done = 0;
for (i = 0; i != n; i++) {
for (i = 0; i < NUM_THREADS; i++) {
GPR_ASSERT(gpr_thd_new(&thd, &thd_body, &t, NULL));
}
gpr_mu_lock(&t.mu);
......@@ -97,10 +98,10 @@ static void test(void) {
gpr_mu_unlock(&t.mu);
GPR_ASSERT(t.n == 0);
gpr_thd_options_set_joinable(&options);
for (i = 0; i < n; i++) {
for (i = 0; i < NUM_THREADS; i++) {
GPR_ASSERT(gpr_thd_new(&thds[i], &thd_body_joinable, NULL, &options));
}
for (i = 0; i < n; i++) {
for (i = 0; i < NUM_THREADS; i++) {
gpr_thd_join(thds[i]);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment