Skip to content

Commit 07ca1ff

Browse files
committed
Adjust test/of_by_one.ml to accept failure to allocate domain
1 parent 0637fb1 commit 07ca1ff

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

test/off_by_one.ml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ let print_array a =
1010
let r = Array.init 20 (fun i -> i + 1)
1111

1212
let scan_task num_doms =
13-
let pool = Task.setup_pool ~num_domains:num_doms () in
14-
let a = Task.run pool (fun () -> Task.parallel_scan pool (+) (Array.make 20 1)) in
15-
Task.teardown_pool pool;
16-
Printf.printf "%i: %s\n%!" num_doms (print_array a);
17-
assert (a = r)
13+
try
14+
let pool = Task.setup_pool ~num_domains:num_doms () in
15+
let a = Task.run pool (fun () -> Task.parallel_scan pool (+) (Array.make 20 1)) in
16+
Task.teardown_pool pool;
17+
Printf.printf "%i: %s\n%!" num_doms (print_array a);
18+
assert (a = r)
19+
with Failure msg ->
20+
begin
21+
assert (msg = "failed to allocate domain");
22+
Printf.printf "Failed to allocate %i domains, recommended_domain_count: %i\n%!"
23+
num_doms (Domain.recommended_domain_count ());
24+
end
1825
;;
1926
for num_dom=0 to 21 do
2027
scan_task num_dom;

0 commit comments

Comments
 (0)