Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
keisukefukuda committed Jul 13, 2017
1 parent 189c5a6 commit 6688e5c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
6 changes: 2 additions & 4 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ def exec_(self, cmds):

info = self.get_info(name)

# TODO(keisukefukuda): if MPICH/MVAPICH,
# add -x PATH, -x LD_LIBRARY_PATH
# TODO(keisukefukuda): if hostfile is given, convert it

except UnknownMPI:
Expand All @@ -511,14 +509,14 @@ def exec_(self, cmds):
elif info['type'] in ['MPICH', 'MVAPICH']:
cmds[:0] = ['-genvlist', 'PATH,LD_LIBRARY_PATH,PYTHONPATH']

print(info['type'])
# sys.stderr.write("{}\n".format(info['type']))

mpiexec = os.path.realpath(
os.path.join(self.prefix(name), 'bin', 'mpiexec'))

cmds[:0] = [mpiexec]

print(' '.join(cmds))
# sys.stderr.write(' '.join(cmds) + "\n")
p = Popen(cmds, env=envs)
p.wait()
exit(p.returncode)
Expand Down
4 changes: 2 additions & 2 deletions init
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function mpienv() {
{
eval $(env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/use.py $*)
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/use.py $*
#env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
# python $root/bin/use.py $*
if [ -z "${BASH_VERSION:-}" -a ! -z "${ZSH_VERSION:-}" ]; then
rehash
fi
Expand Down
33 changes: 23 additions & 10 deletions tests/test_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,42 @@ test_info() {
test_mpi4py() {
export TMPDIR=/tmp

#install_mpich
#mpienv use --mpi4py mpich-3.2
install_ompi
mpienv use --mpi4py openmpi-2.1.1

mpienv exec -n 2 python -c "from mpi4py import MPI"
assertTrue $?

local SCRIPT=$(mktemp)
cat <<EOF >$SCRIPT
from mpi4py import MPI
import sys
print(MPI.__file__)
#print(MPI.__file__)
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
for i in range(0, comm.Get_size()):
if i == rank:
sys.stdout.write(str(rank))
sys.stdout.flush()
comm.barrier()
EOF
# test mpich
install_mpich
echo "------------------"
mpienv use --mpi4py mpich-3.2
echo "------------------"
mpienv exec -n 2 python -c "from mpi4py import MPI"
echo "------------------"
assertTrue $?
mpienv exec -n 2 python $SCRIPT
assertTrue $?
OUT=$(mpienv use --mpi4py mpich-3.2; mpienv exec -n 2 python $SCRIPT)
assertEquals "01" "$OUT"

# test Open MPI
install_ompi
mpienv use --mpi4py openmpi-2.1.1
mpienv exec -n 2 python -c "from mpi4py import MPI"
assertTrue $?
mpienv exec -n 2 python $SCRIPT
assertTrue $?
OUT=$(mpienv use --mpi4py openmpi-2.1.1; mpienv exec -n 2 python $SCRIPT)
assertEquals "01" "$OUT"

rm -f ${SCRIPT}
}

Expand Down

0 comments on commit 6688e5c

Please sign in to comment.