blob: 90618024dc8b7f5b740d5dc9a94b192c8eebd697 [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
7
8Test Teardown FFDC On Test Case Fail
9
George Keishing7c32f302023-10-10 16:11:46 +053010Force Tags VPD_Tool
Rahul Maheshwarief003062020-03-23 07:17:16 -050011
12*** Variables ***
13
14${CMD_GET_PROPERTY_INVENTORY} busctl get-property xyz.openbmc_project.Inventory.Manager
15${DR_WRITE_VALUE} XYZ Component
16${PN_WRITE_VALUE} XYZ1234
17${SN_WRITE_VALUE} ABCD12345678
dnirmala62a3b7d2023-03-16 01:17:05 -050018@{fields} PN SN LocationCode
19@{vpd_fields} PN SN
Rahul Maheshwarief003062020-03-23 07:17:16 -050020
21*** Test Cases ***
22
dnirmala348356a2023-03-06 04:52:56 -060023Verify System VPD Data Via Vpdtool
24 [Documentation] Verify the system VPD details via vpdtool output.
25 [Tags] Verify_System_VPD_Data_Via_Vpdtool
26 [Template] Verify VPD Data Via Vpdtool
Rahul Maheshwarief003062020-03-23 07:17:16 -050027
dnirmala348356a2023-03-06 04:52:56 -060028 # Component Field
29 System Model
30 System SerialNumber
31 System LocationCode
Rahul Maheshwarief003062020-03-23 07:17:16 -050032
33
34Verify VPD Component Read
dnirmala62a3b7d2023-03-16 01:17:05 -050035 [Documentation] Verify details of all VPD component via vpdtool.
Rahul Maheshwarief003062020-03-23 07:17:16 -050036 [Tags] Verify_VPD_Component_Read
37
dnirmala62a3b7d2023-03-16 01:17:05 -050038 ${vpd_records}= Vpdtool -i
39 ${components}= Get Dictionary Keys ${vpd_records}
Rahul Maheshwarief003062020-03-23 07:17:16 -050040 FOR ${component} IN @{components}
41 Verify VPD Component Read Operation ${component}
42 END
43
44
45Verify VPD Field Read
46 [Documentation] Verify reading VPD field value via vpdtool.
47 [Tags] Verify_VPD_Field_Read
48
dnirmala62a3b7d2023-03-16 01:17:05 -050049 ${vpd_records}= Vpdtool -i
50 ${components}= Get Dictionary Keys ${vpd_records}
Rahul Maheshwarief003062020-03-23 07:17:16 -050051 FOR ${component} IN @{components}
George Keishinge01ee582023-05-16 10:17:08 +053052 # Drive component field values response in ascii format
53 # due to that skipping here.
dnirmala62a3b7d2023-03-16 01:17:05 -050054 IF 'drive' in '${component}'
55 Continue FOR Loop
56 ELSE
57 Verify VPD Field Read Operation ${component}
58 END
Rahul Maheshwarief003062020-03-23 07:17:16 -050059 END
60
61
62Verify VPD Field Write
George Keishinge20f82c2020-05-13 10:51:02 -050063 [Documentation] Verify writing VPD field value via vpdtool.
Rahul Maheshwarief003062020-03-23 07:17:16 -050064 [Tags] Verify_VPD_Field_Write
65
66 ${components}= Get Dictionary Keys ${VPD_DETAILS}
67 FOR ${component} IN @{components}
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -060068 # VPD fields "DR", "CC" and "FN" will be added later.
69 @{vpd_fields}= Create List SN PN
70 ${field}= Evaluate random.choice($vpd_fields) random
71 Verify VPD Field Write Operation ${component} ${field}
Rahul Maheshwarief003062020-03-23 07:17:16 -050072 END
73
74
75*** Keywords ***
76
Rahul Maheshwarief003062020-03-23 07:17:16 -050077Verify VPD Component Read Operation
George Keishing16b3c7b2021-01-28 09:23:37 -060078 [Documentation] Verify reading VPD details of given component via vpdtool.
Rahul Maheshwarief003062020-03-23 07:17:16 -050079 [Arguments] ${component}
80 # Description of arguments:
81 # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
82
83 ${vpd_records}= Vpdtool -o -O ${component}
84
85 # Example output from 'Vpdtool -o -O /system/chassis/motherboard/vdd_vrm1':
86 # [/system/chassis/motherboard/vdd_vrm1]:
87 # [DR]: CPU POWER CARD
88 # [type]: xyz.openbmc_project.Inventory.Item.Vrm
89 # [CC]: E123
90 # [FN]: F123456
91 # [LocationCode]: ABCD.XY1.1234567-P0
92 # [SN]: YL2E32010000
93 # [PN]: PN12345
94
dnirmala62a3b7d2023-03-16 01:17:05 -050095 ${vpdtool_res}= Set To Dictionary ${vpd_records}[${component}]
96 FOR ${vpd_field} IN @{fields}
George Keishinge01ee582023-05-16 10:17:08 +053097 ${match_key_exists}= Run Keyword And Return Status
dnirmala62a3b7d2023-03-16 01:17:05 -050098 ... Dictionary Should Contain Key ${vpdtool_res} ${vpd_field}
99 IF '${match_key_exists}' == 'True'
100 # drive components busctl field response in ascii due to that checking only locationcode.
101 IF 'drive' in '${component}'
102 ${vpd_field}= Set Variable LocationCode
103 END
George Keishinge01ee582023-05-16 10:17:08 +0530104 # Skip check if VPD field is empty.
dnirmala62a3b7d2023-03-16 01:17:05 -0500105 Run Keyword If '${vpd_records['${component}']['${vpd_field}']}' == ''
106 ... Continue For Loop
George Keishinge01ee582023-05-16 10:17:08 +0530107
dnirmala62a3b7d2023-03-16 01:17:05 -0500108 # Get VPD field values via busctl.
109 ${busctl_field}= Set Variable If
110 ... '${vpd_field}' == 'LocationCode' com.ibm.ipzvpd.Location LocationCode
111 ... '${vpd_field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
112 ... '${vpd_field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
113 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY}
114 ... /xyz/openbmc_project/inventory${component} ${busctl_field}
115 ${cmd_output}= BMC Execute Command ${cmd}
116 # Check whether the vpdtool response and busctl response matching.
George Keishinge01ee582023-05-16 10:17:08 +0530117 Valid Value vpd_records['${component}']['${vpd_field}']
dnirmala62a3b7d2023-03-16 01:17:05 -0500118 ... ['${cmd_output[0].split('"')[1].strip('"')}']
119 ELSE
120 Continue For Loop
121 END
122 END
Rahul Maheshwarief003062020-03-23 07:17:16 -0500123
124
125Verify VPD Field Read Operation
George Keishing16b3c7b2021-01-28 09:23:37 -0600126 [Documentation] Verify reading all VPD fields for given component via vpdtool.
Rahul Maheshwarief003062020-03-23 07:17:16 -0500127 [Arguments] ${component}
128 # Description of arguments:
129 # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
130
dnirmala62a3b7d2023-03-16 01:17:05 -0500131 ${vpd_records}= Vpdtool -o -O ${component}
132 ${vpdtool_res}= Set To Dictionary ${vpd_records}[${component}]
133 FOR ${field} IN @{vpd_fields}
134 ${match_key_exists}= Run Keyword And Return Status
135 ... Dictionary Should Contain Key ${vpdtool_res} ${field}
136 IF '${match_key_exists}' == 'True'
137 ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field}
138 # Skip check if field value is empty.
139 Run Keyword If '${vpd_records['${component}']['${field}']}' == ''
140 ... Continue For Loop
Rahul Maheshwarief003062020-03-23 07:17:16 -0500141
dnirmala62a3b7d2023-03-16 01:17:05 -0500142 ${busctl_field}= Set Variable If
143 ... '${field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
144 ... '${field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
145 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY}
146 ... /xyz/openbmc_project/inventory${component} ${busctl_field}
147 ${cmd_output}= BMC Execute Command ${cmd}
148
149 # Check vpdtool response and busctl response for the component field.
150 Valid Value vpd_records['${component}']['${field}']
151 ... ['${cmd_output[0].split('"')[1].strip('"')}']
152 ELSE
153 Continue For Loop
154 END
Rahul Maheshwarief003062020-03-23 07:17:16 -0500155 END
156
157
158Verify VPD Field Write Operation
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600159 [Documentation] Verify writing VPD fields for given component via vpdtool.
160 [Arguments] ${component} ${field}
161 [Teardown] Restore VPD Value ${component} ${field} ${old_field_value}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500162 # Description of arguments:
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600163 # component VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
164 # field VPD component field (e.g. PN, SN)
Rahul Maheshwarief003062020-03-23 07:17:16 -0500165
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600166 ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field}
167 ${old_field_value}= Set Variable ${vpd_records['${component}']['${field}']}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500168
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600169 ${write_value}= Set Variable If
170 ... '${field}' == 'DR' ${DR_WRITE_VALUE}
171 ... '${field}' == 'PN' ${PN_WRITE_VALUE}
172 ... '${field}' == 'SN' ${SN_WRITE_VALUE}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500173
Rahul Maheshwari0ef1e152020-11-02 23:10:55 -0600174 Vpdtool -w -O ${component} -R VINI -K ${field} --value ${write_value}
175
176 Verify VPD Field Value ${component} ${field}
177
178
179Restore VPD Value
180 [Documentation] Restore VPD's field value of given component.
181 [Arguments] ${component} ${field} ${value}
182 # Description of arguments:
183 # component VPD component (e.g. /system/chassis/motherboard/vdd_vrm1).
184 # field VPD component field (e.g. PN, SN)
185 # value VPD value to be restore.
186
187 Vpdtool -w -O ${component} -R VINI -K ${field} --value ${value}
Rahul Maheshwarief003062020-03-23 07:17:16 -0500188
189
190Verify VPD Field Value
191 [Documentation] Verify VPD field value via vpdtool.
192 [Arguments] ${component} ${field}
193 # Description of arguments:
194 # component VDP component (e.g. /system/chassis/motherboard/vdd_vrm1).
195 # field VPD field (e.g. DR, SN, PN)
196
197 ${vpd_records}= Vpdtool -r -O ${component} -R VINI -K ${field}
198
199 ${busctl_field}= Set Variable If
200 ... '${field}' == 'DR' xyz.openbmc_project.Inventory.Item PrettyName
201 ... '${field}' == 'PN' xyz.openbmc_project.Inventory.Decorator.Asset PartNumber
202 ... '${field}' == 'SN' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
203
204 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory${component}
205 ... ${busctl_field}
206 ${cmd_output}= BMC Execute Command ${cmd}
207
208 Valid Value vpd_records['${component}']['${field}'] ['${cmd_output[0].split('"')[1].strip('"')}']
dnirmala348356a2023-03-06 04:52:56 -0600209
210
211Verify VPD Data Via Vpdtool
212 [Documentation] Get VPD details of given component via vpdtool and verify it
213 ... using busctl command.
214 [Arguments] ${component} ${field}
215 # Description of arguments:
216 # component VPD component (e.g. System,Chassis etc).
217 # field VPD field (e.g. Serialnumber,LocationCode etc).
218
219 ${component_url}= Run Keyword If
220 ... '${component}' == 'System' Set Variable /system
221
222 # Get VPD details of given component via vpd-tool.
223 ${vpd_records}= Vpdtool -o -O ${component_url}
224
225 # Get VPD details of given component via busctl command.
226 ${busctl_field}= Set Variable If
227 ... '${field}' == 'LocationCode' com.ibm.ipzvpd.Location LocationCode
228 ... '${field}' == 'Model' xyz.openbmc_project.Inventory.Decorator.Asset Model
229 ... '${field}' == 'SerialNumber' xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
230
231 ${cmd}= Catenate ${CMD_GET_PROPERTY_INVENTORY} /xyz/openbmc_project/inventory/system
232 ... ${busctl_field}
233 ${cmd_output}= BMC Execute Command ${cmd}
234 # Example of cmd_output:
235 # [0]: s "ABCD.XY1.1234567-P0"
236 # [1]:
237 # [2]: 0
238
239 # Cross check vpdtool output with busctl response.
240 Should Be Equal As Strings ${vpd_records["/system"]["${field}"]}
241 ... ${cmd_output[0].split('"')[1].strip('"')}