xref: /openbmc/openbmc-test-automation/openpower/vpd/test_vpd_tool.robot (revision e20f82cdaf153b512a0a2fd53220e2d9b64f1e84)
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
20ef00306eSRahul MaheshwariVerify System VPD
21ef00306eSRahul Maheshwari    [Documentation]  Verify system VPD details via vpdtool '-i' option.
22ef00306eSRahul Maheshwari    [Tags]  Verify_System_VPD
23ef00306eSRahul Maheshwari
24ef00306eSRahul Maheshwari    ${vpd_records}=  Vpdtool  -i
25ef00306eSRahul Maheshwari
26ef00306eSRahul Maheshwari    ${components}=  Get Dictionary Keys  ${vpd_records}
27ef00306eSRahul Maheshwari    FOR  ${component}  IN  @{components}
28ef00306eSRahul Maheshwari        Verify VPD Data  ${vpd_records}  ${component}
29ef00306eSRahul Maheshwari    END
30ef00306eSRahul Maheshwari
31ef00306eSRahul Maheshwari
32ef00306eSRahul MaheshwariVerify VPD Component Read
33ef00306eSRahul Maheshwari    [Documentation]  Verify details of VPD component via vpdtool.
34ef00306eSRahul Maheshwari    [Tags]  Verify_VPD_Component_Read
35ef00306eSRahul Maheshwari
36ef00306eSRahul Maheshwari    ${components}=  Get Dictionary Keys  ${VPD_DETAILS}
37ef00306eSRahul Maheshwari    FOR  ${component}  IN  @{components}
38ef00306eSRahul Maheshwari        Verify VPD Component Read Operation  ${component}
39ef00306eSRahul Maheshwari    END
40ef00306eSRahul Maheshwari
41ef00306eSRahul Maheshwari
42ef00306eSRahul MaheshwariVerify VPD Field Read
43ef00306eSRahul Maheshwari    [Documentation]  Verify reading VPD field value via vpdtool.
44ef00306eSRahul Maheshwari    [Tags]  Verify_VPD_Field_Read
45ef00306eSRahul Maheshwari
46ef00306eSRahul Maheshwari    ${components}=  Get Dictionary Keys  ${VPD_DETAILS}
47ef00306eSRahul Maheshwari    FOR  ${component}  IN  @{components}
48ef00306eSRahul Maheshwari        Verify VPD Field Read Operation  ${component}
49ef00306eSRahul Maheshwari    END
50ef00306eSRahul Maheshwari
51ef00306eSRahul Maheshwari
52ef00306eSRahul MaheshwariVerify VPD Field Write
53*e20f82cdSGeorge Keishing    [Documentation]  Verify writing VPD field value via vpdtool.
54ef00306eSRahul Maheshwari    [Tags]  Verify_VPD_Field_Write
55ef00306eSRahul Maheshwari
56ef00306eSRahul Maheshwari    ${components}=  Get Dictionary Keys  ${VPD_DETAILS}
57ef00306eSRahul Maheshwari    FOR  ${component}  IN  @{components}
58ef00306eSRahul Maheshwari        Verify VPD Field Write Operation  ${component}
59ef00306eSRahul Maheshwari    END
60ef00306eSRahul Maheshwari
61ef00306eSRahul Maheshwari
62ef00306eSRahul Maheshwari*** Keywords ***
63ef00306eSRahul Maheshwari
64ef00306eSRahul MaheshwariVerify VPD Data
65ef00306eSRahul Maheshwari    [Documentation]  Verify VPD data of given component.
66ef00306eSRahul Maheshwari    [Arguments]  ${vpd_records}  ${component}
67ef00306eSRahul Maheshwari    # Description of arguments:
68ef00306eSRahul Maheshwari    # vpd_records     All VPD data Via vpdtool.
69ef00306eSRahul Maheshwari    # component       VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
70ef00306eSRahul Maheshwari
71ef00306eSRahul Maheshwari    # Verification of "CC" and "FN" will be added later.
72ef00306eSRahul Maheshwari    @{vpd_fields}=  Create List  DR  LocationCode  SN  PN
73ef00306eSRahul Maheshwari    FOR  ${field}  IN  @{vpd_fields}
74ef00306eSRahul Maheshwari      ${busctl_field}=  Set Variable If
75ef00306eSRahul Maheshwari      ...  '${field}' == 'DR'  xyz.openbmc_project.Inventory.Item PrettyName
76ef00306eSRahul Maheshwari      ...  '${field}' == 'LocationCode'  com.ibm.ipzvpd.Location LocationCode
77ef00306eSRahul Maheshwari      ...  '${field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
78ef00306eSRahul Maheshwari      ...  '${field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
79ef00306eSRahul Maheshwari
80ef00306eSRahul Maheshwari      ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component}
81ef00306eSRahul Maheshwari      ...  ${busctl_field}
82ef00306eSRahul Maheshwari      ${cmd_output}=  BMC Execute Command  ${cmd}
83ef00306eSRahul Maheshwari      # Example of cmd_output:
84ef00306eSRahul Maheshwari      #   [0]:                                            s "ABCD.XY1.1234567-P0"
85ef00306eSRahul Maheshwari      #   [1]:
86ef00306eSRahul Maheshwari      #   [2]:                                            0
87ef00306eSRahul Maheshwari
88ef00306eSRahul Maheshwari      Valid Value  vpd_records['${component}']['${field}']  ['${cmd_output[0].split('"')[1].strip('"')}']
89ef00306eSRahul Maheshwari    END
90ef00306eSRahul Maheshwari    Valid Value  vpd_records['${component}']['type']  ['${VPD_DETAILS['${component}']['type']}']
91ef00306eSRahul Maheshwari
92ef00306eSRahul Maheshwari
93ef00306eSRahul MaheshwariVerify VPD Component Read Operation
94ef00306eSRahul Maheshwari    [Documentation]  Verify reading VPD details of given compoment via vpdtool.
95ef00306eSRahul Maheshwari    [Arguments]  ${component}
96ef00306eSRahul Maheshwari    # Description of arguments:
97ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
98ef00306eSRahul Maheshwari
99ef00306eSRahul Maheshwari    ${vpd_records}=  Vpdtool  -o -O ${component}
100ef00306eSRahul Maheshwari
101ef00306eSRahul Maheshwari    # Example output from 'Vpdtool  -o -O /system/chassis/motherboard/vdd_vrm1':
102ef00306eSRahul Maheshwari    #  [/system/chassis/motherboard/vdd_vrm1]:
103ef00306eSRahul Maheshwari    #    [DR]:                                         CPU POWER CARD
104ef00306eSRahul Maheshwari    #    [type]:                                       xyz.openbmc_project.Inventory.Item.Vrm
105ef00306eSRahul Maheshwari    #    [CC]:                                         E123
106ef00306eSRahul Maheshwari    #    [FN]:                                         F123456
107ef00306eSRahul Maheshwari    #    [LocationCode]:                               ABCD.XY1.1234567-P0
108ef00306eSRahul Maheshwari    #    [SN]:                                         YL2E32010000
109ef00306eSRahul Maheshwari    #    [PN]:                                         PN12345
110ef00306eSRahul Maheshwari
111ef00306eSRahul Maheshwari    Verify VPD Data  ${vpd_records}  ${component}
112ef00306eSRahul Maheshwari
113ef00306eSRahul Maheshwari
114ef00306eSRahul MaheshwariVerify VPD Field Read Operation
115ef00306eSRahul Maheshwari    [Documentation]  Verify reading all VPD fields for given compoment via vpdtool.
116ef00306eSRahul Maheshwari    [Arguments]  ${component}
117ef00306eSRahul Maheshwari    # Description of arguments:
118ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
119ef00306eSRahul Maheshwari
120ef00306eSRahul Maheshwari    # Verification of "CC" and "FN" will be added later.
121ef00306eSRahul Maheshwari    @{vpd_fields}=  Create List  DR  SN  PN
122ef00306eSRahul Maheshwari
123ef00306eSRahul Maheshwari    FOR  ${fields}  IN   @{vpd_fields}
124ef00306eSRahul Maheshwari        Verify VPD Field Value  ${component}  ${fields}
125ef00306eSRahul Maheshwari    END
126ef00306eSRahul Maheshwari
127ef00306eSRahul Maheshwari
128ef00306eSRahul MaheshwariVerify VPD Field Write Operation
129ef00306eSRahul Maheshwari    [Documentation]  Verify writing all VPD fields for given compoment via vpdtool.
130ef00306eSRahul Maheshwari    [Arguments]  ${component}
131ef00306eSRahul Maheshwari    # Description of arguments:
132ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
133ef00306eSRahul Maheshwari
134ef00306eSRahul Maheshwari    # Verification of "CC" and "FN" will be added later.
135ef00306eSRahul Maheshwari    @{vpd_fields}=  Create List  DR  SN  PN
136ef00306eSRahul Maheshwari
137ef00306eSRahul Maheshwari    ${field}=  Evaluate  random.choice($vpd_fields)  random
138ef00306eSRahul Maheshwari
139ef00306eSRahul Maheshwari    FOR  ${fields}  IN   @{vpd_fields}
140ef00306eSRahul Maheshwari        ${write_value}=  Set Variable If
141ef00306eSRahul Maheshwari        ...  '${field}' == 'DR'  ${DR_WRITE_VALUE}
142ef00306eSRahul Maheshwari        ...  '${field}' == 'PN'  ${PN_WRITE_VALUE}
143ef00306eSRahul Maheshwari        ...  '${field}' == 'SN'  ${SN_WRITE_VALUE}
144ef00306eSRahul Maheshwari        Vpdtool  -w -O ${component} -R VINI -K ${field} --value ${write_value}
145ef00306eSRahul Maheshwari        Verify VPD Field Value  ${component}  ${fields}
146ef00306eSRahul Maheshwari    END
147ef00306eSRahul Maheshwari
148ef00306eSRahul Maheshwari
149ef00306eSRahul MaheshwariVerify VPD Field Value
150ef00306eSRahul Maheshwari    [Documentation]  Verify VPD field value via vpdtool.
151ef00306eSRahul Maheshwari    [Arguments]  ${component}  ${field}
152ef00306eSRahul Maheshwari    # Description of arguments:
153ef00306eSRahul Maheshwari    # component       VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
154ef00306eSRahul Maheshwari    # field           VPD field (e.g. DR, SN, PN)
155ef00306eSRahul Maheshwari
156ef00306eSRahul Maheshwari    ${vpd_records}=  Vpdtool  -r -O ${component} -R VINI -K ${field}
157ef00306eSRahul Maheshwari
158ef00306eSRahul Maheshwari    ${busctl_field}=  Set Variable If
159ef00306eSRahul Maheshwari    ...  '${field}' == 'DR'  xyz.openbmc_project.Inventory.Item PrettyName
160ef00306eSRahul Maheshwari    ...  '${field}' == 'PN'  xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
161ef00306eSRahul Maheshwari    ...  '${field}' == 'SN'  xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
162ef00306eSRahul Maheshwari
163ef00306eSRahul Maheshwari    ${cmd}=  Catenate  ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component}
164ef00306eSRahul Maheshwari    ...  ${busctl_field}
165ef00306eSRahul Maheshwari    ${cmd_output}=  BMC Execute Command  ${cmd}
166ef00306eSRahul Maheshwari
167ef00306eSRahul Maheshwari    Valid Value  vpd_records['${component}']['${field}']  ['${cmd_output[0].split('"')[1].strip('"')}']
168