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