mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Merge remote-tracking branch 'upstream/develop' into harmonics
This commit is contained in:
commit
c890929207
85 changed files with 3059 additions and 2181 deletions
|
|
@ -10,7 +10,7 @@ as debugging.
|
|||
|
||||
.. toctree::
|
||||
:numbered:
|
||||
:maxdepth: 2
|
||||
:maxdepth: 3
|
||||
|
||||
structures
|
||||
styleguide
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ following criteria must be satisfied for all proposed changes:
|
|||
|
||||
- Changes have a clear purpose and are useful.
|
||||
- Compiles under all conditions (MPI, OpenMP, HDF5, etc.). This is checked as
|
||||
part of the test suite (see `test_compile.py`_).
|
||||
part of the test suite.
|
||||
- Passes the regression suite.
|
||||
- If appropriate, test cases are added to regression suite.
|
||||
- No memory leaks (checked with valgrind_).
|
||||
|
|
@ -91,6 +91,124 @@ features and bug fixes. The general steps for contributing are as follows:
|
|||
6. After the pull request has been thoroughly vetted, it is merged back into the
|
||||
*develop* branch of mit-crpg/openmc.
|
||||
|
||||
.. _test suite:
|
||||
|
||||
OpenMC Test Suite
|
||||
-----------------
|
||||
|
||||
The purpose of this test suite is to ensure that OpenMC compiles using various
|
||||
combinations of compiler flags and options, and that all user input options can
|
||||
be used successfully without breaking the code. The test suite is comprised of
|
||||
regression tests where different types of input files are configured and the
|
||||
full OpenMC code is executed. Results from simulations are compared with
|
||||
expected results. The test suite is comprised of many build configurations
|
||||
(e.g. debug, mpi, hdf5) and the actual tests which reside in sub-directories
|
||||
in the tests directory. We recommend to developers to test their branches
|
||||
before submitting a formal pull request using gfortran and intel compilers
|
||||
if available.
|
||||
|
||||
The test suite is designed to integrate with cmake using ctest_.
|
||||
The test suite can be run on an already existing build using:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
cd build
|
||||
make test
|
||||
|
||||
or
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
cd build
|
||||
ctest
|
||||
|
||||
There are numerous ctest_ command line options that can be set to have
|
||||
more control over which tests are executed.
|
||||
|
||||
Before running the test suite python script, the following environmental
|
||||
variables should be set if the default paths are incorrect:
|
||||
|
||||
* **FC** - The command of the Fortran compiler (e.g. gfotran, ifort).
|
||||
|
||||
* Default - *gfortran*
|
||||
|
||||
* **MPI_DIR** - The path to the MPI directory.
|
||||
|
||||
* Default - */opt/mpich/3.1-gnu*
|
||||
|
||||
* **HDF5_DIR** - The path to the HDF5 directory.
|
||||
|
||||
* Default - */opt/hdf5/1.8.12-gnu*
|
||||
|
||||
* **PHDF5_DIR** - The path to the parallel HDF5 directory.
|
||||
|
||||
* Default - */opt/phdf5/1.8.12-gnu*
|
||||
|
||||
* **PETSC_DIR** - The path to the PETSc directory.
|
||||
|
||||
* Default - */opt/petsc/3.4.4-gnu*
|
||||
|
||||
To run the full test suite, the following command can be executed in the
|
||||
tests directory:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
python run_tests.py
|
||||
|
||||
A subset of build configurations and/or tests can be run. To see how to use
|
||||
the script run:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
python run_tests.py --help
|
||||
|
||||
As an example, say we want to run all tests with debug flags only on tests
|
||||
that have cone and plot in their name. Also, we would like to run this on
|
||||
4 processors. We can run:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
python run_tests.py -j 4 -C debug -R "cone|plot"
|
||||
|
||||
Note that standard regular expression syntax is used for selecting build
|
||||
configurations and tests. To print out a list of build configurations, we
|
||||
can run:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
python run_tests.py -p
|
||||
|
||||
Adding tests to test suite
|
||||
++++++++++++++++++++++++++
|
||||
|
||||
To add a new test to the test suite, create a sub-directory in the tests
|
||||
directory that conforms to the regular expression *test_*. To configure
|
||||
a test you need to add the following files to your new test directory,
|
||||
*test_name* for example:
|
||||
|
||||
* OpenMC input XML files
|
||||
* **test_name.py** - python test driver script, please refer to other
|
||||
tests to see how to construct. Any output files that are generated
|
||||
during testing must be removed at the end of this script.
|
||||
* **results.py** - python script that extracts results from statepoint
|
||||
output files. By default it should look for a binary file, but can
|
||||
take an argument to overwrite which statepoint file is processed,
|
||||
whether it is at a different batch or with an HDF5 extension. This
|
||||
script must output a results file that is named *results_test.dat*.
|
||||
It is recommended that any real numbers reported use *12.6E* format.
|
||||
* **results_true.dat** - ASCII file that contains the expected results
|
||||
from the test. The file *results_test.dat* is compared to this file
|
||||
during the execution of the python test driver script. When the
|
||||
above files have been created, generate a *results_test.dat* file and
|
||||
copy it to this name and commit. It should be noted that this file
|
||||
should be generated with basic compiler options during openmc
|
||||
configuration and build (e.g., no MPI/HDF5, no debug/optimization).
|
||||
|
||||
In addition to this description, please see the various types of tests that
|
||||
are already included in the test suite to see how to create them. If all is
|
||||
implemented correctly, the new test directory will automatically be added
|
||||
to the CTest framework.
|
||||
|
||||
Private Development
|
||||
-------------------
|
||||
|
||||
|
|
@ -108,10 +226,10 @@ from your private repository into a public fork.
|
|||
.. _git: http://git-scm.com/
|
||||
.. _GitHub: https://github.com/
|
||||
.. _git flow: http://nvie.com/git-model
|
||||
.. _test_compile.py: https://github.com/mit-crpg/openmc/blob/develop/tests/test_compile/test_compile.py
|
||||
.. _valgrind: http://valgrind.org/
|
||||
.. _style guide: http://mit-crpg.github.io/openmc/devguide/styleguide.html
|
||||
.. _pull request: https://help.github.com/articles/using-pull-requests
|
||||
.. _mit-crpg/openmc: https://github.com/mit-crpg/openmc
|
||||
.. _paid plan: https://github.com/plans
|
||||
.. _Bitbucket: https://bitbucket.org
|
||||
.. _ctest: http://www.cmake.org/cmake/help/v2.8.12/ctest.html
|
||||
|
|
|
|||
|
|
@ -322,6 +322,29 @@ This will build an executable named ``openmc``.
|
|||
.. _MinGW: http://www.mingw.org
|
||||
.. _SourceForge: http://sourceforge.net/projects/mingw
|
||||
|
||||
Testing Build
|
||||
-------------
|
||||
|
||||
If you have ENDF/B-VII.0 cross sections from MCNP5/X you can test your build.
|
||||
There are two ways to run tests. The first is to use the Makefile present in
|
||||
the source directory and run the following:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
cd src
|
||||
make test
|
||||
|
||||
If you want more options for testing you can use ctest_ command. For example,
|
||||
if we wanted to run only the plot tests with 4 processors, we run:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
cd src/build
|
||||
ctest -j 4 -R plot
|
||||
|
||||
If you want to run the full test suite with different build options please
|
||||
refer to our :ref:`test suite` documentation.
|
||||
|
||||
---------------------------
|
||||
Cross Section Configuration
|
||||
---------------------------
|
||||
|
|
@ -467,3 +490,4 @@ schemas.xml file in your own OpenMC source directory.
|
|||
.. _GNU Emacs: http://www.gnu.org/software/emacs/
|
||||
.. _validation: http://en.wikipedia.org/wiki/XML_validation
|
||||
.. _RELAX NG: http://relaxng.org/
|
||||
.. _ctest: http://www.cmake.org/cmake/help/v2.8.12/ctest.html
|
||||
|
|
|
|||
|
|
@ -26,15 +26,18 @@ endif()
|
|||
# MPI for distributed-memory parallelism / HDF5 for binary output
|
||||
#===============================================================================
|
||||
|
||||
set(MPI_ENABLED FALSE)
|
||||
if($ENV{FC} MATCHES "mpi.*")
|
||||
message("-- Detected MPI wrapper: $ENV{FC}")
|
||||
add_definitions(-DMPI)
|
||||
set(MPI_ENABLED TRUE)
|
||||
elseif($ENV{FC} MATCHES "h5fc$")
|
||||
message("-- Detected HDF5 wrapper: $ENV{FC}")
|
||||
add_definitions(-DHDF5)
|
||||
elseif($ENV{FC} MATCHES "h5pfc$")
|
||||
message("-- Detected parallel HDF5 wrapper: $ENV{FC}")
|
||||
add_definitions(-DMPI -DHDF5)
|
||||
set(MPI_ENABLED TRUE)
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
|
|
@ -128,7 +131,9 @@ endif()
|
|||
# PETSc for CMFD functionality
|
||||
#===============================================================================
|
||||
|
||||
set (PETSC_ENABLED FALSE)
|
||||
if(petsc)
|
||||
set(PETSC_ENABLED TRUE)
|
||||
find_package(PETSc REQUIRED HINTS $ENV{PETSC_DIR}/conf)
|
||||
find_library(libpetsc petsc $ENV{PETSC_DIR}/lib)
|
||||
|
||||
|
|
@ -206,4 +211,49 @@ if(PYTHONINTERP_FOUND)
|
|||
install(CODE "execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} setup.py install --user
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/utils)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
# Regression tests
|
||||
#===============================================================================
|
||||
|
||||
# This allows mpi test to work
|
||||
enable_testing()
|
||||
|
||||
# Get a list of all the tests to run
|
||||
file(GLOB_RECURSE TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../tests/test_*.py)
|
||||
|
||||
# Check to see if PETSC is compiled for CMFD tests
|
||||
if (NOT ${PETSC_ENABLED})
|
||||
file(GLOB_RECURSE CMFD_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../tests/test_cmfd*.py)
|
||||
foreach(cmfd_test in ${CMFD_TESTS})
|
||||
list(REMOVE_ITEM TESTS ${cmfd_test})
|
||||
endforeach(cmfd_test)
|
||||
endif(NOT ${PETSC_ENABLED})
|
||||
|
||||
# Loop through all the tests
|
||||
foreach(test ${TESTS})
|
||||
|
||||
# Get test information
|
||||
get_filename_component(TEST_NAME ${test} NAME)
|
||||
get_filename_component(TEST_PATH ${test} PATH)
|
||||
|
||||
# Check serial/parallel
|
||||
if (${MPI_ENABLED})
|
||||
|
||||
# Preform a parallel test
|
||||
add_test(NAME ${TEST_NAME}
|
||||
WORKING_DIRECTORY ${TEST_PATH}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $<TARGET_FILE:openmc>
|
||||
--mpi_exec $ENV{MPI_DIR}/bin/mpiexec)
|
||||
|
||||
else(${MPI_ENABLED})
|
||||
|
||||
# Perform a serial test
|
||||
add_test(NAME ${TEST_NAME}
|
||||
WORKING_DIRECTORY ${TEST_PATH}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $<TARGET_FILE:openmc>)
|
||||
|
||||
endif(${MPI_ENABLED})
|
||||
|
||||
endforeach(test)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ clean:
|
|||
make -s -C build clean
|
||||
distclean:
|
||||
rm -fr build
|
||||
test:
|
||||
make -s -C build test
|
||||
install:
|
||||
make -s -C build install
|
||||
|
||||
.PHONY: all clean distclean install
|
||||
.PHONY: all clean distclean test install
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
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
|
||||
|
|
@ -4,29 +4,41 @@ OpenMC Test Suite
|
|||
|
||||
The purpose of this test suite is to ensure that OpenMC compiles using various
|
||||
combinations of compiler flags and options and that all user input options can
|
||||
be used successfully without breaking the code. The test suite is by no means
|
||||
complete and should not be viewed as a comprehensive unit test suite will full
|
||||
coverage. Until more effort can be put into actual unit testing, this suite is a
|
||||
simple means of making sure that new features added into the code don't break
|
||||
existing features.
|
||||
be used successfully without breaking the code. The test suite is based on
|
||||
regression or integrated testing where different types of input files are
|
||||
configured and the full OpenMC code is executed. Results from simulations
|
||||
are compared with expected results. The test suite is comprised of many
|
||||
build configurations (e.g. debug, mpi, hdf5) and the actual tests which
|
||||
reside in sub-directories in the tests directory.
|
||||
|
||||
The test suite is designed to run with the third-party Python package
|
||||
nose_. Running the test suite is as simple as going to the tests/ directory and
|
||||
running:
|
||||
The test suite is designed to integrate with cmake using ctest_. To run the
|
||||
full test suite run:
|
||||
|
||||
.. sh::
|
||||
nosetests
|
||||
.. code-block:: sh
|
||||
|
||||
However, usually testing is split into two parts: compilation and running. To
|
||||
run the compilation tests, use:
|
||||
python run_tests.py
|
||||
|
||||
.. sh::
|
||||
nosetests test_compile
|
||||
A subset of build configurations and/or tests can be run. To see how to use
|
||||
the script run:
|
||||
|
||||
Then, to run all the normal tests (which require that an OpenMC executable is
|
||||
already built):
|
||||
.. code-block:: sh
|
||||
|
||||
.. sh::
|
||||
nosetests --exclude-dir=test_compile
|
||||
python run_tests.py --help
|
||||
|
||||
.. _nose: https://nose.readthedocs.org
|
||||
As an example, say we want to run all tests with debug flags only on tests
|
||||
that have cone and plot in their name. Also, we would like to run this on
|
||||
4 processors. We can run:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
python run_tests.py -j 4 -C debug -R "cone|plot"
|
||||
|
||||
Note that standard regular expression syntax is used for selecting build
|
||||
configurations and tests. To print out a list of build configurations, we
|
||||
can run:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
python run_tests.py -p
|
||||
|
||||
.. _ctest: http://www.cmake.org/cmake/help/v2.8.12/ctest.html
|
||||
|
|
|
|||
|
|
@ -3,158 +3,267 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import nose
|
||||
import glob
|
||||
import shutil
|
||||
from subprocess import call
|
||||
import re
|
||||
import sys
|
||||
from subprocess import call
|
||||
from collections import OrderedDict
|
||||
from optparse import OptionParser
|
||||
|
||||
from nose_mpi import NoseMPI
|
||||
parser = OptionParser()
|
||||
parser.add_option('-j', '--parallel', dest='n_procs',
|
||||
help="Number of parallel jobs.")
|
||||
parser.add_option('-R', '--tests-regex', dest='regex_tests',
|
||||
help="Run tests matching regular expression. \
|
||||
Test names are the directories present in tests folder.\
|
||||
This uses standard regex syntax to select tests.")
|
||||
parser.add_option('-C', '--build-config', dest='build_config',
|
||||
help="Build configurations matching regular expression. \
|
||||
Specific build configurations can be printed out with \
|
||||
optional argument -p, --print. This uses standard \
|
||||
regex syntax to select build configurations.")
|
||||
parser.add_option('-p', '--print', action="store_true",
|
||||
dest="print_build_configs", default=False,
|
||||
help="Print out build configurations.")
|
||||
(opts, args) = parser.parse_args()
|
||||
|
||||
# Default compiler paths
|
||||
FC='gfortran'
|
||||
MPI_DIR='/opt/mpich/3.1-gnu'
|
||||
HDF5_DIR='/opt/hdf5/1.8.12-gnu'
|
||||
PHDF5_DIR='/opt/phdf5/1.8.12-gnu'
|
||||
PETSC_DIR='/opt/petsc/3.4.4-gnu'
|
||||
|
||||
def run_compile():
|
||||
print('-'*17)
|
||||
print('Compilation tests')
|
||||
print('-'*17)
|
||||
# Override default compiler paths if environmental vars are found
|
||||
if 'FC' in os.environ:
|
||||
FC = os.environ['FC']
|
||||
if FC is not 'gfortran':
|
||||
print('NOTE: Test suite only verifed for gfortran compiler.')
|
||||
if 'MPI_DIR' in os.environ:
|
||||
MPI_DIR = os.environ['MPI_DIR']
|
||||
if 'HDF5_DIR' in os.environ:
|
||||
HDF5_DIR = os.environ['HDF5_DIR']
|
||||
if 'PHDF5_DIR' in os.environ:
|
||||
PHDF5_DIR = os.environ['PHDF5_DIR']
|
||||
if 'PETSC_DIR' in os.environ:
|
||||
PETSC_DIR = os.environ['PETSC_DIR']
|
||||
|
||||
# clean up all previous executables
|
||||
openmc_exe = glob.glob(pwd + '/../src/openmc*')
|
||||
for exe in openmc_exe:
|
||||
os.remove(exe)
|
||||
# Define test data structure
|
||||
tests = OrderedDict()
|
||||
|
||||
# run compile test
|
||||
result = nose.run(argv=['nosetests', 'test_compile'] + flags)
|
||||
if not result:
|
||||
print('Did not pass compile tests.')
|
||||
results.append(('compile', result))
|
||||
class Test(object):
|
||||
def __init__(self, debug=False, optimize=False, mpi=False, openmp=False,
|
||||
hdf5=False, petsc=False):
|
||||
self.debug = debug
|
||||
self.optimize = optimize
|
||||
self.mpi = mpi
|
||||
self.openmp = openmp
|
||||
self.hdf5 = hdf5
|
||||
self.petsc = petsc
|
||||
self.success = True
|
||||
self.msg = None
|
||||
self.setup_cmake()
|
||||
|
||||
def setup_cmake(self):
|
||||
# Default cmake
|
||||
self.cmake = ['cmake','-H../src','-Bbuild']
|
||||
|
||||
def run_suite(name=None, mpi=False):
|
||||
print('-'*(len(name) + 6))
|
||||
print(name + ' tests')
|
||||
print('-'*(len(name) + 6))
|
||||
|
||||
# Set arguments list. Note that the first argument is a dummy argument (the
|
||||
# script name). It's not actually recursively calling run_tests.py
|
||||
argv = ['nosetests', '--exclude', 'test_compile'] + flags
|
||||
|
||||
# Add MPI plugin if set
|
||||
if mpi:
|
||||
plugins = [NoseMPI()]
|
||||
argv += ['--mpi-np', '3', '--mpi-exec', mpiexec]
|
||||
else:
|
||||
plugins = None
|
||||
|
||||
try:
|
||||
os.chdir(pwd)
|
||||
shutil.copyfile(pwd + '/../src/openmc-' + name, pwd + '/../src/openmc')
|
||||
result = nose.run(argv=argv, addplugins=plugins)
|
||||
except OSError:
|
||||
result = False
|
||||
print('No OpenMC executable found for ' + name + ' tests')
|
||||
if not result:
|
||||
print('Did not pass ' + name + ' tests')
|
||||
results.append((name, result))
|
||||
|
||||
# set mpiexec path
|
||||
if 'COMPILER' in os.environ:
|
||||
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()
|
||||
sys.path.append(pwd)
|
||||
|
||||
# Set list of tests, either default or from command line
|
||||
flags = []
|
||||
tests = ['compile', 'normal', 'debug', 'optimize',
|
||||
'omp', 'omp-debug', 'omp-optimize',
|
||||
'hdf5', 'hdf5-debug', 'hdf5-optimize',
|
||||
'omp-hdf5', 'omp-hdf5-debug', 'omp-hdf5-optimize',
|
||||
'mpi', 'mpi-debug', 'mpi-optimize',
|
||||
'mpi-omp', 'mpi-omp-debug', 'mpi-omp-optimize',
|
||||
'phdf5', 'phdf5-debug', 'phdf5-optimize',
|
||||
'phdf5-omp', 'phdf5-omp-debug', 'phdf5-omp-optimize',
|
||||
'petsc', 'petsc-debug', 'petsc-optimize',
|
||||
'phdf5-petsc', 'phdf5-petsc-debug', 'phdf5-petsc-optimize',
|
||||
'omp-phdf5-petsc', 'omp-phdf5-petsc-debug',
|
||||
'omp-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('-')]
|
||||
|
||||
# Check for special subsets of tests
|
||||
tests__ = []
|
||||
for i in tests_:
|
||||
|
||||
# All tests will run all the tests except for compile unless
|
||||
# it is also specified on the command line. Note that specifying
|
||||
# compile all-tests is the same as not specifying any args
|
||||
if i == 'all-tests':
|
||||
tests__ = tests
|
||||
try:
|
||||
idx = tests_.index('compile') # check for compile test
|
||||
except ValueError:
|
||||
del tests__[0]
|
||||
finally:
|
||||
break # don't need to check for anything else
|
||||
|
||||
# This checks for any subsets of tests. The string after
|
||||
# all-XXXX will be used to search through all tests.
|
||||
# Specifying XXXX=normal will run tests that don't contain
|
||||
# debug or optimize substring.
|
||||
if i.startswith('all-'):
|
||||
suffix = i.split('all-')[1]
|
||||
if suffix == 'normal':
|
||||
for j in tests:
|
||||
if j.rfind('debug') == -1 and \
|
||||
j.rfind('optimize') == -1:
|
||||
tests__.append(j)
|
||||
else:
|
||||
for j in tests:
|
||||
if j.rfind(suffix) != -1:
|
||||
if suffix == 'omp' and j == 'compile':
|
||||
continue
|
||||
if j == 'compile':
|
||||
continue
|
||||
tests__.append(j)
|
||||
# Check for MPI/HDF5
|
||||
if self.mpi and not self.hdf5:
|
||||
self.fc = MPI_DIR+'/bin/mpif90'
|
||||
elif not self.mpi and self.hdf5:
|
||||
self.fc = HDF5_DIR+'/bin/h5fc'
|
||||
elif self.mpi and self.hdf5:
|
||||
self.fc = PHDF5_DIR+'/bin/h5pfc'
|
||||
else:
|
||||
tests__.append(i) # append specific test (e.g., mpi-debug)
|
||||
tests = tests__ if tests__ else tests
|
||||
self.fc = FC
|
||||
|
||||
# Run tests
|
||||
results = []
|
||||
for name in tests:
|
||||
if name == 'compile':
|
||||
run_compile()
|
||||
elif name in ['normal', 'debug', 'optimize',
|
||||
'hdf5', 'hdf5-debug', 'hdf5-optimize',
|
||||
'omp', 'omp-debug', 'omp-optimize',
|
||||
'omp-hdf5', 'omp-hdf5-debug', 'omp-hdf5-optimize']:
|
||||
run_suite(name=name)
|
||||
elif name in ['mpi', 'mpi-debug', 'mpi-optimize',
|
||||
'mpi-omp', 'mpi-omp-debug', 'mpi-omp-optimize',
|
||||
'phdf5', 'phdf5-debug', 'phdf5-optimize',
|
||||
'phdf5-omp', 'phdf5-omp-debug', 'phdf5-omp-optimize',
|
||||
'petsc', 'petsc-debug', 'petsc-optimize',
|
||||
'phdf5-petsc', 'phdf5-petsc-debug', 'phdf5-petsc-optimize',
|
||||
'omp-phdf5-petsc', 'omp-phdf5-petsc-debug',
|
||||
'omp-phdf5-petsc-optimize']:
|
||||
run_suite(name=name, mpi=True)
|
||||
# Set rest of options
|
||||
if self.debug:
|
||||
self.cmake.append('-Ddebug=on')
|
||||
if self.optimize:
|
||||
self.cmake.append('-Doptimize=on')
|
||||
if self.openmp:
|
||||
self.cmake.append('-Dopenmp=on')
|
||||
if self.petsc:
|
||||
self.cmake.append('-Dpetsc=on')
|
||||
os.environ['PETSC_DIR'] = PETSC_DIR
|
||||
if self.mpi:
|
||||
os.environ['MPI_DIR'] = MPI_DIR
|
||||
|
||||
# print out summary of results
|
||||
def run_cmake(self):
|
||||
os.environ['FC'] = self.fc
|
||||
rc = call(self.cmake)
|
||||
if rc != 0:
|
||||
self.success = False
|
||||
self.msg = 'Failed on cmake.'
|
||||
|
||||
def run_make(self):
|
||||
if not self.success:
|
||||
return
|
||||
|
||||
# Default make string
|
||||
make_list = ['make','-s']
|
||||
|
||||
# Check for parallel
|
||||
if opts.n_procs is not None:
|
||||
make_list.append('-j')
|
||||
make_list.append(opts.n_procs)
|
||||
|
||||
# Run make
|
||||
rc = call(make_list)
|
||||
if rc != 0:
|
||||
self.success = False
|
||||
self.msg = 'Failed on make.'
|
||||
|
||||
def run_ctests(self):
|
||||
if not self.success:
|
||||
return
|
||||
|
||||
# Default ctest string
|
||||
ctest_list = ['ctest']
|
||||
|
||||
# Check for parallel
|
||||
if opts.n_procs is not None:
|
||||
ctest_list.append('-j')
|
||||
ctest_list.append(opts.n_procs)
|
||||
|
||||
# Check for subset of tests
|
||||
if opts.regex_tests is not None:
|
||||
ctest_list.append('-R')
|
||||
ctest_list.append(opts.regex_tests)
|
||||
|
||||
# Run ctests
|
||||
rc = call(ctest_list)
|
||||
if rc != 0:
|
||||
self.success = False
|
||||
self.msg = 'Failed on testing.'
|
||||
|
||||
# Checks to see if file exists in PWD or PATH
|
||||
def check_compiler(self):
|
||||
result = False
|
||||
if os.path.isfile(self.fc):
|
||||
result = True
|
||||
for path in os.environ["PATH"].split(":"):
|
||||
if os.path.isfile(os.path.join(path, self.fc)):
|
||||
result = True
|
||||
if not result:
|
||||
raise Exception("Compiler path '{0}' does not exist."
|
||||
.format(self.fc)+
|
||||
"Please set appropriate environmental variable(s).")
|
||||
|
||||
def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\
|
||||
hdf5=False, petsc=False):
|
||||
tests.update({name:Test(debug, optimize, mpi, openmp, hdf5, petsc)})
|
||||
|
||||
# List of tests
|
||||
add_test('basic-normal')
|
||||
add_test('basic-debug', debug=True)
|
||||
add_test('basic-optimize', optimize=True)
|
||||
add_test('omp-normal', openmp=True)
|
||||
add_test('omp-debug', openmp=True, debug=True)
|
||||
add_test('omp-optimize', openmp=True, optimize=True)
|
||||
add_test('hdf5-normal', hdf5=True)
|
||||
add_test('hdf5-debug', hdf5=True, debug=True)
|
||||
add_test('hdf5-optimize', hdf5=True, optimize=True)
|
||||
add_test('omp-hdf5-normal', openmp=True, hdf5=True)
|
||||
add_test('omp-hdf5-debug', openmp=True, hdf5=True, debug=True)
|
||||
add_test('omp-hdf5-optimize', openmp=True, hdf5=True, optimize=True)
|
||||
add_test('mpi-normal', mpi=True)
|
||||
add_test('mpi-debug', mpi=True, debug=True)
|
||||
add_test('mpi-optimize', mpi=True, optimize=True)
|
||||
add_test('mpi-omp-normal', mpi=True, openmp=True)
|
||||
add_test('mpi-omp-debug', mpi=True, openmp=True, debug=True)
|
||||
add_test('mpi-omp-optimize', mpi=True, openmp=True, optimize=True)
|
||||
add_test('phdf5-normal', mpi=True, hdf5=True)
|
||||
add_test('phdf5-debug', mpi=True, hdf5=True, debug=True)
|
||||
add_test('phdf5-optimize', mpi=True, hdf5=True, optimize=True)
|
||||
add_test('phdf5-omp-normal', mpi=True, hdf5=True, openmp=True)
|
||||
add_test('phdf5-omp-debug', mpi=True, hdf5=True, openmp=True, debug=True)
|
||||
add_test('phdf5-omp-optimize', mpi=True, hdf5=True, openmp=True, optimize=True)
|
||||
add_test('petsc-normal', petsc=True, mpi=True)
|
||||
add_test('petsc-debug', petsc=True, mpi=True, debug=True)
|
||||
add_test('petsc-optimize', petsc=True, mpi=True, optimize=True)
|
||||
add_test('phdf5-petsc-normal', mpi=True, hdf5=True, petsc=True)
|
||||
add_test('phdf5-petsc-debug', mpi=True, hdf5=True, petsc=True, debug=True)
|
||||
add_test('phdf5-petsc-optimize', mpi=True, hdf5=True, petsc=True, optimize=True)
|
||||
add_test('omp-phdf5-petsc-normal', openmp=True, mpi=True, hdf5=True, petsc=True)
|
||||
add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True,
|
||||
debug=True)
|
||||
add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True,
|
||||
optimize=True)
|
||||
|
||||
# Check to see if we are to just print build configuratinos
|
||||
if opts.print_build_configs:
|
||||
for key in tests:
|
||||
print('Configuration Name: {0}'.format(key))
|
||||
print(' Debug Flags:..........{0}'.format(tests[key].debug))
|
||||
print(' Optimization Flags:...{0}'.format(tests[key].optimize))
|
||||
print(' HDF5 Active:..........{0}'.format(tests[key].hdf5))
|
||||
print(' MPI Active:...........{0}'.format(tests[key].mpi))
|
||||
print(' OpenMP Active:........{0}'.format(tests[key].openmp))
|
||||
print(' PETSc Active:.........{0}\n'.format(tests[key].petsc))
|
||||
exit()
|
||||
|
||||
# Delete items of dictionary that don't match regular expression
|
||||
if opts.build_config is not None:
|
||||
for key in tests:
|
||||
if not re.search(opts.build_config, key):
|
||||
del tests[key]
|
||||
|
||||
# Begin testing
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
for test in tests:
|
||||
print('-'*(len(test) + 6))
|
||||
print(test + ' tests')
|
||||
print('-'*(len(test) + 6))
|
||||
sys.stdout.flush()
|
||||
|
||||
# Verify fortran compiler exists
|
||||
tests[test].check_compiler()
|
||||
|
||||
# Run CMAKE to configure build
|
||||
tests[test].run_cmake()
|
||||
|
||||
# Go into build directory
|
||||
os.chdir('build')
|
||||
|
||||
# Build OpenMC
|
||||
tests[test].run_make()
|
||||
|
||||
# Run tests
|
||||
tests[test].run_ctests()
|
||||
|
||||
# Leave build directory
|
||||
os.chdir('..')
|
||||
|
||||
# Copy test log file if failed
|
||||
if tests[test].msg == 'Failed on testing.':
|
||||
shutil.copy('build/Testing/Temporary/LastTest.log',
|
||||
'LastTest_{0}.log'.format(test))
|
||||
|
||||
# Clean up build
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
|
||||
# Print out summary of results
|
||||
print('\n' + '='*54)
|
||||
print('Summary of Compilation Option Testing:\n')
|
||||
|
||||
OK = '\033[92m'
|
||||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
for name, result in results:
|
||||
print(name + '.'*(50 - len(name)), end='')
|
||||
if result:
|
||||
if sys.stdout.isatty():
|
||||
OK = '\033[92m'
|
||||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
else:
|
||||
OK = ''
|
||||
FAIL = ''
|
||||
ENDC = ''
|
||||
BOLD = ''
|
||||
|
||||
for test in tests:
|
||||
print(test + '.'*(50 - len(test)), end='')
|
||||
if tests[test].success:
|
||||
print(BOLD + OK + '[OK]' + ENDC)
|
||||
else:
|
||||
print(BOLD + FAIL + '[FAILED]' + ENDC)
|
||||
print(' '*len(test)+tests[test].msg)
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -4,70 +4,62 @@ import os
|
|||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
from nose.plugins.skip import SkipTest
|
||||
|
||||
from nose_mpi import NoseMPI
|
||||
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
skipAll = False
|
||||
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
global skipAll
|
||||
skipAll = False
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
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)
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
output = proc.communicate()[0]
|
||||
print(output)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
if 'CMFD is not available' in output:
|
||||
global skipAll
|
||||
skipAll = True
|
||||
raise SkipTest
|
||||
assert returncode == 0
|
||||
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
statepoint = glob.glob(pwd + '/statepoint.20.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
|
||||
def test_output_exists():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
|
||||
def test_results():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
statepoint = glob.glob(pwd + '/statepoint.20.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.20.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -4,70 +4,63 @@ import os
|
|||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
from nose.plugins.skip import SkipTest
|
||||
|
||||
from nose_mpi import NoseMPI
|
||||
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
skipAll = False
|
||||
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
global skipAll
|
||||
skipAll = False
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
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)
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
output = proc.communicate()[0]
|
||||
print(output)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
if 'CMFD is not available' in output:
|
||||
global skipAll
|
||||
skipAll = True
|
||||
raise SkipTest
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
def test_created_statepoint():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
statepoint = glob.glob(pwd + '/statepoint.20.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
|
||||
def test_output_exists():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
|
||||
def test_results():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
statepoint = glob.glob(pwd + '/statepoint.20.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.20.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -4,69 +4,63 @@ import os
|
|||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
from nose.plugins.skip import SkipTest
|
||||
|
||||
from nose_mpi import NoseMPI
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
skipAll = False
|
||||
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
global skipAll
|
||||
skipAll = False
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
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)
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
output = proc.communicate()[0]
|
||||
print(output)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
if 'CMFD is not available' in output:
|
||||
global skipAll
|
||||
skipAll = True
|
||||
raise SkipTest
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
def test_created_statepoint():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
statepoint = glob.glob(pwd + '/statepoint.20.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
|
||||
def test_output_exists():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
|
||||
def test_results():
|
||||
if skipAll:
|
||||
raise SkipTest
|
||||
statepoint = glob.glob(pwd + '/statepoint.20.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.20.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -1,360 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""Compilation tests
|
||||
|
||||
This set of tests makes sure that OpenMC can compile for many different
|
||||
combinations of compilation flags and options. By default, only the gfortran
|
||||
and ifort compilers are tested. This requires that the MPI, HDF5, and PETSC
|
||||
libraries are already set up appropriately in the Makefile.
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
import shutil
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
# Set default copmilers
|
||||
fc = 'gfortran'
|
||||
h5fc = 'h5fc'
|
||||
h5pfc = 'h5pfc'
|
||||
mpifc = 'mpif90'
|
||||
|
||||
|
||||
def setup():
|
||||
# Change to source directory
|
||||
os.chdir(pwd + '/../../src')
|
||||
|
||||
|
||||
def test_normal():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -H. -Bbuild'.format(fc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-normal')
|
||||
|
||||
|
||||
def test_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Ddebug=on -H. -Bbuild'.format(fc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-debug')
|
||||
|
||||
|
||||
def test_profile():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dprofile=on -H. -Bbuild'.format(fc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-profile')
|
||||
|
||||
|
||||
def test_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Doptimize=on -H. -Bbuild'.format(fc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-optimize')
|
||||
|
||||
|
||||
def test_mpi():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -H. -Bbuild'.format(mpifc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-mpi')
|
||||
|
||||
|
||||
def test_mpi_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Ddebug=on -H. -Bbuild'.format(mpifc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-mpi-debug')
|
||||
|
||||
|
||||
def test_mpi_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Doptimize=on -H. -Bbuild'.format(mpifc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-mpi-optimize')
|
||||
|
||||
|
||||
def test_omp():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -H. -Bbuild'.format(fc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-omp')
|
||||
|
||||
|
||||
def test_omp_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -Ddebug=on '.format(fc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-omp-debug')
|
||||
|
||||
|
||||
def test_omp_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -Doptimize=on '.format(fc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-omp-optimize')
|
||||
|
||||
|
||||
def test_hdf5():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -H. -Bbuild'.format(h5fc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-hdf5')
|
||||
|
||||
|
||||
def test_hdf5_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Ddebug=on -H. -Bbuild'.format(h5fc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-hdf5-debug')
|
||||
|
||||
|
||||
def test_hdf5_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Doptimize=on -H. -Bbuild'.format(h5fc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-hdf5-optimize')
|
||||
|
||||
|
||||
def test_omp_hdf5():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -H. -Bbuild'.format(h5fc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-omp-hdf5')
|
||||
|
||||
|
||||
def test_omp_hdf5_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -Ddebug=on '.format(h5fc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-omp-hdf5-debug')
|
||||
|
||||
|
||||
def test_omp_hdf5_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -Doptimize=on '.format(h5fc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-omp-hdf5-optimize')
|
||||
|
||||
|
||||
def test_petsc():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dpetsc=on -H. -Bbuild'.format(mpifc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-petsc')
|
||||
|
||||
|
||||
def test_petsc_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dpetsc=on -Ddebug=on '.format(mpifc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-petsc-debug')
|
||||
|
||||
|
||||
def test_petsc_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dpetsc=on -Doptimize=on '.format(mpifc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-petsc-optimize')
|
||||
|
||||
|
||||
def test_mpi_omp():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -H. -Bbuild'.format(mpifc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-mpi-omp')
|
||||
|
||||
|
||||
def test_mpi_omp_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -Ddebug=on '.format(mpifc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-mpi-omp-debug')
|
||||
|
||||
|
||||
def test_mpi_omp_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -Doptimize=on '.format(mpifc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-mpi-omp-optimize')
|
||||
|
||||
|
||||
def test_mpi_hdf5():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -H. -Bbuild'.format(h5pfc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-phdf5')
|
||||
|
||||
|
||||
def test_mpi_hdf5_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Ddebug=on -H. -Bbuild'.format(h5pfc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-phdf5-debug')
|
||||
|
||||
|
||||
def test_mpi_hdf5_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Doptimize=on -H. -Bbuild'.format(h5pfc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-phdf5-optimize')
|
||||
|
||||
|
||||
def test_mpi_omp_hdf5():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -H. -Bbuild'.format(h5pfc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-phdf5-omp')
|
||||
|
||||
|
||||
def test_mpi_omp_hdf5_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -Ddebug=on '.format(h5pfc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-phdf5-omp-debug')
|
||||
|
||||
|
||||
def test_mpi_omp_hdf5_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dopenmp=on -Doptimize=on '.format(h5pfc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-phdf5-omp-optimize')
|
||||
|
||||
|
||||
def test_mpi_hdf5_petsc():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dpetsc=on -H. -Bbuild'.format(h5pfc))
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-phdf5-petsc')
|
||||
|
||||
|
||||
def test_mpi_hdf5_petsc_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dpetsc=on -Ddebug=on '.format(h5pfc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-phdf5-petsc-debug')
|
||||
|
||||
|
||||
def test_mpi_hdf5_petsc_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dpetsc=on -Doptimize=on '.format(h5pfc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-phdf5-petsc-optimize')
|
||||
|
||||
|
||||
def test_mpi_omp_hdf5_petsc():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dpetsc=on -Dopenmp=on '.format(h5pfc) +
|
||||
'-H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-omp-phdf5-petsc')
|
||||
|
||||
|
||||
def test_mpi_omp_hdf5_petsc_debug():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dpetsc=on -Dopenmp=on '.format(h5pfc) +
|
||||
'-Ddebug=on -H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-omp-phdf5-petsc-debug')
|
||||
|
||||
|
||||
def test_mpi_omp_hdf5_petsc_optimize():
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
returncode = run('FC={0} cmake -Dpetsc=on -Dopenmp=on '.format(h5pfc) +
|
||||
'-Doptimize=on -H. -Bbuild')
|
||||
assert returncode == 0
|
||||
returncode = run('make -s -C build')
|
||||
assert returncode == 0
|
||||
shutil.move('build/bin/openmc', 'openmc-omp-phdf5-petsc-optimize')
|
||||
|
||||
|
||||
def run(commands):
|
||||
proc = Popen(commands, shell=True, stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
return returncode
|
||||
|
||||
|
||||
def teardown(commands):
|
||||
shutil.rmtree('build', ignore_errors=True)
|
||||
shutil.copy('openmc-normal', 'openmc')
|
||||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_created_output():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_created_output()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob('statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,30 +3,31 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob('statepoint.10.*')
|
||||
|
|
@ -34,11 +35,23 @@ def test_results():
|
|||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.7.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,56 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,57 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,52 +3,69 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_summary_exists():
|
||||
summary = glob.glob(pwd + '/summary.*')
|
||||
assert len(summary) == 1
|
||||
assert summary[0].endswith('out') or summary[0].endswith('h5')
|
||||
summary = glob.glob(os.path.join(cwd, 'summary.*'))
|
||||
assert len(summary) == 1, 'Either multiple or no summary file exists.'
|
||||
assert summary[0].endswith('out') or summary[0].endswith('h5'),\
|
||||
'Summary file is not a binary or hdf5 file.'
|
||||
|
||||
def test_cross_sections_exists():
|
||||
assert os.path.exists(pwd + '/cross_sections.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'cross_sections.out')),\
|
||||
'Cross section output file does not exist.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*') + glob.glob(pwd + '/summary.*')
|
||||
output.append(pwd + '/summary.out')
|
||||
output.append(pwd + '/cross_sections.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*')) + glob.glob(os.path.join(cwd, 'summary.*'))
|
||||
output.append(os.path.join(cwd, 'summary.out'))
|
||||
output.append(os.path.join(cwd, 'cross_sections.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_summary_exists()
|
||||
test_cross_sections_exists()
|
||||
test_statepoint_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,50 +3,63 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
stderr=PIPE, stdout=PIPE)
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=PIPE, stdout=PIPE)
|
||||
stdout, stderr = proc.communicate()
|
||||
assert stderr != ''
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_restart():
|
||||
particle = glob.glob(pwd + '/particle_10_394.*')
|
||||
assert len(particle) == 1
|
||||
particle = glob.glob(os.path.join(cwd, 'particle_10_394.*'))
|
||||
assert len(particle) == 1, 'Either multiple or no particle restart files exist.'
|
||||
assert particle[0].endswith('binary') or \
|
||||
particle[0].endswith('h5')
|
||||
particle[0].endswith('h5'), 'Particle restart file not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
particle = glob.glob(pwd + '/particle_10_394.*')
|
||||
particle = glob.glob(os.path.join(cwd, 'particle_10_394.*'))
|
||||
call(['python', 'results.py', particle[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def test_run_restart():
|
||||
particle = glob.glob(pwd + '/particle_10_394.*')
|
||||
proc = Popen([pwd + '/../../src/openmc -r ' + particle[0]],
|
||||
stderr=PIPE, stdout=PIPE, shell=True)
|
||||
particle = glob.glob(os.path.join(cwd, 'particle_10_394.*'))
|
||||
proc = Popen([opts.exe, '-r', particle[0], cwd], stderr=PIPE, stdout=PIPE)
|
||||
stdout, stderr = proc.communicate()
|
||||
assert stderr == ''
|
||||
assert stderr == '', 'Particle restart not successful.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.*') + \
|
||||
glob.glob(pwd + '/particle_*') + \
|
||||
[pwd + '/results_test.dat']
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.*')) + \
|
||||
glob.glob(os.path.join(cwd, 'particle_*')) + \
|
||||
[os.path.join(cwd, 'results_test.dat')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_restart()
|
||||
test_results()
|
||||
test_run_restart()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -2,30 +2,41 @@
|
|||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from nose_mpi import NoseMPI
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, '-p'],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, '-p', cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '-p'], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '-p', cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_plot_exists():
|
||||
assert os.path.exists(pwd + '/1_plot.ppm')
|
||||
assert os.path.exists(os.path.join(cwd ,'1_plot.ppm')), 'Plot ppm file does not exist.'
|
||||
|
||||
def teardown():
|
||||
output = [pwd + '/1_plot.ppm']
|
||||
output = [os.path.join(cwd ,'1_plot.ppm')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_plot_exists()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -2,32 +2,43 @@
|
|||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from nose_mpi import NoseMPI
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, '-p'],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, '-p', cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '-p'], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '-p', cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_plots_exists():
|
||||
assert os.path.exists(pwd + '/1_plot.ppm')
|
||||
assert os.path.exists(pwd + '/2_plot.ppm')
|
||||
assert os.path.exists(pwd + '/3_plot.ppm')
|
||||
assert os.path.exists(os.path.join(cwd ,'1_plot.ppm')), 'Plot 1 result does not exist.'
|
||||
assert os.path.exists(os.path.join(cwd ,'2_plot.ppm')), 'Plot 2 result does not exist.'
|
||||
assert os.path.exists(os.path.join(cwd ,'3_plot.ppm')), 'Plot 3 result does not exist.'
|
||||
|
||||
def teardown():
|
||||
output = [pwd + '/1_plot.ppm', pwd + '/2_plot.ppm', pwd + '/3_plot.ppm']
|
||||
output = [os.path.join(cwd ,'1_plot.ppm'), os.path.join(cwd ,'2_plot.ppm'), os.path.join(cwd ,'3_plot.ppm')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_plots_exists()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -2,30 +2,41 @@
|
|||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from nose_mpi import NoseMPI
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, '-p'],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, '-p', cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '-p'], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '-p', cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_plot_exists():
|
||||
assert os.path.exists(pwd + '/1_plot.ppm')
|
||||
assert os.path.exists(os.path.join(cwd ,'1_plot.ppm')), 'Plot ppm file does not exist.'
|
||||
|
||||
def teardown():
|
||||
output = [pwd + '/1_plot.ppm']
|
||||
output = [os.path.join(cwd ,'1_plot.ppm')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_plot_exists()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -2,32 +2,43 @@
|
|||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from nose_mpi import NoseMPI
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path, '-p'],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, '-p', cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '-p'], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '-p', cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_plots_exists():
|
||||
assert os.path.exists(pwd + '/1_plot.ppm')
|
||||
assert os.path.exists(pwd + '/2_plot.ppm')
|
||||
assert os.path.exists(pwd + '/3_plot.ppm')
|
||||
assert os.path.exists(os.path.join(cwd ,'1_plot.ppm')), 'Plot 1 result does not exist.'
|
||||
assert os.path.exists(os.path.join(cwd ,'2_plot.ppm')), 'Plot 2 result does not exist.'
|
||||
assert os.path.exists(os.path.join(cwd ,'3_plot.ppm')), 'Plot 3 result does not exist.'
|
||||
|
||||
def teardown():
|
||||
output = [pwd + '/1_plot.ppm', pwd + '/2_plot.ppm', pwd + '/3_plot.ppm']
|
||||
output = [os.path.join(cwd ,'1_plot.ppm'), os.path.join(cwd ,'2_plot.ppm'), os.path.join(cwd ,'3_plot.ppm')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_plots_exists()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,47 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,10 +3,15 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
settings1="""<?xml version="1.0"?>
|
||||
<settings>
|
||||
|
|
@ -45,57 +50,67 @@ settings2 = """<?xml version="1.0"?>
|
|||
</settings>
|
||||
"""
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
|
||||
def test_run1():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
source = glob.glob(pwd + '/source.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
source = glob.glob(os.path.join(cwd, 'source.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multple or no source files exist.'
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5'),\
|
||||
'Source file is not a binary or hdf5 file.'
|
||||
|
||||
def test_run2():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
source = glob.glob(pwd + '/source.10.*')
|
||||
openmc_path = os.path.join(cwd, '../../src/openmc')
|
||||
source = glob.glob(os.path.join(cwd, 'source.10.*'))
|
||||
with open('settings.xml','w') as fh:
|
||||
fh.write(settings2.format(source[0].split('.')[2]))
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
with open('settings.xml','w') as fh:
|
||||
fh.write(settings1)
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output += glob.glob(pwd + '/source.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output += glob.glob(os.path.join(cwd, 'source.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run1()
|
||||
test_statepoint_exists()
|
||||
test_run2()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.*')
|
||||
assert len(statepoint) == 5
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.*'))
|
||||
assert len(statepoint) == 5, '5 statepoint files must exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file detected that is not binary or hdf5.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.8.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.8.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do no agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_statepoint_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.*')
|
||||
assert len(statepoint) == 5
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.*'))
|
||||
assert len(statepoint) == 5, '5 statepoint files must exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file detected that is not binary or hdf5.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.8.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.8.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_statepoint_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
source = glob.glob(pwd + '/source.*')
|
||||
assert len(source) == 1
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint file exists.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
source = glob.glob(os.path.join(cwd, 'source.*'))
|
||||
assert len(source) == 1, 'Either multple or no source file exists.'
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5'),\
|
||||
'Source file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output += glob.glob(pwd + '/source.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output += glob.glob(os.path.join(cwd, 'source.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_statepoint_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,127 +3,146 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.*')
|
||||
assert len(statepoint) == 2
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
sourcepoint = glob.glob(pwd + '/source.7.*')
|
||||
assert len(sourcepoint) == 1
|
||||
assert sourcepoint[0].endswith('binary') or sourcepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.*'))
|
||||
assert len(statepoint) == 2, '2 statepoint files must exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file must either be binary or hdf5.'
|
||||
sourcepoint = glob.glob(os.path.join(cwd, 'source.7.*'))
|
||||
assert len(sourcepoint) == 1, 'Either multiple or no source files found.'
|
||||
assert sourcepoint[0].endswith('binary') or sourcepoint[0].endswith('h5'),\
|
||||
'Source file must either be binary or hdf5.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
os.remove(statepoint[0])
|
||||
|
||||
def test_restart_form1():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
sourcepoint = glob.glob(pwd + '/source.7.*')
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
|
||||
'-r', statepoint[0], sourcepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
sourcepoint = glob.glob(os.path.join(cwd, 'source.7.*'))
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe,
|
||||
'-r', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '-r', statepoint[0], sourcepoint[0]], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '-r', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC restart 1 did not exit successfully.'
|
||||
|
||||
def test_created_statepoint_form1():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Batch 10 statepoint file does not exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file must be a binary or hdf5 file.'
|
||||
|
||||
def test_results_form1():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Restart 1 results do not agree.'
|
||||
os.remove(statepoint[0])
|
||||
|
||||
def test_restart_form2():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
sourcepoint = glob.glob(pwd + '/source.7.*')
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
|
||||
'--restart', statepoint[0], sourcepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
sourcepoint = glob.glob(os.path.join(cwd, 'source.7.*'))
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe,
|
||||
'--restart', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '--restart', statepoint[0], sourcepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '--restart', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC restart 2 did not exit successfully.'
|
||||
|
||||
def test_created_statepoint_form2():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Batch 10 statepoint file does not exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file not a binary or hdf5 file.'
|
||||
|
||||
def test_results_form2():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Restart 2 results do not agree.'
|
||||
os.remove(statepoint[0])
|
||||
|
||||
def test_restart_serial():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
sourcepoint = glob.glob(pwd + '/source.7.*')
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
proc = Popen([openmc_path, '--restart', statepoint[0], sourcepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
sourcepoint = glob.glob(os.path.join(cwd, 'source.7.*'))
|
||||
proc = Popen([opts.exe, '--restart', statepoint[0], sourcepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC restart serial did not exit successfully.'
|
||||
|
||||
def test_created_statepoint_serial():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Batch 10 statepoint file does not exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results_serial():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Serial results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.*')
|
||||
output += glob.glob(pwd + '/source.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.*'))
|
||||
output += glob.glob(os.path.join(cwd, 'source.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
test_restart_form1()
|
||||
test_created_statepoint_form1()
|
||||
test_results_form1()
|
||||
test_restart_form2()
|
||||
test_created_statepoint_form2()
|
||||
test_results_form2()
|
||||
test_restart_serial()
|
||||
test_created_statepoint_serial()
|
||||
test_results_serial()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,48 +3,63 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoints_exist():
|
||||
statepoint = glob.glob(pwd + '/statepoint.3.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(pwd + '/statepoint.6.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(pwd + '/statepoint.9.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.3.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint.3 files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint.3 file is not a binary or hdf5 file.'
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.6.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint.6 files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint.6 file is not a binary or hdf5 file.'
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.9.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint.9 files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint.9 file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.9.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.9.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_statepoints_exist()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -4,54 +4,71 @@ import os
|
|||
import glob
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoints_exist():
|
||||
statepoint = glob.glob(pwd + '/statepoint.2.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(pwd + '/statepoint.4.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(pwd + '/statepoint.6.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(pwd + '/statepoint.8.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.2.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint.2 files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint.2 file is not a binary or hdf5 file.'
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.4.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint.4 files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint.4 file is not a binary or hdf5 file.'
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.6.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint.6 files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint.6 file is not a binary or hdf5 file.'
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.8.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint.8 files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint.8 file is not a binary or hdf5 file.'
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint.10 files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint.10 file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_statepoints_exist()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,118 +3,135 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Initial test results do not agree.'
|
||||
|
||||
def test_restart_form1():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
|
||||
'-r', statepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe,
|
||||
'-r', statepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '-r', statepoint[0]], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '-r', statepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC restart 1 did not exit successfully.'
|
||||
|
||||
def test_created_statepoint_form1():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results_form1():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Restart 1 test results do not agree.'
|
||||
|
||||
def test_restart_form2():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
|
||||
'--restart', statepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe,
|
||||
'--restart', statepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path, '--restart', statepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, '--restart', statepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC restart 2 did not exit successfully.'
|
||||
|
||||
def test_created_statepoint_form2():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results_form2():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Restart 2 test results do not agree.'
|
||||
|
||||
def test_restart_serial():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
proc = Popen([openmc_path, '--restart', statepoint[0]],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
proc = Popen([opts.exe, '--restart', statepoint[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC restart serial did not exit successfully.'
|
||||
|
||||
def test_created_statepoint_serial():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results_serial():
|
||||
statepoint = glob.glob(pwd + '/statepoint.7.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
|
||||
assert compare, 'Restart serial test results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.7.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
test_restart_form1()
|
||||
test_created_statepoint_form1()
|
||||
test_results_form1()
|
||||
test_restart_form2()
|
||||
test_created_statepoint_form2()
|
||||
test_results_form2()
|
||||
test_restart_serial()
|
||||
test_created_statepoint_serial()
|
||||
test_results_serial()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
source = glob.glob(pwd + '/source.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
source = glob.glob(os.path.join(cwd, 'source.10.*'))
|
||||
assert len(source) == 1, 'Either multiple or no source files exist.'
|
||||
assert source[0].endswith('binary') or source[0].endswith('h5'),\
|
||||
'Source file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output += glob.glob(pwd + '/source.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output += glob.glob(os.path.join(cwd, 'source.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_statepoint_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,46 +3,60 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/tallies.out')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,44 +3,57 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
stdout = proc.communicate()[0]
|
||||
print(stdout)
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
assert stdout.find('Simulating Particle 453') != -1
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -4,38 +4,32 @@ import os
|
|||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
from nose.plugins.skip import SkipTest
|
||||
|
||||
from nose_mpi import NoseMPI
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
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)
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
returncode = proc.wait()
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
assert returncode == 0
|
||||
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_outputs():
|
||||
outputs = [glob.glob(''.join((pwd, '/track_1_1_1.*')))]
|
||||
outputs.append(glob.glob(''.join((pwd, '/track_1_1_2.*'))))
|
||||
outputs = [glob.glob(''.join((cwd, '/track_1_1_1.*')))]
|
||||
outputs.append(glob.glob(''.join((cwd, '/track_1_1_2.*'))))
|
||||
for files in outputs:
|
||||
assert len(files) == 1
|
||||
assert files[0].endswith('binary') or files[0].endswith('h5')
|
||||
|
||||
assert len(files) == 1, 'Multiple or no track files detected.'
|
||||
assert files[0].endswith('binary') or files[0].endswith('h5'),\
|
||||
'Track files not a binary or hdf5 file'
|
||||
|
||||
def test_outputs():
|
||||
# If vtk python module is not available, we can't run track.py so skip this
|
||||
|
|
@ -43,23 +37,35 @@ def test_outputs():
|
|||
try:
|
||||
import vtk
|
||||
except ImportError:
|
||||
raise SkipTest
|
||||
print('----------------Skipping test-------------')
|
||||
return
|
||||
|
||||
call(['../../src/utils/track.py', '-o', 'poly'] +
|
||||
glob.glob(''.join((pwd, '/track*'))))
|
||||
poly = ''.join((pwd, '/poly.pvtp'))
|
||||
assert os.path.isfile(poly)
|
||||
metric = ''.join((pwd, '/true_poly.pvtp'))
|
||||
glob.glob(''.join((cwd, '/track*'))))
|
||||
poly = ''.join((cwd, '/poly.pvtp'))
|
||||
assert os.path.isfile(poly), 'poly.pvtp file not found.'
|
||||
metric = ''.join((cwd, '/true_poly.pvtp'))
|
||||
compare = filecmp.cmp(poly, metric)
|
||||
if not compare:
|
||||
os.rename('poly.pvtp', 'error_poly.pvtp')
|
||||
assert compare
|
||||
|
||||
assert compare, 'Results to not agree'
|
||||
|
||||
def teardown():
|
||||
temp_files = glob.glob(''.join((pwd, '/statepoint*')))
|
||||
temp_files = temp_files + glob.glob(''.join((pwd, '/track*')))
|
||||
temp_files = temp_files + glob.glob(''.join((pwd, '/poly*')))
|
||||
temp_files = glob.glob(''.join((cwd, '/statepoint*')))
|
||||
temp_files = temp_files + glob.glob(''.join((cwd, '/track*')))
|
||||
temp_files = temp_files + glob.glob(''.join((cwd, '/poly*')))
|
||||
for f in temp_files:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_outputs()
|
||||
test_outputs()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -3,42 +3,55 @@
|
|||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
from nose_mpi import NoseMPI
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
openmc_path = pwd + '/../../src/openmc'
|
||||
if int(NoseMPI.mpi_np) > 0:
|
||||
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
assert len(statepoint) == 1
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(pwd + '/statepoint.10.*')
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.10.*')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
|
|
|
|||
|
|
@ -1,30 +1,48 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
from subprocess import Popen, call, STDOUT, PIPE
|
||||
from glob import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--exe', dest='exe',
|
||||
help="Path to openmc executable with basic \
|
||||
configuration options (no HDF5, no MPI, etc.)")
|
||||
parser.add_option('-R', '--tests-regex', dest='regex_tests',
|
||||
help="Run tests matching regular expression. \
|
||||
Test names are the directories present in tests folder.\
|
||||
This uses standard regex syntax to select tests.")
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
# Terminal color configurations
|
||||
OKGREEN = '\033[92m'
|
||||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
|
||||
# Check for arguments
|
||||
if len(sys.argv) > 1:
|
||||
folders = []
|
||||
for i in range(len(sys.argv)):
|
||||
if i == 0:
|
||||
continue
|
||||
folders.append(sys.argv[i])
|
||||
# Check for valid executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Need to specify an OpenMC executable')
|
||||
else:
|
||||
folders = glob('test_*')
|
||||
openmc_exe = os.path.abspath(opts.exe)
|
||||
|
||||
# Get a list of all test folders
|
||||
folders = glob('test_*')
|
||||
|
||||
# Check to see if a subset of tests is specified on command line
|
||||
if opts.regex_tests is not None:
|
||||
folders = [item for item in folders if re.search(opts.regex_tests, item)]
|
||||
|
||||
# Loop around directories
|
||||
for adir in sorted(folders):
|
||||
|
||||
# Skip test compile or plot
|
||||
if adir == 'test_compile' or adir.find('plot') != -1:
|
||||
if adir.find('plot') != -1:
|
||||
continue
|
||||
|
||||
# Go into that directory
|
||||
|
|
@ -33,18 +51,18 @@ for adir in sorted(folders):
|
|||
os.putenv('PWD', pwd)
|
||||
|
||||
# Print status to screen
|
||||
sys.stdout.write(adir)
|
||||
print(adir, end="")
|
||||
sz = len(adir)
|
||||
for i in range(35 - sz):
|
||||
sys.stdout.write('.')
|
||||
print('.', end="")
|
||||
|
||||
# Run openmc
|
||||
proc = Popen(['../../src/openmc'], stderr=STDOUT, stdout=PIPE)
|
||||
proc = Popen([openmc_exe], stderr=STDOUT, stdout=PIPE)
|
||||
returncode = proc.wait()
|
||||
if returncode == 0:
|
||||
sys.stdout.write(BOLD + OKGREEN + "[OK]" + ENDC + "\n")
|
||||
print(BOLD + OKGREEN + "[OK]" + ENDC)
|
||||
else:
|
||||
sys.stdout.write(BOLD + FAIL + "[FAILED]" + ENDC + "\n")
|
||||
print(BOLD + FAIL + "[FAILED]" + ENDC)
|
||||
|
||||
# Process results
|
||||
if returncode == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue