blob: 496574c131440edbd5d6ae02a2680cf9f165a53b [file] [log] [blame]
Rahul Maheshwarief003062020-03-23 07:17:16 -05001*** 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
Sridevi Rameshf6304c62025-04-17 12:04:48 -05007Resource ../../lib/boot_utils.robot
Rahul Maheshwarief003062020-03-23 07:17:16 -05008
9Test Teardown FFDC On Test Case Fail
10
Matt Fischer6fb70d92023-10-24 19:06:33 -060011Test Tags VPD_Tool
Rahul Maheshwarief003062020-03-23 07:17:16 -050012
13*** Variables ***
14
15${CMD_GET_PROPERTY_INVENTORY} busctl get-property xyz.openbmc_project.Inventory.Manager
16${DR_WRITE_VALUE} XYZ Component
17${PN_WRITE_VALUE} XYZ1234
18${SN_WRITE_VALUE} ABCD12345678
dnirmala62a3b7d2023-03-16 01:17:05 -050019@{fields} PN SN LocationCode
20@{vpd_fields} PN SN
Rahul Maheshwarief003062020-03-23 07:17:16 -050021
22*** Test Cases ***
23
dnirmala348356a2023-03-06 04:52:56 -060024Verify System VPD Data Via Vpdtool
25 [Documentation] Verify the system VPD details via vpdtool output.
26 [Tags] Verify_System_VPD_Data_Via_Vpdtool
27 [Template] Verify VPD Data Via Vpdtool
Rahul Maheshwarief003062020-03-23 07:17:16 -050028
dnirmala348356a2023-03-06 04:52:56 -060029 # Component Field
30 System Model
31 System SerialNumber
32 System LocationCode
Rahul Maheshwarief003062020-03-23 07:17:16 -050033
34
35Verify VPD Component Read
dnirmala62a3b7d2023-03-16 01:17:05 -050036 [Documentation] Verify details of all VPD component via vpdtool.
Rahul Maheshwarief003062020-03-23 07:17:16 -050037 [Tags] Verify_VPD_Component_Read
38
dnirmala62a3b7d2023-03-16 01:17:05 -050039 ${vpd_records}= Vpdtool -i
40 ${components}= Get Dictionary Keys ${vpd_records}
Rahul Maheshwarief003062020-03-23 07:17:16 -050041 FOR ${component} IN @{components}
42 Verify VPD Component Read Operation ${component}
43 END
44
45
46Verify VPD Field Read
47 [Documentation] Verify reading VPD field value via vpdtool.
48 [Tags] Verify_VPD_Field_Read
49
dnirmala62a3b7d2023-03-16 01:17:05 -050050 ${vpd_records}= Vpdtool -i
51 ${components}= Get Dictionary Keys ${vpd_records}
Rahul Maheshwarief003062020-03-23 07:17:16 -050052 FOR ${component} IN @{components}
George Keishinge01ee582023-05-16 10:17:08 +053053 # Drive component field values response in ascii format
54 # due to that skipping here.
dnirmala62a3b7d2023-03-16 01:17:05 -050055 IF 'drive' in '${component}'
56 Continue FOR Loop
57 ELSE
58 Verify VPD Field Read Operation ${component}
59 END
Rahul Maheshwarief003062020-03-23 07:17:16 -050060 END
61
62
63Verify VPD Field Write
George Keishinge20f82c2020-05-13 10:51:02 -050064 [Documentation] Verify writing VPD field value via vpdtool.
Rahul Maheshwarief003062020-03-23 07:17:16 -050065 [Tags] Verify_VPD_Field_Write
66
Sridevi Rameshf6304c62025-04-17 12:04:48 -050067 # Put system to power off state before VPD write operation.
68 Redfish Power Off stack_mode=skip
69
Rahul Maheshwarief003062020-03-23 07:17:16 -050070 ${components}= Get Dictionary Keys ${VPD_DETAILS}
71 FOR ${component} IN @{components}
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -060072 # VPD fields "DR", "CC" and "FN" will be added later.
73 @{vpd_fields}= Create List SN PN
74 ${field}= Evaluate random.choice($vpd_fields) random
75 Verify VPD Field Write Operation ${component} ${field}
Rahul Maheshwarief003062020-03-23 07:17:16 -050076 END
77
78
79*** Keywords ***
80
Rahul Maheshwarief003062020-03-23 07:17:16 -050081Verify VPD Component Read Operation
George Keishing16b3c7b2021-01-28 09:23:37 -060082 [Documentation] Verify reading VPD details of given component via vpdtool.
Rahul Maheshwarief003062020-03-23 07:17:16 -050083 [Arguments] ${component}
84 # Description of arguments:
85 # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
86
87 ${vpd_records}= Vpdtool -o -O ${component}
88
89 # Example output from 'Vpdtool -o -O /system/chassis/motherboard/vdd_vrm1':
90 # [/system/chassis/motherboard/vdd_vrm1]:
91 # [DR]: CPU POWER CARD
92 # [type]: xyz.openbmc_project.Inventory.Item.Vrm
93 # [CC]: E123
94 # [FN]: F123456
95 # [LocationCode]: ABCD.XY1.1234567-P0
96 # [SN]: YL2E32010000
97 # [PN]: PN12345
98
dnirmala62a3b7d2023-03-16 01:17:05 -050099 ${vpdtool_res}= Set To Dictionary ${vpd_records}[${component}]
100 FOR ${vpd_field} IN @{fields}
George Keishinge01ee582023-05-16 10:17:08 +0530101 ${match_key_exists}= Run Keyword And Return Status
dnirmala62a3b7d2023-03-16 01:17:05 -0500102 ... Dictionary Should Contain Key ${vpdtool_res} ${vpd_field}
103 IF '${match_key_exists}' == 'True'
104 # drive components busctl field response in ascii due to that checking only locationcode.
105 IF 'drive' in '${component}'
106 ${vpd_field}= Set Variable LocationCode
107 END
George Keishinge01ee582023-05-16 10:17:08 +0530108 # Skip check if VPD field is empty.
dnirmala62a3b7d2023-03-16 01:17:05 -0500109 Run Keyword If '${vpd_records['${component}']['${vpd_field}']}' == ''
110 ... Continue For Loop
George Keishinge01ee582023-05-16 10:17:08 +0530111
dnirmala62a3b7d2023-03-16 01:17:05 -0500112 # Get VPD field values via busctl.
113 ${busctl_field}= Set Variable If
114 ... '${vpd_field}' == 'LocationCode' com.ibm.ipzvpd.Location LocationCode
115 ... '${vpd_field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
116 ... '${vpd_field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
117 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY}
118 ... /xyz/openbmc_project/inventory${component} ${busctl_field}
119 ${cmd_output}= BMC Execute Command ${cmd}
120 # Check whether the vpdtool response and busctl response matching.
George Keishinge01ee582023-05-16 10:17:08 +0530121 Valid Value vpd_records['${component}']['${vpd_field}']
dnirmala62a3b7d2023-03-16 01:17:05 -0500122 ... ['${cmd_output[0].split('"')[1].strip('"')}']
123 ELSE
124 Continue For Loop
125 END
126 END
Rahul Maheshwarief003062020-03-23 07:17:16 -0500127
128
129Verify VPD Field Read Operation
George Keishing16b3c7b2021-01-28 09:23:37 -0600130 [Documentation] Verify reading all VPD fields for given component via vpdtool.
Rahul Maheshwarief003062020-03-23 07:17:16 -0500131 [Arguments] ${component}
132 # Description of arguments:
133 # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
134
dnirmala62a3b7d2023-03-16 01:17:05 -0500135 ${vpd_records}= Vpdtool -o -O ${component}
136 ${vpdtool_res}= Set To Dictionary ${vpd_records}[${component}]
137 FOR ${field} IN @{vpd_fields}
138 ${match_key_exists}= Run Keyword And Return Status
139 ... Dictionary Should Contain Key ${vpdtool_res} ${field}
140 IF '${match_key_exists}' == 'True'
141 ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field}
142 # Skip check if field value is empty.
143 Run Keyword If '${vpd_records['${component}']['${field}']}' == ''
144 ... Continue For Loop
Rahul Maheshwarief003062020-03-23 07:17:16 -0500145
dnirmala62a3b7d2023-03-16 01:17:05 -0500146 ${busctl_field}= Set Variable If
147 ... '${field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
148 ... '${field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
149 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY}
150 ... /xyz/openbmc_project/inventory${component} ${busctl_field}
151 ${cmd_output}= BMC Execute Command ${cmd}
152
153 # Check vpdtool response and busctl response for the component field.
154 Valid Value vpd_records['${component}']['${field}']
155 ... ['${cmd_output[0].split('"')[1].strip('"')}']
156 ELSE
157 Continue For Loop
158 END
Rahul Maheshwarief003062020-03-23 07:17:16 -0500159 END
160
161
162Verify VPD Field Write Operation
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600163 [Documentation] Verify writing VPD fields for given component via vpdtool.
164 [Arguments] ${component} ${field}
165 [Teardown] Restore VPD Value ${component} ${field} ${old_field_value}
Sridevi Rameshf6304c62025-04-17 12:04:48 -0500166
Rahul Maheshwarief003062020-03-23 07:17:16 -0500167 # Description of arguments:
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600168 # component VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
169 # field VPD component field (e.g. PN, SN)
Rahul Maheshwarief003062020-03-23 07:17:16 -0500170
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600171 ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field}
Sridevi Rameshf6304c62025-04-17 12:04:48 -0500172 Set Test Variable ${old_field_value} ${vpd_records['${component}']['${field}']}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500173
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600174 ${write_value}= Set Variable If
175 ... '${field}' == 'DR' ${DR_WRITE_VALUE}
176 ... '${field}' == 'PN' ${PN_WRITE_VALUE}
177 ... '${field}' == 'SN' ${SN_WRITE_VALUE}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500178
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600179 Vpdtool -w -O ${component} -R VINI -K ${field} --value ${write_value}
180
181 Verify VPD Field Value ${component} ${field}
182
183
184Restore VPD Value
185 [Documentation] Restore VPD's field value of given component.
186 [Arguments] ${component} ${field} ${value}
187 # Description of arguments:
188 # component VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
189 # field VPD component field (e.g. PN, SN)
190 # value VPD value to be restore.
191
192 Vpdtool -w -O ${component} -R VINI -K ${field} --value ${value}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500193
194
195Verify VPD Field Value
196 [Documentation] Verify VPD field value via vpdtool.
197 [Arguments] ${component} ${field}
198 # Description of arguments:
199 # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
200 # field VPD field (e.g. DR, SN, PN)
201
Sridevi Rameshf6304c62025-04-17 12:04:48 -0500202 Redfish OBMC Reboot (off) stack_mode=normal
Rahul Maheshwarief003062020-03-23 07:17:16 -0500203 ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field}
204
205 ${busctl_field}= Set Variable If
206 ... '${field}' == 'DR' xyz.openbmc_project.Inventory.Item PrettyName
207 ... '${field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
208 ... '${field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
209
210 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component}
211 ... ${busctl_field}
212 ${cmd_output}= BMC Execute Command ${cmd}
213
214 Valid Value vpd_records['${component}']['${field}'] ['${cmd_output[0].split('"')[1].strip('"')}']
dnirmala348356a2023-03-06 04:52:56 -0600215
216
217Verify VPD Data Via Vpdtool
218 [Documentation] Get VPD details of given component via vpdtool and verify it
219 ... using busctl command.
220 [Arguments] ${component} ${field}
221 # Description of arguments:
222 # component VPD component (e.g. System,Chassis etc).
223 # field VPD field (e.g. Serialnumber,LocationCode etc).
224
225 ${component_url}= Run Keyword If
226 ... '${component}' == 'System' Set Variable /system
227
228 # Get VPD details of given component via vpd-tool.
229 ${vpd_records}= Vpdtool -o -O ${component_url}
230
231 # Get VPD details of given component via busctl command.
232 ${busctl_field}= Set Variable If
233 ... '${field}' == 'LocationCode' com.ibm.ipzvpd.Location LocationCode
234 ... '${field}' == 'Model' xyz.openbmc_project.Inventory.Decorator.Asset Model
235 ... '${field}' == 'SerialNumber' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
236
237 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory/system
238 ... ${busctl_field}
239 ${cmd_output}= BMC Execute Command ${cmd}
240 # Example of cmd_output:
241 # [0]: s "ABCD.XY1.1234567-P0"
242 # [1]:
243 # [2]: 0
244
245 # Cross check vpdtool output with busctl response.
246 Should Be Equal As Strings ${vpd_records["/system"]["${field}"]}
247 ... ${cmd_output[0].split('"')[1].strip('"')}