[Cmake-commits] [cmake-commits] king committed CMakeLists.txt 1.1 1.2 check.cmake NONE 1.1 timeout.c 1.2 1.3 timeout.cmake NONE 1.1

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Nov 30 16:31:30 EST 2009


Update of /cvsroot/CMake/CMake/Tests/CTestTestTimeout
In directory public:/mounts/ram/cvs-serv16954/Tests/CTestTestTimeout

Modified Files:
	CMakeLists.txt timeout.c 
Added Files:
	check.cmake timeout.cmake 
Log Message:
CTest: Test process tree kill on timeout

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.


--- NEW FILE: check.cmake ---
# 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()

Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/CTestTestTimeout/CMakeLists.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** CMakeLists.txt	29 Sep 2009 19:18:46 -0000	1.1
--- CMakeLists.txt	30 Nov 2009 21:31:27 -0000	1.2
***************
*** 1,3 ****
! cmake_minimum_required (VERSION 2.6)
  PROJECT(CTestTestTimeout)
  
--- 1,3 ----
! cmake_minimum_required (VERSION 2.8)
  PROJECT(CTestTestTimeout)
  
***************
*** 13,18 ****
  ENABLE_TESTING ()
  
! ADD_TEST (TestTimeout Timeout)
  SET_TESTS_PROPERTIES(TestTimeout PROPERTIES TIMEOUT 1)
  
  INCLUDE (CTest)
--- 13,30 ----
  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)

Index: timeout.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/CTestTestTimeout/timeout.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** timeout.c	30 Sep 2009 18:48:40 -0000	1.2
--- timeout.c	30 Nov 2009 21:31:27 -0000	1.3
***************
*** 5,8 ****
--- 5,10 ----
  #endif
  
+ #include <stdio.h>
+ 
  int main(void)
  {
***************
*** 12,15 ****
--- 14,18 ----
    sleep(5);
  #endif
+   printf("timeout process finished sleeping!\n");
    return -1;
  }

--- NEW FILE: timeout.cmake ---
# Remove the log file.
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})



More information about the Cmake-commits mailing list