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