diff --git a/docs/source/devguide/index.rst b/docs/source/devguide/index.rst index 1ceba324c1..999de9a536 100644 --- a/docs/source/devguide/index.rst +++ b/docs/source/devguide/index.rst @@ -10,7 +10,7 @@ as debugging. .. toctree:: :numbered: - :maxdepth: 2 + :maxdepth: 3 structures styleguide diff --git a/docs/source/devguide/statepoint.rst b/docs/source/devguide/statepoint.rst index 9862a45282..5f05c92c83 100644 --- a/docs/source/devguide/statepoint.rst +++ b/docs/source/devguide/statepoint.rst @@ -4,6 +4,296 @@ State Point Binary File Specifications ====================================== +----------- +Revision 11 +----------- + +**integer(4) FILETYPE_STATEPOINT** + + Flags whether this file is a statepoint file or a particle restart file. + +**integer(4) REVISION_STATEPOINT** + + Revision of the binary state point file. Any time a change is made in the + format of the state-point file, this integer is incremented. + +**integer(4) VERSION_MAJOR** + + Major version number for OpenMC + +**integer(4) VERSION_MINOR** + + Minor version number for OpenMC + +**integer(4) VERSION_RELEASE** + + Release version number for OpenMC + +**character(19) time_stamp** + + Date and time the state point was written. + +**character(255) path** + + Absolute path to directory containing input files. + +**integer(8) seed** + + Pseudo-random number generator seed. + +**integer(4) run_mode** + + run mode used. The modes are described in constants.F90. + +**integer(8) n_particles** + + Number of particles used per generation. + +**integer(4) n_batches** + + Total number of batches (active + inactive). + +**integer(4) current_batch** + + The number of batches already simulated. + +if (run_mode == MODE_EIGENVALUE) + + **integer(4) n_inactive** + + Number of inactive batches + + **integer(4) gen_per_batch** + + Number of generations per batch for criticality calculations + + *do i = 1, current_batch \* gen_per_batch* + + **real(8) k_generation(i)** + + k-effective for the i-th total generation + + *do i = 1, current_batch \* gen_per_batch* + + **real(8) entropy(i)** + + Shannon entropy for the i-th total generation + + **real(8) k_col_abs** + + Sum of product of collision/absorption estimates of k-effective + + **real(8) k_col_tra** + + Sum of product of collision/track-length estimates of k-effective + + **real(8) k_abs_tra** + + Sum of product of absorption/track-length estimates of k-effective + + **real(8) k_combined(2)** + + Mean and standard deviation of a combined estimate of k-effective + + **integer(4) cmfd_on** + + Flag that cmfd is on + + if (cmfd_on) + + **integer(4) cmfd % indices** + + Indices for cmfd mesh (i,j,k,g) + + **real(8) cmfd % k_cmfd(1:current_batch)** + + CMFD eigenvalues + + **real(8) cmfd % src(1:G,1:I,1:J,1:K)** + + CMFD fission source + + **real(8) cmfd % entropy(1:current_batch)** + + CMFD estimate of Shannon entropy + + **real(8) cmfd % balance(1:current_batch)** + + RMS of the residual neutron balance equation on CMFD mesh + + **real(8) cmfd % dom(1:current_batch)** + + CMFD estimate of dominance ratio + + **real(8) cmfd % scr_cmp(1:current_batch)** + + RMS comparison of difference between OpenMC and CMFD fission source + +**integer(4) n_meshes** + + Number of meshes in tallies.xml file + +*do i = 1, n_meshes* + + **integer(4) meshes(i) % id** + + Unique ID of mesh. + + **integer(4) meshes(i) % type** + + Type of mesh. + + **integer(4) meshes(i) % n_dimension** + + Number of dimensions for mesh (2 or 3). + + **integer(4) meshes(i) % dimension(:)** + + Number of mesh cells in each dimension. + + **real(8) meshes(i) % lower_left(:)** + + Coordinates of lower-left corner of mesh. + + **real(8) meshes(i) % upper_right(:)** + + Coordinates of upper-right corner of mesh. + + **real(8) meshes(i) % width(:)** + + Width of each mesh cell in each dimension. + +**integer(4) n_tallies** + +*do i = 1, n_tallies* + + **integer(4) tallies(i) % id** + + Unique ID of tally. + + **integer(4) tallies(i) % n_realizations** + + Number of realizations for the i-th tally. + + **integer(4) size(tallies(i) % scores, 1)** + + Total number of score bins for the i-th tally + + **integer(4) size(tallies(i) % scores, 2)** + + Total number of filter bins for the i-th tally + + **integer(4) tallies(i) % n_filters** + + *do j = 1, tallies(i) % n_filters* + + **integer(4) tallies(i) % filter(j) % type** + + Type of tally filter. + + **integer(4) tallies(i) % filter(j) % n_bins** + + Number of bins for filter. + + **integer(4)/real(8) tallies(i) % filter(j) % bins(:)** + + Value for each filter bin of this type. + + **integer(4) tallies(i) % n_nuclide_bins** + + Number of nuclide bins. If none are specified, this is just one. + + *do j = 1, tallies(i) % n_nuclide_bins* + + **integer(4) tallies(i) % nuclide_bins(j)** + + Values of specified nuclide bins + + **integer(4) tallies(i) % n_score_bins** + + Number of scoring bins. + + *do j = 1, tallies(i) % n_score_bins* + + **integer(4) tallies(i) % score_bins(j)** + + Values of specified scoring bins (e.g. SCORE_FLUX). + + *do j = 1, tallies(i) % n_score_bins* + + **integer(4) tallies(i) % scatt_order(j)** + + Scattering Order specified scoring bins. + + **integer(4) tallies(i) % n_score_bins** + + Number of scoring bins without accounting for those added by + the scatter-pn command. + +**integer(4) source_present** + + Flag indicated if source bank is present in the file + +**integer(4) n_realizations** + + Number of realizations for global tallies. + +**integer(4) N_GLOBAL_TALLIES** + + Number of global tally scores + +*do i = 1, N_GLOBAL_TALLIES* + + **real(8) global_tallies(i) % sum** + + Accumulated sum for the i-th global tally + + **real(8) global_tallies(i) % sum_sq** + + Accumulated sum of squares for the i-th global tally + +**integer(4) tallies_on** + + Flag indicated if tallies are present in the file. + +if (tallies_on > 0) + + *do i = 1, n_tallies* + + *do k = 1, size(tallies(i) % scores, 2)* + + *do j = 1, size(tallies(i) % scores, 1)* + + **real(8) tallies(i) % scores(j,k) % sum** + + Accumulated sum for the j-th score and k-th filter of the + i-th tally + + **real(8) tallies(i) % scores(j,k) % sum_sq** + + Accumulated sum of squares for the j-th score and k-th + filter of the i-th tally + +if (run_mode == MODE_EIGENVALUE and source_present) + + *do i = 1, n_particles* + + **real(8) source_bank(i) % wgt** + + Weight of the i-th source particle + + **real(8) source_bank(i) % xyz(1:3)** + + Coordinates of the i-th source particle. + + **real(8) source_bank(i) % uvw(1:3)** + + Direction of the i-th source particle + + **real(8) source_bank(i) % E** + + Energy of the i-th source particle. + ----------- Revision 10 ----------- diff --git a/docs/source/devguide/workflow.rst b/docs/source/devguide/workflow.rst index f3793628af..7a955f97d8 100644 --- a/docs/source/devguide/workflow.rst +++ b/docs/source/devguide/workflow.rst @@ -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,81 @@ 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 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 integrate with cmake using ctest_. To run the +full test suite run: + +.. 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 +183,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 diff --git a/docs/source/releasenotes/notes_0.5.4.rst b/docs/source/releasenotes/notes_0.5.4.rst index 174064e35b..a69354aa0a 100644 --- a/docs/source/releasenotes/notes_0.5.4.rst +++ b/docs/source/releasenotes/notes_0.5.4.rst @@ -4,10 +4,6 @@ Release Notes for OpenMC 0.5.4 ============================== -.. note:: - These release notes are for an upcoming release of OpenMC and are still - subject to change. - ------------------- System Requirements ------------------- @@ -21,16 +17,17 @@ the problem at hand (mostly on the number of nuclides in the problem). New Features ------------ -- New XML parsing backend (FoX) +- Source sites outside geometry are resampled +- XML-Fortran backend replaced by FoX XML - Ability to write particle track files - Handle lost particles more gracefully (via particle track files) -- Source sites outside geometry are resampled - Multiple random number generator streams -- plot_mesh_tally.py utility converted to use Tkinter rather than PyQt +- Mesh tally plotting utility converted to use Tkinter rather than PyQt - Script added to download ACE data from NNDC - Mixed ASCII/binary cross_sections.xml now allowed - Expanded options for writing source bank - Re-enabled ability to use source file as starting source +- S(a,b) recalculation avoided when same nuclide and S(a,b) table are accessed --------- Bug Fixes @@ -41,12 +38,16 @@ Bug Fixes - 8884fb_: Check for all ZAIDs for S(a,b) tables - b38af0_: Fix XML reading on multiple levels of input - d28750_: Fix bug in convert_xsdir.py +- cf567c_: ENDF/B-VI data checked for compatibility +- 6b9461_: Fix p_valid sampling inside of sample_energy .. _32c03c: https://github.com/mit-crpg/openmc/commit/32c03c .. _c71ef5: https://github.com/mit-crpg/openmc/commit/c71ef5 .. _8884fb: https://github.com/mit-crpg/openmc/commit/8884fb .. _b38af0: https://github.com/mit-crpg/openmc/commit/b38af0 .. _d28750: https://github.com/mit-crpg/openmc/commit/d28750 +.. _cf567c: https://github.com/mit-crpg/openmc/commit/cf567c +.. _6b9461: https://github.com/mit-crpg/openmc/commit/6b9461 ------------ Contributors diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index 83eb2a3d8a..eebe6bfc14 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -414,6 +414,8 @@ attributes/sub-elements: source bank will be available. It should be noted that a user can set both this element to "true" and specify batches to write a permanent source bank. + *Default*: false + ```` Element ------------------------------ diff --git a/docs/source/usersguide/install.rst b/docs/source/usersguide/install.rst index 53bfbe4018..45e7671f52 100644 --- a/docs/source/usersguide/install.rst +++ b/docs/source/usersguide/install.rst @@ -83,8 +83,8 @@ Prerequisites OpenMC with. HDF5_ must be built with parallel I/O features if you intend to use HDF5_ with MPI. An example of configuring HDF5_ is listed below:: - FC=/opt/mpich/3.0.4-gnu/bin/mpif90 CC=/opt/mpich/3.0.4-gnu/bin/mpicc \ - ./configure --prefix=/opt/hdf5/1.8.11-gnu --enable-fortran \ + FC=/opt/mpich/3.1/bin/mpif90 CC=/opt/mpich/3.1/bin/mpicc \ + ./configure --prefix=/opt/hdf5/1.8.12 --enable-fortran \ --enable-fortran2003 --enable-parallel You may omit ``--enable-parallel`` if you want to compile HDF5_ in serial. @@ -97,8 +97,8 @@ Prerequisites requires PETSc_ to be configured with Fortran datatypes. An example of configuring PETSc_ is listed below:: - ./configure --prefix=/opt/petsc/3.4.2-gnu --download-f-blas-lapack \ - --with-mpi-dir=/opt/mpich/3.0.4-gnu/ --with-shared-libraries=0 \ + ./configure --prefix=/opt/petsc/3.4.4 --download-f-blas-lapack \ + --with-mpi-dir=/opt/mpich/3.1 --with-shared-libraries \ --with-fortran-datatypes The BLAS/LAPACK library is not required to be downloaded and can be linked @@ -194,8 +194,8 @@ should be used: Compiling with MPI ++++++++++++++++++ -To compile with MPI, set the FC environment variable to the path to the MPI -Fortran wrapper. For example, in a bash shell: +To compile with MPI, set the :envvar:`FC` environment variable to the path to +the MPI Fortran wrapper. For example, in a bash shell: .. code-block:: sh @@ -212,8 +212,8 @@ command, i.e. Compiling with HDF5 +++++++++++++++++++ -To compile with MPI, set the FC environment variable to the path to the HDF5 -Fortran wrapper. For example, in a bash shell: +To compile with MPI, set the :envvar:`FC` environment variable to the path to +the HDF5 Fortran wrapper. For example, in a bash shell: .. code-block:: sh @@ -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 diff --git a/src/Makefile b/src/Makefile index 9c295176a0..990f22d9d3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 diff --git a/src/cmfd_loss_operator.F90 b/src/cmfd_loss_operator.F90 index 69be017644..b89f0f5772 100644 --- a/src/cmfd_loss_operator.F90 +++ b/src/cmfd_loss_operator.F90 @@ -396,7 +396,7 @@ contains end subroutine indices_to_matrix !=============================================================================== -! MATRIX_TO_INDICES converts a matrix index to spatial and group indicies +! MATRIX_TO_INDICES converts a matrix index to spatial and group indices !=============================================================================== subroutine matrix_to_indices(irow, g, i, j, k, ng, nx, ny, nz) diff --git a/src/constants.F90 b/src/constants.F90 index 9091460148..ef0d7c8ef3 100644 --- a/src/constants.F90 +++ b/src/constants.F90 @@ -8,7 +8,7 @@ module constants ! OpenMC major, minor, and release numbers integer, parameter :: VERSION_MAJOR = 0 integer, parameter :: VERSION_MINOR = 5 - integer, parameter :: VERSION_RELEASE = 3 + integer, parameter :: VERSION_RELEASE = 4 ! Revision numbers for binary files integer, parameter :: REVISION_STATEPOINT = 11 diff --git a/src/global.F90 b/src/global.F90 index c27f34f9e8..515b774bf9 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -359,7 +359,7 @@ module global logical :: cmfd_tally_on = .true. ! CMFD display info - character(len=25) :: cmfd_display + character(len=25) :: cmfd_display = 'balance' ! Information about state points to be written integer :: n_state_points = 0 diff --git a/src/input_xml.F90 b/src/input_xml.F90 index fffd4a54e7..76b1f696fd 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -685,7 +685,10 @@ contains call get_node_value(node_sp, "overwrite_latest", temp_str) call lower_case(temp_str) if (trim(temp_str) == 'true' .or. & - trim(temp_str) == '1') source_latest = .true. + trim(temp_str) == '1') then + source_latest = .true. + source_separate = .true. + end if end if else ! If no tag was present, by default we keep source bank in diff --git a/src/physics.F90 b/src/physics.F90 index 2d3cfeb39f..bb138668cd 100644 --- a/src/physics.F90 +++ b/src/physics.F90 @@ -867,9 +867,9 @@ contains end if ! Bank source neutrons - if (nu == 0 .or. n_bank == 3*work) return + if (nu == 0 .or. n_bank == size(fission_bank)) return p % fission = .true. ! Fission neutrons will be banked - do i = int(n_bank,4) + 1, int(min(n_bank + nu, 3*work),4) + do i = int(n_bank,4) + 1, int(min(n_bank + nu, int(size(fission_bank),8)),4) ! Bank source neutrons by copying particle data fission_bank(i) % xyz = p % coord0 % xyz @@ -894,7 +894,7 @@ contains end do ! increment number of bank sites - n_bank = min(n_bank + nu, 3*work) + n_bank = min(n_bank + nu, int(size(fission_bank),8)) ! Store total weight banked for analog fission tallies p % n_bank = nu @@ -1331,19 +1331,17 @@ contains ! SAMPLE ENERGY DISTRIBUTION IF THERE ARE MULTIPLE if (associated(edist % next)) then - if (edist % p_valid % n_regions > 0) then - p_valid = interpolate_tab1(edist % p_valid, E_in) + p_valid = interpolate_tab1(edist % p_valid, E_in) - if (prn() > p_valid) then - if (edist % law == 44 .or. edist % law == 61) then - call sample_energy(edist%next, E_in, E_out, mu_out) - elseif (edist % law == 66) then - call sample_energy(edist%next, E_in, E_out, A=A, Q=Q) - else - call sample_energy(edist%next, E_in, E_out) - end if - return + if (prn() > p_valid) then + if (edist % law == 44 .or. edist % law == 61) then + call sample_energy(edist%next, E_in, E_out, mu_out) + elseif (edist % law == 66) then + call sample_energy(edist%next, E_in, E_out, A=A, Q=Q) + else + call sample_energy(edist%next, E_in, E_out) end if + return end if end if diff --git a/src/source.F90 b/src/source.F90 index 2d3f74ec99..ced7fe1dc5 100644 --- a/src/source.F90 +++ b/src/source.F90 @@ -130,6 +130,7 @@ contains end if end if end do + call p % clear() case (SRC_SPACE_POINT) ! Point source diff --git a/src/state_point.F90 b/src/state_point.F90 index 4cf62c7c10..6884620e2f 100644 --- a/src/state_point.F90 +++ b/src/state_point.F90 @@ -104,7 +104,7 @@ contains ! Write out CMFD info if (cmfd_on) then call sp % write_data(1, "cmfd_on") - call sp % write_data(cmfd % indices, "indicies", length=4, group="cmfd") + call sp % write_data(cmfd % indices, "indices", length=4, group="cmfd") call sp % write_data(cmfd % k_cmfd, "k_cmfd", length=current_batch, & group="cmfd") call sp % write_data(cmfd % cmfd_src, "cmfd_src", & @@ -230,13 +230,13 @@ contains end do TALLY_METADATA - end if + ! Indicate where source bank is stored in statepoint + if (source_separate) then + call sp % write_data(0, "source_present") + else + call sp % write_data(1, "source_present") + end if - ! Indicate where source bank is stored in statepoint - if (source_separate) then - call sp % write_data(0, "source_present") - else - call sp % write_data(1, "source_present") end if ! Check for the no-tally-reduction method @@ -517,7 +517,6 @@ contains subroutine load_state_point() - character(MAX_FILE_LEN) :: filename character(MAX_FILE_LEN) :: path_temp character(19) :: current_time integer :: i @@ -599,7 +598,7 @@ contains ! Write out CMFD info if (int_array(1) == 1) then - call sp % read_data(cmfd % indices, "indicies", length=4, group="cmfd") + call sp % read_data(cmfd % indices, "indices", length=4, group="cmfd") call sp % read_data(cmfd % k_cmfd, "k_cmfd", length=restart_batch, & group="cmfd") length = cmfd % indices([4,1,2,3]) @@ -790,7 +789,7 @@ contains call sp % file_close() ! Write message - message = "Loading source file " // trim(filename) // "..." + message = "Loading source file " // trim(path_source_point) // "..." call write_message(1) ! Open source file diff --git a/src/utils/statepoint.py b/src/utils/statepoint.py index 47809d4728..9613421e07 100644 --- a/src/utils/statepoint.py +++ b/src/utils/statepoint.py @@ -195,7 +195,7 @@ class StatePoint(object): # Read CMFD information cmfd_present = self._get_int(path='cmfd_on')[0] if cmfd_present == 1: - self.cmfd_indices = self._get_int(4, path='cmfd/indicies') + self.cmfd_indices = self._get_int(4, path='cmfd/indices') self.k_cmfd = self._get_double(self.current_batch, path='cmfd/k_cmfd') self.cmfd_src = self._get_double_array(np.product(self.cmfd_indices), diff --git a/tests/readme.rst b/tests/readme.rst index fcc4d737fc..7c4d29e438 100644 --- a/tests/readme.rst +++ b/tests/readme.rst @@ -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 diff --git a/tests/run_tests.py b/tests/run_tests.py index 9d686b68a6..a664438c81 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -3,10 +3,28 @@ from __future__ import print_function import os -import sys import shutil +import re from subprocess import call from collections import OrderedDict +from optparse import OptionParser + +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() # Compiler paths FC_DEFAULT='gfortran' @@ -68,7 +86,17 @@ class Test(object): def run_make(self): if not self.success: return - rc = call(['make','-j', '-s','-C','build']) + + # 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.' @@ -76,7 +104,22 @@ class Test(object): def run_ctests(self): if not self.success: return - rc = call(['make','test','-C','build']) + + # 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.' @@ -117,67 +160,58 @@ 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) +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) -# Process command line arguments -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 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() - # Check for special subsets of tests - tests__ = [] - for i in tests_: - - # This checks for any subsets of tests. The string after - # all-XXXX will be used to search through all tests. - if i.startswith('all-'): - suffix = i.split('all-')[1] - for j in tests: - if j.rfind(suffix) != -1: - try: - tests__.index(j) - except ValueError: - tests__.append(j) - - # Test name specified on command line - else: - try: - tests__.index(i) - except ValueError: - tests__.append(i) # append specific test (e.g., mpi-debug) - - # Delete items of dictionary that are not in tests__ - for key in iter(tests): - try: - tests__.index(key) - except ValueError: +# 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 -call(['rm','-rf','build']) -for test in iter(tests): +shutil.rmtree('build', ignore_errors=True) +for test in tests: print('-'*(len(test) + 6)) print(test + ' tests') print('-'*(len(test) + 6)) - # 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 - call(['rm','-rf','build']) + shutil.rmtree('build', ignore_errors=True) # Print out summary of results print('\n' + '='*54) @@ -188,7 +222,7 @@ FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' -for test in iter(tests): +for test in tests: print(test + '.'*(50 - len(test)), end='') if tests[test].success: print(BOLD + OK + '[OK]' + ENDC) diff --git a/tests/test_basic/test_basic.py b/tests/test_basic/test_basic.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_basic/test_basic.py +++ b/tests/test_basic/test_basic.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_cmfd_feed/test_cmfd_feed.py b/tests/test_cmfd_feed/test_cmfd_feed.py index bafce9f444..4bc2914e3a 100644 --- a/tests/test_cmfd_feed/test_cmfd_feed.py +++ b/tests/test_cmfd_feed/test_cmfd_feed.py @@ -54,7 +54,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_cmfd_jfnk/test_cmfd_jfnk.py b/tests/test_cmfd_jfnk/test_cmfd_jfnk.py index 1386da3fee..0fae02dfdb 100644 --- a/tests/test_cmfd_jfnk/test_cmfd_jfnk.py +++ b/tests/test_cmfd_jfnk/test_cmfd_jfnk.py @@ -55,7 +55,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_cmfd_nofeed/test_cmfd_nofeed.py b/tests/test_cmfd_nofeed/test_cmfd_nofeed.py index 1386da3fee..0fae02dfdb 100644 --- a/tests/test_cmfd_nofeed/test_cmfd_nofeed.py +++ b/tests/test_cmfd_nofeed/test_cmfd_nofeed.py @@ -55,7 +55,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_confidence_intervals/test_confidence_intervals.py b/tests/test_confidence_intervals/test_confidence_intervals.py index 22932a02cd..30c53738fb 100644 --- a/tests/test_confidence_intervals/test_confidence_intervals.py +++ b/tests/test_confidence_intervals/test_confidence_intervals.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_density_atombcm/test_density_atombcm.py b/tests/test_density_atombcm/test_density_atombcm.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_density_atombcm/test_density_atombcm.py +++ b/tests/test_density_atombcm/test_density_atombcm.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_density_atomcm3/test_density_atomcm3.py b/tests/test_density_atomcm3/test_density_atomcm3.py index 77610a8261..c748062691 100644 --- a/tests/test_density_atomcm3/test_density_atomcm3.py +++ b/tests/test_density_atomcm3/test_density_atomcm3.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_density_kgm3/test_density_kgm3.py b/tests/test_density_kgm3/test_density_kgm3.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_density_kgm3/test_density_kgm3.py +++ b/tests/test_density_kgm3/test_density_kgm3.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_density_sum/test_density_sum.py b/tests/test_density_sum/test_density_sum.py index d6b4ac9cfa..f4167d1333 100644 --- a/tests/test_density_sum/test_density_sum.py +++ b/tests/test_density_sum/test_density_sum.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py b/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py index 1e61af4a2b..453b1951fc 100644 --- a/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py +++ b/tests/test_eigenvalue_genperbatch/test_eigenvalue_genperbatch.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py b/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py +++ b/tests/test_eigenvalue_no_inactive/test_eigenvalue_no_inactive.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_energy_grid/test_energy_grid.py b/tests/test_energy_grid/test_energy_grid.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_energy_grid/test_energy_grid.py +++ b/tests/test_energy_grid/test_energy_grid.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_entropy/test_entropy.py b/tests/test_entropy/test_entropy.py index 404b94634f..035a5c0ada 100644 --- a/tests/test_entropy/test_entropy.py +++ b/tests/test_entropy/test_entropy.py @@ -48,7 +48,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_filter_cell/test_filter_cell.py b/tests/test_filter_cell/test_filter_cell.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_filter_cell/test_filter_cell.py +++ b/tests/test_filter_cell/test_filter_cell.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_filter_cellborn/test_filter_cellborn.py b/tests/test_filter_cellborn/test_filter_cellborn.py index c5cb425422..15f73ee352 100644 --- a/tests/test_filter_cellborn/test_filter_cellborn.py +++ b/tests/test_filter_cellborn/test_filter_cellborn.py @@ -48,7 +48,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_filter_energy/test_filter_energy.py b/tests/test_filter_energy/test_filter_energy.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_filter_energy/test_filter_energy.py +++ b/tests/test_filter_energy/test_filter_energy.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_filter_energyout/test_filter_energyout.py b/tests/test_filter_energyout/test_filter_energyout.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_filter_energyout/test_filter_energyout.py +++ b/tests/test_filter_energyout/test_filter_energyout.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_filter_group_transfer/test_filter_group_transfer.py b/tests/test_filter_group_transfer/test_filter_group_transfer.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_filter_group_transfer/test_filter_group_transfer.py +++ b/tests/test_filter_group_transfer/test_filter_group_transfer.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_filter_material/test_filter_material.py b/tests/test_filter_material/test_filter_material.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_filter_material/test_filter_material.py +++ b/tests/test_filter_material/test_filter_material.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_filter_mesh_2d/test_filter_mesh_2d.py b/tests/test_filter_mesh_2d/test_filter_mesh_2d.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_filter_mesh_2d/test_filter_mesh_2d.py +++ b/tests/test_filter_mesh_2d/test_filter_mesh_2d.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_filter_mesh_3d/test_filter_mesh_3d.py b/tests/test_filter_mesh_3d/test_filter_mesh_3d.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_filter_mesh_3d/test_filter_mesh_3d.py +++ b/tests/test_filter_mesh_3d/test_filter_mesh_3d.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_filter_universe/test_filter_universe.py b/tests/test_filter_universe/test_filter_universe.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_filter_universe/test_filter_universe.py +++ b/tests/test_filter_universe/test_filter_universe.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_fixed_source/test_fixed_source.py b/tests/test_fixed_source/test_fixed_source.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_fixed_source/test_fixed_source.py +++ b/tests/test_fixed_source/test_fixed_source.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_lattice/test_lattice.py b/tests/test_lattice/test_lattice.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_lattice/test_lattice.py +++ b/tests/test_lattice/test_lattice.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_lattice_multiple/test_lattice_multiple.py b/tests/test_lattice_multiple/test_lattice_multiple.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_lattice_multiple/test_lattice_multiple.py +++ b/tests/test_lattice_multiple/test_lattice_multiple.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_natural_element/results_true.dat b/tests/test_natural_element/results_true.dat index 335f10c5ad..9b2e933ab3 100644 --- a/tests/test_natural_element/results_true.dat +++ b/tests/test_natural_element/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.012443E+00 2.162448E-02 +1.010190E+00 1.740589E-02 diff --git a/tests/test_natural_element/test_natural_element.py b/tests/test_natural_element/test_natural_element.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_natural_element/test_natural_element.py +++ b/tests/test_natural_element/test_natural_element.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_output/test_output.py b/tests/test_output/test_output.py index 4ed4255392..b19e5d76d6 100644 --- a/tests/test_output/test_output.py +++ b/tests/test_output/test_output.py @@ -59,7 +59,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_particle_restart/test_particle_restart.py b/tests/test_particle_restart/test_particle_restart.py index 4c63efe372..6c5dcf0be2 100644 --- a/tests/test_particle_restart/test_particle_restart.py +++ b/tests/test_particle_restart/test_particle_restart.py @@ -54,7 +54,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_plot_background/test_plot_background.py b/tests/test_plot_background/test_plot_background.py index fdf786314c..4c990578a4 100644 --- a/tests/test_plot_background/test_plot_background.py +++ b/tests/test_plot_background/test_plot_background.py @@ -33,7 +33,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_plot_basis/test_plot_basis.py b/tests/test_plot_basis/test_plot_basis.py index 2c650d8767..057fd09a97 100644 --- a/tests/test_plot_basis/test_plot_basis.py +++ b/tests/test_plot_basis/test_plot_basis.py @@ -35,7 +35,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_plot_colspec/test_plot_colspec.py b/tests/test_plot_colspec/test_plot_colspec.py index fdf786314c..4c990578a4 100644 --- a/tests/test_plot_colspec/test_plot_colspec.py +++ b/tests/test_plot_colspec/test_plot_colspec.py @@ -33,7 +33,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_plot_mask/test_plot_mask.py b/tests/test_plot_mask/test_plot_mask.py index 2c650d8767..057fd09a97 100644 --- a/tests/test_plot_mask/test_plot_mask.py +++ b/tests/test_plot_mask/test_plot_mask.py @@ -35,7 +35,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_ptables_off/test_ptables_off.py b/tests/test_ptables_off/test_ptables_off.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_ptables_off/test_ptables_off.py +++ b/tests/test_ptables_off/test_ptables_off.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_reflective_cone/test_reflective_cone.py b/tests/test_reflective_cone/test_reflective_cone.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_reflective_cone/test_reflective_cone.py +++ b/tests/test_reflective_cone/test_reflective_cone.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_reflective_cylinder/test_reflective_cylinder.py b/tests/test_reflective_cylinder/test_reflective_cylinder.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_reflective_cylinder/test_reflective_cylinder.py +++ b/tests/test_reflective_cylinder/test_reflective_cylinder.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_reflective_plane/test_reflective_plane.py b/tests/test_reflective_plane/test_reflective_plane.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_reflective_plane/test_reflective_plane.py +++ b/tests/test_reflective_plane/test_reflective_plane.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_reflective_sphere/test_reflective_sphere.py b/tests/test_reflective_sphere/test_reflective_sphere.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_reflective_sphere/test_reflective_sphere.py +++ b/tests/test_reflective_sphere/test_reflective_sphere.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_rotation/test_rotation.py b/tests/test_rotation/test_rotation.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_rotation/test_rotation.py +++ b/tests/test_rotation/test_rotation.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_salphabeta/test_salphabeta.py b/tests/test_salphabeta/test_salphabeta.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_salphabeta/test_salphabeta.py +++ b/tests/test_salphabeta/test_salphabeta.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_salphabeta_multiple/results_true.dat b/tests/test_salphabeta_multiple/results_true.dat index bbd61cdb53..3165faa41e 100644 --- a/tests/test_salphabeta_multiple/results_true.dat +++ b/tests/test_salphabeta_multiple/results_true.dat @@ -1,2 +1,2 @@ k-combined: -9.761880E-01 9.170415E-03 +9.701793E-01 8.482149E-03 diff --git a/tests/test_salphabeta_multiple/test_salphabeta_multiple.py b/tests/test_salphabeta_multiple/test_salphabeta_multiple.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_salphabeta_multiple/test_salphabeta_multiple.py +++ b/tests/test_salphabeta_multiple/test_salphabeta_multiple.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_MT/test_score_MT.py b/tests/test_score_MT/test_score_MT.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_MT/test_score_MT.py +++ b/tests/test_score_MT/test_score_MT.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_absorption/test_score_absorption.py b/tests/test_score_absorption/test_score_absorption.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_absorption/test_score_absorption.py +++ b/tests/test_score_absorption/test_score_absorption.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_current/test_score_current.py b/tests/test_score_current/test_score_current.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_current/test_score_current.py +++ b/tests/test_score_current/test_score_current.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_events/test_score_events.py b/tests/test_score_events/test_score_events.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_events/test_score_events.py +++ b/tests/test_score_events/test_score_events.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_fission/test_score_fission.py b/tests/test_score_fission/test_score_fission.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_fission/test_score_fission.py +++ b/tests/test_score_fission/test_score_fission.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_flux/test_score_flux.py b/tests/test_score_flux/test_score_flux.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_flux/test_score_flux.py +++ b/tests/test_score_flux/test_score_flux.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_kappafission/test_score_kappafission.py b/tests/test_score_kappafission/test_score_kappafission.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_kappafission/test_score_kappafission.py +++ b/tests/test_score_kappafission/test_score_kappafission.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_nufission/test_score_nufission.py b/tests/test_score_nufission/test_score_nufission.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_nufission/test_score_nufission.py +++ b/tests/test_score_nufission/test_score_nufission.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_nuscatter/test_score_nuscatter.py b/tests/test_score_nuscatter/test_score_nuscatter.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_nuscatter/test_score_nuscatter.py +++ b/tests/test_score_nuscatter/test_score_nuscatter.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_scatter/test_score_scatter.py b/tests/test_score_scatter/test_score_scatter.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_scatter/test_score_scatter.py +++ b/tests/test_score_scatter/test_score_scatter.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_scatter_n/test_score_scatter_n.py b/tests/test_score_scatter_n/test_score_scatter_n.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_scatter_n/test_score_scatter_n.py +++ b/tests/test_score_scatter_n/test_score_scatter_n.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_scatter_pn/test_score_scatter_pn.py b/tests/test_score_scatter_pn/test_score_scatter_pn.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_scatter_pn/test_score_scatter_pn.py +++ b/tests/test_score_scatter_pn/test_score_scatter_pn.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_score_total/test_score_total.py b/tests/test_score_total/test_score_total.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_score_total/test_score_total.py +++ b/tests/test_score_total/test_score_total.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_seed/test_seed.py b/tests/test_seed/test_seed.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_seed/test_seed.py +++ b/tests/test_seed/test_seed.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_source_angle_mono/test_source_angle_mono.py b/tests/test_source_angle_mono/test_source_angle_mono.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_source_angle_mono/test_source_angle_mono.py +++ b/tests/test_source_angle_mono/test_source_angle_mono.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_source_energy_maxwell/test_source_energy_maxwell.py b/tests/test_source_energy_maxwell/test_source_energy_maxwell.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_source_energy_maxwell/test_source_energy_maxwell.py +++ b/tests/test_source_energy_maxwell/test_source_energy_maxwell.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_source_energy_mono/test_source_energy_mono.py b/tests/test_source_energy_mono/test_source_energy_mono.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_source_energy_mono/test_source_energy_mono.py +++ b/tests/test_source_energy_mono/test_source_energy_mono.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_source_file/test_source_file.py b/tests/test_source_file/test_source_file.py index 3eca852d57..1be4b92cf8 100644 --- a/tests/test_source_file/test_source_file.py +++ b/tests/test_source_file/test_source_file.py @@ -105,7 +105,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_source_point/test_source_point.py b/tests/test_source_point/test_source_point.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_source_point/test_source_point.py +++ b/tests/test_source_point/test_source_point.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_sourcepoint_batch/test_sourcepoint_batch.py b/tests/test_sourcepoint_batch/test_sourcepoint_batch.py index f62ddacf9e..e7fd49b40a 100644 --- a/tests/test_sourcepoint_batch/test_sourcepoint_batch.py +++ b/tests/test_sourcepoint_batch/test_sourcepoint_batch.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_sourcepoint_interval/test_sourcepoint_interval.py b/tests/test_sourcepoint_interval/test_sourcepoint_interval.py index 52aa3b2d24..d59b5261d4 100644 --- a/tests/test_sourcepoint_interval/test_sourcepoint_interval.py +++ b/tests/test_sourcepoint_interval/test_sourcepoint_interval.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_sourcepoint_latest/settings.xml b/tests/test_sourcepoint_latest/settings.xml index 5056db4724..fa7f07dfae 100644 --- a/tests/test_sourcepoint_latest/settings.xml +++ b/tests/test_sourcepoint_latest/settings.xml @@ -1,7 +1,7 @@ - + 10 diff --git a/tests/test_sourcepoint_latest/test_sourcepoint_latest.py b/tests/test_sourcepoint_latest/test_sourcepoint_latest.py index cdf6d560b4..858656e837 100644 --- a/tests/test_sourcepoint_latest/test_sourcepoint_latest.py +++ b/tests/test_sourcepoint_latest/test_sourcepoint_latest.py @@ -52,7 +52,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_sourcepoint_restart/test_sourcepoint_restart.py b/tests/test_sourcepoint_restart/test_sourcepoint_restart.py index a67f078da6..81b16255f7 100644 --- a/tests/test_sourcepoint_restart/test_sourcepoint_restart.py +++ b/tests/test_sourcepoint_restart/test_sourcepoint_restart.py @@ -129,7 +129,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_statepoint_batch/test_statepoint_batch.py b/tests/test_statepoint_batch/test_statepoint_batch.py index 7dbce32cc0..ea3993d10b 100644 --- a/tests/test_statepoint_batch/test_statepoint_batch.py +++ b/tests/test_statepoint_batch/test_statepoint_batch.py @@ -55,7 +55,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_statepoint_interval/test_statepoint_interval.py b/tests/test_statepoint_interval/test_statepoint_interval.py index de42fc4e3a..f80cc2dca2 100644 --- a/tests/test_statepoint_interval/test_statepoint_interval.py +++ b/tests/test_statepoint_interval/test_statepoint_interval.py @@ -64,7 +64,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_statepoint_restart/test_statepoint_restart.py b/tests/test_statepoint_restart/test_statepoint_restart.py index 8b0636d6da..06b982917b 100644 --- a/tests/test_statepoint_restart/test_statepoint_restart.py +++ b/tests/test_statepoint_restart/test_statepoint_restart.py @@ -118,7 +118,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py index b21720ef57..00e70444d0 100644 --- a/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py +++ b/tests/test_statepoint_sourcesep/test_statepoint_sourcesep.py @@ -52,7 +52,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_survival_biasing/test_survival_biasing.py b/tests/test_survival_biasing/test_survival_biasing.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_survival_biasing/test_survival_biasing.py +++ b/tests/test_survival_biasing/test_survival_biasing.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_tally_assumesep/test_tally_assumesep.py b/tests/test_tally_assumesep/test_tally_assumesep.py index 435cb80ebc..f2068f85f9 100644 --- a/tests/test_tally_assumesep/test_tally_assumesep.py +++ b/tests/test_tally_assumesep/test_tally_assumesep.py @@ -51,7 +51,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_trace/test_trace.py b/tests/test_trace/test_trace.py index d9511551ac..dae89b62b4 100644 --- a/tests/test_trace/test_trace.py +++ b/tests/test_trace/test_trace.py @@ -49,7 +49,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_track_output/test_track_output.py b/tests/test_track_output/test_track_output.py index 25c9449c51..d4670a1385 100644 --- a/tests/test_track_output/test_track_output.py +++ b/tests/test_track_output/test_track_output.py @@ -61,7 +61,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_translation/test_translation.py b/tests/test_translation/test_translation.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_translation/test_translation.py +++ b/tests/test_translation/test_translation.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_uniform_fs/test_uniform_fs.py b/tests/test_uniform_fs/test_uniform_fs.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_uniform_fs/test_uniform_fs.py +++ b/tests/test_uniform_fs/test_uniform_fs.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_universe/test_universe.py b/tests/test_universe/test_universe.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_universe/test_universe.py +++ b/tests/test_universe/test_universe.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/test_void/results_true.dat b/tests/test_void/results_true.dat index a649385868..e569957b77 100644 --- a/tests/test_void/results_true.dat +++ b/tests/test_void/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.010313E+00 3.162080E-02 +1.006312E+00 3.000112E-02 diff --git a/tests/test_void/test_void.py b/tests/test_void/test_void.py index 54733fb13c..ef2dceed89 100644 --- a/tests/test_void/test_void.py +++ b/tests/test_void/test_void.py @@ -47,7 +47,7 @@ def teardown(): if __name__ == '__main__': # test for openmc executable - if opts.exe == None: + if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests diff --git a/tests/update_results.py b/tests/update_results.py index 7afb63e158..c9c0be85dc 100755 --- a/tests/update_results.py +++ b/tests/update_results.py @@ -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: