88eefaced1
We extend the CTestTestTimeout test to check that when a test times out its children (grandchildren of ctest) are killed. Instead of running the timeout executable directly, we run it through a cmake script that redirects the timeout executable output to a file. A second test later runs and verifies that the timeout executable was unable to complete and write data to the log file. Only if the first inner test times out and the second inner test passes (log is empty) does the CTestTestTimeout test pass.
31 lines
936 B
CMake
31 lines
936 B
CMake
cmake_minimum_required (VERSION 2.8)
|
|
PROJECT(CTestTestTimeout)
|
|
|
|
SET(DART_ROOT "" CACHE STRING "" FORCE)
|
|
ENABLE_TESTING()
|
|
INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake)
|
|
|
|
GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH)
|
|
SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest")
|
|
|
|
ADD_EXECUTABLE (Timeout timeout.c)
|
|
|
|
ENABLE_TESTING ()
|
|
|
|
ADD_TEST(NAME TestTimeout
|
|
COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout>
|
|
-D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/timeout.cmake
|
|
)
|
|
SET_TESTS_PROPERTIES(TestTimeout PROPERTIES TIMEOUT 1)
|
|
|
|
ADD_TEST(NAME CheckChild
|
|
COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout>
|
|
-D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake
|
|
)
|
|
SET_TESTS_PROPERTIES(CheckChild PROPERTIES DEPENDS TestTimeout)
|
|
|
|
|
|
INCLUDE (CTest)
|