From 975fd21284f3c950d1015d8cd6517894b2894f2f Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sat, 7 Sep 2013 15:02:46 -0400 Subject: [PATCH] Allow test suite to be run with compiler other than gfortran. --- tests/run_tests.py | 21 +++++----- tests/test_compile/test_compile.py | 65 ++++++++++++++++-------------- 2 files changed, 47 insertions(+), 39 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index 2b816a228..5e261fba7 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -55,7 +55,11 @@ def run_suite(name=None, mpi=False): results.append((name, result)) # set mpiexec path -mpiexec = '/opt/mpich/3.0.4-gnu/bin/mpiexec' +if os.environ.has_key('COMPILER'): + compiler = os.environ['COMPILER'] +else: + compiler = 'gnu' +mpiexec = '/opt/mpich/3.0.4-{0}/bin/mpiexec'.format(compiler) # get current working directory pwd = os.getcwd() @@ -63,23 +67,22 @@ sys.path.append(pwd) # Set list of tests, either default or from command line flags = [] -tests = ['compile', 'gfortran', 'gfortran-dbg', 'gfortran-opt', - 'gfortran-hdf5', 'gfortran-mpi', 'gfortran-phdf5', - 'gfortran-petsc', 'gfortran-phdf5-petsc', - 'gfortran-phdf5-petsc-opt'] +tests = ['compile', 'normal', 'debug', 'optimize', 'hdf5', 'mpi', 'phdf5', + 'petsc', 'phdf5-petsc', 'phdf5-petsc-optimize'] if len(sys.argv) > 1: flags = [i for i in sys.argv[1:] if i.startswith('-')] - tests = [i for i in sys.argv[1:] if not i.startswith('-')] + tests_ = [i for i in sys.argv[1:] if not i.startswith('-')] + tests = tests_ if tests_ else tests # Run tests results = [] for name in tests: if name == 'compile': run_compile() - elif name in ['gfortran', 'gfortran-dbg', 'gfortran-opt', 'gfortran-hdf5']: + elif name in ['normal', 'debug', 'optimize', 'hdf5']: run_suite(name=name) - elif name in ['gfortran-mpi', 'gfortran-phdf5', 'gfortran-petsc', - 'gfortran-phdf5-petsc', 'gfortran-phdf5-petsc-opt']: + elif name in ['mpi', 'phdf5', 'petsc', 'phdf5-petsc', + 'phdf5-petsc-optimize']: run_suite(name=name, mpi=True) # print out summary of results diff --git a/tests/test_compile/test_compile.py b/tests/test_compile/test_compile.py index dbbeaa533..72e4dd653 100644 --- a/tests/test_compile/test_compile.py +++ b/tests/test_compile/test_compile.py @@ -15,68 +15,73 @@ import shutil pwd = os.path.dirname(__file__) +if os.environ.has_key('COMPILER'): + compiler = 'COMPILER=' + os.environ['COMPILER'] +else: + compiler = 'COMPILER=gnu' + def setup(): # Change to source directory os.chdir(pwd + '/../../src') -def test_gfortran(): +def test_normal(): returncode = run(['make','distclean']) - returncode = run(['make']) + returncode = run(['make', compiler]) assert returncode == 0 - shutil.move('openmc', 'openmc-gfortran') + shutil.move('openmc', 'openmc-normal') -def test_gfortran_debug(): +def test_debug(): returncode = run(['make','distclean']) - returncode = run(['make', 'DEBUG=yes']) + returncode = run(['make', compiler, 'DEBUG=yes']) assert returncode == 0 - shutil.move('openmc', 'openmc-gfortran-dbg') + shutil.move('openmc', 'openmc-debug') -def test_gfortran_profile(): +def test_profile(): returncode = run(['make','distclean']) - returncode = run(['make', 'PROFILE=yes']) + returncode = run(['make', compiler, 'PROFILE=yes']) assert returncode == 0 -def test_gfortran_optimize(): +def test_optimize(): returncode = run(['make','distclean']) - returncode = run(['make', 'OPTIMIZE=yes']) + returncode = run(['make', compiler, 'OPTIMIZE=yes']) assert returncode == 0 - shutil.move('openmc', 'openmc-gfortran-opt') + shutil.move('openmc', 'openmc-optimize') -def test_gfortran_mpi(): +def test_mpi(): returncode = run(['make','distclean']) - returncode = run(['make', 'MPI=yes']) + returncode = run(['make', compiler, 'MPI=yes']) assert returncode == 0 - shutil.move('openmc', 'openmc-gfortran-mpi') + shutil.move('openmc', 'openmc-mpi') -def test_gfortran_hdf5(): +def test_hdf5(): returncode = run(['make','distclean']) - returncode = run(['make', 'HDF5=yes']) + returncode = run(['make', compiler, 'HDF5=yes']) assert returncode == 0 - shutil.move('openmc', 'openmc-gfortran-hdf5') + shutil.move('openmc', 'openmc-hdf5') -def test_gfortran_petsc(): +def test_petsc(): returncode = run(['make','distclean']) - returncode = run(['make', 'MPI=yes', 'PETSC=yes']) + returncode = run(['make', compiler, 'MPI=yes', 'PETSC=yes']) assert returncode == 0 - shutil.move('openmc', 'openmc-gfortran-petsc') + shutil.move('openmc', 'openmc-petsc') -def test_gfortran_mpi_hdf5(): +def test_mpi_hdf5(): returncode = run(['make','distclean']) - returncode = run(['make', 'MPI=yes', 'HDF5=yes']) + returncode = run(['make', compiler, 'MPI=yes', 'HDF5=yes']) assert returncode == 0 - shutil.move('openmc', 'openmc-gfortran-phdf5') + shutil.move('openmc', 'openmc-phdf5') -def test_gfortran_mpi_hdf5_petsc(): +def test_mpi_hdf5_petsc(): returncode = run(['make','distclean']) - returncode = run(['make', 'MPI=yes', 'HDF5=yes', 'PETSC=yes']) + returncode = run(['make', compiler, 'MPI=yes', 'HDF5=yes', 'PETSC=yes']) assert returncode == 0 - shutil.move('openmc', 'openmc-gfortran-phdf5-petsc') + shutil.move('openmc', 'openmc-phdf5-petsc') -def test_gfortran_mpi_hdf5_petsc_optimize(): +def test_mpi_hdf5_petsc_optimize(): returncode = run(['make','distclean']) - returncode = run(['make', 'MPI=yes', 'HDF5=yes', 'PETSC=yes', 'OPTIMIZE=yes']) + returncode = run(['make', compiler, 'MPI=yes', 'HDF5=yes', 'PETSC=yes', 'OPTIMIZE=yes']) assert returncode == 0 - shutil.move('openmc', 'openmc-gfortran-phdf5-petsc-opt') + shutil.move('openmc', 'openmc-phdf5-petsc-optimize') def run(commands): proc = Popen(commands, stderr=STDOUT, stdout=PIPE) @@ -86,4 +91,4 @@ def run(commands): def teardown(commands): returncode = run(['make','distclean']) - shutil.copy('openmc-gfortran','openmc') + shutil.copy('openmc-normal','openmc')