1*e4b67f82SSunil M*** Settings ***
2*e4b67f82SSunil MDocumentation  Cleanup user patches from BMC.
3*e4b67f82SSunil M
4*e4b67f82SSunil MLibrary    ../lib/gen_robot_keyword.py
5*e4b67f82SSunil MResource   ../lib/utils.robot
6*e4b67f82SSunil MResource   ../extended/obmc_boot_test_resource.robot
7*e4b67f82SSunil M
8*e4b67f82SSunil M*** Variables ***
9*e4b67f82SSunil M
10*e4b67f82SSunil M# User defined path to cleanup.
11*e4b67f82SSunil M${CLEANUP_DIR_PATH}  ${EMPTY}
12*e4b67f82SSunil M# List that holds space separated filepaths to skip from cleanup.
13*e4b67f82SSunil M${SKIP_LIST}  ${EMPTY}
14*e4b67f82SSunil M# Number of files before cleanup.
15*e4b67f82SSunil M${file_count1}
16*e4b67f82SSunil M
17*e4b67f82SSunil M*** Test Cases ***
18*e4b67f82SSunil M
19*e4b67f82SSunil MCleanup User Patches
20*e4b67f82SSunil M    [Documentation]  Do the cleanup in cleanup directory path.
21*e4b67f82SSunil M
22*e4b67f82SSunil M    Should Not Be Empty  ${CLEANUP_DIR_PATH}
23*e4b67f82SSunil M    Open Connection And Log In
24*e4b67f82SSunil M    Remove Files
25*e4b67f82SSunil M
26*e4b67f82SSunil M*** Keywords ***
27*e4b67f82SSunil M
28*e4b67f82SSunil MRemove Files
29*e4b67f82SSunil M    [Documentation]  Remove leftover files in cleanup directory path.
30*e4b67f82SSunil M
31*e4b67f82SSunil M    Should Not Be Empty  ${SKIP_LIST}
32*e4b67f82SSunil M    @{skip_list}=  Set Variable  ${SKIP_LIST.split()}
33*e4b67f82SSunil M    ${skip_list_string}=  Set Variable  ${EMPTY}
34*e4b67f82SSunil M    :FOR  ${file}  IN  @{skip_list}
35*e4b67f82SSunil M    \  ${skip_list_string}=   Set Variable  ${skip_list_string} ! -path "${file}"
36*e4b67f82SSunil M
37*e4b67f82SSunil M    ${file_count1}=  Execute Command On BMC  find ${CLEANUP_DIR_PATH} | wc -l
38*e4b67f82SSunil M    Set Global Variable  ${file_count1}
39*e4b67f82SSunil M    Write  find ${CLEANUP_DIR_PATH} \\( ${skip_list_string} \\) | xargs rm
40*e4b67f82SSunil M    Write  find ${CLEANUP_DIR_PATH} \\( ${skip_list_string} \\) | xargs rmdir
41*e4b67f82SSunil M    ${file_count2}=  Execute Command On BMC  find ${CLEANUP_DIR_PATH} | wc -l
42*e4b67f82SSunil M
43*e4b67f82SSunil M    Run Keyword If  ${file_count2} < ${file_count1}
44*e4b67f82SSunil M    ...  Reboot And Verify
45*e4b67f82SSunil M
46*e4b67f82SSunil MReboot And Verify
47*e4b67f82SSunil M    [Documentation]  Reboot BMC and verify cleanup.
48*e4b67f82SSunil M
49*e4b67f82SSunil M    Run Key U  OBMC Boot Test \ OBMC Reboot (off)
50*e4b67f82SSunil M    ${file_count2}=  Execute Command On BMC  find ${CLEANUP_DIR_PATH} | wc -l
51*e4b67f82SSunil M    Should Be True  ${file_count2} < ${file_count1}
52