George Keishing | 4346a41 | 2016-07-19 11:26:49 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This module is for collecting data on test case failure |
| 3 | ... for openbmc systems. It will collect the data with a |
| 4 | ... default name openbmc_ffdc_report.txt under directory |
| 5 | ... logs/testSuite/testcaseName/ on failure. |
| 6 | |
| 7 | Library String |
| 8 | Library DateTime |
| 9 | Library openbmc_ffdc_list.py |
| 10 | |
| 11 | Resource resource.txt |
| 12 | Resource connection_client.robot |
| 13 | |
| 14 | *** Variables *** |
| 15 | |
| 16 | ${PRINT_LINE} ------------------------------------------------------------------------ |
| 17 | |
| 18 | ${MSG_INTRO} This document contains the following information: |
| 19 | ${MSG_DETAIL} ${\n}\t\t[ Detailed Logs Captured Section ] |
| 20 | ${HEADER_MSG} ${\n}${PRINT_LINE}${\n}\t\tOPEN BMC TEST FAILURE DATA CAPTURE |
| 21 | ... ${\n}\t\t---------------------------------- |
| 22 | ... ${\n}${\n}TEST SUITE FILE\t\t: ${SUITE_NAME} ${\n} |
| 23 | ${FOOTER_MSG} ${PRINT_LINE} ${\n} |
| 24 | |
| 25 | ${FFDC_LOG_PATH} ${EXECDIR}${/}logs${/} |
| 26 | |
| 27 | *** Keywords *** |
| 28 | |
| 29 | Log FFDC |
| 30 | [Documentation] Generic FFDC entry point. Place holder to hook in |
| 31 | ... other data collection |
| 32 | |
| 33 | Log FFDC If Test Case Failed |
| 34 | |
| 35 | |
| 36 | Log FFDC If Test Case Failed |
| 37 | [Documentation] Main entry point to gather logs on Test case failure |
| 38 | |
| 39 | # Return from here if the test case is a PASS |
| 40 | Return From Keyword If '${TEST_STATUS}' != 'FAIL' |
| 41 | |
| 42 | ${cur_time}= get current time stamp |
| 43 | Log To Console ${\n}FFDC Collection Started \t: ${cur_time} |
| 44 | # Log directory setup |
| 45 | ${suite_dir}= get strip string ${SUITE_NAME} |
| 46 | ${testname_dir}= get strip string ${TEST_NAME} |
| 47 | |
| 48 | Set Suite Variable ${FFDC_DIR_PATH} ${FFDC_LOG_PATH}${suite_dir}${/}${testname_dir} |
| 49 | |
| 50 | # -- FFDC workspace create -- |
| 51 | create ffdc directory |
| 52 | openbmc header message |
| 53 | |
| 54 | # -- FFDC processing entry point -- |
| 55 | Execute FFDC command list on BMC |
| 56 | |
| 57 | ${cur_time}= get current time stamp |
| 58 | Log To Console FFDC Collection Completed \t: ${cur_time} |
| 59 | Log ${\n}${FFDC_DIR_PATH} |
| 60 | |
| 61 | |
| 62 | create ffdc directory |
| 63 | [Documentation] Creates directory and report file |
| 64 | Create Directory ${FFDC_DIR_PATH} |
| 65 | create ffdc report file |
| 66 | |
| 67 | |
| 68 | create ffdc report file |
| 69 | [Documentation] Create a generic file name for ffdc |
| 70 | Set Suite Variable ${FFDC_FILE_PATH} ${FFDC_DIR_PATH}${/}openbmc_ffdc_report.txt |
| 71 | Create File ${FFDC_FILE_PATH} |
| 72 | |
| 73 | |
| 74 | write data to file |
| 75 | [Documentation] Write data to the ffdc report document |
| 76 | [Arguments] ${data}="" |
| 77 | Append To File ${FFDC_FILE_PATH} ${data} |
| 78 | |
| 79 | |
| 80 | get current time stamp |
| 81 | [Documentation] Get the current time stamp data |
| 82 | ${cur_time}= Get Current Date result_format=%Y-%m-%d %H:%M:%S,%f |
| 83 | [return] ${cur_time} |
| 84 | |
| 85 | openbmc header message |
| 86 | [Documentation] Write header message to the report document |
| 87 | ${cur_time}= get current time stamp |
| 88 | write data to file ${HEADER_MSG} |
| 89 | write data to file TEST CASE NAME\t\t: ${TEST_NAME}${\n} |
| 90 | write data to file FAILURE TIME STAMP\t: ${cur_time}${\n} |
| 91 | write data to file ${\n}${MSG_INTRO}${\n} |
| 92 | |
| 93 | # --- FFDC header notes --- |
| 94 | @{entries}= Get ffdc index |
| 95 | :FOR ${index} IN @{entries} |
| 96 | \ write data to file * ${index.upper()} |
| 97 | \ write data to file ${\n} |
| 98 | |
| 99 | write data to file ${FOOTER_MSG} |
| 100 | write data to file ${MSG_DETAIL} |
| 101 | |
| 102 | write cmd output to ffdc file |
| 103 | [Documentation] Write cmd output data to the report document |
| 104 | [Arguments] ${data_str}="" ${data_cmd}="" |
| 105 | write data to file ${\n}${FOOTER_MSG} |
| 106 | write data to file ${ENTRY_CMD_TYPE.upper()} : ${data_str}\t |
| 107 | write data to file Executed : ${data_cmd} ${\n} |
| 108 | write data to file ${FOOTER_MSG} |
| 109 | |
| 110 | |
| 111 | Execute FFDC command list on BMC |
| 112 | [Documentation] Get the commands, connect to BMC and execute commands |
| 113 | ${con_status}= Run Keyword And Return Status Open Connection And Log In |
| 114 | Run Keyword And Return If ${con_status} == ${False} Log Open Connection Failed |
| 115 | |
| 116 | @{entries}= Get ffdc index |
| 117 | :FOR ${index} IN @{entries} |
| 118 | \ Loop through ffdc dict list and execute ${index} |
| 119 | |
| 120 | |
| 121 | Loop through ffdc dict list and execute |
| 122 | [Documentation] Feed in key pair list from dictionary to execute |
| 123 | [Arguments] ${data_str}= |
| 124 | @{ffdc_default_list}= Get ffdc cmd ${data_str} |
| 125 | |
| 126 | Set Suite Variable ${ENTRY_CMD_TYPE} ${data_str} |
| 127 | :FOR ${cmd} IN @{ffdc_default_list} |
| 128 | \ Execute command and write to ffdc ${cmd[0]} ${cmd[1]} |
| 129 | |
| 130 | |
| 131 | Execute command and write to ffdc |
| 132 | [Documentation] Execute command on bmc box and write to ffdc |
| 133 | [Arguments] ${data_str}="" ${data_cmd}="" |
| 134 | write cmd output to ffdc file ${data_str} ${data_cmd} |
| 135 | |
| 136 | ${stdout} ${stderr}= Execute Command ${data_cmd} return_stderr=True |
| 137 | # Write stdout data on success and error msg to the file on failure |
| 138 | Run Keyword If '${stderr}' == '${EMPTY}' write data to file ${stdout} ${\n} |
| 139 | ... ELSE Run Keyword write data to file ${stderr} ${\n} |
| 140 | write data to file ${FOOTER_MSG} |
| 141 | |
| 142 | |
| 143 | Offload file list from BMC |
| 144 | [Documentation] Copy files to current log directory |
| 145 | ${con_status}= Run Keyword And Return Status Open Connection for SCP |
| 146 | Run Keyword And Return If ${con_status} == ${False} Log SCP Connection Failed |
| 147 | |
| 148 | # --- Files to be copied --- |
| 149 | @{ffdc_default_list}= Get ffdc file BMC Files |
| 150 | Set Suite Variable ${ENTRY_CMD_TYPE} BMC Files |
| 151 | |
| 152 | :FOR ${cmd} IN @{ffdc_default_list} |
| 153 | # Get File from server to current test FFDC directory |
| 154 | \ write cmd output to ffdc file ${cmd[0]} scp file ${cmd[1]} |
| 155 | \ scp.Get File ${cmd[1]} ${FFDC_DIR_PATH} |
| 156 | |