From 01f69c24b67ba9b15f502f274c0a56f1aef0bb79 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sun, 20 Oct 2013 17:51:38 +0000 Subject: [PATCH] Add expect= facility git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31344 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/macros/macro_add_test.cmake | 75 +++++++++++------ deal.II/cmake/macros/macro_pickup_tests.cmake | 24 +----- deal.II/cmake/scripts/run_test.cmake | 81 ++++++++++++------- deal.II/include/deal.II/fe/fe_bdm.h | 1 - deal.II/tests/all-headers/CMakeLists.txt | 11 ++- 5 files changed, 117 insertions(+), 75 deletions(-) diff --git a/deal.II/cmake/macros/macro_add_test.cmake b/deal.II/cmake/macros/macro_add_test.cmake index bf6c32a37e..67bc4fe0b9 100644 --- a/deal.II/cmake/macros/macro_add_test.cmake +++ b/deal.II/cmake/macros/macro_add_test.cmake @@ -26,32 +26,23 @@ # - 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/.cc -# -# as well as the comparison file -# -# ./tests/category/ # -# is available in the testsuite. -# -# If is equal to 0, the plain, generated executable will be run. If -# 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/.cc" +# as well as the comparison file "./tests/category/" is +# available in the testsuite. The output of compiled source file is +# compared against the file comparison file. # -# The output of .cc is compared against the 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 @@ -61,10 +52,47 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file _n_cpu) ) 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: @@ -184,6 +212,7 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file _n_cpu) 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} diff --git a/deal.II/cmake/macros/macro_pickup_tests.cmake b/deal.II/cmake/macros/macro_pickup_tests.cmake index 5da1848350..9226c5e2ac 100644 --- a/deal.II/cmake/macros/macro_pickup_tests.cmake +++ b/deal.II/cmake/macros/macro_pickup_tests.cmake @@ -39,6 +39,7 @@ MACRO(DEAL_II_PICKUP_TESTS) # # Respect TEST_PICKUP_REGEX: # + IF( "${TEST_PICKUP_REGEX}" STREQUAL "" OR "${_category}/${_test}" MATCHES "${TEST_PICKUP_REGEX}" ) SET(_define_test TRUE) @@ -50,6 +51,7 @@ MACRO(DEAL_II_PICKUP_TESTS) # 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} ) @@ -68,27 +70,9 @@ MACRO(DEAL_II_PICKUP_TESTS) 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() diff --git a/deal.II/cmake/scripts/run_test.cmake b/deal.II/cmake/scripts/run_test.cmake index 8ffb2eabf8..89edef1be3 100644 --- a/deal.II/cmake/scripts/run_test.cmake +++ b/deal.II/cmake/scripts/run_test.cmake @@ -17,50 +17,63 @@ # # 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:") @@ -69,7 +82,17 @@ ELSE() 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() diff --git a/deal.II/include/deal.II/fe/fe_bdm.h b/deal.II/include/deal.II/fe/fe_bdm.h index c3e1d675b5..25c9e9e3d0 100644 --- a/deal.II/include/deal.II/fe/fe_bdm.h +++ b/deal.II/include/deal.II/fe/fe_bdm.h @@ -28,7 +28,6 @@ #include - DEAL_II_NAMESPACE_OPEN /** diff --git a/deal.II/tests/all-headers/CMakeLists.txt b/deal.II/tests/all-headers/CMakeLists.txt index 0018f68d46..2a68496524 100644 --- a/deal.II/tests/all-headers/CMakeLists.txt +++ b/deal.II/tests/all-headers/CMakeLists.txt @@ -45,7 +45,7 @@ FOREACH(_full_file ${_header}) 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 @@ -66,9 +66,16 @@ FOREACH(_full_file ${_header}) COMPILE_DEFINITIONS HEADER= ) + 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} -- 2.39.5