Merge topic 'revise-CTestTestTimeout'
9afcecaf
Tests: Try to make CTestTestTimeout more robust
This commit is contained in:
commit
6ca21345c8
|
@ -2394,7 +2394,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
|
|||
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log"
|
||||
)
|
||||
set_tests_properties(CTestTestTimeout PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed")
|
||||
PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*TestSleep *\\.+ *Passed.*timeout correctly killed child")
|
||||
|
||||
add_test(
|
||||
NAME CTestTestRerunFailed
|
||||
|
|
|
@ -11,18 +11,14 @@ if(NOT TIMEOUT)
|
|||
endif()
|
||||
|
||||
add_definitions(-DTIMEOUT=${TIMEOUT})
|
||||
add_executable (Timeout timeout.c)
|
||||
add_executable (Sleep sleep.c)
|
||||
|
||||
add_test(NAME TestTimeout
|
||||
COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout>
|
||||
COMMAND ${CMAKE_COMMAND} -D Sleep=$<TARGET_FILE:Sleep>
|
||||
-D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/timeout.cmake
|
||||
)
|
||||
set_tests_properties(TestTimeout PROPERTIES TIMEOUT ${TIMEOUT})
|
||||
|
||||
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)
|
||||
add_test(NAME TestSleep COMMAND Sleep)
|
||||
set_tests_properties(TestSleep PROPERTIES DEPENDS TestTimeout)
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# Block just as long as timeout.cmake would if it were not killed.
|
||||
execute_process(COMMAND ${Timeout})
|
||||
|
||||
# Verify that the log is empty, which indicates that the grandchild
|
||||
# was killed before it finished sleeping.
|
||||
file(READ "${Log}" LOG)
|
||||
if(NOT "${LOG}" STREQUAL "")
|
||||
message(FATAL_ERROR "${LOG}")
|
||||
endif()
|
|
@ -0,0 +1,21 @@
|
|||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "before sleep\n");
|
||||
fflush(stderr); /* should not be needed, but just in case */
|
||||
#if defined(_WIN32)
|
||||
Sleep((TIMEOUT+4)*1000);
|
||||
#else
|
||||
sleep((TIMEOUT+4));
|
||||
#endif
|
||||
fprintf(stderr, "after sleep\n");
|
||||
fflush(stderr); /* should not be needed, but just in case */
|
||||
return 0;
|
||||
}
|
|
@ -24,3 +24,16 @@ CTEST_START(Experimental)
|
|||
CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
|
||||
CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
|
||||
CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
|
||||
|
||||
set(log ${CTEST_BINARY_DIRECTORY}/timeout.log)
|
||||
if(EXISTS "${log}")
|
||||
# Verify that the timeout test did not finish sleeping.
|
||||
file(STRINGS "${log}" after_sleep REGEX "after sleep")
|
||||
if(after_sleep)
|
||||
message(FATAL_ERROR "Log indicates timeout did not kill child.")
|
||||
else()
|
||||
message("Log indicates timeout correctly killed child.")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Log does not exist:\n ${log}")
|
||||
endif()
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
Sleep((TIMEOUT+4)*1000);
|
||||
#else
|
||||
sleep((TIMEOUT+4));
|
||||
#endif
|
||||
printf("timeout process finished sleeping!\n");
|
||||
return -1;
|
||||
}
|
|
@ -3,4 +3,4 @@ file(REMOVE ${Log})
|
|||
|
||||
# Run a child that sleeps longer than the timout of this test.
|
||||
# Log its output so check.cmake can verify it dies.
|
||||
execute_process(COMMAND ${Timeout} OUTPUT_FILE ${Log})
|
||||
execute_process(COMMAND ${Sleep} ERROR_FILE ${Log})
|
||||
|
|
Loading…
Reference in New Issue