blob: e8105d111d92b3e27a4888278becb054aba49dca [file] [log] [blame]
James Kuszmaulba0ac1a2022-08-12 16:29:30 -07001set (RUNS 3)
2
3# Create the subdirectory required by this unit test.
4file (MAKE_DIRECTORY ${TEST_DIR}/${TEST_SUBDIR})
5
6foreach (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)
18endforeach (iter)
19
20file (GLOB LOG_FILES ${TEST_DIR}/${TEST_SUBDIR}/test_cleanup_*.relativefoo)
21list (LENGTH LOG_FILES NUM_FILES)
22
23if (NOT NUM_FILES EQUAL 1)
24 message (SEND_ERROR "Expected 1 log file in build directory ${TEST_DIR}${TEST_SUBDIR} but found ${NUM_FILES}")
25endif (NOT NUM_FILES EQUAL 1)
26
27# Remove the subdirectory required by this unit test.
28file (REMOVE_RECURSE ${TEST_DIR}/${TEST_SUBDIR})