1ef00306eSRahul Maheshwari*** Settings *** 2ef00306eSRahul MaheshwariDocumentation This suite tests System Vital Product Data (VPD) using vpdtool. 3ef00306eSRahul Maheshwari 4ef00306eSRahul MaheshwariLibrary ../../lib/vpd_utils.py 5ef00306eSRahul MaheshwariVariables ../../data/vpd_variables.py 6ef00306eSRahul MaheshwariResource ../../lib/openbmc_ffdc.robot 7ef00306eSRahul Maheshwari 8ef00306eSRahul MaheshwariTest Teardown FFDC On Test Case Fail 9ef00306eSRahul Maheshwari 10ef00306eSRahul Maheshwari 11ef00306eSRahul Maheshwari*** Variables *** 12ef00306eSRahul Maheshwari 13ef00306eSRahul Maheshwari${CMD_GET_PROPERTY_INVENTORY} busctl get-property xyz.openbmc_project.Inventory.Manager 14ef00306eSRahul Maheshwari${DR_WRITE_VALUE} XYZ Component 15ef00306eSRahul Maheshwari${PN_WRITE_VALUE} XYZ1234 16ef00306eSRahul Maheshwari${SN_WRITE_VALUE} ABCD12345678 17*62a3b7dbSdnirmala@{fields} PN SN LocationCode 18*62a3b7dbSdnirmala@{vpd_fields} PN SN 19ef00306eSRahul Maheshwari 20ef00306eSRahul Maheshwari*** Test Cases *** 21ef00306eSRahul Maheshwari 22348356a3SdnirmalaVerify System VPD Data Via Vpdtool 23348356a3Sdnirmala [Documentation] Verify the system VPD details via vpdtool output. 24348356a3Sdnirmala [Tags] Verify_System_VPD_Data_Via_Vpdtool 25348356a3Sdnirmala [Template] Verify VPD Data Via Vpdtool 26ef00306eSRahul Maheshwari 27348356a3Sdnirmala # Component Field 28348356a3Sdnirmala System Model 29348356a3Sdnirmala System SerialNumber 30348356a3Sdnirmala System LocationCode 31ef00306eSRahul Maheshwari 32ef00306eSRahul Maheshwari 33ef00306eSRahul MaheshwariVerify VPD Component Read 34*62a3b7dbSdnirmala [Documentation] Verify details of all VPD component via vpdtool. 35ef00306eSRahul Maheshwari [Tags] Verify_VPD_Component_Read 36ef00306eSRahul Maheshwari 37*62a3b7dbSdnirmala ${vpd_records}= Vpdtool -i 38*62a3b7dbSdnirmala ${components}= Get Dictionary Keys ${vpd_records} 39ef00306eSRahul Maheshwari FOR ${component} IN @{components} 40ef00306eSRahul Maheshwari Verify VPD Component Read Operation ${component} 41ef00306eSRahul Maheshwari END 42ef00306eSRahul Maheshwari 43ef00306eSRahul Maheshwari 44ef00306eSRahul MaheshwariVerify VPD Field Read 45ef00306eSRahul Maheshwari [Documentation] Verify reading VPD field value via vpdtool. 46ef00306eSRahul Maheshwari [Tags] Verify_VPD_Field_Read 47ef00306eSRahul Maheshwari 48*62a3b7dbSdnirmala ${vpd_records}= Vpdtool -i 49*62a3b7dbSdnirmala ${components}= Get Dictionary Keys ${vpd_records} 50ef00306eSRahul Maheshwari FOR ${component} IN @{components} 51*62a3b7dbSdnirmala # drive component field values response in ascii format due to that skipping here. 52*62a3b7dbSdnirmala IF 'drive' in '${component}' 53*62a3b7dbSdnirmala Continue FOR Loop 54*62a3b7dbSdnirmala ELSE 55ef00306eSRahul Maheshwari Verify VPD Field Read Operation ${component} 56ef00306eSRahul Maheshwari END 57*62a3b7dbSdnirmala END 58ef00306eSRahul Maheshwari 59ef00306eSRahul Maheshwari 60ef00306eSRahul MaheshwariVerify VPD Field Write 61e20f82cdSGeorge Keishing [Documentation] Verify writing VPD field value via vpdtool. 62ef00306eSRahul Maheshwari [Tags] Verify_VPD_Field_Write 63ef00306eSRahul Maheshwari 64ef00306eSRahul Maheshwari ${components}= Get Dictionary Keys ${VPD_DETAILS} 65ef00306eSRahul Maheshwari FOR ${component} IN @{components} 660ef1e157SRahul Maheshwari # VPD fields "DR", "CC" and "FN" will be added later. 670ef1e157SRahul Maheshwari @{vpd_fields}= Create List SN PN 680ef1e157SRahul Maheshwari ${field}= Evaluate random.choice($vpd_fields) random 690ef1e157SRahul Maheshwari Verify VPD Field Write Operation ${component} ${field} 70ef00306eSRahul Maheshwari END 71ef00306eSRahul Maheshwari 72ef00306eSRahul Maheshwari 73ef00306eSRahul Maheshwari*** Keywords *** 74ef00306eSRahul Maheshwari 75ef00306eSRahul MaheshwariVerify VPD Component Read Operation 7616b3c7bfSGeorge Keishing [Documentation] Verify reading VPD details of given component via vpdtool. 77ef00306eSRahul Maheshwari [Arguments] ${component} 78ef00306eSRahul Maheshwari # Description of arguments: 79ef00306eSRahul Maheshwari # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1). 80ef00306eSRahul Maheshwari 81ef00306eSRahul Maheshwari ${vpd_records}= Vpdtool -o -O ${component} 82ef00306eSRahul Maheshwari 83ef00306eSRahul Maheshwari # Example output from 'Vpdtool -o -O /system/chassis/motherboard/vdd_vrm1': 84ef00306eSRahul Maheshwari # [/system/chassis/motherboard/vdd_vrm1]: 85ef00306eSRahul Maheshwari # [DR]: CPU POWER CARD 86ef00306eSRahul Maheshwari # [type]: xyz.openbmc_project.Inventory.Item.Vrm 87ef00306eSRahul Maheshwari # [CC]: E123 88ef00306eSRahul Maheshwari # [FN]: F123456 89ef00306eSRahul Maheshwari # [LocationCode]: ABCD.XY1.1234567-P0 90ef00306eSRahul Maheshwari # [SN]: YL2E32010000 91ef00306eSRahul Maheshwari # [PN]: PN12345 92ef00306eSRahul Maheshwari 93*62a3b7dbSdnirmala ${vpdtool_res}= Set To Dictionary ${vpd_records}[${component}] 94*62a3b7dbSdnirmala FOR ${vpd_field} IN @{fields} 95*62a3b7dbSdnirmala ${match_key_exists}= Run Keyword And Return Status 96*62a3b7dbSdnirmala ... Dictionary Should Contain Key ${vpdtool_res} ${vpd_field} 97*62a3b7dbSdnirmala IF '${match_key_exists}' == 'True' 98*62a3b7dbSdnirmala # drive components busctl field response in ascii due to that checking only locationcode. 99*62a3b7dbSdnirmala IF 'drive' in '${component}' 100*62a3b7dbSdnirmala ${vpd_field}= Set Variable LocationCode 101*62a3b7dbSdnirmala END 102*62a3b7dbSdnirmala # Skip check if VPD field is empty. 103*62a3b7dbSdnirmala Run Keyword If '${vpd_records['${component}']['${vpd_field}']}' == '' 104*62a3b7dbSdnirmala ... Continue For Loop 105*62a3b7dbSdnirmala 106*62a3b7dbSdnirmala # Get VPD field values via busctl. 107*62a3b7dbSdnirmala ${busctl_field}= Set Variable If 108*62a3b7dbSdnirmala ... '${vpd_field}' == 'LocationCode' com.ibm.ipzvpd.Location LocationCode 109*62a3b7dbSdnirmala ... '${vpd_field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber 110*62a3b7dbSdnirmala ... '${vpd_field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber 111*62a3b7dbSdnirmala ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} 112*62a3b7dbSdnirmala ... /xyz/openbmc_project/inventory${component} ${busctl_field} 113*62a3b7dbSdnirmala ${cmd_output}= BMC Execute Command ${cmd} 114*62a3b7dbSdnirmala # Check whether the vpdtool response and busctl response matching. 115*62a3b7dbSdnirmala Valid Value vpd_records['${component}']['${vpd_field}'] 116*62a3b7dbSdnirmala ... ['${cmd_output[0].split('"')[1].strip('"')}'] 117*62a3b7dbSdnirmala ELSE 118*62a3b7dbSdnirmala Continue For Loop 119*62a3b7dbSdnirmala END 120*62a3b7dbSdnirmala END 121ef00306eSRahul Maheshwari 122ef00306eSRahul Maheshwari 123ef00306eSRahul MaheshwariVerify VPD Field Read Operation 12416b3c7bfSGeorge Keishing [Documentation] Verify reading all VPD fields for given component via vpdtool. 125ef00306eSRahul Maheshwari [Arguments] ${component} 126ef00306eSRahul Maheshwari # Description of arguments: 127ef00306eSRahul Maheshwari # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1). 128ef00306eSRahul Maheshwari 129*62a3b7dbSdnirmala ${vpd_records}= Vpdtool -o -O ${component} 130*62a3b7dbSdnirmala ${vpdtool_res}= Set To Dictionary ${vpd_records}[${component}] 131*62a3b7dbSdnirmala FOR ${field} IN @{vpd_fields} 132*62a3b7dbSdnirmala ${match_key_exists}= Run Keyword And Return Status 133*62a3b7dbSdnirmala ... Dictionary Should Contain Key ${vpdtool_res} ${field} 134*62a3b7dbSdnirmala IF '${match_key_exists}' == 'True' 135*62a3b7dbSdnirmala ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field} 136*62a3b7dbSdnirmala # Skip check if field value is empty. 137*62a3b7dbSdnirmala Run Keyword If '${vpd_records['${component}']['${field}']}' == '' 138*62a3b7dbSdnirmala ... Continue For Loop 139ef00306eSRahul Maheshwari 140*62a3b7dbSdnirmala ${busctl_field}= Set Variable If 141*62a3b7dbSdnirmala ... '${field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber 142*62a3b7dbSdnirmala ... '${field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber 143*62a3b7dbSdnirmala ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} 144*62a3b7dbSdnirmala ... /xyz/openbmc_project/inventory${component} ${busctl_field} 145*62a3b7dbSdnirmala ${cmd_output}= BMC Execute Command ${cmd} 146*62a3b7dbSdnirmala 147*62a3b7dbSdnirmala # Check vpdtool response and busctl response for the component field. 148*62a3b7dbSdnirmala Valid Value vpd_records['${component}']['${field}'] 149*62a3b7dbSdnirmala ... ['${cmd_output[0].split('"')[1].strip('"')}'] 150*62a3b7dbSdnirmala ELSE 151*62a3b7dbSdnirmala Continue For Loop 152*62a3b7dbSdnirmala END 153ef00306eSRahul Maheshwari END 154ef00306eSRahul Maheshwari 155ef00306eSRahul Maheshwari 156ef00306eSRahul MaheshwariVerify VPD Field Write Operation 1570ef1e157SRahul Maheshwari [Documentation] Verify writing VPD fields for given component via vpdtool. 1580ef1e157SRahul Maheshwari [Arguments] ${component} ${field} 1590ef1e157SRahul Maheshwari [Teardown] Restore VPD Value ${component} ${field} ${old_field_value} 160ef00306eSRahul Maheshwari # Description of arguments: 1610ef1e157SRahul Maheshwari # component VPD component (e.g. /system/chassis/motherboard/vdd_vrm1). 1620ef1e157SRahul Maheshwari # field VPD component field (e.g. PN, SN) 163ef00306eSRahul Maheshwari 1640ef1e157SRahul Maheshwari ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field} 1650ef1e157SRahul Maheshwari ${old_field_value}= Set Variable ${vpd_records['${component}']['${field}']} 166ef00306eSRahul Maheshwari 167ef00306eSRahul Maheshwari ${write_value}= Set Variable If 168ef00306eSRahul Maheshwari ... '${field}' == 'DR' ${DR_WRITE_VALUE} 169ef00306eSRahul Maheshwari ... '${field}' == 'PN' ${PN_WRITE_VALUE} 170ef00306eSRahul Maheshwari ... '${field}' == 'SN' ${SN_WRITE_VALUE} 1710ef1e157SRahul Maheshwari 172ef00306eSRahul Maheshwari Vpdtool -w -O ${component} -R VINI -K ${field} --value ${write_value} 1730ef1e157SRahul Maheshwari 1740ef1e157SRahul Maheshwari Verify VPD Field Value ${component} ${field} 1750ef1e157SRahul Maheshwari 1760ef1e157SRahul Maheshwari 1770ef1e157SRahul MaheshwariRestore VPD Value 1780ef1e157SRahul Maheshwari [Documentation] Restore VPD's field value of given component. 1790ef1e157SRahul Maheshwari [Arguments] ${component} ${field} ${value} 1800ef1e157SRahul Maheshwari # Description of arguments: 1810ef1e157SRahul Maheshwari # component VPD component (e.g. /system/chassis/motherboard/vdd_vrm1). 1820ef1e157SRahul Maheshwari # field VPD component field (e.g. PN, SN) 1830ef1e157SRahul Maheshwari # value VPD value to be restore. 1840ef1e157SRahul Maheshwari 1850ef1e157SRahul Maheshwari Vpdtool -w -O ${component} -R VINI -K ${field} --value ${value} 186ef00306eSRahul Maheshwari 187ef00306eSRahul Maheshwari 188ef00306eSRahul MaheshwariVerify VPD Field Value 189ef00306eSRahul Maheshwari [Documentation] Verify VPD field value via vpdtool. 190ef00306eSRahul Maheshwari [Arguments] ${component} ${field} 191ef00306eSRahul Maheshwari # Description of arguments: 192ef00306eSRahul Maheshwari # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1). 193ef00306eSRahul Maheshwari # field VPD field (e.g. DR, SN, PN) 194ef00306eSRahul Maheshwari 195ef00306eSRahul Maheshwari ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field} 196ef00306eSRahul Maheshwari 197ef00306eSRahul Maheshwari ${busctl_field}= Set Variable If 198ef00306eSRahul Maheshwari ... '${field}' == 'DR' xyz.openbmc_project.Inventory.Item PrettyName 199ef00306eSRahul Maheshwari ... '${field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber 200ef00306eSRahul Maheshwari ... '${field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber 201ef00306eSRahul Maheshwari 202ef00306eSRahul Maheshwari ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component} 203ef00306eSRahul Maheshwari ... ${busctl_field} 204ef00306eSRahul Maheshwari ${cmd_output}= BMC Execute Command ${cmd} 205ef00306eSRahul Maheshwari 206ef00306eSRahul Maheshwari Valid Value vpd_records['${component}']['${field}'] ['${cmd_output[0].split('"')[1].strip('"')}'] 207348356a3Sdnirmala 208348356a3Sdnirmala 209348356a3SdnirmalaVerify VPD Data Via Vpdtool 210348356a3Sdnirmala [Documentation] Get VPD details of given component via vpdtool and verify it 211348356a3Sdnirmala ... using busctl command. 212348356a3Sdnirmala [Arguments] ${component} ${field} 213348356a3Sdnirmala # Description of arguments: 214348356a3Sdnirmala # component VPD component (e.g. System,Chassis etc). 215348356a3Sdnirmala # field VPD field (e.g. Serialnumber,LocationCode etc). 216348356a3Sdnirmala 217348356a3Sdnirmala ${component_url}= Run Keyword If 218348356a3Sdnirmala ... '${component}' == 'System' Set Variable /system 219348356a3Sdnirmala 220348356a3Sdnirmala # Get VPD details of given component via vpd-tool. 221348356a3Sdnirmala ${vpd_records}= Vpdtool -o -O ${component_url} 222348356a3Sdnirmala 223348356a3Sdnirmala # Get VPD details of given component via busctl command. 224348356a3Sdnirmala ${busctl_field}= Set Variable If 225348356a3Sdnirmala ... '${field}' == 'LocationCode' com.ibm.ipzvpd.Location LocationCode 226348356a3Sdnirmala ... '${field}' == 'Model' xyz.openbmc_project.Inventory.Decorator.Asset Model 227348356a3Sdnirmala ... '${field}' == 'SerialNumber' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber 228348356a3Sdnirmala 229348356a3Sdnirmala ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory/system 230348356a3Sdnirmala ... ${busctl_field} 231348356a3Sdnirmala ${cmd_output}= BMC Execute Command ${cmd} 232348356a3Sdnirmala # Example of cmd_output: 233348356a3Sdnirmala # [0]: s "ABCD.XY1.1234567-P0" 234348356a3Sdnirmala # [1]: 235348356a3Sdnirmala # [2]: 0 236348356a3Sdnirmala 237348356a3Sdnirmala # Cross check vpdtool output with busctl response. 238348356a3Sdnirmala Should Be Equal As Strings ${vpd_records["/system"]["${field}"]} 239348356a3Sdnirmala ... ${cmd_output[0].split('"')[1].strip('"')} 240