xref: /openbmc/openbmc-test-automation/openpower/vpd/test_vpd_tool.robot (revision e01ee587388c1b1ed3ce1fd29247144a0fa6dffb)
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
1762a3b7dbSdnirmala@{fields}                      PN  SN  LocationCode
1862a3b7dbSdnirmala@{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
3462a3b7dbSdnirmala    [Documentation]  Verify details of all VPD component via vpdtool.
35ef00306eSRahul Maheshwari    [Tags]  Verify_VPD_Component_Read
36ef00306eSRahul Maheshwari
3762a3b7dbSdnirmala    ${vpd_records}=  Vpdtool  -i
3862a3b7dbSdnirmala    ${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
4862a3b7dbSdnirmala    ${vpd_records}=  Vpdtool  -i
4962a3b7dbSdnirmala    ${components}=  Get Dictionary Keys  ${vpd_records}
50ef00306eSRahul Maheshwari    FOR  ${component}  IN  @{components}
51*e01ee587SGeorge Keishing       # Drive component field values response in ascii format
52*e01ee587SGeorge Keishing       # due to that skipping here.
5362a3b7dbSdnirmala       IF  'drive' in '${component}'
5462a3b7dbSdnirmala           Continue FOR Loop
5562a3b7dbSdnirmala       ELSE
56ef00306eSRahul Maheshwari           Verify VPD Field Read Operation  ${component}
57ef00306eSRahul Maheshwari       END
5862a3b7dbSdnirmala    END
59ef00306eSRahul Maheshwari
60ef00306eSRahul Maheshwari
61ef00306eSRahul MaheshwariVerify VPD Field Write
62e20f82cdSGeorge Keishing    [Documentation]  Verify writing VPD field value via vpdtool.
63ef00306eSRahul Maheshwari    [Tags]  Verify_VPD_Field_Write
64ef00306eSRahul Maheshwari
65ef00306eSRahul Maheshwari    ${components}=  Get Dictionary Keys  ${VPD_DETAILS}
66ef00306eSRahul Maheshwari    FOR  ${component}  IN  @{components}
670ef1e157SRahul Maheshwari        # VPD fields "DR", "CC" and "FN" will be added later.
680ef1e157SRahul Maheshwari        @{vpd_fields}=  Create List  SN  PN
690ef1e157SRahul Maheshwari        ${field}=  Evaluate  random.choice($vpd_fields)  random
700ef1e157SRahul Maheshwari        Verify VPD Field Write Operation  ${component}  ${field}
71ef00306eSRahul Maheshwari    END
72ef00306eSRahul Maheshwari
73ef00306eSRahul Maheshwari
74ef00306eSRahul Maheshwari*** Keywords ***
75ef00306eSRahul Maheshwari
76ef00306eSRahul MaheshwariVerify VPD Component Read Operation
7716b3c7bfSGeorge Keishing    [Documentation]  Verify reading VPD details of given component via vpdtool.
78ef00306eSRahul Maheshwari    [Arguments]  ${component}
79ef00306eSRahul Maheshwari    # Description of arguments:
80ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
81ef00306eSRahul Maheshwari
82ef00306eSRahul Maheshwari    ${vpd_records}=  Vpdtool  -o -O ${component}
83ef00306eSRahul Maheshwari
84ef00306eSRahul Maheshwari    # Example output from 'Vpdtool  -o -O /system/chassis/motherboard/vdd_vrm1':
85ef00306eSRahul Maheshwari    #  [/system/chassis/motherboard/vdd_vrm1]:
86ef00306eSRahul Maheshwari    #    [DR]:                                         CPU POWER CARD
87ef00306eSRahul Maheshwari    #    [type]:                                       xyz.openbmc_project.Inventory.Item.Vrm
88ef00306eSRahul Maheshwari    #    [CC]:                                         E123
89ef00306eSRahul Maheshwari    #    [FN]:                                         F123456
90ef00306eSRahul Maheshwari    #    [LocationCode]:                               ABCD.XY1.1234567-P0
91ef00306eSRahul Maheshwari    #    [SN]:                                         YL2E32010000
92ef00306eSRahul Maheshwari    #    [PN]:                                         PN12345
93ef00306eSRahul Maheshwari
9462a3b7dbSdnirmala    ${vpdtool_res}=  Set To Dictionary  ${vpd_records}[${component}]
9562a3b7dbSdnirmala    FOR  ${vpd_field}  IN  @{fields}
9662a3b7dbSdnirmala        ${match_key_exists}=  Run Keyword And Return Status
9762a3b7dbSdnirmala        ...  Dictionary Should Contain Key  ${vpdtool_res}  ${vpd_field}
9862a3b7dbSdnirmala          IF  '${match_key_exists}' == 'True'
9962a3b7dbSdnirmala              #  drive components busctl field response in ascii due to that checking only locationcode.
10062a3b7dbSdnirmala              IF  'drive' in '${component}'
10162a3b7dbSdnirmala                  ${vpd_field}=  Set Variable  LocationCode
10262a3b7dbSdnirmala              END
10362a3b7dbSdnirmala              # Skip check if VPD field is empty.
10462a3b7dbSdnirmala              Run Keyword If  '${vpd_records['${component}']['${vpd_field}']}' == ''
10562a3b7dbSdnirmala              ...  Continue For Loop
10662a3b7dbSdnirmala
10762a3b7dbSdnirmala              # Get VPD field values via busctl.
10862a3b7dbSdnirmala              ${busctl_field}=  Set Variable If
10962a3b7dbSdnirmala              ...  '${vpd_field}' == 'LocationCode'  com.ibm.ipzvpd.Location LocationCode
11062a3b7dbSdnirmala              ...  '${vpd_field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
11162a3b7dbSdnirmala              ...  '${vpd_field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
11262a3b7dbSdnirmala              ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY}
11362a3b7dbSdnirmala              ...  /xyz/openbmc_project/inventory${component} ${busctl_field}
11462a3b7dbSdnirmala              ${cmd_output}=  BMC Execute Command  ${cmd}
11562a3b7dbSdnirmala              # Check whether the vpdtool response and busctl response matching.
11662a3b7dbSdnirmala              Valid Value  vpd_records['${component}']['${vpd_field}']
11762a3b7dbSdnirmala              ...  ['${cmd_output[0].split('"')[1].strip('"')}']
11862a3b7dbSdnirmala          ELSE
11962a3b7dbSdnirmala             Continue For Loop
12062a3b7dbSdnirmala          END
12162a3b7dbSdnirmala    END
122ef00306eSRahul Maheshwari
123ef00306eSRahul Maheshwari
124ef00306eSRahul MaheshwariVerify VPD Field Read Operation
12516b3c7bfSGeorge Keishing    [Documentation]  Verify reading all VPD fields for given component via vpdtool.
126ef00306eSRahul Maheshwari    [Arguments]  ${component}
127ef00306eSRahul Maheshwari    # Description of arguments:
128ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
129ef00306eSRahul Maheshwari
13062a3b7dbSdnirmala    ${vpd_records}=  Vpdtool  -o -O ${component}
13162a3b7dbSdnirmala    ${vpdtool_res}=  Set To Dictionary  ${vpd_records}[${component}]
13262a3b7dbSdnirmala    FOR  ${field}  IN  @{vpd_fields}
13362a3b7dbSdnirmala         ${match_key_exists}=  Run Keyword And Return Status
13462a3b7dbSdnirmala         ...  Dictionary Should Contain Key  ${vpdtool_res}  ${field}
13562a3b7dbSdnirmala         IF  '${match_key_exists}' == 'True'
13662a3b7dbSdnirmala             ${vpd_records}=  Vpdtool  -r -O ${component} -R VINI -K ${field}
13762a3b7dbSdnirmala             # Skip check if field value is empty.
13862a3b7dbSdnirmala             Run Keyword If  '${vpd_records['${component}']['${field}']}' == ''
13962a3b7dbSdnirmala             ...  Continue For Loop
140ef00306eSRahul Maheshwari
14162a3b7dbSdnirmala             ${busctl_field}=  Set Variable If
14262a3b7dbSdnirmala             ...  '${field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
14362a3b7dbSdnirmala             ...  '${field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
14462a3b7dbSdnirmala             ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY}
14562a3b7dbSdnirmala             ...  /xyz/openbmc_project/inventory${component} ${busctl_field}
14662a3b7dbSdnirmala             ${cmd_output}=  BMC Execute Command  ${cmd}
14762a3b7dbSdnirmala
14862a3b7dbSdnirmala             # Check vpdtool response and busctl response for the component field.
14962a3b7dbSdnirmala             Valid Value  vpd_records['${component}']['${field}']
15062a3b7dbSdnirmala             ...  ['${cmd_output[0].split('"')[1].strip('"')}']
15162a3b7dbSdnirmala         ELSE
15262a3b7dbSdnirmala            Continue For Loop
15362a3b7dbSdnirmala         END
154ef00306eSRahul Maheshwari    END
155ef00306eSRahul Maheshwari
156ef00306eSRahul Maheshwari
157ef00306eSRahul MaheshwariVerify VPD Field Write Operation
1580ef1e157SRahul Maheshwari    [Documentation]  Verify writing VPD fields for given component via vpdtool.
1590ef1e157SRahul Maheshwari    [Arguments]  ${component}  ${field}
1600ef1e157SRahul Maheshwari    [Teardown]  Restore VPD Value  ${component}  ${field}  ${old_field_value}
161ef00306eSRahul Maheshwari    # Description of arguments:
1620ef1e157SRahul Maheshwari    # component       VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
1630ef1e157SRahul Maheshwari    # field           VPD component field (e.g. PN, SN)
164ef00306eSRahul Maheshwari
1650ef1e157SRahul Maheshwari    ${vpd_records}=  Vpdtool  -r -O ${component} -R VINI -K ${field}
1660ef1e157SRahul Maheshwari    ${old_field_value}=  Set Variable  ${vpd_records['${component}']['${field}']}
167ef00306eSRahul Maheshwari
168ef00306eSRahul Maheshwari    ${write_value}=  Set Variable If
169ef00306eSRahul Maheshwari    ...  '${field}' == 'DR'  ${DR_WRITE_VALUE}
170ef00306eSRahul Maheshwari    ...  '${field}' == 'PN'  ${PN_WRITE_VALUE}
171ef00306eSRahul Maheshwari    ...  '${field}' == 'SN'  ${SN_WRITE_VALUE}
1720ef1e157SRahul Maheshwari
173ef00306eSRahul Maheshwari    Vpdtool  -w -O ${component} -R VINI -K ${field} --value ${write_value}
1740ef1e157SRahul Maheshwari
1750ef1e157SRahul Maheshwari    Verify VPD Field Value  ${component}  ${field}
1760ef1e157SRahul Maheshwari
1770ef1e157SRahul Maheshwari
1780ef1e157SRahul MaheshwariRestore VPD Value
1790ef1e157SRahul Maheshwari    [Documentation]  Restore VPD's field value of given component.
1800ef1e157SRahul Maheshwari    [Arguments]  ${component}  ${field}  ${value}
1810ef1e157SRahul Maheshwari    # Description of arguments:
1820ef1e157SRahul Maheshwari    # component       VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
1830ef1e157SRahul Maheshwari    # field           VPD component field (e.g. PN, SN)
1840ef1e157SRahul Maheshwari    # value           VPD value to be restore.
1850ef1e157SRahul Maheshwari
1860ef1e157SRahul Maheshwari    Vpdtool  -w -O ${component} -R VINI -K ${field} --value ${value}
187ef00306eSRahul Maheshwari
188ef00306eSRahul Maheshwari
189ef00306eSRahul MaheshwariVerify VPD Field Value
190ef00306eSRahul Maheshwari    [Documentation]  Verify VPD field value via vpdtool.
191ef00306eSRahul Maheshwari    [Arguments]  ${component}  ${field}
192ef00306eSRahul Maheshwari    # Description of arguments:
193ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
194ef00306eSRahul Maheshwari    # field           VPD field (e.g. DR, SN, PN)
195ef00306eSRahul Maheshwari
196ef00306eSRahul Maheshwari    ${vpd_records}=  Vpdtool  -r -O ${component} -R VINI -K ${field}
197ef00306eSRahul Maheshwari
198ef00306eSRahul Maheshwari    ${busctl_field}=  Set Variable If
199ef00306eSRahul Maheshwari    ...  '${field}' == 'DR'  xyz.openbmc_project.Inventory.Item PrettyName
200ef00306eSRahul Maheshwari    ...  '${field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
201ef00306eSRahul Maheshwari    ...  '${field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
202ef00306eSRahul Maheshwari
203ef00306eSRahul Maheshwari    ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component}
204ef00306eSRahul Maheshwari    ...  ${busctl_field}
205ef00306eSRahul Maheshwari    ${cmd_output}=  BMC Execute Command  ${cmd}
206ef00306eSRahul Maheshwari
207ef00306eSRahul Maheshwari    Valid Value  vpd_records['${component}']['${field}']  ['${cmd_output[0].split('"')[1].strip('"')}']
208348356a3Sdnirmala
209348356a3Sdnirmala
210348356a3SdnirmalaVerify VPD Data Via Vpdtool
211348356a3Sdnirmala    [Documentation]  Get VPD details of given component via vpdtool and verify it
212348356a3Sdnirmala    ...              using busctl command.
213348356a3Sdnirmala    [Arguments]  ${component}  ${field}
214348356a3Sdnirmala    # Description of arguments:
215348356a3Sdnirmala    # component       VPD component (e.g. System,Chassis etc).
216348356a3Sdnirmala    # field           VPD field (e.g. Serialnumber,LocationCode etc).
217348356a3Sdnirmala
218348356a3Sdnirmala    ${component_url}=  Run Keyword If
219348356a3Sdnirmala    ...  '${component}' == 'System'  Set Variable  /system
220348356a3Sdnirmala
221348356a3Sdnirmala    # Get VPD details of given component via vpd-tool.
222348356a3Sdnirmala    ${vpd_records}=  Vpdtool  -o -O ${component_url}
223348356a3Sdnirmala
224348356a3Sdnirmala    # Get VPD details of given component via busctl command.
225348356a3Sdnirmala    ${busctl_field}=  Set Variable If
226348356a3Sdnirmala    ...  '${field}' == 'LocationCode'  com.ibm.ipzvpd.Location LocationCode
227348356a3Sdnirmala    ...  '${field}' == 'Model'  xyz.openbmc_project.Inventory.Decorator.Asset Model
228348356a3Sdnirmala    ...  '${field}' == 'SerialNumber'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
229348356a3Sdnirmala
230348356a3Sdnirmala    ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory/system
231348356a3Sdnirmala    ...  ${busctl_field}
232348356a3Sdnirmala    ${cmd_output}=  BMC Execute Command  ${cmd}
233348356a3Sdnirmala    # Example of cmd_output:
234348356a3Sdnirmala    #   [0]:                                            s "ABCD.XY1.1234567-P0"
235348356a3Sdnirmala    #   [1]:
236348356a3Sdnirmala    #   [2]:                                            0
237348356a3Sdnirmala
238348356a3Sdnirmala    # Cross check vpdtool output with busctl response.
239348356a3Sdnirmala    Should Be Equal As Strings  ${vpd_records["/system"]["${field}"]}
240348356a3Sdnirmala    ...  ${cmd_output[0].split('"')[1].strip('"')}
241