#
#
# Usage:
-# DEAL_II_ADD_TEST(category test_name comparison_file [configurations])
+# DEAL_II_ADD_TEST(category test_name comparison_file n_cpu [configurations])
#
# This macro assumes that a source file
#
# ./tests/category/<test_name>.cc
#
+# as well as the comparison file
+#
+# ./tests/category/<comparison_file>
+#
# is available in the testsuite.
#
+# If <n_cpu> is equal to 0, the plain, generated executable will be run. If
+# <n_cpu> is a number larger than 0, the mpirun loader will be used to
+# launch the executable
+#
# [configurations] is a list of configurations against this test should be
# run. Possible values are an empty list, DEBUG, RELEASE or
# "DEBUG;RELEASE".
# <comparison_file>.
#
-MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file)
+MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file _n_cpu)
FOREACH(_build ${DEAL_II_BUILD_TYPES})
${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX}
)
+ #
+ # Build up the command line to run the test depending on _n_cpu:
+ #
+ IF("${_n_cpu}" STREQUAL "0")
+ SET(_run_command ${_full_test})
+ ELSE()
+ SET(_run_command mpirun -np ${_n_cpu} ${_full_test})
+ ENDIF()
#
# Add a top level target to run and compare the test:
#
-
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_test}/output
COMMAND
# A this stage a build is always successful: :-)
${CMAKE_COMMAND} -E echo "${_full_test}: BUILD successful"
COMMAND
- ${_full_test}
+ ${_run_command}
|| (echo "${_full_test}: RUN failed. Output:"
&& cat output
&& rm output
${_full_test}
${CMAKE_SOURCE_DIR}/cmake/scripts/normalize.pl
)
-
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_test}/diff
COMMAND
${TEST_DIFF}
#
# And finally add the test:
#
-
ADD_TEST(NAME ${_category}/${_test}
COMMAND ${CMAKE_COMMAND}
-DTEST=${_full_test}.diff
LABEL "${_category}"
TIMEOUT ${TEST_TIME_LIMIT}
)
-
ENDIF()
-
ENDFOREACH()
-
ENDMACRO()
-
GET_FILENAME_COMPONENT(_category ${CMAKE_CURRENT_SOURCE_DIR} NAME)
FILE(GLOB _tests "*.output")
-
FOREACH(_test ${_tests})
#
ENDIF()
#
- # Query configuration and check whether we support it. Otherwise do
- # not define test:
+ # Query configuration and check whether we support it. Otherwise
+ # set _define_test to FALSE:
#
STRING(REGEX MATCHALL "WITH_([0-9]|[A-Z]|_)*=(ON|OFF)" _matches ${_test})
FOREACH(_match ${_matches})
ENDIF()
ENDFOREACH()
+
IF(_define_test)
+
#
- # TODO: mpirun support
+ # Determine whether the test should be run with mpirun:
#
+ STRING(REGEX MATCH "mpirun=([0-9]*)" _n_cpu ${_test})
+ IF("${_n_cpu}" STREQUAL "")
+ # 0 indicates that no mpirun should be used
+ SET(_n_cpu 0)
+ ELSE()
+ STRING(REGEX REPLACE "^mpirun=([0-9]*)$" "\\1" _n_cpu ${_n_cpu})
+ ENDIF()
IF(_test MATCHES debug)
SET(_configuration DEBUG)
SET(_comparison ${_test})
STRING(REGEX REPLACE "\\..*" "" _test ${_test})
- DEAL_II_ADD_TEST(${_category} ${_test} ${_comparison} ${_configuration})
+ DEAL_II_ADD_TEST(${_category} ${_test} ${_comparison} ${_n_cpu} ${_configuration})
ENDIF()
ENDFOREACH()