xref: /openbmc/openbmc-test-automation/openpower/vpd/test_vpd_tool.robot (revision 348356a3f9fc0c52b7f113f59d03687fb88873cd)
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
17ef00306eSRahul Maheshwari
18ef00306eSRahul Maheshwari*** Test Cases ***
19ef00306eSRahul Maheshwari
20*348356a3SdnirmalaVerify System VPD Data Via Vpdtool
21*348356a3Sdnirmala    [Documentation]  Verify the system VPD details via vpdtool output.
22*348356a3Sdnirmala    [Tags]  Verify_System_VPD_Data_Via_Vpdtool
23*348356a3Sdnirmala    [Template]  Verify VPD Data Via Vpdtool
24ef00306eSRahul Maheshwari
25*348356a3Sdnirmala    # Component     Field
26*348356a3Sdnirmala    System          Model
27*348356a3Sdnirmala    System          SerialNumber
28*348356a3Sdnirmala    System          LocationCode
29ef00306eSRahul Maheshwari
30ef00306eSRahul Maheshwari
31ef00306eSRahul MaheshwariVerify VPD Component Read
32ef00306eSRahul Maheshwari    [Documentation]  Verify details of VPD component via vpdtool.
33ef00306eSRahul Maheshwari    [Tags]  Verify_VPD_Component_Read
34ef00306eSRahul Maheshwari
35ef00306eSRahul Maheshwari    ${components}=  Get Dictionary Keys  ${VPD_DETAILS}
36ef00306eSRahul Maheshwari    FOR  ${component}  IN  @{components}
37ef00306eSRahul Maheshwari        Verify VPD Component Read Operation  ${component}
38ef00306eSRahul Maheshwari    END
39ef00306eSRahul Maheshwari
40ef00306eSRahul Maheshwari
41ef00306eSRahul MaheshwariVerify VPD Field Read
42ef00306eSRahul Maheshwari    [Documentation]  Verify reading VPD field value via vpdtool.
43ef00306eSRahul Maheshwari    [Tags]  Verify_VPD_Field_Read
44ef00306eSRahul Maheshwari
45ef00306eSRahul Maheshwari    ${components}=  Get Dictionary Keys  ${VPD_DETAILS}
46ef00306eSRahul Maheshwari    FOR  ${component}  IN  @{components}
47ef00306eSRahul Maheshwari        Verify VPD Field Read Operation  ${component}
48ef00306eSRahul Maheshwari    END
49ef00306eSRahul Maheshwari
50ef00306eSRahul Maheshwari
51ef00306eSRahul MaheshwariVerify VPD Field Write
52e20f82cdSGeorge Keishing    [Documentation]  Verify writing VPD field value via vpdtool.
53ef00306eSRahul Maheshwari    [Tags]  Verify_VPD_Field_Write
54ef00306eSRahul Maheshwari
55ef00306eSRahul Maheshwari    ${components}=  Get Dictionary Keys  ${VPD_DETAILS}
56ef00306eSRahul Maheshwari    FOR  ${component}  IN  @{components}
570ef1e157SRahul Maheshwari        # VPD fields "DR", "CC" and "FN" will be added later.
580ef1e157SRahul Maheshwari        @{vpd_fields}=  Create List  SN  PN
590ef1e157SRahul Maheshwari        ${field}=  Evaluate  random.choice($vpd_fields)  random
600ef1e157SRahul Maheshwari        Verify VPD Field Write Operation  ${component}  ${field}
61ef00306eSRahul Maheshwari    END
62ef00306eSRahul Maheshwari
63ef00306eSRahul Maheshwari
64ef00306eSRahul Maheshwari*** Keywords ***
65ef00306eSRahul Maheshwari
66ef00306eSRahul MaheshwariVerify VPD Data
67ef00306eSRahul Maheshwari    [Documentation]  Verify VPD data of given component.
68ef00306eSRahul Maheshwari    [Arguments]  ${vpd_records}  ${component}
69ef00306eSRahul Maheshwari    # Description of arguments:
70ef00306eSRahul Maheshwari    # vpd_records     All VPD data Via vpdtool.
71ef00306eSRahul Maheshwari    # component       VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
72ef00306eSRahul Maheshwari
73ef00306eSRahul Maheshwari    # Verification of "CC" and "FN" will be added later.
74ef00306eSRahul Maheshwari    @{vpd_fields}=  Create List  DR  LocationCode  SN  PN
75ef00306eSRahul Maheshwari    FOR  ${field}  IN  @{vpd_fields}
76ef00306eSRahul Maheshwari      ${busctl_field}=  Set Variable If
77ef00306eSRahul Maheshwari      ...  '${field}' == 'DR'  xyz.openbmc_project.Inventory.Item PrettyName
78ef00306eSRahul Maheshwari      ...  '${field}' == 'LocationCode'  com.ibm.ipzvpd.Location LocationCode
79ef00306eSRahul Maheshwari      ...  '${field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
80ef00306eSRahul Maheshwari      ...  '${field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
81ef00306eSRahul Maheshwari
82ef00306eSRahul Maheshwari      ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component}
83ef00306eSRahul Maheshwari      ...  ${busctl_field}
84ef00306eSRahul Maheshwari      ${cmd_output}=  BMC Execute Command  ${cmd}
85ef00306eSRahul Maheshwari      # Example of cmd_output:
86ef00306eSRahul Maheshwari      #   [0]:                                            s "ABCD.XY1.1234567-P0"
87ef00306eSRahul Maheshwari      #   [1]:
88ef00306eSRahul Maheshwari      #   [2]:                                            0
89ef00306eSRahul Maheshwari
90ef00306eSRahul Maheshwari      Valid Value  vpd_records['${component}']['${field}']  ['${cmd_output[0].split('"')[1].strip('"')}']
91ef00306eSRahul Maheshwari    END
92ef00306eSRahul Maheshwari    Valid Value  vpd_records['${component}']['type']  ['${VPD_DETAILS['${component}']['type']}']
93ef00306eSRahul Maheshwari
94ef00306eSRahul Maheshwari
95ef00306eSRahul MaheshwariVerify VPD Component Read Operation
9616b3c7bfSGeorge Keishing    [Documentation]  Verify reading VPD details of given component via vpdtool.
97ef00306eSRahul Maheshwari    [Arguments]  ${component}
98ef00306eSRahul Maheshwari    # Description of arguments:
99ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
100ef00306eSRahul Maheshwari
101ef00306eSRahul Maheshwari    ${vpd_records}=  Vpdtool  -o -O ${component}
102ef00306eSRahul Maheshwari
103ef00306eSRahul Maheshwari    # Example output from 'Vpdtool  -o -O /system/chassis/motherboard/vdd_vrm1':
104ef00306eSRahul Maheshwari    #  [/system/chassis/motherboard/vdd_vrm1]:
105ef00306eSRahul Maheshwari    #    [DR]:                                         CPU POWER CARD
106ef00306eSRahul Maheshwari    #    [type]:                                       xyz.openbmc_project.Inventory.Item.Vrm
107ef00306eSRahul Maheshwari    #    [CC]:                                         E123
108ef00306eSRahul Maheshwari    #    [FN]:                                         F123456
109ef00306eSRahul Maheshwari    #    [LocationCode]:                               ABCD.XY1.1234567-P0
110ef00306eSRahul Maheshwari    #    [SN]:                                         YL2E32010000
111ef00306eSRahul Maheshwari    #    [PN]:                                         PN12345
112ef00306eSRahul Maheshwari
113ef00306eSRahul Maheshwari    Verify VPD Data  ${vpd_records}  ${component}
114ef00306eSRahul Maheshwari
115ef00306eSRahul Maheshwari
116ef00306eSRahul MaheshwariVerify VPD Field Read Operation
11716b3c7bfSGeorge Keishing    [Documentation]  Verify reading all VPD fields for given component via vpdtool.
118ef00306eSRahul Maheshwari    [Arguments]  ${component}
119ef00306eSRahul Maheshwari    # Description of arguments:
120ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
121ef00306eSRahul Maheshwari
122ef00306eSRahul Maheshwari    # Verification of "CC" and "FN" will be added later.
123ef00306eSRahul Maheshwari    @{vpd_fields}=  Create List  DR  SN  PN
124ef00306eSRahul Maheshwari
125ef00306eSRahul Maheshwari    FOR  ${fields}  IN   @{vpd_fields}
126ef00306eSRahul Maheshwari        Verify VPD Field Value  ${component}  ${fields}
127ef00306eSRahul Maheshwari    END
128ef00306eSRahul Maheshwari
129ef00306eSRahul Maheshwari
130ef00306eSRahul MaheshwariVerify VPD Field Write Operation
1310ef1e157SRahul Maheshwari    [Documentation]  Verify writing VPD fields for given component via vpdtool.
1320ef1e157SRahul Maheshwari    [Arguments]  ${component}  ${field}
1330ef1e157SRahul Maheshwari    [Teardown]  Restore VPD Value  ${component}  ${field}  ${old_field_value}
134ef00306eSRahul Maheshwari    # Description of arguments:
1350ef1e157SRahul Maheshwari    # component       VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
1360ef1e157SRahul Maheshwari    # field           VPD component field (e.g. PN, SN)
137ef00306eSRahul Maheshwari
1380ef1e157SRahul Maheshwari    ${vpd_records}=  Vpdtool  -r -O ${component} -R VINI -K ${field}
1390ef1e157SRahul Maheshwari    ${old_field_value}=  Set Variable  ${vpd_records['${component}']['${field}']}
140ef00306eSRahul Maheshwari
141ef00306eSRahul Maheshwari    ${write_value}=  Set Variable If
142ef00306eSRahul Maheshwari    ...  '${field}' == 'DR'  ${DR_WRITE_VALUE}
143ef00306eSRahul Maheshwari    ...  '${field}' == 'PN'  ${PN_WRITE_VALUE}
144ef00306eSRahul Maheshwari    ...  '${field}' == 'SN'  ${SN_WRITE_VALUE}
1450ef1e157SRahul Maheshwari
146ef00306eSRahul Maheshwari    Vpdtool  -w -O ${component} -R VINI -K ${field} --value ${write_value}
1470ef1e157SRahul Maheshwari
1480ef1e157SRahul Maheshwari    Verify VPD Field Value  ${component}  ${field}
1490ef1e157SRahul Maheshwari
1500ef1e157SRahul Maheshwari
1510ef1e157SRahul MaheshwariRestore VPD Value
1520ef1e157SRahul Maheshwari    [Documentation]  Restore VPD's field value of given component.
1530ef1e157SRahul Maheshwari    [Arguments]  ${component}  ${field}  ${value}
1540ef1e157SRahul Maheshwari    # Description of arguments:
1550ef1e157SRahul Maheshwari    # component       VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
1560ef1e157SRahul Maheshwari    # field           VPD component field (e.g. PN, SN)
1570ef1e157SRahul Maheshwari    # value           VPD value to be restore.
1580ef1e157SRahul Maheshwari
1590ef1e157SRahul Maheshwari    Vpdtool  -w -O ${component} -R VINI -K ${field} --value ${value}
160ef00306eSRahul Maheshwari
161ef00306eSRahul Maheshwari
162ef00306eSRahul MaheshwariVerify VPD Field Value
163ef00306eSRahul Maheshwari    [Documentation]  Verify VPD field value via vpdtool.
164ef00306eSRahul Maheshwari    [Arguments]  ${component}  ${field}
165ef00306eSRahul Maheshwari    # Description of arguments:
166ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
167ef00306eSRahul Maheshwari    # field           VPD field (e.g. DR, SN, PN)
168ef00306eSRahul Maheshwari
169ef00306eSRahul Maheshwari    ${vpd_records}=  Vpdtool  -r -O ${component} -R VINI -K ${field}
170ef00306eSRahul Maheshwari
171ef00306eSRahul Maheshwari    ${busctl_field}=  Set Variable If
172ef00306eSRahul Maheshwari    ...  '${field}' == 'DR'  xyz.openbmc_project.Inventory.Item PrettyName
173ef00306eSRahul Maheshwari    ...  '${field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
174ef00306eSRahul Maheshwari    ...  '${field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
175ef00306eSRahul Maheshwari
176ef00306eSRahul Maheshwari    ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component}
177ef00306eSRahul Maheshwari    ...  ${busctl_field}
178ef00306eSRahul Maheshwari    ${cmd_output}=  BMC Execute Command  ${cmd}
179ef00306eSRahul Maheshwari
180ef00306eSRahul Maheshwari    Valid Value  vpd_records['${component}']['${field}']  ['${cmd_output[0].split('"')[1].strip('"')}']
181*348356a3Sdnirmala
182*348356a3Sdnirmala
183*348356a3SdnirmalaVerify VPD Data Via Vpdtool
184*348356a3Sdnirmala    [Documentation]  Get VPD details of given component via vpdtool and verify it
185*348356a3Sdnirmala    ...              using busctl command.
186*348356a3Sdnirmala    [Arguments]  ${component}  ${field}
187*348356a3Sdnirmala    # Description of arguments:
188*348356a3Sdnirmala    # component       VPD component (e.g. System,Chassis etc).
189*348356a3Sdnirmala    # field           VPD field (e.g. Serialnumber,LocationCode etc).
190*348356a3Sdnirmala
191*348356a3Sdnirmala    ${component_url}=  Run Keyword If
192*348356a3Sdnirmala    ...  '${component}' == 'System'  Set Variable  /system
193*348356a3Sdnirmala
194*348356a3Sdnirmala    # Get VPD details of given component via vpd-tool.
195*348356a3Sdnirmala    ${vpd_records}=  Vpdtool  -o -O ${component_url}
196*348356a3Sdnirmala
197*348356a3Sdnirmala    # Get VPD details of given component via busctl command.
198*348356a3Sdnirmala    ${busctl_field}=  Set Variable If
199*348356a3Sdnirmala    ...  '${field}' == 'LocationCode'  com.ibm.ipzvpd.Location LocationCode
200*348356a3Sdnirmala    ...  '${field}' == 'Model'  xyz.openbmc_project.Inventory.Decorator.Asset Model
201*348356a3Sdnirmala    ...  '${field}' == 'SerialNumber'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
202*348356a3Sdnirmala
203*348356a3Sdnirmala    ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory/system
204*348356a3Sdnirmala    ...  ${busctl_field}
205*348356a3Sdnirmala    ${cmd_output}=  BMC Execute Command  ${cmd}
206*348356a3Sdnirmala    # Example of cmd_output:
207*348356a3Sdnirmala    #   [0]:                                            s "ABCD.XY1.1234567-P0"
208*348356a3Sdnirmala    #   [1]:
209*348356a3Sdnirmala    #   [2]:                                            0
210*348356a3Sdnirmala
211*348356a3Sdnirmala    # Cross check vpdtool output with busctl response.
212*348356a3Sdnirmala    Should Be Equal As Strings  ${vpd_records["/system"]["${field}"]}
213*348356a3Sdnirmala    ...  ${cmd_output[0].split('"')[1].strip('"')}
214