mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
added new tests script to run full test switch with different compiler options
This commit is contained in:
parent
c1fae67b50
commit
8753d7b8b1
5 changed files with 157 additions and 1 deletions
41
tests/nose_mpi.py
Normal file
41
tests/nose_mpi.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import os
|
||||
import logging
|
||||
from nose.plugins import Plugin
|
||||
|
||||
log = logging.getLogger('nose.plugins.nose_mpi')
|
||||
|
||||
class NoseMPI(Plugin):
|
||||
|
||||
mpi_np = "0"
|
||||
mpi_exec = "/opt/mpich/3.0.4-gnu/bin/mpiexec"
|
||||
|
||||
def options(self, parser, env=os.environ):
|
||||
"""Define the command line options for plugin."""
|
||||
super(NoseMPI, self).options(parser, env)
|
||||
|
||||
parser.add_option(
|
||||
"--mpi-np", dest="mpi_np", default=0,
|
||||
help="Number of MPI processors to execute OpenMC executable.")
|
||||
|
||||
parser.add_option(
|
||||
"--mpi-exec", dest="mpi_exec",
|
||||
default="/opt/mpich/3.0.4-gnu/bin/mpiexec",
|
||||
help="Absolute path to mpiexec file.")
|
||||
|
||||
def configure(self, options, conf):
|
||||
"""Configure plugin based on command line options"""
|
||||
super(NoseMPI, self).configure(options, conf)
|
||||
|
||||
try:
|
||||
mpi_np = int(options.mpi_np)
|
||||
self.enabled = True
|
||||
NoseMPI.mpi_np = options.mpi_np
|
||||
except:
|
||||
self.enabled = False
|
||||
return
|
||||
|
||||
if not os.path.exists(options.mpi_exec):
|
||||
print 'Need to specify valid mpiexec path.'
|
||||
exit()
|
||||
|
||||
NoseMPI.mpi_exec = options.mpi_exec
|
||||
94
tests/run_tests.py
Normal file
94
tests/run_tests.py
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/sh env python
|
||||
|
||||
# load in packages
|
||||
import os
|
||||
import sys
|
||||
import nose
|
||||
from subprocess import call
|
||||
|
||||
pwd = os.getcwd()
|
||||
|
||||
# run compile test
|
||||
result = nose.run(argv=['run_tests.py','-v','test_compile'])
|
||||
if not result:
|
||||
sys.exit('Did not pass compile tests.')
|
||||
|
||||
# run gfortran tests
|
||||
print '\n--------------'
|
||||
print 'gfortran tests'
|
||||
print '--------------\n'
|
||||
os.chdir(pwd)
|
||||
os.rename(pwd + '/../src/openmc-gfortran', pwd + '/../src/openmc')
|
||||
result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile','test_basic'])
|
||||
if not result:
|
||||
sys.exit('Did not pass gfortran tests')
|
||||
|
||||
# run gfortran-dbg tests
|
||||
print '\n--------------'
|
||||
print 'gfortran-dbg tests'
|
||||
print '--------------\n'
|
||||
os.rename(pwd + '/../src/openmc-gfortran-dbg', pwd + '/../src/openmc')
|
||||
result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile','test_basic'])
|
||||
if not result:
|
||||
sys.exit('Did not pass gfortran-dbg tests')
|
||||
|
||||
# run gfortran-opt tests
|
||||
print '\n--------------'
|
||||
print 'gfortran-opt tests'
|
||||
print '--------------\n'
|
||||
os.rename(pwd + '/../src/openmc-gfortran-opt', pwd + '/../src/openmc')
|
||||
result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile','test_basic'])
|
||||
if not result:
|
||||
sys.exit('Did not pass gfortran-opt tests')
|
||||
|
||||
# run gfortran-hdf5 tests
|
||||
print '\n--------------'
|
||||
print 'gfortran-hdf5 tests'
|
||||
print '--------------\n'
|
||||
#os.rename(pwd + '/../src/openmc-gfortran-hdf5', pwd + '/../src/openmc')
|
||||
#result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile','test_basic'])
|
||||
#if not result:
|
||||
# sys.exit('Did not pass gfortran-hdf5 tests')
|
||||
|
||||
# run gfortran-mpi tests
|
||||
print '\n--------------'
|
||||
print 'gfortran-mpi tests'
|
||||
print '--------------\n'
|
||||
os.rename(pwd + '/../src/openmc-gfortran-mpi', pwd + '/../src/openmc')
|
||||
result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile',
|
||||
'--mpi-np','3','--mpi-exec',
|
||||
'/opt/mpich/3.0.4-gnu/bin/mpiexec','test_basic'])
|
||||
if not result:
|
||||
sys.exit('Did not pass gfortran-mpi tests')
|
||||
|
||||
# run gfortran-phdf5 tests
|
||||
print '\n--------------'
|
||||
print 'gfortran-phdf5 tests'
|
||||
print '--------------\n'
|
||||
#result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile',
|
||||
# '--mpi-np','3','--mpi-exec',
|
||||
# '/opt/mpich/3.0.4-gnu/bin/mpiexec','test_basic'])
|
||||
#if not result:
|
||||
# sys.exit('Did not pass gfortran-phdf5 tests')
|
||||
|
||||
# run gfortran-petsc tests
|
||||
print '\n--------------'
|
||||
print 'gfortran-petsc tests'
|
||||
print '--------------\n'
|
||||
os.rename(pwd + '/../src/openmc-gfortran-petsc', pwd + '/../src/openmc')
|
||||
result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile',
|
||||
'--mpi-np','3','--mpi-exec',
|
||||
'/opt/mpich/3.0.4-gnu/bin/mpiexec','test_basic'])
|
||||
if not result:
|
||||
sys.exit('Did not pass gfortran-petsc tests')
|
||||
|
||||
# run gfortran-phdf5-petsc tests
|
||||
print '\n--------------'
|
||||
print 'gfortran-phdf5-petsc tests'
|
||||
print '--------------\n'
|
||||
os.rename(pwd + '/../src/openmc-gfortran-phdf5-petsc', pwd + '/../src/openmc')
|
||||
result = nose.run(argv=['run_tests.py','-v','--exclude','test_compile',
|
||||
'--mpi-np','3','--mpi-exec',
|
||||
'/opt/mpich/3.0.4-gnu/bin/mpiexec','test_basic'])
|
||||
if not result:
|
||||
sys.exit('Did not pass gfortran-phdf5-petsc tests')
|
||||
7
tests/setup.py
Normal file
7
tests/setup.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from setuptools import setup
|
||||
setup(name="nose-mpi",
|
||||
entry_points = {
|
||||
'nose.plugins':['nose_mpi = nose_mpi:NoseMPI']
|
||||
},
|
||||
install_requires = ['nose']
|
||||
)
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
|
|
@ -11,7 +12,13 @@ def setup():
|
|||
os.chdir(pwd)
|
||||
|
||||
def test_run():
|
||||
proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE)
|
||||
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
returncode = proc.wait()
|
||||
print(proc.communicate()[0])
|
||||
assert returncode == 0
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ def test_gfortran_debug():
|
|||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'DEBUG=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-gfortran-dbg')
|
||||
|
||||
def test_gfortran_profile():
|
||||
returncode = run(['make','distclean'])
|
||||
|
|
@ -39,31 +40,37 @@ def test_gfortran_optimize():
|
|||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'OPTIMIZE=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-gfortran-opt')
|
||||
|
||||
def test_gfortran_mpi():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'MPI=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-gfortran-mpi')
|
||||
|
||||
def test_gfortran_hdf5():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'HDF5=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-gfortran-hdf5')
|
||||
|
||||
def test_gfortran_petsc():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'MPI=yes', 'PETSC=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-gfortran-petsc')
|
||||
|
||||
def test_gfortran_mpi_hdf5():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'MPI=yes', 'HDF5=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-gfortran-phdf5')
|
||||
|
||||
def test_gfortran_mpi_hdf5_petsc():
|
||||
returncode = run(['make','distclean'])
|
||||
returncode = run(['make', 'MPI=yes', 'HDF5=yes', 'PETSC=yes'])
|
||||
assert returncode == 0
|
||||
shutil.move('openmc', 'openmc-gfortran-phdf5-petsc')
|
||||
|
||||
def test_intel():
|
||||
returncode = run(['make','distclean'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue