Skip to content

Commit 2f363c7

Browse files
authored
Add a test checking number of ranks is correct (#907)
* Add a test checking number of ranks is correct * Update test_gather.jl
1 parent 17d5b04 commit 2f363c7

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

test/runtests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ istest(f) = endswith(f, ".jl") && startswith(f, "test_") && !in(f, excludefiles)
7878
testfiles = sort(filter(istest, readdir(testdir)))
7979

8080
@testset "$f" for f in testfiles
81-
cmd(n=nprocs) = `$(mpiexec()) -n $n $(Base.julia_cmd()) --startup-file=no $(joinpath(testdir, f))`
81+
cmd(n=nprocs) =
82+
addenv(`$(mpiexec()) -n $n $(Base.julia_cmd()) --startup-file=no $(joinpath(testdir, f))`,
83+
# `JULIA_MPI_TEST_NUM_PROCESSES` is used in `test_gather.jl` to
84+
# test number of processes.
85+
"JULIA_MPI_TEST_NUM_PROCESSES"=>string(n))
8286
if f == "test_spawn.jl"
8387
# Some command as the others, but always use a single process
8488
run(cmd(1))

test/test_gather.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,23 @@ else
9797
@test C === nothing
9898
end
9999

100+
# Test that the number of ranks is as expected:
101+
# <https://github.com/JuliaParallel/MPI.jl/issues/905>.
102+
num_processes = get(ENV, "JULIA_MPI_TEST_NUM_PROCESSES", nothing)
103+
if isnothing(num_processes)
104+
@test_broken false
105+
else
106+
ranks = MPI.Gather(rank, comm)
107+
comm_sizes = MPI.Gather(sz, comm)
108+
109+
if isroot
110+
n = parse(Int, num_processes)
111+
# Note: there's a similar test above, but not comparing with the
112+
# externally set `JULIA_MPI_TEST_NUM_PROCESSES`.
113+
@test sort(ranks) == 0:(n - 1)
114+
@test all(==(n), comm_sizes)
115+
end
116+
end
117+
100118
MPI.Finalize()
101119
@test MPI.Finalized()

0 commit comments

Comments
 (0)