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