| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 1 | *** Settings *** | 
|  | 2 | Documentation   This suite tests System Vital Product Data (VPD) using vpdtool. | 
|  | 3 |  | 
|  | 4 | Library         ../../lib/vpd_utils.py | 
|  | 5 | Variables       ../../data/vpd_variables.py | 
|  | 6 | Resource        ../../lib/openbmc_ffdc.robot | 
|  | 7 |  | 
|  | 8 | Test Teardown   FFDC On Test Case Fail | 
|  | 9 |  | 
|  | 10 |  | 
|  | 11 | *** Variables *** | 
|  | 12 |  | 
|  | 13 | ${CMD_GET_PROPERTY_INVENTORY}  busctl get-property xyz.openbmc_project.Inventory.Manager | 
|  | 14 | ${DR_WRITE_VALUE}              XYZ Component | 
|  | 15 | ${PN_WRITE_VALUE}              XYZ1234 | 
|  | 16 | ${SN_WRITE_VALUE}              ABCD12345678 | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 17 | @{fields}                      PN  SN  LocationCode | 
|  | 18 | @{vpd_fields}                  PN  SN | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 19 |  | 
|  | 20 | *** Test Cases *** | 
|  | 21 |  | 
| dnirmala | 348356a | 2023-03-06 04:52:56 -0600 | [diff] [blame] | 22 | Verify System VPD Data Via Vpdtool | 
|  | 23 | [Documentation]  Verify the system VPD details via vpdtool output. | 
|  | 24 | [Tags]  Verify_System_VPD_Data_Via_Vpdtool | 
|  | 25 | [Template]  Verify VPD Data Via Vpdtool | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 26 |  | 
| dnirmala | 348356a | 2023-03-06 04:52:56 -0600 | [diff] [blame] | 27 | # Component     Field | 
|  | 28 | System          Model | 
|  | 29 | System          SerialNumber | 
|  | 30 | System          LocationCode | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 31 |  | 
|  | 32 |  | 
|  | 33 | Verify VPD Component Read | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 34 | [Documentation]  Verify details of all VPD component via vpdtool. | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 35 | [Tags]  Verify_VPD_Component_Read | 
|  | 36 |  | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 37 | ${vpd_records}=  Vpdtool  -i | 
|  | 38 | ${components}=  Get Dictionary Keys  ${vpd_records} | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 39 | FOR  ${component}  IN  @{components} | 
|  | 40 | Verify VPD Component Read Operation  ${component} | 
|  | 41 | END | 
|  | 42 |  | 
|  | 43 |  | 
|  | 44 | Verify VPD Field Read | 
|  | 45 | [Documentation]  Verify reading VPD field value via vpdtool. | 
|  | 46 | [Tags]  Verify_VPD_Field_Read | 
|  | 47 |  | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 48 | ${vpd_records}=  Vpdtool  -i | 
|  | 49 | ${components}=  Get Dictionary Keys  ${vpd_records} | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 50 | FOR  ${component}  IN  @{components} | 
| George Keishing | e01ee58 | 2023-05-16 10:17:08 +0530 | [diff] [blame] | 51 | # Drive component field values response in ascii format | 
|  | 52 | # due to that skipping here. | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 53 | IF  'drive' in '${component}' | 
|  | 54 | Continue FOR Loop | 
|  | 55 | ELSE | 
|  | 56 | Verify VPD Field Read Operation  ${component} | 
|  | 57 | END | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 58 | END | 
|  | 59 |  | 
|  | 60 |  | 
|  | 61 | Verify VPD Field Write | 
| George Keishing | e20f82c | 2020-05-13 10:51:02 -0500 | [diff] [blame] | 62 | [Documentation]  Verify writing VPD field value via vpdtool. | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 63 | [Tags]  Verify_VPD_Field_Write | 
|  | 64 |  | 
|  | 65 | ${components}=  Get Dictionary Keys  ${VPD_DETAILS} | 
|  | 66 | FOR  ${component}  IN  @{components} | 
| Rahul Maheshwari | 0ef1e15 | 2020-11-02 23:10:55 -0600 | [diff] [blame] | 67 | # VPD fields "DR", "CC" and "FN" will be added later. | 
|  | 68 | @{vpd_fields}=  Create List  SN  PN | 
|  | 69 | ${field}=  Evaluate  random.choice($vpd_fields)  random | 
|  | 70 | Verify VPD Field Write Operation  ${component}  ${field} | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 71 | END | 
|  | 72 |  | 
|  | 73 |  | 
|  | 74 | *** Keywords *** | 
|  | 75 |  | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 76 | Verify VPD Component Read Operation | 
| George Keishing | 16b3c7b | 2021-01-28 09:23:37 -0600 | [diff] [blame] | 77 | [Documentation]  Verify reading VPD details of given component via vpdtool. | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 78 | [Arguments]  ${component} | 
|  | 79 | # Description of arguments: | 
|  | 80 | # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1). | 
|  | 81 |  | 
|  | 82 | ${vpd_records}=  Vpdtool  -o -O ${component} | 
|  | 83 |  | 
|  | 84 | # Example output from 'Vpdtool  -o -O /system/chassis/motherboard/vdd_vrm1': | 
|  | 85 | #  [/system/chassis/motherboard/vdd_vrm1]: | 
|  | 86 | #    [DR]:                                         CPU POWER CARD | 
|  | 87 | #    [type]:                                       xyz.openbmc_project.Inventory.Item.Vrm | 
|  | 88 | #    [CC]:                                         E123 | 
|  | 89 | #    [FN]:                                         F123456 | 
|  | 90 | #    [LocationCode]:                               ABCD.XY1.1234567-P0 | 
|  | 91 | #    [SN]:                                         YL2E32010000 | 
|  | 92 | #    [PN]:                                         PN12345 | 
|  | 93 |  | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 94 | ${vpdtool_res}=  Set To Dictionary  ${vpd_records}[${component}] | 
|  | 95 | FOR  ${vpd_field}  IN  @{fields} | 
| George Keishing | e01ee58 | 2023-05-16 10:17:08 +0530 | [diff] [blame] | 96 | ${match_key_exists}=  Run Keyword And Return Status | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 97 | ...  Dictionary Should Contain Key  ${vpdtool_res}  ${vpd_field} | 
|  | 98 | IF  '${match_key_exists}' == 'True' | 
|  | 99 | #  drive components busctl field response in ascii due to that checking only locationcode. | 
|  | 100 | IF  'drive' in '${component}' | 
|  | 101 | ${vpd_field}=  Set Variable  LocationCode | 
|  | 102 | END | 
| George Keishing | e01ee58 | 2023-05-16 10:17:08 +0530 | [diff] [blame] | 103 | # Skip check if VPD field is empty. | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 104 | Run Keyword If  '${vpd_records['${component}']['${vpd_field}']}' == '' | 
|  | 105 | ...  Continue For Loop | 
| George Keishing | e01ee58 | 2023-05-16 10:17:08 +0530 | [diff] [blame] | 106 |  | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 107 | # Get VPD field values via busctl. | 
|  | 108 | ${busctl_field}=  Set Variable If | 
|  | 109 | ...  '${vpd_field}' == 'LocationCode'  com.ibm.ipzvpd.Location LocationCode | 
|  | 110 | ...  '${vpd_field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber | 
|  | 111 | ...  '${vpd_field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber | 
|  | 112 | ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} | 
|  | 113 | ...  /xyz/openbmc_project/inventory${component} ${busctl_field} | 
|  | 114 | ${cmd_output}=  BMC Execute Command  ${cmd} | 
|  | 115 | # Check whether the vpdtool response and busctl response matching. | 
| George Keishing | e01ee58 | 2023-05-16 10:17:08 +0530 | [diff] [blame] | 116 | Valid Value  vpd_records['${component}']['${vpd_field}'] | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 117 | ...  ['${cmd_output[0].split('"')[1].strip('"')}'] | 
|  | 118 | ELSE | 
|  | 119 | Continue For Loop | 
|  | 120 | END | 
|  | 121 | END | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 122 |  | 
|  | 123 |  | 
|  | 124 | Verify VPD Field Read Operation | 
| George Keishing | 16b3c7b | 2021-01-28 09:23:37 -0600 | [diff] [blame] | 125 | [Documentation]  Verify reading all VPD fields for given component via vpdtool. | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 126 | [Arguments]  ${component} | 
|  | 127 | # Description of arguments: | 
|  | 128 | # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1). | 
|  | 129 |  | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 130 | ${vpd_records}=  Vpdtool  -o -O ${component} | 
|  | 131 | ${vpdtool_res}=  Set To Dictionary  ${vpd_records}[${component}] | 
|  | 132 | FOR  ${field}  IN  @{vpd_fields} | 
|  | 133 | ${match_key_exists}=  Run Keyword And Return Status | 
|  | 134 | ...  Dictionary Should Contain Key  ${vpdtool_res}  ${field} | 
|  | 135 | IF  '${match_key_exists}' == 'True' | 
|  | 136 | ${vpd_records}=  Vpdtool  -r -O ${component} -R VINI -K ${field} | 
|  | 137 | # Skip check if field value is empty. | 
|  | 138 | Run Keyword If  '${vpd_records['${component}']['${field}']}' == '' | 
|  | 139 | ...  Continue For Loop | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 140 |  | 
| dnirmala | 62a3b7d | 2023-03-16 01:17:05 -0500 | [diff] [blame] | 141 | ${busctl_field}=  Set Variable If | 
|  | 142 | ...  '${field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber | 
|  | 143 | ...  '${field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber | 
|  | 144 | ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} | 
|  | 145 | ...  /xyz/openbmc_project/inventory${component} ${busctl_field} | 
|  | 146 | ${cmd_output}=  BMC Execute Command  ${cmd} | 
|  | 147 |  | 
|  | 148 | # Check vpdtool response and busctl response for the component field. | 
|  | 149 | Valid Value  vpd_records['${component}']['${field}'] | 
|  | 150 | ...  ['${cmd_output[0].split('"')[1].strip('"')}'] | 
|  | 151 | ELSE | 
|  | 152 | Continue For Loop | 
|  | 153 | END | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 154 | END | 
|  | 155 |  | 
|  | 156 |  | 
|  | 157 | Verify VPD Field Write Operation | 
| Rahul Maheshwari | 0ef1e15 | 2020-11-02 23:10:55 -0600 | [diff] [blame] | 158 | [Documentation]  Verify writing VPD fields for given component via vpdtool. | 
|  | 159 | [Arguments]  ${component}  ${field} | 
|  | 160 | [Teardown]  Restore VPD Value  ${component}  ${field}  ${old_field_value} | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 161 | # Description of arguments: | 
| Rahul Maheshwari | 0ef1e15 | 2020-11-02 23:10:55 -0600 | [diff] [blame] | 162 | # component       VPD component (e.g. /system/chassis/motherboard/vdd_vrm1). | 
|  | 163 | # field           VPD component field (e.g. PN, SN) | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 164 |  | 
| Rahul Maheshwari | 0ef1e15 | 2020-11-02 23:10:55 -0600 | [diff] [blame] | 165 | ${vpd_records}=  Vpdtool  -r -O ${component} -R VINI -K ${field} | 
|  | 166 | ${old_field_value}=  Set Variable  ${vpd_records['${component}']['${field}']} | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 167 |  | 
| Rahul Maheshwari | 0ef1e15 | 2020-11-02 23:10:55 -0600 | [diff] [blame] | 168 | ${write_value}=  Set Variable If | 
|  | 169 | ...  '${field}' == 'DR'  ${DR_WRITE_VALUE} | 
|  | 170 | ...  '${field}' == 'PN'  ${PN_WRITE_VALUE} | 
|  | 171 | ...  '${field}' == 'SN'  ${SN_WRITE_VALUE} | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 172 |  | 
| Rahul Maheshwari | 0ef1e15 | 2020-11-02 23:10:55 -0600 | [diff] [blame] | 173 | Vpdtool  -w -O ${component} -R VINI -K ${field} --value ${write_value} | 
|  | 174 |  | 
|  | 175 | Verify VPD Field Value  ${component}  ${field} | 
|  | 176 |  | 
|  | 177 |  | 
|  | 178 | Restore VPD Value | 
|  | 179 | [Documentation]  Restore VPD's field value of given component. | 
|  | 180 | [Arguments]  ${component}  ${field}  ${value} | 
|  | 181 | # Description of arguments: | 
|  | 182 | # component       VPD component (e.g. /system/chassis/motherboard/vdd_vrm1). | 
|  | 183 | # field           VPD component field (e.g. PN, SN) | 
|  | 184 | # value           VPD value to be restore. | 
|  | 185 |  | 
|  | 186 | Vpdtool  -w -O ${component} -R VINI -K ${field} --value ${value} | 
| Rahul Maheshwari | ef00306 | 2020-03-23 07:17:16 -0500 | [diff] [blame] | 187 |  | 
|  | 188 |  | 
|  | 189 | Verify VPD Field Value | 
|  | 190 | [Documentation]  Verify VPD field value via vpdtool. | 
|  | 191 | [Arguments]  ${component}  ${field} | 
|  | 192 | # Description of arguments: | 
|  | 193 | # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1). | 
|  | 194 | # field           VPD field (e.g. DR, SN, PN) | 
|  | 195 |  | 
|  | 196 | ${vpd_records}=  Vpdtool  -r -O ${component} -R VINI -K ${field} | 
|  | 197 |  | 
|  | 198 | ${busctl_field}=  Set Variable If | 
|  | 199 | ...  '${field}' == 'DR'  xyz.openbmc_project.Inventory.Item PrettyName | 
|  | 200 | ...  '${field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber | 
|  | 201 | ...  '${field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber | 
|  | 202 |  | 
|  | 203 | ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component} | 
|  | 204 | ...  ${busctl_field} | 
|  | 205 | ${cmd_output}=  BMC Execute Command  ${cmd} | 
|  | 206 |  | 
|  | 207 | Valid Value  vpd_records['${component}']['${field}']  ['${cmd_output[0].split('"')[1].strip('"')}'] | 
| dnirmala | 348356a | 2023-03-06 04:52:56 -0600 | [diff] [blame] | 208 |  | 
|  | 209 |  | 
|  | 210 | Verify VPD Data Via Vpdtool | 
|  | 211 | [Documentation]  Get VPD details of given component via vpdtool and verify it | 
|  | 212 | ...              using busctl command. | 
|  | 213 | [Arguments]  ${component}  ${field} | 
|  | 214 | # Description of arguments: | 
|  | 215 | # component       VPD component (e.g. System,Chassis etc). | 
|  | 216 | # field           VPD field (e.g. Serialnumber,LocationCode etc). | 
|  | 217 |  | 
|  | 218 | ${component_url}=  Run Keyword If | 
|  | 219 | ...  '${component}' == 'System'  Set Variable  /system | 
|  | 220 |  | 
|  | 221 | # Get VPD details of given component via vpd-tool. | 
|  | 222 | ${vpd_records}=  Vpdtool  -o -O ${component_url} | 
|  | 223 |  | 
|  | 224 | # Get VPD details of given component via busctl command. | 
|  | 225 | ${busctl_field}=  Set Variable If | 
|  | 226 | ...  '${field}' == 'LocationCode'  com.ibm.ipzvpd.Location LocationCode | 
|  | 227 | ...  '${field}' == 'Model'  xyz.openbmc_project.Inventory.Decorator.Asset Model | 
|  | 228 | ...  '${field}' == 'SerialNumber'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber | 
|  | 229 |  | 
|  | 230 | ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory/system | 
|  | 231 | ...  ${busctl_field} | 
|  | 232 | ${cmd_output}=  BMC Execute Command  ${cmd} | 
|  | 233 | # Example of cmd_output: | 
|  | 234 | #   [0]:                                            s "ABCD.XY1.1234567-P0" | 
|  | 235 | #   [1]: | 
|  | 236 | #   [2]:                                            0 | 
|  | 237 |  | 
|  | 238 | # Cross check vpdtool output with busctl response. | 
|  | 239 | Should Be Equal As Strings  ${vpd_records["/system"]["${field}"]} | 
|  | 240 | ...  ${cmd_output[0].split('"')[1].strip('"')} |