Make CTestTestTimeout time configurable
In this test we start up a cmake script that runs a process that sleeps, and the timeout for the script is shorter than the sleep time. However, in order to properly detect that the sleeping grandchild is killed when the script times out we need to give sufficient time for the script to start the grandchild. Otherwise the log file for the grandchild is not available. On some (cygwin) builds our previous 1 second timeout for the script was not long enough to let the interpreter load and start the grandchild. We make the timeout time configurable by setting CTestTestTimeout_TIME in the cache for CMake itself. It tells the test how long to let the script run. The grandchild always sleeps for 4 seconds longer to ensure a comfortable window during which the process tree can be killed.
This commit is contained in:
parent
ed55b1b8d2
commit
b14734b9b6
|
@ -2,6 +2,11 @@ cmake_minimum_required (VERSION 2.8)
|
|||
PROJECT(CTestTestTimeout)
|
||||
INCLUDE(CTest)
|
||||
|
||||
IF(NOT TIMEOUT)
|
||||
SET(TIMEOUT 1)
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-DTIMEOUT=${TIMEOUT})
|
||||
ADD_EXECUTABLE (Timeout timeout.c)
|
||||
|
||||
ADD_TEST(NAME TestTimeout
|
||||
|
@ -9,7 +14,7 @@ ADD_TEST(NAME TestTimeout
|
|||
-D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/timeout.cmake
|
||||
)
|
||||
SET_TESTS_PROPERTIES(TestTimeout PROPERTIES TIMEOUT 1)
|
||||
SET_TESTS_PROPERTIES(TestTimeout PROPERTIES TIMEOUT ${TIMEOUT})
|
||||
|
||||
ADD_TEST(NAME CheckChild
|
||||
COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout>
|
||||
|
|
|
@ -21,6 +21,7 @@ SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIP
|
|||
#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY})
|
||||
|
||||
FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "
|
||||
TIMEOUT:STRING=@CTestTestTimeout_TIME@
|
||||
CMAKE_TEST_GENERATOR:STRING=@CMAKE_TEST_GENERATOR@
|
||||
CMAKE_TEST_MAKEPROGRAM:FILEPATH=@CMAKE_TEST_MAKEPROGRAM@
|
||||
MAKECOMMAND:STRING=@MAKECOMMAND@
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
int main(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
Sleep(5000);
|
||||
Sleep((TIMEOUT+4)*1000);
|
||||
#else
|
||||
sleep(5);
|
||||
sleep((TIMEOUT+4));
|
||||
#endif
|
||||
printf("timeout process finished sleeping!\n");
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue