Skip to content

Commit

Permalink
Merge pull request #1228 from DLR-AMR/fix-cmake_parallel_tests
Browse files Browse the repository at this point in the history
Add a default value to run the test-suite 2
  • Loading branch information
Davknapp authored Aug 21, 2024
2 parents 67e4cb9 + 52b4a91 commit 3a7928d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ option( T8CODE_BUILD_DOCUMENTATION "Build t8code's documentation" OFF )
include(CMakeDependentOption)
cmake_dependent_option( T8CODE_BUILD_DOCUMENTATION_SPHINX "Build t8code's documentation using sphinx" OFF "T8CODE_BUILD_DOCUMENTATION" OFF )

set(T8CODE_CUSTOM_TEST_COMMAND "" CACHE STRING "Define custom test command, e.g.: mpirun -n 4")
set(T8CODE_CUSTOM_TEST_COMMAND "" CACHE STRING "Define custom test command, e.g.: mpirun -np 8 (overwrites standard mpirun -np 4 if build with mpi)")

if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE "Release" )
Expand Down
14 changes: 12 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ function( add_t8_test )
target_link_libraries( ${ADD_T8_TEST_NAME} PRIVATE T8 gtest pthread)

# Split custom test command into a list by whitespace.
separate_arguments (T8CODE_CUSTOM_TEST_COMMAND_LIST NATIVE_COMMAND "${T8CODE_CUSTOM_TEST_COMMAND}")
# If MPI is enabled, and no custom test command is provided, use mpirun -np 4 as the default command.
# If MPI is not enabled, use the custom test command as is.
if ( T8CODE_ENABLE_MPI )
if ( T8CODE_CUSTOM_TEST_COMMAND STREQUAL "" )
separate_arguments (T8CODE_TEST_COMMAND_LIST NATIVE_COMMAND "mpirun -np 4")
else ( T8CODE_CUSTOM_TEST_COMMAND STREQUAL "" )
separate_arguments (T8CODE_TEST_COMMAND_LIST NATIVE_COMMAND ${T8CODE_CUSTOM_TEST_COMMAND})
endif ( T8CODE_CUSTOM_TEST_COMMAND STREQUAL "" )
else( T8CODE_ENABLE_MPI )
separate_arguments (T8CODE_TEST_COMMAND_LIST NATIVE_COMMAND ${T8CODE_CUSTOM_TEST_COMMAND})
endif ( T8CODE_ENABLE_MPI )

add_test( NAME ${ADD_T8_TEST_NAME} COMMAND ${T8CODE_CUSTOM_TEST_COMMAND_LIST} ./${ADD_T8_TEST_NAME} )
add_test( NAME ${ADD_T8_TEST_NAME} COMMAND ${T8CODE_TEST_COMMAND_LIST} ./${ADD_T8_TEST_NAME} )
endfunction()

# Copy test files to build folder so that the t8_test programs can find them.
Expand Down

0 comments on commit 3a7928d

Please sign in to comment.