RunCleanerTest3.cmake 1009 B

12345678910111213141516171819202122232425262728
  1. set (RUNS 3)
  2. # Create the subdirectory required by this unit test.
  3. file (MAKE_DIRECTORY ${TEST_DIR}/${TEST_SUBDIR})
  4. foreach (iter RANGE 1 ${RUNS})
  5. execute_process (COMMAND ${LOGCLEANUP} -log_dir=${TEST_DIR}
  6. RESULT_VARIABLE _RESULT)
  7. if (NOT _RESULT EQUAL 0)
  8. message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})")
  9. endif (NOT _RESULT EQUAL 0)
  10. # Ensure the log files to have different modification timestamps such that
  11. # exactly one log file remains at the end. Otherwise all log files will be
  12. # retained.
  13. execute_process (COMMAND ${CMAKE_COMMAND} -E sleep 2)
  14. endforeach (iter)
  15. file (GLOB LOG_FILES ${TEST_DIR}/${TEST_SUBDIR}/test_cleanup_*.relativefoo)
  16. list (LENGTH LOG_FILES NUM_FILES)
  17. if (NOT NUM_FILES EQUAL 1)
  18. message (SEND_ERROR "Expected 1 log file in build directory ${TEST_DIR}${TEST_SUBDIR} but found ${NUM_FILES}")
  19. endif (NOT NUM_FILES EQUAL 1)
  20. # Remove the subdirectory required by this unit test.
  21. file (REMOVE_RECURSE ${TEST_DIR}/${TEST_SUBDIR})