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