From: Matthias Maier Date: Sat, 28 Sep 2013 14:49:06 +0000 (+0000) Subject: Bugfix: Avoid a race condition between concurrent invocations of the X-Git-Tag: v8.1.0~570^2~165 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9246387ad6a40fced4a79057709d2fc38bca5c64;p=dealii.git Bugfix: Avoid a race condition between concurrent invocations of the same test with different mpirun processes git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31000 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/cmake/macros/macro_add_test.cmake b/tests/cmake/macros/macro_add_test.cmake index 3bd9ab3f4b..1a5ebd515c 100644 --- a/tests/cmake/macros/macro_add_test.cmake +++ b/tests/cmake/macros/macro_add_test.cmake @@ -74,52 +74,52 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file _n_cpu) # # Setup a bunch of variables describing the test: # + STRING(TOLOWER ${_build} _build_lowercase) - SET(_test_short ${_test_name}.${_build_lowercase}) # short test name - SET(_target ${_category}-${_test_short}) # the target name for the executable # If _n_cpu is equal to "0", a normal, sequental test will be run, # otherwise run the test with mpirun: IF("${_n_cpu}" STREQUAL "0") - SET(_diff_target ${_target}.diff) # diff target name - SET(_test_full ${_category}/${_test_name}.${_build_lowercase}) # full test name - SET(_test_directory ${CMAKE_CURRENT_BINARY_DIR}/${_test_short}) # directory to run the test in - SET(_run_command ${_target}) # the command to issue + SET(_target ${_test_name}.${_build_lowercase}) # the target name for the executable + SET(_run_command) # the first part of the command to issue SET(_n_cpu 1) # set it to one, we'll still occupy one processor to run a test ;-) ELSE() - SET(_diff_target ${_category}-${_test_name}.mpirun${_n_cpu}.${_build_lowercase}.diff) # diff target name - SET(_test_full ${_category}/${_test_name}.mpirun=${_n_cpu}.${_build_lowercase}) # full test name - SET(_test_directory ${CMAKE_CURRENT_BINARY_DIR}/${_test_short}/mpirun=${_n_cpu}) # directory to run the test in - SET(_run_command mpirun -np ${_n_cpu} ${CMAKE_CURRENT_BINARY_DIR}/${_test_short}/${_target}) # the command to issue + SET(_target ${_test_name}.mpirun=${_n_cpu}.${_build_lowercase}) # the target name for the executable + SET(_run_command mpirun -np ${_n_cpu}) # the first part of the command to issue ENDIF() + SET(_test_full ${_category}/${_target}) # full test name + SET(_test_directory ${CMAKE_CURRENT_BINARY_DIR}/${_target}) # directory to run the test in + + # avoid "=" in target names: + STRING(REGEX REPLACE "=" "" _target "${_target}") + LIST(APPEND _run_command ${_target}) # the second part of the command to issue + SET(_diff_target ${_target}.diff) # diff target name + FILE(MAKE_DIRECTORY ${_test_directory}) # # Add an executable for the current test and set up compile # definitions and the full link interface: # - IF(NOT TARGET ${_target}) - # only add the target once - - ADD_EXECUTABLE(${_target} EXCLUDE_FROM_ALL ${_test_name}.cc) - - SET_TARGET_PROPERTIES(${_target} PROPERTIES - LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" - COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_${_build}}" - COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}" - LINKER_LANGUAGE "CXX" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_test_short}" - ) - SET_PROPERTY(TARGET ${_target} APPEND PROPERTY - INCLUDE_DIRECTORIES "${DEAL_II_INCLUDE_DIRS}" - ) - SET_PROPERTY(TARGET ${_target} APPEND PROPERTY - COMPILE_DEFINITIONS - SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" - ) - TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET_${_build}}) - ENDIF() + + ADD_EXECUTABLE(${_target} EXCLUDE_FROM_ALL ${_test_name}.cc) + + SET_TARGET_PROPERTIES(${_target} PROPERTIES + LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" + COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_${_build}}" + COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}" + LINKER_LANGUAGE "CXX" + RUNTIME_OUTPUT_DIRECTORY "${_test_directory}" + ) + SET_PROPERTY(TARGET ${_target} APPEND PROPERTY + INCLUDE_DIRECTORIES "${DEAL_II_INCLUDE_DIRS}" + ) + SET_PROPERTY(TARGET ${_target} APPEND PROPERTY + COMPILE_DEFINITIONS + SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" + ) + TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET_${_build}}) # # Add a top level target to run and compare the test: