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