]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Testsuite: Bugfix: Add a guard file mechanism
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Oct 2013 22:36:03 +0000 (22:36 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Oct 2013 22:36:03 +0000 (22:36 +0000)
This commit adds a guard file mechanism to detect whether an individual
test that was forcefully interrupted e.g. by sigkilling the run_test.cmake
script due to hitting a timeout in ctest.

In that case all test stages are rerun completely.

git-svn-id: https://svn.dealii.org/trunk@31403 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/macros/macro_add_test.cmake
deal.II/cmake/scripts/run_test.cmake
deal.II/tests/all-headers/CMakeLists.txt
deal.II/tests/build_tests/CMakeLists.txt

index 0bda009a4c9cb2eaf281688c6a1e9695049e2df3..517f39e692e574eceb3c6eafe405618c8e1a9cd5 100644 (file)
@@ -130,7 +130,14 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file)
       IF(NOT TARGET ${_target})
         # only add the target once
 
-        ADD_EXECUTABLE(${_target} EXCLUDE_FROM_ALL ${_test_name}.cc)
+        ADD_CUSTOM_COMMAND(
+          OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}/timeout_guard.cc
+          COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${_target}/timeout_guard.cc
+          )
+
+        ADD_EXECUTABLE(${_target} EXCLUDE_FROM_ALL ${_test_name}.cc
+          ${CMAKE_CURRENT_BINARY_DIR}/${_target}/timeout_guard.cc
+          )
 
         SET_TARGET_PROPERTIES(${_target} PROPERTIES
           LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
@@ -218,6 +225,7 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file)
           -DEXPECT=${_expect}
           -DADDITIONAL_OUTPUT=${ARGN}
           -DDEAL_II_BINARY_DIR=${CMAKE_BINARY_DIR}
+          -DGUARD_FILE=${CMAKE_CURRENT_BINARY_DIR}/${_target}/timeout_guard.cc
           -P ${DEAL_II_SOURCE_DIR}/cmake/scripts/run_test.cmake
         WORKING_DIRECTORY ${_test_directory}
         )
index fb2a42f5e0398c768a15dbd89e20f454c892ebff..3e929e32e76666d8ab943ea0f4ceaa5b7bdbf94a 100644 (file)
 #
 #   ADDITIONAL_OUTPUT - A list of additional output lines that should be printed
 #
+#   GUARD_FILE - used to detect a forced interruption of this script: On
+#                startup the backed up file ${GUARD_FILE}_back is put back
+#                in place as ${GUARD_FILE} and on exit ${GUARD_FILE} is
+#                backed up as ${GUARD_FILE}_back. If on startup a stale
+#                ${GUARD_FILE} is found, it is deleted.
+#
+
+IF(NOT "${GUARD_FILE}" STREQUAL "" AND EXISTS ${GUARD_FILE})
+  #
+  # Guard file still exists, so this script must have been interrupted.
+  # Remove guard file to force a complete rerun:
+  #
+  EXECUTE_PROCESS(COMMAND rm -f ${GUARD_FILE})
+ELSEIF(NOT "${GUARD_FILE}" STREQUAL "" AND EXISTS ${GUARD_FILE}_bck)
+  #
+  # A backed up guard file exists. Put it back in place:
+  #
+  EXECUTE_PROCESS(COMMAND mv ${GUARD_FILE}_bck ${GUARD_FILE})
+ENDIF()
+
 
 IF("${EXPECT}" STREQUAL "")
   SET(EXPECT "PASSED")
@@ -77,7 +97,8 @@ ENDFOREACH()
 MESSAGE("===============================   OUTPUT BEGIN  ===============================")
 
 IF("${_stage}" STREQUAL "PASSED")
-  MESSAGE("${TEST}: PASSED.")
+  #MESSAGE("${TEST}: PASSED.")
+  MESSAGE(${_output})
 
 ELSE()
 
@@ -93,6 +114,14 @@ ENDIF()
 
 MESSAGE("===============================    OUTPUT END   ===============================")
 
+#
+# Back up guard file:
+#
+
+IF(NOT "${GUARD_FILE}" STREQUAL "" AND EXISTS ${GUARD_FILE})
+  EXECUTE_PROCESS(COMMAND mv ${GUARD_FILE} ${GUARD_FILE}_bck)
+ENDIF()
+
 #
 # Bail out:
 #
index 2a68496524fa2b0c73520d08e4f9d9f345272d13..62fd18c942c75ce5da3d4ffcddf74879c1c0e4f1 100644 (file)
@@ -45,14 +45,21 @@ FOREACH(_full_file ${_header})
     STRING(TOLOWER ${_build} _build_lowercase)
 
     SET(_test ${_category}/${_path}/${_file}.${_build_lowercase})
-    STRING(REGEX REPLACE "\\/" "-" _target ${_test})
+    STRING(REGEX REPLACE "\\/" "-" _target ${_path}/${_file}.${_build_lowercase})
 
     # Respect TEST_PICKUP_REGEX:
     IF( "${TEST_PICKUP_REGEX}" STREQUAL "" OR
         _test MATCHES "${TEST_PICKUP_REGEX}" )
 
+      ADD_CUSTOM_COMMAND(
+        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}_timeout_guard.cc
+        COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${_target}_timeout_guard.cc
+        )
+
       # Add an object library for each header file and build configuration:
-      ADD_LIBRARY(${_target} OBJECT EXCLUDE_FROM_ALL test_header.cc)
+      ADD_LIBRARY(${_target} OBJECT EXCLUDE_FROM_ALL test_header.cc
+        ${CMAKE_CURRENT_BINARY_DIR}/${_target}_timeout_guard.cc
+        )
 
       SET_TARGET_PROPERTIES(${_target} PROPERTIES
         LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
@@ -77,6 +84,7 @@ FOREACH(_full_file ${_header})
       ADD_TEST(NAME ${_test}
         COMMAND ${CMAKE_COMMAND} -DTRGT=${_target}.build -DTEST=${_test}
           -DDEAL_II_BINARY_DIR=${CMAKE_BINARY_DIR}
+          -DGUARD_FILE=${CMAKE_CURRENT_BINARY_DIR}/${_target}_timeout_guard.cc
           -P ${DEAL_II_SOURCE_DIR}/cmake/scripts/run_test.cmake
         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
         )
index e0beebfc1ede8031663fab054e6413fc00d32ba0..ec3297c821f841c7155b628aaeb613f3c15b87cf 100644 (file)
@@ -62,6 +62,12 @@ FOREACH(_step_full ${_steps})
     IF( "${TEST_PICKUP_REGEX}" STREQUAL "" OR
         _test MATCHES "${TEST_PICKUP_REGEX}"  )
 
+      ADD_CUSTOM_COMMAND(
+        OUTPUT ${_step_dir}/timeout_guard
+        COMMAND ${CMAKE_COMMAND} -E make_directory ${_step_dir}
+        COMMAND touch ${_step_dir}/timeout_guard
+        )
+
       SET(_step_dir ${CMAKE_CURRENT_BINARY_DIR}/${_step}.${_build_lowercase})
 
       FILE(GLOB _files ${_step_full}/*)
@@ -76,12 +82,12 @@ FOREACH(_step_full ${_steps})
 
       # A rule how to copy the example step to the current directory:
       ADD_CUSTOM_COMMAND(OUTPUT ${_step_dir}/CMakeLists.txt
-        COMMAND ${CMAKE_COMMAND} -E make_directory ${_step_dir}
         ${_command}
         DEPENDS
           ${_files}
           ${DEAL_II_TARGET_DEBUG}
           ${DEAL_II_TARGET_RELEASE}
+          ${_step_dir}/timeout_guard
           )
 
       # And a rule on how to configure the example step:
@@ -144,7 +150,7 @@ FOREACH(_step_full ${_steps})
       ITEM_MATCHES(_match ${_step} ${_${_build_lowercase}_steps})
       IF(_match)
         # Add a full test (CONFIGURE, BUILD, RUN):
-        SET(_target ${_category}-${_step}.${_build_lowercase}.run)
+        SET(_target ${_step}.${_build_lowercase}.run)
         ADD_CUSTOM_TARGET(${_target}
           COMMAND
                echo "${_test}: CONFIGURE successful."
@@ -155,7 +161,7 @@ FOREACH(_step_full ${_steps})
           )
       ELSE()
         # Add a minimal test (CONFIGURE, BUILD):
-        SET(_target ${_category}-${_step}.${_build_lowercase}.build)
+        SET(_target ${_step}.${_build_lowercase}.build)
         ADD_CUSTOM_TARGET(${_target}
           COMMAND
                echo "${_test}: CONFIGURE successful."
@@ -169,6 +175,7 @@ FOREACH(_step_full ${_steps})
       ADD_TEST(NAME ${_test}
         COMMAND ${CMAKE_COMMAND} -DTRGT=${_target} -DTEST=${_test}
           -DDEAL_II_BINARY_DIR=${CMAKE_BINARY_DIR}
+          -DGUARD_FILE=${_step_dir}/timeout_guard
           -P ${DEAL_II_SOURCE_DIR}/cmake/scripts/run_test.cmake
         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
         )

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.