Skip to content

Commit

Permalink
Update ctest command (erf-model#1365)
Browse files Browse the repository at this point in the history
* Wrap fcompare in srun to fix CI pipe issue

* Add option to change number of ranks for tests

---------

Co-authored-by: Cole Kendrick <[email protected]>
  • Loading branch information
gardner48 and ckendrick authored Jan 4, 2024
1 parent 31ed2ef commit efcb272
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

set(FCOMPARE_EXE ${CMAKE_BINARY_DIR}/Submodules/AMReX/Tools/Plotfile/amrex_fcompare CACHE INTERNAL "Path to fcompare executable for regression tests")
set(ERF_TEST_NRANKS 4 CACHE STRING "Number of MPI ranks to use for each test")
include(${CMAKE_CURRENT_SOURCE_DIR}/CTestList.cmake)
6 changes: 4 additions & 2 deletions Tests/CTestList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ macro(setup_test)
file(COPY ${TEST_FILES} DESTINATION "${CURRENT_TEST_BINARY_DIR}/")

if(ERF_ENABLE_MPI)
set(NP 4)
set(NP ${ERF_TEST_NRANKS})
set(MPI_COMMANDS "${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${NP} ${MPIEXEC_PREFLAGS}")
set(MPI_FCOMP_COMMANDS "${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 1 ${MPIEXEC_PREFLAGS}")
else()
set(NP 1)
unset(MPI_COMMANDS)
unset(MPI_FCOMP_COMMANDS)
endif()

# Set some default runtime options for all tests in this category
Expand All @@ -38,7 +40,7 @@ function(add_test_r TEST_NAME TEST_EXE PLTFILE)
set(TEST_EXE ${CMAKE_BINARY_DIR}/Exec/${TEST_EXE})
set(FCOMPARE_TOLERANCE "-r 1e-12 --abs_tol 1.0e-12")
set(FCOMPARE_FLAGS "-a ${FCOMPARE_TOLERANCE}")
set(test_command sh -c "${MPI_COMMANDS} ${TEST_EXE} ${CURRENT_TEST_BINARY_DIR}/${TEST_NAME}.i ${RUNTIME_OPTIONS} > ${TEST_NAME}.log && ${FCOMPARE_EXE} ${FCOMPARE_FLAGS} ${PLOT_GOLD} ${CURRENT_TEST_BINARY_DIR}/${PLTFILE}")
set(test_command sh -c "${MPI_COMMANDS} ${TEST_EXE} ${CURRENT_TEST_BINARY_DIR}/${TEST_NAME}.i ${RUNTIME_OPTIONS} > ${TEST_NAME}.log && ${MPI_FCOMP_COMMANDS} ${FCOMPARE_EXE} ${FCOMPARE_FLAGS} ${PLOT_GOLD} ${CURRENT_TEST_BINARY_DIR}/${PLTFILE}")

add_test(${TEST_NAME} ${test_command})
set_tests_properties(${TEST_NAME}
Expand Down

0 comments on commit efcb272

Please sign in to comment.