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