diff options
author | Brad King <brad.king@kitware.com> | 2014-05-27 13:46:38 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-05-27 13:46:38 (GMT) |
commit | 6ca21345c85324e01b49975706bbac2bcde91267 (patch) | |
tree | 0aac76fdbca5bd6ac977ca041d1c606074dfa7cb | |
parent | c5315524629bea99ccaaa4e0e666fe4918f66064 (diff) | |
parent | 9afcecaf32acb4333b33d46522f98457bfa8856d (diff) | |
download | CMake-6ca21345c85324e01b49975706bbac2bcde91267.zip CMake-6ca21345c85324e01b49975706bbac2bcde91267.tar.gz CMake-6ca21345c85324e01b49975706bbac2bcde91267.tar.bz2 |
Merge topic 'revise-CTestTestTimeout'
9afcecaf Tests: Try to make CTestTestTimeout more robust
-rw-r--r-- | Tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CTestTestTimeout/CMakeLists.txt | 12 | ||||
-rw-r--r-- | Tests/CTestTestTimeout/check.cmake | 9 | ||||
-rw-r--r-- | Tests/CTestTestTimeout/sleep.c | 21 | ||||
-rw-r--r-- | Tests/CTestTestTimeout/test.cmake.in | 13 | ||||
-rw-r--r-- | Tests/CTestTestTimeout/timeout.c | 18 | ||||
-rw-r--r-- | Tests/CTestTestTimeout/timeout.cmake | 2 |
7 files changed, 40 insertions, 37 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5014ef3..8d2b7fc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -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 diff --git a/Tests/CTestTestTimeout/CMakeLists.txt b/Tests/CTestTestTimeout/CMakeLists.txt index 476d0a5..2e3bd6a 100644 --- a/Tests/CTestTestTimeout/CMakeLists.txt +++ b/Tests/CTestTestTimeout/CMakeLists.txt @@ -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) diff --git a/Tests/CTestTestTimeout/check.cmake b/Tests/CTestTestTimeout/check.cmake deleted file mode 100644 index b16f2aa..0000000 --- a/Tests/CTestTestTimeout/check.cmake +++ /dev/null @@ -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() diff --git a/Tests/CTestTestTimeout/sleep.c b/Tests/CTestTestTimeout/sleep.c new file mode 100644 index 0000000..33ce307 --- /dev/null +++ b/Tests/CTestTestTimeout/sleep.c @@ -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; +} diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in index 4178849..68c74d8 100644 --- a/Tests/CTestTestTimeout/test.cmake.in +++ b/Tests/CTestTestTimeout/test.cmake.in @@ -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() diff --git a/Tests/CTestTestTimeout/timeout.c b/Tests/CTestTestTimeout/timeout.c deleted file mode 100644 index 370ab22..0000000 --- a/Tests/CTestTestTimeout/timeout.c +++ /dev/null @@ -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; -} diff --git a/Tests/CTestTestTimeout/timeout.cmake b/Tests/CTestTestTimeout/timeout.cmake index 198cc97..0989b65 100644 --- a/Tests/CTestTestTimeout/timeout.cmake +++ b/Tests/CTestTestTimeout/timeout.cmake @@ -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}) |