blob: 2058cd10e6917cb641b8cb435060ecab55f273e6 [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}
Sunil M22d293b2017-05-29 05:35:40 -050028 :FOR ${file} IN @{skip_list}
Joy Onyerikwu9b668972018-05-22 19:10:43 -050029 \ ${skip_list_string}= Set Variable ${skip_list_string} && rm ${file}
Sunil M22d293b2017-05-29 05:35:40 -050030
Joy Onyerikwu9b668972018-05-22 19:10:43 -050031 ${file_count1} ${stderr} ${rc}= BMC Execute Command
32 ... find ${cleanup_dir_path} | wc -l
33 BMC Execute Command ${skip_list_string}
Sunil M22d293b2017-05-29 05:35:40 -050034
Joy Onyerikwu9b668972018-05-22 19:10:43 -050035 ${file_count2} ${stderrt} ${rc}= BMC Execute Command
36 ... find ${cleanup_dir_path} | wc -l
Sunil M22d293b2017-05-29 05:35:40 -050037 Should Be True ${file_count2} < ${file_count1}
Joy Onyerikwu9b668972018-05-22 19:10:43 -050038 # Delete the directory if it is empty.
39 Run Keyword If ${file_count2} <= 1
40 ... BMC Execute Command rm -r ${cleanup_dir_path}