# - specifying the maximal wall clock time in seconds a test is allowed
# to run
#
-# Usage:
-# 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
+# Usage:
+# DEAL_II_ADD_TEST(category test_name comparison_file)
#
-# [configurations] is a list of configurations against this test should be
-# run. Possible values are an empty list, DEBUG, RELEASE or
-# "DEBUG;RELEASE".
+# 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. The output of compiled source file is
+# compared against the file comparison file.
#
-# The output of <test_name>.cc is compared against the file
-# <comparison_file>.
+# This macro gets the following options from the comparison file name (have
+# a look at the testsuite documentation for details):
+# - usage of mpirun and number of simultaneous processes
+# - valid build configurations
+# - expected test stage
#
-MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file _n_cpu)
+MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file)
IF(NOT DEAL_II_PROJECT_CONFIG_INCLUDED)
MESSAGE(FATAL_ERROR
)
ENDIF()
+ GET_FILENAME_COMPONENT(_file ${_comparison_file} NAME)
+
+ #
+ # Determine valid build configurations for this test:
+ #
+
+ SET(_configuration)
+ IF(_file MATCHES "debug")
+ SET(_configuration DEBUG)
+ ELSEIF(_file MATCHES "release")
+ SET(_configuration RELEASE)
+ ENDIF()
+
+ #
+ # Determine whether the test should be run with mpirun:
+ #
+
+ STRING(REGEX MATCH "mpirun=([0-9]*)" _n_cpu ${_file})
+ IF("${_n_cpu}" STREQUAL "")
+ SET(_n_cpu 0) # 0 indicates that no mpirun should be used
+ ELSE()
+ STRING(REGEX REPLACE "^mpirun=([0-9]*)$" "\\1" _n_cpu ${_n_cpu})
+ ENDIF()
+
+ #
+ # Determine the expected build stage of this test:
+ #
+
+ STRING(REGEX MATCH "expect=([a-z]*)" _expect ${_file})
+ IF("${_expect}" STREQUAL "")
+ SET(_expect "PASSED")
+ ELSE()
+ STRING(REGEX REPLACE "^expect=([a-z]*)$" "\\1" _expect ${_expect})
+ STRING(TOUPPER ${_expect} _expect)
+ ENDIF()
+
+
FOREACH(_build ${DEAL_II_BUILD_TYPES})
- ITEM_MATCHES(_match "${_build}" ${ARGN})
- IF(_match OR "${ARGN}" STREQUAL "")
+ ITEM_MATCHES(_match "${_build}" ${_configuration})
+ IF(_match OR "${_configuration}" STREQUAL "")
#
# Setup a bunch of variables describing the test:
COMMAND ${CMAKE_COMMAND}
-DTRGT=${_diff_target}
-DTEST=${_test_full}
+ -DEXPECT=${_expect}
-DDEAL_II_BINARY_DIR=${CMAKE_BINARY_DIR}
-P ${DEAL_II_SOURCE_DIR}/cmake/scripts/run_test.cmake
WORKING_DIRECTORY ${_test_directory}
#
# Respect TEST_PICKUP_REGEX:
#
+
IF( "${TEST_PICKUP_REGEX}" STREQUAL "" OR
"${_category}/${_test}" MATCHES "${TEST_PICKUP_REGEX}" )
SET(_define_test TRUE)
# Query configuration and check whether we support it. Otherwise
# set _define_test to FALSE:
#
+
STRING(REGEX MATCHALL
"with_([0-9]|[a-z]|_)*=(on|off|yes|no|true|false)" _matches ${_test}
)
ENDFOREACH()
IF(_define_test)
- #
- # 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)
- ELSEIF(_test MATCHES release)
- SET(_configuration RELEASE)
- ELSE()
- SET(_configuration)
- ENDIF()
-
STRING(REGEX REPLACE "\\..*" "" _test ${_test})
- DEAL_II_ADD_TEST(${_category} ${_test} ${_comparison} ${_n_cpu} ${_configuration})
+ DEAL_II_ADD_TEST(${_category} ${_test} ${_comparison})
ENDIF()
+
ENDFOREACH()
ENDMACRO()
#
# This is a small worker to run a single test in the testsuite
#
-# The following variables have to be set:
+# The following variables must be set:
#
# TRGT - the name of the target that should be invoked
# TEST - the test name (used for status messages)
# DEAL_II_BINARY_DIR - the build directory that contains the target
#
+# Optional options:
+# EXPECT - the stage this test must reach to be considered successful
+# (return value 0)
+# Possible values are CONFIGURE, BUILD, RUN, DIFF, PASSED
+#
+
+IF("${EXPECT}" STREQUAL "")
+ SET(EXPECT "PASSED")
+ENDIF()
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND}
--build ${DEAL_II_BINARY_DIR} --target ${TRGT}
- RESULT_VARIABLE _result_code
+ RESULT_VARIABLE _result_code # ignored ;-)
OUTPUT_VARIABLE _output
)
-IF("${_result_code}" STREQUAL "0")
+#
+# Determine the last succesful stage of the test:
+# (Possible values are CONFIGURE, BUILD, RUN, DIFF, PASSED)
+#
- MESSAGE("Test ${TEST}: PASSED")
- MESSAGE("=============================== OUTPUT BEGIN ===============================")
- # Do not output everything, just that we are successful:
- MESSAGE("${TEST}: PASSED.")
- MESSAGE("=============================== OUTPUT END ===============================")
+STRING(REGEX MATCH "${TEST}: CONFIGURE failed\\." _configure_regex ${_output})
+STRING(REGEX MATCH "${TEST}: BUILD failed\\." _build_regex ${_output})
+STRING(REGEX MATCH "${TEST}: RUN failed\\." _run_regex ${_output})
+STRING(REGEX MATCH "${TEST}: DIFF failed\\." _diff_regex ${_output})
+STRING(REGEX MATCH "${TEST}: PASSED\\." _passed_regex ${_output})
-ELSE()
+IF(NOT "${_configure_regex}" STREQUAL "")
+ SET(_stage CONFIGURE)
+ELSEIF(NOT "${_run_regex}" STREQUAL "")
+ SET(_stage RUN)
+ELSEIF(NOT "${_diff_regex}" STREQUAL "")
+ SET(_stage DIFF)
+ELSEIF(NOT "${_passed_regex}" STREQUAL "")
+ SET(_stage PASSED)
+ELSE() # unconditionally, because "BUILD failed." doesn't have to be printed...
+ SET(_stage BUILD)
+ENDIF()
- #
- # Determine whether the CONFIGURE, BUILD or RUN stages were run successfully:
- #
+#
+# Print out the test result:
+#
- STRING(REGEX MATCH "${TEST}: CONFIGURE failed\\." _configure_regex ${_output})
- STRING(REGEX MATCH "${TEST}: BUILD failed\\." _build_regex ${_output})
- STRING(REGEX MATCH "${TEST}: RUN failed\\." _run_regex ${_output})
- STRING(REGEX MATCH "${TEST}: DIFF failed\\." _diff_regex ${_output})
+MESSAGE("Test ${TEST}: ${_stage}")
+MESSAGE("=============================== OUTPUT BEGIN ===============================")
- IF(NOT "${_configure_regex}" STREQUAL "")
- SET(_stage CONFIGURE)
- ELSEIF(NOT "${_run_regex}" STREQUAL "")
- SET(_stage RUN)
- ELSEIF(NOT "${_diff_regex}" STREQUAL "")
- SET(_stage DIFF)
- ELSE() # unconditionally, because "BUILD failed." doesn't have to be printed...
- SET(_stage BUILD)
- ENDIF()
+IF("${_stage}" STREQUAL "PASSED")
+ MESSAGE("${TEST}: PASSED.")
+
+ELSE()
- MESSAGE("Test ${TEST}: ${_stage}")
- MESSAGE("=============================== OUTPUT BEGIN ===============================")
IF( "${_stage}" STREQUAL "BUILD" AND "${_build_regex}" STREQUAL "" )
# Some special output in case the BUILD stage failed in a regression test:
MESSAGE("${TEST}: BUILD failed. Output:")
MESSAGE("")
MESSAGE("${TEST}: ****** ${_stage} failed *******")
MESSAGE("")
- MESSAGE("=============================== OUTPUT END ===============================")
- MESSAGE(FATAL_ERROR "*** abort")
+ENDIF()
+MESSAGE("=============================== OUTPUT END ===============================")
+
+#
+# Bail out:
+#
+
+IF(NOT "${_stage}" STREQUAL "${EXPECT}")
+ MESSAGE("Excpected stage ${EXPECT} - aborting")
+ MESSAGE(FATAL_ERROR "*** abort")
+ELSEIF(NOT "${_stage}" STREQUAL "PASSED")
+ MESSAGE("Excpected stage ${EXPECT} - test considered successful.")
ENDIF()
#include <vector>
-
DEAL_II_NAMESPACE_OPEN
/**
STRING(TOLOWER ${_build} _build_lowercase)
SET(_test ${_category}/${_path}/${_file}.${_build_lowercase})
- SET(_target ${_category}-${_path}-${_file}.${_build_lowercase})
+ STRING(REGEX REPLACE "\\/" "-" _target ${_test})
# Respect TEST_PICKUP_REGEX:
IF( "${TEST_PICKUP_REGEX}" STREQUAL "" OR
COMPILE_DEFINITIONS HEADER=<deal.II/${_path}/${_file}>
)
+ ADD_CUSTOM_TARGET(${_target}.build
+ COMMAND
+ echo "${_test}: BUILD successful."
+ && echo "${_test}: PASSED."
+ )
+ ADD_DEPENDENCIES(${_target}.build ${_target})
+
# And finally add the test:
ADD_TEST(NAME ${_test}
- COMMAND ${CMAKE_COMMAND} -DTRGT=${_target} -DTEST=${_test}
+ COMMAND ${CMAKE_COMMAND} -DTRGT=${_target}.build -DTEST=${_test}
-DDEAL_II_BINARY_DIR=${CMAKE_BINARY_DIR}
-P ${DEAL_II_SOURCE_DIR}/cmake/scripts/run_test.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}