Skip to content
Snippets Groups Projects
Commit d59623c8 authored by Martin Nolte's avatar Martin Nolte
Browse files

[bugfix] make `dune_add_test` play nicely with MPICH

The standard `add_test` allows CMake targets to be passed as commands.
However, when passing them to MPI, this does not work in two cases:
- MPICH does not search for the executable in the current working
directory.
- The name of the executable need not coincide with the name of the
target (e.g., on Windows).

This patch fixes both issues by checking whether the command is a CMake
target and obtaining the location of the primary output file in this
case. This name is then passed to MPI or `add_test`, respectively.

This closes #24.
parent 62714041
Branches
Tags
1 merge request!363[bugfix] make `dune_add_test` play nicely with MPICH
Pipeline #
......@@ -282,12 +282,16 @@ function(dune_add_test)
# Add one test for each specified processor number
foreach(procnum ${ADDTEST_MPI_RANKS})
if((NOT "${procnum}" GREATER "${DUNE_MAX_TEST_CORES}") AND (NOT ADDTEST_COMPILE_ONLY))
if(NOT ${procnum} STREQUAL "1")
set(ACTUAL_TESTCOMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${procnum} ${ADDTEST_COMMAND} ${MPIEXEC_POSTFLAGS})
set(ACTUAL_NAME "${ADDTEST_NAME}-mpi-${procnum}")
set(ACTUAL_NAME ${ADDTEST_NAME})
if(TARGET "${ADDTEST_COMMAND}")
set(ACTUAL_TESTCOMMAND "$<TARGET_FILE:${ADDTEST_COMMAND}>")
else()
set(ACTUAL_TESTCOMMAND ${ADDTEST_COMMAND})
set(ACTUAL_NAME ${ADDTEST_NAME})
endif()
if(NOT ${procnum} STREQUAL "1")
set(ACTUAL_TESTCOMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${procnum} ${ACTUAL_TESTCOMMAND} ${MPIEXEC_POSTFLAGS})
set(ACTUAL_NAME "${ACTUAL_NAME}-mpi-${procnum}")
endif()
# Now add the actual test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment