Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Module to test PLDM BIOS commands. |
| 4 | |
| 5 | Library Collections |
| 6 | Library String |
| 7 | Library ../lib/pldm_utils.py |
| 8 | Variables ../data/pldm_variables.py |
| 9 | Resource ../lib/openbmc_ffdc.robot |
| 10 | |
| 11 | Test Setup Printn |
| 12 | Test Teardown FFDC On Test Case Fail |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 13 | Suite Setup PLDM BIOS Suite Setup |
George Keishing | e18030c | 2022-07-20 13:37:01 -0500 | [diff] [blame] | 14 | Suite Teardown Run Keyword And Ignore Error PLDM BIOS Suite Cleanup |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 15 | |
George Keishing | 5431685 | 2023-10-16 14:03:29 +0530 | [diff] [blame] | 16 | Force Tags Pldm_Bios |
| 17 | |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 18 | *** Test Cases *** |
| 19 | |
| 20 | Verify GetDateTime |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 21 | [Documentation] Verify host date & time. |
| 22 | [Tags] Verify_GetDateTime |
| 23 | |
| 24 | # Example output: |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 25 | # { |
| 26 | # "Response": "2020-11-07 07:10:10" |
| 27 | # } |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 28 | |
| 29 | ${pldm_output}= Pldmtool bios GetDateTime |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 30 | @{date_time}= Split String ${pldm_output['Response']} ${SPACE} |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 31 | @{time}= Split String ${date_time}[1] : |
| 32 | |
George Keishing | 2e56ad9 | 2022-10-12 11:39:54 -0500 | [diff] [blame] | 33 | ${bmc_date}= Get Current Date from BMC |
| 34 | # Date format example: 2022-10-12 16:31:17 |
| 35 | Log To Console BMC Date: ${bmc_date} |
| 36 | # Example : ['2022-10-12', '16:31:17'] |
| 37 | @{current_time}= Split String ${bmc_date} ${EMPTY} |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 38 | |
George Keishing | 2e56ad9 | 2022-10-12 11:39:54 -0500 | [diff] [blame] | 39 | # verify date matching pldmtool vs BMC current time. |
| 40 | Should Contain ${current_time} ${date_time[0]} |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 41 | |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 42 | |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 43 | Verify SetDateTime |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 44 | [Documentation] Verify set date & time for the host. |
| 45 | [Tags] Verify_SetDateTime |
| 46 | |
| 47 | # Example output: |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 48 | # { |
| 49 | # "Response": "SUCCESS" |
| 50 | # } |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 51 | |
| 52 | ${current_date_time}= Get Current Date UTC exclude_millis=True |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 53 | # Example output: |
| 54 | # 2020-11-25 07:34:30 |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 55 | |
| 56 | ${date}= Add Time To Date ${current_date_time} 400 days exclude_millis=True |
| 57 | ${upgrade_date}= Evaluate re.sub(r'-* *:*', "", '${date}') modules=re |
| 58 | |
| 59 | ${time}= Add Time To Date ${current_date_time} 01:01:00 exclude_millis=True |
| 60 | ${upgrade_time}= Evaluate re.sub(r'-* *:*', "", '${time}') modules=re |
| 61 | |
| 62 | # Set date. |
| 63 | ${cmd_set_date}= Evaluate $CMD_SETDATETIME % '${upgrade_date}' |
| 64 | ${pldm_output}= Pldmtool ${cmd_set_date} |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 65 | Valid Value pldm_output['Response'] ['SUCCESS'] |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 66 | |
| 67 | # Set time. |
| 68 | ${cmd_set_time}= Evaluate $CMD_SETDATETIME % '${upgrade_time}' |
| 69 | ${pldm_output}= Pldmtool ${cmd_set_time} |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 70 | |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 71 | |
Sridevi Ramesh | f60581b | 2020-04-07 05:11:12 -0500 | [diff] [blame] | 72 | Verify GetBIOSTable For AttributeValueTable |
| 73 | [Documentation] Verify if attribute value table content exist for |
| 74 | ... GetBIOSTable with table type attribute value table. |
| 75 | [Tags] Verify_GetBIOSTable_For_AttributeValueTable |
| 76 | |
| 77 | # Example pldm_output: |
| 78 | # [pldm_attributevaluetable]: True |
| 79 | # [attributehandle]: 0 |
| 80 | # [ attributetype]: BIOSStringReadOnly |
| 81 | # [ currentstringlength]: 15 |
Sridevi Ramesh | f60581b | 2020-04-07 05:11:12 -0500 | [diff] [blame] | 82 | |
George Keishing | f924895 | 2021-05-28 07:52:37 -0500 | [diff] [blame] | 83 | ${count}= Get Length ${attr_table_data} |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 84 | ${attr_val_list}= Create List |
| 85 | FOR ${i} IN RANGE ${count} |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 86 | Append To List ${attr_val_list} ${attr_table_data}[${i}][AttributeType] |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 87 | END |
| 88 | Valid List attr_val_list required_values=${RESPONSE_LIST_GETBIOSTABLE_ATTRVALTABLE} |
Sridevi Ramesh | fe52e40 | 2020-02-05 00:15:24 -0600 | [diff] [blame] | 89 | |
Sridevi Ramesh | 5753745 | 2021-01-18 03:25:05 -0600 | [diff] [blame] | 90 | |
Sridevi Ramesh | 5753745 | 2021-01-18 03:25:05 -0600 | [diff] [blame] | 91 | Verify GetBIOSAttributeCurrentValueByHandle |
Sridevi Ramesh | 5753745 | 2021-01-18 03:25:05 -0600 | [diff] [blame] | 92 | [Documentation] Verify GetBIOSAttributeCurrentValueByHandle with the |
| 93 | ... various BIOS attribute handle and its values. |
| 94 | [Tags] Verify_GetBIOSAttributeCurrentValueByHandle |
| 95 | |
| 96 | # Example output: |
| 97 | # |
| 98 | # pldmtool bios GetBIOSAttributeCurrentValueByHandle -a pvm_fw_boot_side |
| 99 | # { |
| 100 | # "CurrentValue": "Temp" |
| 101 | # } |
| 102 | |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 103 | ${attr_val_data}= GetBIOSEnumAttributeOptionalValues ${attr_table_data} |
Sridevi Ramesh | 5753745 | 2021-01-18 03:25:05 -0600 | [diff] [blame] | 104 | @{attr_handles}= Get Dictionary Keys ${attr_val_data} |
| 105 | FOR ${i} IN @{attr_handles} |
| 106 | ${cur_attr}= Pldmtool bios GetBIOSAttributeCurrentValueByHandle -a ${i} |
| 107 | @{attr_val_list}= Set Variable ${attr_val_data}[${i}] |
| 108 | Run Keyword If '${cur_attr['CurrentValue']}' not in @{attr_val_list} |
| 109 | ... Fail Invalid GetBIOSAttributeCurrentValueByHandle value found. |
| 110 | END |
| 111 | |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 112 | |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 113 | *** Keywords *** |
| 114 | |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 115 | PLDM BIOS Suite Setup |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 116 | [Documentation] Perform PLDM BIOS suite setup. |
| 117 | |
| 118 | ${pldm_output}= Pldmtool bios GetBIOSTable --type AttributeTable |
| 119 | Set Global Variable ${attr_table_data} ${pldm_output} |
| 120 | |
George Keishing | 1d14970 | 2022-09-20 01:53:38 -0500 | [diff] [blame] | 121 | Set Time To Manual Mode |
| 122 | |
| 123 | Sleep 10s |
| 124 | |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 125 | |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 126 | PLDM BIOS Suite Cleanup |
Sridevi Ramesh | 2ab3d38 | 2021-03-29 04:16:01 -0500 | [diff] [blame] | 127 | [Documentation] Perform PLDM BIOS suite cleanup. |
Sridevi Ramesh | 1495bc4 | 2020-02-04 03:13:33 -0600 | [diff] [blame] | 128 | |
| 129 | ${result}= Get Current Date UTC exclude_millis=True |
| 130 | ${current_date_time}= Evaluate re.sub(r'-* *:*', "", '${result}') modules=re |
| 131 | ${cmd_set_date_time}= Evaluate $CMD_SETDATETIME % '${current_date_time}' |
| 132 | ${pldm_output}= Pldmtool ${cmd_set_date_time} |
Sridevi Ramesh | 961050b | 2020-11-12 11:04:30 -0600 | [diff] [blame] | 133 | Valid Value pldm_output['Response'] ['SUCCESS'] |
George Keishing | 1d14970 | 2022-09-20 01:53:38 -0500 | [diff] [blame] | 134 | |
| 135 | |
| 136 | Set Time To Manual Mode |
| 137 | [Documentation] Set date time to manual mode via Redfish. |
| 138 | |
George Keishing | a92a2e1 | 2022-09-20 02:12:42 -0500 | [diff] [blame] | 139 | Redfish.Login |
George Keishing | 1d14970 | 2022-09-20 01:53:38 -0500 | [diff] [blame] | 140 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${False}}} |
| 141 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
George Keishing | 2e56ad9 | 2022-10-12 11:39:54 -0500 | [diff] [blame] | 142 | |
| 143 | |
| 144 | Get Current Date from BMC |
| 145 | [Documentation] Runs the date command from BMC and returns current date and time. |
| 146 | |
| 147 | # Get Current Date from BMC. |
| 148 | ${date} ${stderr} ${rc}= BMC Execute Command date |
| 149 | |
| 150 | # Split the string and remove first and 2nd last value from the list and |
| 151 | # join to form %d %b %H:%M:%S %Y date format |
| 152 | ${date}= Split String ${date} |
| 153 | Remove From List ${date} 0 |
| 154 | Remove From List ${date} -2 |
| 155 | ${date}= Evaluate " ".join(${date}) |
| 156 | |
| 157 | # Convert the date format to %Y/%m/%d %H:%M:%S |
| 158 | ${date}= Convert Date ${date} date_format=%b %d %H:%M:%S %Y |
| 159 | ... result_format=%Y-%m-%d %H:%M:%S exclude_millis=True |
| 160 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame^] | 161 | RETURN ${date} |