blob: 8040ead5166a89bfec04fa11239992c9a2a3ee14 [file] [log] [blame]
Sunil M22d293b2017-05-29 05:35:40 -05001*** Settings ***
2Resource ../lib/utils.robot
3Resource ../lib/connection_client.robot
4Resource ../lib/boot_utils.robot
5
6*** Variables ***
7# User defined path to do the cleanup.
8${CLEANUP_DIR_PATH} ${EMPTY}
9# List that holds space separated filepaths to skip from cleanup.
10${SKIP_LIST} ${EMPTY}
11
12*** Keywords ***
13
Sunil M22d293b2017-05-29 05:35:40 -050014
15Cleanup Dir
16 [Documentation] Remove leftover files in cleanup directory path.
17 [Arguments] ${cleanup_dir_path}=${CLEANUP_DIR_PATH}
18 ... ${skip_list}=${SKIP_LIST}
19
20 # Description of argument(s):
21 # cleanup_dir_path Directory path to do the cleanup.
22 # skip_list List of files to skip from cleanup.
23
24 Should Not Be Empty ${cleanup_dir_path}
25 Should Not Be Empty ${SKIP_LIST}
Joy Onyerikwu9b668972018-05-22 19:10:43 -050026
27 ${skip_list_string}= Set Variable cd ${cleanup_dir_path}
Marissa Garza20ccfc72020-06-19 12:51:10 -050028 FOR ${file} IN @{skip_list}
29 ${skip_list_string}= Set Variable ${skip_list_string} && rm ${file}
30 END
Sunil M22d293b2017-05-29 05:35:40 -050031
Joy Onyerikwu9b668972018-05-22 19:10:43 -050032 ${file_count1} ${stderr} ${rc}= BMC Execute Command
33 ... find ${cleanup_dir_path} | wc -l
34 BMC Execute Command ${skip_list_string}
Sunil M22d293b2017-05-29 05:35:40 -050035
Joy Onyerikwu9b668972018-05-22 19:10:43 -050036 ${file_count2} ${stderrt} ${rc}= BMC Execute Command
37 ... find ${cleanup_dir_path} | wc -l
Sunil M22d293b2017-05-29 05:35:40 -050038 Should Be True ${file_count2} < ${file_count1}
Joy Onyerikwu9b668972018-05-22 19:10:43 -050039 # Delete the directory if it is empty.
40 Run Keyword If ${file_count2} <= 1
41 ... BMC Execute Command rm -r ${cleanup_dir_path}