blob: 189660d8ad029b3bbadc1848f249d842b1a490c4 [file] [log] [blame]
Rahul Maheshwari712baaf2019-07-29 23:52:36 -05001*** Settings ***
2
3Documentation Module to test IPMI SEL functionality.
4Resource ../lib/ipmi_client.robot
5Resource ../lib/openbmc_ffdc.robot
chithragd7e009b2022-03-01 12:20:57 +00006Library ../lib/ipmi_utils.py
Tony Lee160aa872020-02-12 16:11:39 +08007Variables ../data/ipmi_raw_cmd_table.py
Rahul Maheshwari712baaf2019-07-29 23:52:36 -05008
chithragd7e009b2022-03-01 12:20:57 +00009Test Setup Test Setup Execution
Rahul Maheshwari712baaf2019-07-29 23:52:36 -050010Test Teardown FFDC On Test Case Fail
11
ganesanb11fe27f2022-08-24 10:00:17 +000012*** Variables ***
13
14# Based on 13th byte of add SEL entry command as per IPMI spec
15# event_dir and event_type variable value needs to be given.
16${sel_no_entry_msg} SEL has no entries
17${event_type} Lower Non-critical going low
18${event_dir} Asserted
19
Rahul Maheshwari712baaf2019-07-29 23:52:36 -050020*** Test Cases ***
21
22Verify IPMI SEL Version
23 [Documentation] Verify IPMI SEL's version info.
24 [Tags] Verify_IPMI_SEL_Version
25 ${version_info}= Get IPMI SEL Setting Version
26 ${setting_status}= Fetch From Left ${version_info} (
27 ${setting_status}= Evaluate $setting_status.replace(' ','')
28
29 Should Be True ${setting_status} >= 1.5
30 Should Contain ${version_info} v2 compliant case_insensitive=True
31
32
33Verify Empty SEL
George Keishingd3498672022-04-08 09:00:42 -050034 [Documentation] Verify IPMI sel clear command clears the SEL entry.
Rahul Maheshwari712baaf2019-07-29 23:52:36 -050035 [Tags] Verify_Empty_SEL
George Keishingdc656672020-02-25 07:45:16 -060036
Nandish-Matti5df06fa2023-03-21 07:26:44 -050037 Redfish Power Off stack_mode=skip
38
George Keishing3c230882022-04-29 03:20:24 -050039 # Generate an error log and verify there is one at least.
George Keishingd3498672022-04-08 09:00:42 -050040 Create Test PEL Log
41 ${resp}= Run IPMI Standard Command sel elist last 1
42 Log To Console ${resp}
43
44 Should Contain Any ${resp} system hardware failure Asserted
45 ... msg=Add SEL Entry failed.
46
47 # Send SEL clear command and verify if it really clears up the SEL entry.
Rahul Maheshwari712baaf2019-07-29 23:52:36 -050048 Run IPMI Standard Command sel clear
George Keishingdc656672020-02-25 07:45:16 -060049 Sleep 5s
Rahul Maheshwari712baaf2019-07-29 23:52:36 -050050
51 ${resp}= Run IPMI Standard Command sel list
52 Should Contain ${resp} SEL has no entries case_insensitive=True
53
Tony Lee160aa872020-02-12 16:11:39 +080054
55Verify Add SEL Entry
56 [Documentation] Verify add SEL entry.
57 [Tags] Verify_Add_SEL_Entry
58 [Teardown] Run Keywords FFDC On Test Case Fail AND Run IPMI Standard Command sel clear
59
George Keishingbd8d6ba2021-11-17 01:53:51 -060060 # The IPMI raw command to generate Temp sensor error is no longer working.
61 # Our aim is to check if the SEL command is listed in IPMI or not.
chithragd7e009b2022-03-01 12:20:57 +000062 # Original keyword "Create User Defined SEL" for reference
George Keishingbd8d6ba2021-11-17 01:53:51 -060063 Create Test PEL Log
64
Tony Lee160aa872020-02-12 16:11:39 +080065 # Get last SEL entry.
66 ${resp}= Run IPMI Standard Command sel elist last 1
George Keishingbd8d6ba2021-11-17 01:53:51 -060067 # output:
68 # 1 | 11/17/2021 | 07:49:20 | System Event #0x01 | Undetermined system hardware failure | Asserted
69 Run Keywords Should Contain ${resp} system hardware failure AND
70 ... Should Contain ${resp} Asserted msg=Add SEL Entry failed.
Tony Lee160aa872020-02-12 16:11:39 +080071
72
chithragd7e009b2022-03-01 12:20:57 +000073Verify Add SEL Entry For Any Random Sensor
74 [Documentation] Create SEL entry and verify for any given random sensor.
75 [Tags] Verify_Add_SEL_Entry_For_Any_Random_Sensor
76 [Teardown] Run Keywords FFDC On Test Case Fail AND Run IPMI Standard Command sel clear
77
78 # Get any sensor available from sensor list.
ganesanbd282b562022-05-11 20:30:52 +053079 ${sensor_name}= Fetch One Threshold Sensor From Sensor List
chithragd7e009b2022-03-01 12:20:57 +000080
81 # Get Sensor ID from SDR get "sensor".
82 ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID
ganesanb11fe27f2022-08-24 10:00:17 +000083 ${sensor_number}= Get Bytes From SDR Sensor ${sensor_data1}
chithragd7e009b2022-03-01 12:20:57 +000084
85 # Get Sensor Type from SDR get "sensor".
86 ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold)
ganesanb11fe27f2022-08-24 10:00:17 +000087 ${sensor_type_id}= Get Bytes From SDR Sensor ${sensor_data2}
chithragd7e009b2022-03-01 12:20:57 +000088
89 # Add SEL Entry.
90 # ${sel_entry_id} is the Record ID for added record (LSB First).
91 ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number}
92 ${sel_entry_id}= Split String ${sel_create_resp}
93
94 # Get last SEL entry.
ganesanb11fe27f2022-08-24 10:00:17 +000095 ${resp}= Run IPMI Standard Command sel elist
96 Should Not Contain ${resp} ${sel_no_entry_msg}
chithragd7e009b2022-03-01 12:20:57 +000097
ganesanb11fe27f2022-08-24 10:00:17 +000098 # Output of the Sel elist.
chithragd7e009b2022-03-01 12:20:57 +000099 # Below example is a continuous line statement.
100 # N | MM/DD/YYYY | HH:MM:SS | Sensor_Type Sensor_Name |
101 # Lower Non-critical going low | Asserted | Reading 0.
102
ganesanb11fe27f2022-08-24 10:00:17 +0000103 ${get_sel_entry}= Get Lines Containing String ${resp} ${sensor_name}
104 ${sel_entry}= Get Lines Containing String ${get_sel_entry} ${event_type}
105 Should Contain ${sel_entry} ${event_dir} msg=Add SEL Entry failed.
chithragd7e009b2022-03-01 12:20:57 +0000106
107 # Get SEL Entry IPMI Raw Command.
108 ${entry}= Get SEL Entry Via IPMI ${sel_entry_id[0]} ${sel_entry_id[1]}
109
110 # Compare SEL Record ID.
111 ${sel_record_id}= Set Variable ${entry[2:4]}
112 Should Be Equal ${sel_record_id} ${sel_entry_id}
113
114 # Sensor type compare.
115 Should Be Equal ${sensor_type_id} ${entry[12]}
116
117 # Sensor number compare.
118 Should Be Equal ${sensor_number} ${entry[13]}
119
120
Tony Lee160aa872020-02-12 16:11:39 +0800121Verify Reserve SEL
122 [Documentation] Verify reserve SEL.
123 [Tags] Verify_Reserve_SEL
124
125 ${resp}= Run IPMI Standard Command
126 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]}
127 ${reserve_id}= Split String ${resp}
128
129 # Execute clear SEL raw command with Reservation ID.
130 # Command will not execute unless the correct Reservation ID value is provided.
131 Run IPMI Standard Command
132 ... raw 0x0a 0x47 0x${reserve_id[0]} 0x${reserve_id[1]} 0x43 0x4c 0x52 0xaa
133
chithragd7e009b2022-03-01 12:20:57 +0000134 # Check SEL list.
135 ${resp}= Run IPMI Standard Command sel list
136 Should Contain ${resp} SEL has no entries case_insensitive=True
137
138
139Verify IPMI SEL Most Recent Addition Timestamp
140 [Documentation] Verify most recent addition timestamp in SEL info.
141 [Tags] Verify_IPMI_SEL_Most_Recent_Addition_Timestamp
142
143 # Get Most Recent Addition Timestamp from SEL Info.
144 ${addition_timestamp}= Get Most Recent Addition Timestamp From SEL Info
145
146 IF '${addition_timestamp}' != 'ffffffff'
147 # Convert to epoch timestamp.
148 ${epoch_addition}= Convert To Integer ${addition_timestamp} 16
149
150 # Get SEL List last 1 entry date and time and convert to epoch timestamp.
151 ${sel_epoch_time}= Get SEL Elist Last Entry Date In Epoch
152
153 # Compare epoch of sel entry timestamp and last addition timestamp.
154 ${diff}= Evaluate int(${sel_epoch_time}) - int(${epoch_addition})
155 Should Be True ${diff}<=600
156
157 ELSE
158 # Get any Sensor available from Sensor list
ganesanbd282b562022-05-11 20:30:52 +0530159 ${sensor_name}= Fetch One Threshold Sensor From Sensor List
chithragd7e009b2022-03-01 12:20:57 +0000160
161 # Get Sensor ID from SDR Get "sensor" and Identify Sensor ID.
162 ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID
ganesanb11fe27f2022-08-24 10:00:17 +0000163 ${sensor_number}= Get Bytes From SDR Sensor ${sensor_data1}
chithragd7e009b2022-03-01 12:20:57 +0000164
165 # Get Sensor Type from SDR Get "sensor" and Identify Sensor Type.
166 ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold)
ganesanb11fe27f2022-08-24 10:00:17 +0000167 ${sensor_type_id}= Get Bytes From SDR Sensor ${sensor_data2}
chithragd7e009b2022-03-01 12:20:57 +0000168
169 # Add SEL Entry.
170 ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number}
171
172 # Get SEL List last 1 entry date and time and convert to epoch timestamp.
173 ${sel_epoch_time}= Get SEL Elist Last Entry Date In Epoch
174
175 # Get Most Recent Addition Timestamp from SEL Info.
176 ${addition}= Get Most Recent Addition Timestamp From SEL Info
177 ${epoch_addition}= Convert To Integer ${addition} 16
178
179 # Compare epoch of sel entry timestamp and last addition timestamp.
180 ${diff}= Evaluate int(${epoch_addition}) - int(${sel_epoch_time})
181 Should Be True ${diff}<=5
182 END
183
184
185Verify IPMI SEL Most Recent Erase Timestamp
186 [Documentation] Verify Most Recent Erase Timestamp In SEL Info with current
187 ... BMC epoch timestamp.
188 [Tags] Verify_IPMI_SEL_Most_Recent_Erase_Timestamp
189
190 # Get BMC Current Time.
191 ${bmc_epoch_time}= Get BMC Time In Epoch
192
193 # Get Most Recent Addition Timestamp from SEL Info.
194 ${addition_timestamp}= Get Most Recent Addition Timestamp From SEL Info
195 Should Be Equal ${addition_timestamp} ffffffff
196
197 # Get Most Recent Erase Timestamp from SEL Info.
198 ${erase_timestamp}= Get Most Recent Erase Timestamp From SEL Info
199 ${epoch_erase}= Convert To Integer ${erase_timestamp} 16
200
201 # Compare epoch of erase timestamp and current bmc timestamp.
202 ${diff}= Evaluate int(${epoch_erase}) - int(${bmc_epoch_time})
203 Should Be True ${diff}<=5
204
205
206Verify Clear SEL With Invalid Reservation ID
207 [Documentation] Verify clear SEL After generating another reserve ID.
208 [Tags] Verify_Clear_SEL_With_Invalid_Reservation_ID
209
210 # Reserve Sel command - 1.
211 ${resp}= Run IPMI Standard Command
212 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]}
213 ${reserve_id}= Split String ${resp}
214
215 # Reserve Sel command - 2.
216 ${resp}= Run IPMI Standard Command
217 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]}
218
219 ${cmd}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]}
220 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][1]}
221
222 # Clear SEL command.
223 ${clear_resp}= Run Keyword and Expect Error *${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][4]}*
224 ... Run IPMI Standard Command raw ${cmd}
225 Should Contain ${clear_resp} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][5]}
226
227
228Verify Reservation ID Erasure Status
229 [Documentation] Verify Erasure status by clearing SEL with Reserve ID and verify the response byte,
230 ... whether erasure status is updated in clear sel command response data using new Reserve ID.
231 [Tags] Verify_Reservation_ID_Erasure_Status
232
233 # Generate Reserve ID 1.
234 ${resp}= Run IPMI Standard Command
235 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]}
236 ${reserve_id}= Split String ${resp}
237
238 ${cmd1}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]}
239 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][1]}
240
241 # Execute clear SEL raw command with Reservation ID.
242 # Command will not execute unless the correct Reservation ID value is provided.
243 Run IPMI Standard Command raw ${cmd1}
244
245 # Generate Reserver ID 2.
246 ${resp}= Run IPMI Standard Command
247 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]}
248 ${reserve_id}= Split String ${resp}
249
250 ${cmd2}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]}
251 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][6]}
252
253 # Check the Erasure status of Clear SEL.
254 ${data}= Run IPMI Standard Command raw ${cmd2}
255
256 # 00 - Erasure in Progress , 01 - Erasure Complete.
257 Should Contain Any ${data} 00 01
258
259
260Verify Clear SEL After Cold Reset
261 [Documentation] Verify Clear SEL for a reserve SEL ID after Cold Reset.
262 [Tags] Verify_Clear_SEL_After_Cold_Reset
263
264 # Reserve Sel command.
265 ${resp}= Run IPMI Standard Command
266 ... raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]}
267 ${reserve_id}= Split String ${resp}
268
269 # Run Cold Reset.
ganesanbd282b562022-05-11 20:30:52 +0530270 IPMI MC Reset Cold (off)
chithragd7e009b2022-03-01 12:20:57 +0000271
272 ${cmd}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][0]} 0x${reserve_id[0]}
273 ... 0x${reserve_id[1]} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][1]}
274
275 # Clear SEL command.
276 ${clear_resp}= Run Keyword and Expect Error *${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][5]}*
277 ... Run IPMI Standard Command raw ${cmd}
278
279 Should Contain ${clear_resp} ${IPMI_RAW_CMD['SEL_entry']['Clear_SEL'][4]}
280
Tony Lee160aa872020-02-12 16:11:39 +0800281
282*** Keywords ***
283
chithragd7e009b2022-03-01 12:20:57 +0000284Create User Defined SEL
285 [Documentation] Create a user defined tempearature sensor SEL.
Tony Lee160aa872020-02-12 16:11:39 +0800286
287 # Create a SEL.
288 # Example:
289 # a | 02/14/2020 | 01:16:58 | Temperature #0x17 | | Asserted
Tony Lee21e5d902020-04-28 09:28:00 +0800290 Run IPMI Command
291 ... 0x0a 0x44 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x01 ${sensor_number} 0x00 0xa0 0x04 0x07
chithragd7e009b2022-03-01 12:20:57 +0000292
293
294Get SEL Entry Via IPMI
295 [Documentation] Get SEL Entry Via IPMI raw command.
296 [Arguments] ${record1} ${record2}
297
298 # Description of Argument(s):
299 # ${record1} Record ID for added record, LS Byte
300 # ${record2} Record ID for added record, MS Byte
301
302 # For example, when a first sel entry is added with IPMI raw command, the response will be "01 00".
303 # Here, ${record1} is 01, and ${record2} is 00.
304
305 ${cmd}= Catenate ${IPMI_RAW_CMD['SEL_entry']['Get_SEL_Entry'][0]} 0x${record1}
306 ... 0x${record2} ${IPMI_RAW_CMD['SEL_entry']['Get_SEL_Entry'][1]}
307
308 # Get SEL Entry Raw command.
309 ${resp}= Run IPMI Standard Command raw ${cmd}
310 ${resp}= Split String ${resp}
311
312 [Return] ${resp}
313
314
315Get Most Recent Addition Timestamp From SEL Info
316 [Documentation] Get Most recent addition timestamp From SEL Info.
317
318 # Get SEL Info raw command.
319 ${sel_info}= Get SEL Info Via IPMI
320
321 # Get Most Recent Addition timestamp in hex.
322 ${addition_timestamp}= Set Variable ${sel_info[5:9]}
323 Reverse List ${addition_timestamp}
324 ${addition_timestamp}= Evaluate "".join(${addition_timestamp})
325
326 [Return] ${addition_timestamp}
327
328
329Get Most Recent Erase Timestamp From SEL Info
330 [Documentation] Get Most recent erase timestamp From SEL Info.
331
332 # Get SEL Info Raw command.
333 ${sel_info}= Get SEL Info Via IPMI
334
335 # Get Most Recent Erase timestamp in hex.
336 ${erase_timestamp}= Set Variable ${sel_info[9:13]}
337 Reverse List ${erase_timestamp}
338 ${erase_timestamp}= Evaluate "".join(${erase_timestamp})
339
340 [Return] ${erase_timestamp}
341
342
343Get SEL Elist Last Entry Date In Epoch
344 [Documentation] Get the time from SEL elist last entry and returns epoch time.
345
346 # Get SEL list last entry.
347 ${resp}= Run IPMI Standard Command sel elist last 1
348
349 # Get date from the sel entry and convert to epoch timestamp.
350 ${sel_entry_date}= Fetch Added SEL Date ${resp}
351 ${epoch_date}= Convert Date ${sel_entry_date} epoch exclude_millis=yes date_format=%m/%d/%Y %H:%M:%S
352
353 [Return] ${epoch_date}
354
355
356Get BMC Time In Epoch
357 [Documentation] Get the current time from BMC and returns epoch time.
358
359 # Get the bmc native bmc date command response.
360 ${date}= Get Current Date from BMC
361
362 ${epoch_date}= Convert Date ${date} epoch exclude_millis=yes date_format=%m/%d/%Y %H:%M:%S
363
364 [Return] ${epoch_date}
365
366
367Test Setup Execution
368 [Documentation] Do test setup tasks.
369
370 Run IPMI Standard Command sel clear
371 Sleep 5s