blob: 060f47f65cd0bac076a58db5c2e5f605fd569aa0 [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}'
Sridevi Rameshc6e7f932025-05-07 11:26:54 -050056 CONTINUE
dnirmala62a3b7d2023-03-16 01:17:05 -050057 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.
Sridevi Rameshc6e7f932025-05-07 11:26:54 -0500109 IF '${vpd_records['${component}']['${vpd_field}']}' == '' CONTINUE
George Keishinge01ee582023-05-16 10:17:08 +0530110
dnirmala62a3b7d2023-03-16 01:17:05 -0500111 # Get VPD field values via busctl.
112 ${busctl_field}= Set Variable If
113 ... '${vpd_field}' == 'LocationCode' com.ibm.ipzvpd.Location LocationCode
114 ... '${vpd_field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
115 ... '${vpd_field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
116 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY}
117 ... /xyz/openbmc_project/inventory${component} ${busctl_field}
118 ${cmd_output}= BMC Execute Command ${cmd}
119 # Check whether the vpdtool response and busctl response matching.
George Keishinge01ee582023-05-16 10:17:08 +0530120 Valid Value vpd_records['${component}']['${vpd_field}']
dnirmala62a3b7d2023-03-16 01:17:05 -0500121 ... ['${cmd_output[0].split('"')[1].strip('"')}']
122 ELSE
Sridevi Rameshc6e7f932025-05-07 11:26:54 -0500123 CONTINUE
dnirmala62a3b7d2023-03-16 01:17:05 -0500124 END
125 END
Rahul Maheshwarief003062020-03-23 07:17:16 -0500126
127
128Verify VPD Field Read Operation
George Keishing16b3c7b2021-01-28 09:23:37 -0600129 [Documentation] Verify reading all VPD fields for given component via vpdtool.
Rahul Maheshwarief003062020-03-23 07:17:16 -0500130 [Arguments] ${component}
131 # Description of arguments:
132 # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
133
dnirmala62a3b7d2023-03-16 01:17:05 -0500134 ${vpd_records}= Vpdtool -o -O ${component}
135 ${vpdtool_res}= Set To Dictionary ${vpd_records}[${component}]
136 FOR ${field} IN @{vpd_fields}
137 ${match_key_exists}= Run Keyword And Return Status
138 ... Dictionary Should Contain Key ${vpdtool_res} ${field}
139 IF '${match_key_exists}' == 'True'
140 ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field}
141 # Skip check if field value is empty.
Sridevi Rameshc6e7f932025-05-07 11:26:54 -0500142 IF '${vpd_records['${component}']['${field}']}' == '' CONTINUE
Rahul Maheshwarief003062020-03-23 07:17:16 -0500143
dnirmala62a3b7d2023-03-16 01:17:05 -0500144 ${busctl_field}= Set Variable If
145 ... '${field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
146 ... '${field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
147 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY}
148 ... /xyz/openbmc_project/inventory${component} ${busctl_field}
149 ${cmd_output}= BMC Execute Command ${cmd}
150
151 # Check vpdtool response and busctl response for the component field.
152 Valid Value vpd_records['${component}']['${field}']
153 ... ['${cmd_output[0].split('"')[1].strip('"')}']
154 ELSE
Sridevi Rameshc6e7f932025-05-07 11:26:54 -0500155 CONTINUE
dnirmala62a3b7d2023-03-16 01:17:05 -0500156 END
Rahul Maheshwarief003062020-03-23 07:17:16 -0500157 END
158
159
160Verify VPD Field Write Operation
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600161 [Documentation] Verify writing VPD fields for given component via vpdtool.
162 [Arguments] ${component} ${field}
163 [Teardown] Restore VPD Value ${component} ${field} ${old_field_value}
Sridevi Rameshf6304c62025-04-17 12:04:48 -0500164
Rahul Maheshwarief003062020-03-23 07:17:16 -0500165 # Description of arguments:
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600166 # component VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
167 # field VPD component field (e.g. PN, SN)
Rahul Maheshwarief003062020-03-23 07:17:16 -0500168
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600169 ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field}
Sridevi Rameshf6304c62025-04-17 12:04:48 -0500170 Set Test Variable ${old_field_value} ${vpd_records['${component}']['${field}']}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500171
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600172 ${write_value}= Set Variable If
173 ... '${field}' == 'DR' ${DR_WRITE_VALUE}
174 ... '${field}' == 'PN' ${PN_WRITE_VALUE}
175 ... '${field}' == 'SN' ${SN_WRITE_VALUE}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500176
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600177 Vpdtool -w -O ${component} -R VINI -K ${field} --value ${write_value}
178
179 Verify VPD Field Value ${component} ${field}
180
181
182Restore VPD Value
183 [Documentation] Restore VPD's field value of given component.
184 [Arguments] ${component} ${field} ${value}
185 # Description of arguments:
186 # component VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
187 # field VPD component field (e.g. PN, SN)
188 # value VPD value to be restore.
189
190 Vpdtool -w -O ${component} -R VINI -K ${field} --value ${value}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500191
192
193Verify VPD Field Value
194 [Documentation] Verify VPD field value via vpdtool.
195 [Arguments] ${component} ${field}
196 # Description of arguments:
197 # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
198 # field VPD field (e.g. DR, SN, PN)
199
Sridevi Rameshf6304c62025-04-17 12:04:48 -0500200 Redfish OBMC Reboot (off) stack_mode=normal
Rahul Maheshwarief003062020-03-23 07:17:16 -0500201 ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field}
202
203 ${busctl_field}= Set Variable If
204 ... '${field}' == 'DR' xyz.openbmc_project.Inventory.Item PrettyName
205 ... '${field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
206 ... '${field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
207
208 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component}
209 ... ${busctl_field}
210 ${cmd_output}= BMC Execute Command ${cmd}
211
212 Valid Value vpd_records['${component}']['${field}'] ['${cmd_output[0].split('"')[1].strip('"')}']
dnirmala348356a2023-03-06 04:52:56 -0600213
214
215Verify VPD Data Via Vpdtool
216 [Documentation] Get VPD details of given component via vpdtool and verify it
217 ... using busctl command.
218 [Arguments] ${component} ${field}
219 # Description of arguments:
220 # component VPD component (e.g. System,Chassis etc).
221 # field VPD field (e.g. Serialnumber,LocationCode etc).
222
223 ${component_url}= Run Keyword If
224 ... '${component}' == 'System' Set Variable /system
225
226 # Get VPD details of given component via vpd-tool.
227 ${vpd_records}= Vpdtool -o -O ${component_url}
228
229 # Get VPD details of given component via busctl command.
230 ${busctl_field}= Set Variable If
231 ... '${field}' == 'LocationCode' com.ibm.ipzvpd.Location LocationCode
232 ... '${field}' == 'Model' xyz.openbmc_project.Inventory.Decorator.Asset Model
233 ... '${field}' == 'SerialNumber' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
234
235 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory/system
236 ... ${busctl_field}
237 ${cmd_output}= BMC Execute Command ${cmd}
238 # Example of cmd_output:
239 # [0]: s "ABCD.XY1.1234567-P0"
240 # [1]:
241 # [2]: 0
242
243 # Cross check vpdtool output with busctl response.
244 Should Be Equal As Strings ${vpd_records["/system"]["${field}"]}
245 ... ${cmd_output[0].split('"')[1].strip('"')}