169e6f711SGeorge Keishing*** Settings ***
269e6f711SGeorge KeishingDocumentation      Utility keywords for FFDC
369e6f711SGeorge Keishing
469e6f711SGeorge KeishingLibrary            String
569e6f711SGeorge KeishingLibrary            DateTime
669e6f711SGeorge KeishingLibrary            openbmc_ffdc_list.py
7839a0c27SSandhya SomashekarResource           resource.robot
869e6f711SGeorge KeishingResource           connection_client.robot
915e6d2f4SSweta PotthuriResource           utils.robot
1069e6f711SGeorge Keishing
1169e6f711SGeorge Keishing*** Variables ***
1269e6f711SGeorge Keishing
1369e6f711SGeorge Keishing${PRINT_LINE}      ------------------------------------------------------------------------
1469e6f711SGeorge Keishing
1569e6f711SGeorge Keishing${MSG_INTRO}       This report contains the following information:
1669e6f711SGeorge Keishing${MSG_DETAIL}      ${\n}\t\t[ Detailed Logs Captured Section ]
1769e6f711SGeorge Keishing${HEADER_MSG}      ${\n}\t\t---------------------------
1869e6f711SGeorge Keishing...                ${\n}\t\t FIRST FAILURE DATA CAPTURE
1969e6f711SGeorge Keishing...                ${\n}\t\t---------------------------
2069e6f711SGeorge Keishing${FOOTER_MSG}      ${\n}${PRINT_LINE} ${\n}
2169e6f711SGeorge Keishing
2269e6f711SGeorge Keishing${FFDC_LOG_PATH}   ${EXECDIR}${/}logs${/}
2369e6f711SGeorge Keishing${TEST_HISTORY}    ${FFDC_LOG_PATH}${/}test_history.txt
2469e6f711SGeorge Keishing
2569e6f711SGeorge Keishing*** Keywords ***
2669e6f711SGeorge Keishing
2769e6f711SGeorge KeishingGet Test Dir and Name
2869e6f711SGeorge Keishing    [Documentation]    SUITE_NAME and TEST_NAME are automatic variables
2969e6f711SGeorge Keishing    ...                and is populated dynamically by the robot framework
3069e6f711SGeorge Keishing    ...                during execution
3169e6f711SGeorge Keishing    ${suite_name}=     Get strip string   ${SUITE_NAME}
3269e6f711SGeorge Keishing    ${suite_name}=     Catenate  SEPARATOR=    ${FFDC_TIME}_   ${suite_name}
3369e6f711SGeorge Keishing    ${test_name}=      Get strip string   ${TEST_NAME}
3469e6f711SGeorge Keishing    ${test_name}=   Catenate  SEPARATOR=  ${FFDC_TIME}_   ${test_name}
35c9ea9368SGunnar Mills    [Return]  ${suite_name}   ${test_name}
3669e6f711SGeorge Keishing
3769e6f711SGeorge Keishing
3869e6f711SGeorge KeishingCreate FFDC Directory
3969e6f711SGeorge Keishing    [Documentation]    Creates directory and report file
4069e6f711SGeorge Keishing    Create Directory   ${FFDC_DIR_PATH}
4169e6f711SGeorge Keishing    Create FFDC Report File
4269e6f711SGeorge Keishing
4369e6f711SGeorge Keishing
4469e6f711SGeorge KeishingCreate FFDC Report File
4569e6f711SGeorge Keishing    [Documentation]     Create a generic file name for ffdc
4669e6f711SGeorge Keishing    Set Suite Variable
47aca140d6SGunnar Mills    ...  ${FFDC_FILE_PATH}   ${FFDC_DIR_PATH}${/}${FFDC_TIME}_BMC_general.txt
4869e6f711SGeorge Keishing    Create File         ${FFDC_FILE_PATH}
4969e6f711SGeorge Keishing
5069e6f711SGeorge Keishing
5115e6d2f4SSweta PotthuriWrite Data To File
5269e6f711SGeorge Keishing    [Documentation]     Write data to the ffdc report document
5369e6f711SGeorge Keishing    [Arguments]         ${data}=      ${filepath}=${FFDC_FILE_PATH}
5469e6f711SGeorge Keishing    Append To File      ${filepath}   ${data}
5569e6f711SGeorge Keishing
5669e6f711SGeorge Keishing
5769e6f711SGeorge KeishingGet Current Time Stamp
5869e6f711SGeorge Keishing    [Documentation]     Get the current time stamp data
5969e6f711SGeorge Keishing    ${cur_time}=    Get Current Date   result_format=%Y-%m-%d %H:%M:%S:%f
6069e6f711SGeorge Keishing    ${cur_time}=    Get strip string   ${cur_time}
61c9ea9368SGunnar Mills    [Return]   ${cur_time}
6269e6f711SGeorge Keishing
6369e6f711SGeorge Keishing
6469e6f711SGeorge KeishingHeader Message
6577458547SMichael Walsh    [Documentation]     Write header message to the report document manifest
6677458547SMichael Walsh    ...                 and return a list of generated files.
6769e6f711SGeorge Keishing    ...                 TEST_NAME, TEST_MESSAGE,SUITE_SOURCE, TEST_DOCUMENTATION
6869e6f711SGeorge Keishing    ...                 are auto variables and are populated dynamically by the
69259c540dSMichael Walsh    ...                 robot framework during execution.
70259c540dSMichael Walsh    ...                 1. Write opening statement headers message.
71259c540dSMichael Walsh    ...                 2. Add test setup and config information.
72259c540dSMichael Walsh    ...                 3. Print types of data collection.
7369e6f711SGeorge Keishing
74fdde2589SMichael Walsh
75fdde2589SMichael Walsh    ${ffdc_file_list}=  Create List  ${FFDC_FILE_PATH}
76fdde2589SMichael Walsh    Return From Keyword If  '${TEST_MODE}'  ${ffdc_file_list}
77fdde2589SMichael Walsh
78259c540dSMichael Walsh    ${TEST_NAME}=  Get Variable Value  ${TEST_NAME}
79259c540dSMichael Walsh    ${TEST_MESSAGE}=  Get Variable Value  ${TEST_MESSAGE}
80259c540dSMichael Walsh    ${TEST_DOCUMENTATION}=  Get Variable Value  ${TEST_DOCUMENTATION}
8115e6d2f4SSweta Potthuri    Write Data To File  ${HEADER_MSG}
8215e6d2f4SSweta Potthuri    Write Data To File  ${FOOTER_MSG}
8315e6d2f4SSweta Potthuri    Write Data To File  Test Suite File\t\t: ${SUITE_NAME} ${\n}
8415e6d2f4SSweta Potthuri    Write Data To File  Test Case Name\t\t: ${TEST_NAME}${\n}
8515e6d2f4SSweta Potthuri    Write Data To File  Test Source File\t: ${SUITE_SOURCE}${\n}
8615e6d2f4SSweta Potthuri    Write Data To File  Failure Time Stamp\t: ${FFDC_TIME}${\n}
8715e6d2f4SSweta Potthuri    Write Data To File  Test Error Message\t: ${TEST_MESSAGE}${\n}
8815e6d2f4SSweta Potthuri    Write Data To File  Test Documentation\t:${\n}${TEST_DOCUMENTATION}${\n}
8915e6d2f4SSweta Potthuri    Write Data To File  ${FOOTER_MSG}
9069e6f711SGeorge Keishing
9169e6f711SGeorge Keishing    Test Setup Info
9269e6f711SGeorge Keishing
9315e6d2f4SSweta Potthuri    Write Data To File  ${\n}${MSG_INTRO}${\n}
9469e6f711SGeorge Keishing
9569e6f711SGeorge Keishing    # --- FFDC header notes ---
9669e6f711SGeorge Keishing    @{entries}=  Get ffdc cmd index
97*20ccfc71SMarissa Garza    FOR  ${index}  IN  @{entries}
98*20ccfc71SMarissa Garza        Write Data To File  * ${index.upper()}
99*20ccfc71SMarissa Garza        Write Data To File  ${\n}
100*20ccfc71SMarissa Garza    END
10169e6f711SGeorge Keishing
10215e6d2f4SSweta Potthuri    Write Data To File  ${MSG_DETAIL}
10377458547SMichael Walsh    [Return]  ${ffdc_file_list}
10469e6f711SGeorge Keishing
10569e6f711SGeorge Keishing
10669e6f711SGeorge KeishingWrite Cmd Output to FFDC File
10769e6f711SGeorge Keishing    [Documentation]      Write cmd output data to the report document
10869e6f711SGeorge Keishing    [Arguments]          ${name_str}   ${cmd}
10969e6f711SGeorge Keishing
11015e6d2f4SSweta Potthuri    Write Data To File   ${FOOTER_MSG}
11115e6d2f4SSweta Potthuri    Write Data To File   ${ENTRY_INDEX.upper()} : ${name_str}\t
11215e6d2f4SSweta Potthuri    Write Data To File   Executed : ${cmd}
11315e6d2f4SSweta Potthuri    Write Data To File   ${FOOTER_MSG}
11469e6f711SGeorge Keishing
11569e6f711SGeorge Keishing
11669e6f711SGeorge KeishingTest Setup Info
11769e6f711SGeorge Keishing    [Documentation]      BMC IP, Model and other information
11869e6f711SGeorge Keishing
11915e6d2f4SSweta Potthuri    Write Data To File  ${\n}-----------------------${\n}
12015e6d2f4SSweta Potthuri    Write Data To File  Test Setup Information:
12115e6d2f4SSweta Potthuri    Write Data To File  ${\n}-----------------------${\n}
12215e6d2f4SSweta Potthuri    Write Data To File  OPENBMC HOST \t: ${OPENBMC_HOST}${\n}
12315e6d2f4SSweta Potthuri    ${model_name}=  Get BMC System Model
12415e6d2f4SSweta Potthuri    Write Data To File  SYSTEM TYPE \t: ${model_name}
1253e840a53SGeorge Keishing
1263e840a53SGeorge Keishing
1273e840a53SGeorge KeishingError Logs Should Not Exist
1283e840a53SGeorge Keishing    [Documentation]  Verify that error logs do not exist.
1293e840a53SGeorge Keishing
130a8800da7SSteven Sombar    ${resp}=  OpenBMC Get Request  ${BMC_LOGGING_ENTRY}list  quiet=${1}
1313e840a53SGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
13295672940SSteven Sombar    ...  msg=Unexpected BMC error log(s) present.
13343d6ba3aSSteven Sombar
13443d6ba3aSSteven Sombar
13543d6ba3aSSteven SombarError Logs Should Exist
13643d6ba3aSSteven Sombar    [Documentation]  Verify that error logs exist.
13743d6ba3aSSteven Sombar
138a8800da7SSteven Sombar    ${resp}=  OpenBMC Get Request  ${BMC_LOGGING_ENTRY}list  quiet=${1}
13943d6ba3aSSteven Sombar    Run Keyword If  ${resp.status_code} != ${HTTP_OK}  Fail
14043d6ba3aSSteven Sombar    ...  msg=Expected BMC error log(s) are not present.
141