xref: /openbmc/openbmc-test-automation/pldm/test_pldm_bios.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
11495bc4fSSridevi Ramesh*** Settings ***
21495bc4fSSridevi Ramesh
31495bc4fSSridevi RameshDocumentation    Module to test PLDM BIOS commands.
41495bc4fSSridevi Ramesh
51495bc4fSSridevi RameshLibrary          Collections
61495bc4fSSridevi RameshLibrary          String
71495bc4fSSridevi RameshLibrary          ../lib/pldm_utils.py
81495bc4fSSridevi RameshVariables        ../data/pldm_variables.py
91495bc4fSSridevi RameshResource         ../lib/openbmc_ffdc.robot
101495bc4fSSridevi Ramesh
111495bc4fSSridevi RameshTest Setup       Printn
121495bc4fSSridevi RameshTest Teardown    FFDC On Test Case Fail
132ab3d388SSridevi RameshSuite Setup      PLDM BIOS Suite Setup
14e18030c5SGeorge KeishingSuite Teardown   Run Keyword And Ignore Error  PLDM BIOS Suite Cleanup
151495bc4fSSridevi Ramesh
16*6fb70d98SMatt FischerTest Tags       Pldm_Bios
175431685fSGeorge Keishing
181495bc4fSSridevi Ramesh*** Test Cases ***
191495bc4fSSridevi Ramesh
201495bc4fSSridevi RameshVerify GetDateTime
211495bc4fSSridevi Ramesh    [Documentation]  Verify host date & time.
221495bc4fSSridevi Ramesh    [Tags]  Verify_GetDateTime
231495bc4fSSridevi Ramesh
241495bc4fSSridevi Ramesh    # Example output:
25961050baSSridevi Ramesh    # {
26961050baSSridevi Ramesh    #     "Response": "2020-11-07 07:10:10"
27961050baSSridevi Ramesh    # }
281495bc4fSSridevi Ramesh
291495bc4fSSridevi Ramesh    ${pldm_output}=  Pldmtool  bios GetDateTime
30961050baSSridevi Ramesh    @{date_time}=  Split String  ${pldm_output['Response']}  ${SPACE}
311495bc4fSSridevi Ramesh    @{time}=  Split String  ${date_time}[1]  :
321495bc4fSSridevi Ramesh
332e56ad9bSGeorge Keishing    ${bmc_date}=  Get Current Date from BMC
342e56ad9bSGeorge Keishing    # Date format example: 2022-10-12 16:31:17
352e56ad9bSGeorge Keishing    Log To Console  BMC Date: ${bmc_date}
362e56ad9bSGeorge Keishing    # Example : ['2022-10-12', '16:31:17']
372e56ad9bSGeorge Keishing    @{current_time}=  Split String  ${bmc_date}  ${EMPTY}
381495bc4fSSridevi Ramesh
392e56ad9bSGeorge Keishing    # verify date matching pldmtool vs BMC current time.
402e56ad9bSGeorge Keishing    Should Contain  ${current_time}  ${date_time[0]}
411495bc4fSSridevi Ramesh
422ab3d388SSridevi Ramesh
431495bc4fSSridevi RameshVerify SetDateTime
441495bc4fSSridevi Ramesh    [Documentation]  Verify set date & time for the host.
451495bc4fSSridevi Ramesh    [Tags]  Verify_SetDateTime
461495bc4fSSridevi Ramesh
471495bc4fSSridevi Ramesh    # Example output:
48961050baSSridevi Ramesh    # {
49961050baSSridevi Ramesh    #     "Response": "SUCCESS"
50961050baSSridevi Ramesh    # }
511495bc4fSSridevi Ramesh
521495bc4fSSridevi Ramesh    ${current_date_time}=  Get Current Date  UTC  exclude_millis=True
53961050baSSridevi Ramesh    # Example output:
54961050baSSridevi Ramesh    # 2020-11-25 07:34:30
551495bc4fSSridevi Ramesh
561495bc4fSSridevi Ramesh    ${date}=  Add Time To Date  ${current_date_time}  400 days  exclude_millis=True
571495bc4fSSridevi Ramesh    ${upgrade_date}=  Evaluate  re.sub(r'-* *:*', "", '${date}')  modules=re
581495bc4fSSridevi Ramesh
591495bc4fSSridevi Ramesh    ${time}=  Add Time To Date  ${current_date_time}  01:01:00  exclude_millis=True
601495bc4fSSridevi Ramesh    ${upgrade_time}=  Evaluate  re.sub(r'-* *:*', "", '${time}')  modules=re
611495bc4fSSridevi Ramesh
621495bc4fSSridevi Ramesh    # Set date.
631495bc4fSSridevi Ramesh    ${cmd_set_date}=  Evaluate  $CMD_SETDATETIME % '${upgrade_date}'
641495bc4fSSridevi Ramesh    ${pldm_output}=  Pldmtool  ${cmd_set_date}
65961050baSSridevi Ramesh    Valid Value  pldm_output['Response']  ['SUCCESS']
661495bc4fSSridevi Ramesh
671495bc4fSSridevi Ramesh    # Set time.
681495bc4fSSridevi Ramesh    ${cmd_set_time}=  Evaluate  $CMD_SETDATETIME % '${upgrade_time}'
691495bc4fSSridevi Ramesh    ${pldm_output}=  Pldmtool  ${cmd_set_time}
70fe52e405SSridevi Ramesh
712ab3d388SSridevi Ramesh
72f60581b6SSridevi RameshVerify GetBIOSTable For AttributeValueTable
73f60581b6SSridevi Ramesh    [Documentation]  Verify if attribute value table content exist for
74f60581b6SSridevi Ramesh    ...              GetBIOSTable with table type attribute value table.
75f60581b6SSridevi Ramesh    [Tags]  Verify_GetBIOSTable_For_AttributeValueTable
76f60581b6SSridevi Ramesh
77f60581b6SSridevi Ramesh    # Example pldm_output:
78f60581b6SSridevi Ramesh    # [pldm_attributevaluetable]:                     True
79f60581b6SSridevi Ramesh    # [attributehandle]:                              0
80f60581b6SSridevi Ramesh    # [     attributetype]:                           BIOSStringReadOnly
81f60581b6SSridevi Ramesh    # [     currentstringlength]:                     15
82f60581b6SSridevi Ramesh
832ab3d388SSridevi Ramesh    ${count}=  Get Length  ${attr_table_data}
84961050baSSridevi Ramesh    ${attr_val_list}=  Create List
85961050baSSridevi Ramesh    FOR  ${i}  IN RANGE  ${count}
862ab3d388SSridevi Ramesh        Append To List  ${attr_val_list}  ${attr_table_data}[${i}][AttributeType]
87961050baSSridevi Ramesh    END
88961050baSSridevi Ramesh    Valid List  attr_val_list  required_values=${RESPONSE_LIST_GETBIOSTABLE_ATTRVALTABLE}
89fe52e405SSridevi Ramesh
9057537452SSridevi Ramesh
9157537452SSridevi RameshVerify GetBIOSAttributeCurrentValueByHandle
9257537452SSridevi Ramesh    [Documentation]  Verify GetBIOSAttributeCurrentValueByHandle with the
9357537452SSridevi Ramesh    ...              various BIOS attribute handle and its values.
9457537452SSridevi Ramesh    [Tags]  Verify_GetBIOSAttributeCurrentValueByHandle
9557537452SSridevi Ramesh
9657537452SSridevi Ramesh    # Example output:
9757537452SSridevi Ramesh    #
9857537452SSridevi Ramesh    # pldmtool bios GetBIOSAttributeCurrentValueByHandle -a pvm_fw_boot_side
9957537452SSridevi Ramesh    # {
10057537452SSridevi Ramesh    #     "CurrentValue": "Temp"
10157537452SSridevi Ramesh    # }
10257537452SSridevi Ramesh
1032ab3d388SSridevi Ramesh    ${attr_val_data}=  GetBIOSEnumAttributeOptionalValues  ${attr_table_data}
10457537452SSridevi Ramesh    @{attr_handles}=  Get Dictionary Keys  ${attr_val_data}
10557537452SSridevi Ramesh    FOR  ${i}  IN  @{attr_handles}
10657537452SSridevi Ramesh        ${cur_attr}=  Pldmtool  bios GetBIOSAttributeCurrentValueByHandle -a ${i}
10757537452SSridevi Ramesh        @{attr_val_list}=  Set Variable  ${attr_val_data}[${i}]
10857537452SSridevi Ramesh        Run Keyword If  '${cur_attr['CurrentValue']}' not in @{attr_val_list}
10957537452SSridevi Ramesh        ...  Fail  Invalid GetBIOSAttributeCurrentValueByHandle value found.
11057537452SSridevi Ramesh    END
11157537452SSridevi Ramesh
1122ab3d388SSridevi Ramesh
1131495bc4fSSridevi Ramesh*** Keywords ***
1141495bc4fSSridevi Ramesh
1152ab3d388SSridevi RameshPLDM BIOS Suite Setup
1162ab3d388SSridevi Ramesh    [Documentation]  Perform PLDM BIOS suite setup.
1172ab3d388SSridevi Ramesh
1182ab3d388SSridevi Ramesh    ${pldm_output}=  Pldmtool  bios GetBIOSTable --type AttributeTable
1192ab3d388SSridevi Ramesh    Set Global Variable  ${attr_table_data}  ${pldm_output}
1202ab3d388SSridevi Ramesh
1211d14970aSGeorge Keishing    Set Time To Manual Mode
1221d14970aSGeorge Keishing
1231d14970aSGeorge Keishing    Sleep  10s
1241d14970aSGeorge Keishing
1252ab3d388SSridevi Ramesh
1261495bc4fSSridevi RameshPLDM BIOS Suite Cleanup
1272ab3d388SSridevi Ramesh    [Documentation]  Perform PLDM BIOS suite cleanup.
1281495bc4fSSridevi Ramesh
1291495bc4fSSridevi Ramesh    ${result}=  Get Current Date  UTC  exclude_millis=True
1301495bc4fSSridevi Ramesh    ${current_date_time}=  Evaluate  re.sub(r'-* *:*', "", '${result}')  modules=re
1311495bc4fSSridevi Ramesh    ${cmd_set_date_time}=  Evaluate  $CMD_SETDATETIME % '${current_date_time}'
1321495bc4fSSridevi Ramesh    ${pldm_output}=  Pldmtool  ${cmd_set_date_time}
133961050baSSridevi Ramesh    Valid Value  pldm_output['Response']  ['SUCCESS']
1341d14970aSGeorge Keishing
1351d14970aSGeorge Keishing
1361d14970aSGeorge KeishingSet Time To Manual Mode
1371d14970aSGeorge Keishing    [Documentation]  Set date time to manual mode via Redfish.
1381d14970aSGeorge Keishing
139a92a2e14SGeorge Keishing    Redfish.Login
1401d14970aSGeorge Keishing    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${False}}}
1411d14970aSGeorge Keishing    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
1422e56ad9bSGeorge Keishing
1432e56ad9bSGeorge Keishing
1442e56ad9bSGeorge KeishingGet Current Date from BMC
1452e56ad9bSGeorge Keishing    [Documentation]  Runs the date command from BMC and returns current date and time.
1462e56ad9bSGeorge Keishing
1472e56ad9bSGeorge Keishing    # Get Current Date from BMC.
1482e56ad9bSGeorge Keishing    ${date}  ${stderr}  ${rc}=  BMC Execute Command   date
1492e56ad9bSGeorge Keishing
1502e56ad9bSGeorge Keishing    # Split the string and remove first and 2nd last value from the list and
1512e56ad9bSGeorge Keishing    # join to form %d %b %H:%M:%S %Y date format
1522e56ad9bSGeorge Keishing    ${date}=  Split String  ${date}
1532e56ad9bSGeorge Keishing    Remove From List  ${date}  0
1542e56ad9bSGeorge Keishing    Remove From List  ${date}  -2
1552e56ad9bSGeorge Keishing    ${date}=  Evaluate  " ".join(${date})
1562e56ad9bSGeorge Keishing
1572e56ad9bSGeorge Keishing    # Convert the date format to %Y/%m/%d %H:%M:%S
1582e56ad9bSGeorge Keishing    ${date}=  Convert Date  ${date}  date_format=%b %d %H:%M:%S %Y
1592e56ad9bSGeorge Keishing    ...  result_format=%Y-%m-%d %H:%M:%S  exclude_millis=True
1602e56ad9bSGeorge Keishing
161409df05dSGeorge Keishing    RETURN   ${date}
162