Skip to content

Commit b52f186

Browse files
authored
Merge pull request #117 from dgrove-oss/concur-test-tweaks
relax passing conditions for dispatch_concur
2 parents bb676c2 + 0722c3f commit b52f186

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

tests/dispatch_concur.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
static volatile size_t done, concur;
3333
static int use_group_async;
3434
static uint32_t activecpu;
35-
static int32_t xfail = 0;
35+
static uint32_t min_acceptable_concurrency;
3636

3737
static dispatch_queue_t q;
3838
static dispatch_group_t g, gw;
@@ -96,8 +96,8 @@ test_concur_async(size_t n, size_t qw)
9696

9797
if (qw > 1) {
9898
size_t concurrency = MIN(n * workers, qw);
99-
if (concurrency > done && done >= activecpu) {
100-
xfail++;
99+
if (done > min_acceptable_concurrency) {
100+
test_long_less_than_or_equal("concurrently completed workers", done, concurrency);
101101
} else {
102102
test_long("concurrently completed workers", done, concurrency);
103103
}
@@ -111,8 +111,8 @@ test_concur_async(size_t n, size_t qw)
111111
free(mcs);
112112

113113
size_t expect = MIN(n, qw);
114-
if (expect > max_concur && max_concur >= activecpu) {
115-
xfail++;
114+
if (max_concur > min_acceptable_concurrency) {
115+
test_long_less_than_or_equal("max submission concurrency", max_concur, expect);
116116
} else {
117117
test_long("max submission concurrency", max_concur, expect);
118118
}
@@ -154,8 +154,8 @@ test_concur_sync(size_t n, size_t qw)
154154
free(mcs);
155155

156156
size_t expect = qw == 1 ? 1 : n;
157-
if (expect > max_concur && max_concur >= activecpu) {
158-
xfail++;
157+
if (max_concur > min_acceptable_concurrency) {
158+
test_long_less_than_or_equal("max sync concurrency", max_concur, expect);
159159
} else {
160160
test_long("max sync concurrency", max_concur, expect);
161161
}
@@ -185,8 +185,8 @@ test_concur_apply(size_t n, size_t qw)
185185
free(mcs);
186186

187187
size_t expect = MIN(n, qw);
188-
if (expect > max_concur && max_concur >= activecpu) {
189-
xfail++;
188+
if (max_concur > min_acceptable_concurrency) {
189+
test_long_less_than_or_equal("max apply concurrency", max_concur, expect);
190190
} else {
191191
test_long("max apply concurrency", max_concur, expect);
192192
}
@@ -233,6 +233,7 @@ main(int argc __attribute__((unused)), char* argv[] __attribute__((unused)))
233233
sysctlbyname("hw.activecpu", &activecpu, &s, NULL, 0);
234234
#endif
235235
size_t n = activecpu / 2 > 1 ? activecpu / 2 : 1, w = activecpu * 2;
236+
min_acceptable_concurrency = n;
236237
dispatch_queue_t tq, ttq;
237238
long qw, tqw, ttqw;
238239
const char *ql, *tql, *ttql;
@@ -274,8 +275,6 @@ main(int argc __attribute__((unused)), char* argv[] __attribute__((unused)))
274275
dispatch_release(ttq);
275276
}
276277

277-
test_long_less_than_or_equal("6 failures for this test is acceptable", xfail, 6);
278-
279278
dispatch_release(g);
280279
dispatch_release(gw);
281280

0 commit comments

Comments
 (0)