Skip to content

Commit 36c536d

Browse files
committed
Adjust pass/fail criteria in dispatch_concur
Adjust pass/fail criteria to allow some divergence when the level of expected concurrency is greater than the number of hardware CPUs on the system on which the test is being run.
1 parent 2976fc4 commit 36c536d

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

tests/dispatch_concur.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
static volatile size_t done, concur;
3333
static int use_group_async;
34+
static uint32_t activecpu;
35+
static int32_t xfail = 0;
3436

3537
static dispatch_queue_t q;
3638
static dispatch_group_t g, gw;
@@ -92,15 +94,28 @@ test_concur_async(size_t n, size_t qw)
9294

9395
dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
9496

95-
test_long("concurrently completed workers", done,
96-
MIN(n * workers, qw >= n ? qw - n : 0));
97+
if (qw > 1) {
98+
size_t concurrency = MIN(n * workers, qw);
99+
if (concurrency > done && done >= activecpu) {
100+
xfail++;
101+
} else {
102+
test_long("concurrently completed workers", done, concurrency);
103+
}
104+
} else {
105+
test_long_less_than_or_equal("concurrently completed workers", done, 1);
106+
}
97107

98108
for (i = 0, mc = mcs; i < n; i++, mc++) {
99109
if (*mc > max_concur) max_concur = *mc;
100110
}
101111
free(mcs);
102112

103-
test_long("max submission concurrency", max_concur, MIN(n, qw));
113+
size_t expect = MIN(n, qw);
114+
if (expect > max_concur && max_concur >= activecpu) {
115+
xfail++;
116+
} else {
117+
test_long("max submission concurrency", max_concur, expect);
118+
}
104119

105120
dispatch_group_wait(gw, DISPATCH_TIME_FOREVER);
106121
usleep(1000);
@@ -138,7 +153,12 @@ test_concur_sync(size_t n, size_t qw)
138153
}
139154
free(mcs);
140155

141-
test_long("max sync concurrency", max_concur, qw == 1 ? 1 : n);
156+
size_t expect = qw == 1 ? 1 : n;
157+
if (expect > max_concur && max_concur >= activecpu) {
158+
xfail++;
159+
} else {
160+
test_long("max sync concurrency", max_concur, expect);
161+
}
142162
}
143163

144164
static void
@@ -164,7 +184,12 @@ test_concur_apply(size_t n, size_t qw)
164184
}
165185
free(mcs);
166186

167-
test_long("max apply concurrency", max_concur, MIN(n, qw));
187+
size_t expect = MIN(n, qw);
188+
if (expect > max_concur && max_concur >= activecpu) {
189+
xfail++;
190+
} else {
191+
test_long("max apply concurrency", max_concur, expect);
192+
}
168193
}
169194

170195
static dispatch_queue_t
@@ -201,7 +226,6 @@ main(int argc __attribute__((unused)), char* argv[] __attribute__((unused)))
201226
{
202227
dispatch_test_start("Dispatch Private Concurrent/Wide Queue"); // <rdar://problem/8049506&8169448&8186485>
203228

204-
uint32_t activecpu;
205229
#ifdef __linux__
206230
activecpu = sysconf(_SC_NPROCESSORS_ONLN);
207231
#else
@@ -250,6 +274,8 @@ main(int argc __attribute__((unused)), char* argv[] __attribute__((unused)))
250274
dispatch_release(ttq);
251275
}
252276

277+
test_long_less_than_or_equal("6 failures for this test is acceptable", xfail, 6);
278+
253279
dispatch_release(g);
254280
dispatch_release(gw);
255281

0 commit comments

Comments
 (0)