blob: 7fed9f7354a44b1cab22697febf7a8d073bc1410 [file] [log] [blame]
leetf3c71d32021-12-21 07:09:42 -05001*** Settings ***
2
3Documentation Module to test IPMI watchdog functionality.
4Resource ../lib/ipmi_client.robot
5Resource ../lib/openbmc_ffdc.robot
6Resource ../lib/boot_utils.robot
7Library ../lib/ipmi_utils.py
8Library String
9Library Collections
10Variables ../data/ipmi_raw_cmd_table.py
11
12*** Variables ***
13
14${timer_delay} 3
15${power_state_change} 20
16
17*** Test Cases ***
18
19Test IPMI Watchdog Timer Don't Log Bit
20 [Documentation] Execute out of band set/get don't log bit for watchdog timer.
21 [Tags] Test_IPMI_Watchdog_Timer_Don't_Log_Bit
22 [Template] Execute IPMI Raw Command And Verify Response Data
23
24 # Test action set_raw_cmd get_raw_cmd resp_expect
25 Enable ${IPMI_RAW_CMD['Watchdog']['Set'][0]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
26 ... ${IPMI_RAW_CMD['Watchdog']['Get'][1]}
27 Disable ${IPMI_RAW_CMD['Watchdog']['Set'][3]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
28 ... ${IPMI_RAW_CMD['Watchdog']['Get'][3]}
29
30Test IPMI Watchdog Timer Stop Bit
31 [Documentation] Execute out of band set/get stop/resume timer stop bit for watchdog timer.
32 [Tags] Test_IPMI_Watchdog_Timer_Stop_Bit
33 [Template] Execute IPMI Raw Command And Verify Response Data
34
35 # Stop_Bit set_raw_cmd get_raw_cmd resp_expect
36 Stop ${IPMI_RAW_CMD['Watchdog']['Set'][6]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
37 ... ${IPMI_RAW_CMD['Watchdog']['Get'][5]}
38 Resume ${IPMI_RAW_CMD['Watchdog']['Set'][9]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
39 ... ${IPMI_RAW_CMD['Watchdog']['Get'][7]}
40
41Test IPMI Watchdog Timer Use Bits
42 [Documentation] Execute out of band set/get timer use bits for watchdog timer.
43 [Tags] Test_IPMI_Watchdog_Timer_Use_Bits
44 [Template] Execute IPMI Raw Command And Verify Response Data
45
46 # Timer Use set_raw_cmd get_raw_cmd resp_expect
47 FRB2 ${IPMI_RAW_CMD['Watchdog']['Set'][12]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
48 ... ${IPMI_RAW_CMD['Watchdog']['Get'][9]}
49 POST ${IPMI_RAW_CMD['Watchdog']['Set'][15]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
50 ... ${IPMI_RAW_CMD['Watchdog']['Get'][11]}
51 OS ${IPMI_RAW_CMD['Watchdog']['Set'][18]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
52 ... ${IPMI_RAW_CMD['Watchdog']['Get'][13]}
53 SMS ${IPMI_RAW_CMD['Watchdog']['Set'][21]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
54 ... ${IPMI_RAW_CMD['Watchdog']['Get'][15]}
55 OEM ${IPMI_RAW_CMD['Watchdog']['Set'][24]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
56 ... ${IPMI_RAW_CMD['Watchdog']['Get'][17]}
57
58Test IPMI Watchdog Timer Pre-Timeout Interrupt Bits
59 [Documentation] Execute out of band set/get pre-timeout interrupt bits for watchdog timer.
60 [Tags] Test_IPMI_Watchdog_Timer_Pre-Timeout_Interrupt_Bits
61 [Template] Execute IPMI Raw Command And Verify Response Data
62
63 # Interrupt set_raw_cmd get_raw_cmd resp_expect
64 None ${IPMI_RAW_CMD['Watchdog']['Set'][27]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
65 ... ${IPMI_RAW_CMD['Watchdog']['Get'][19]}
66 NMI ${IPMI_RAW_CMD['Watchdog']['Set'][30]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
67 ... ${IPMI_RAW_CMD['Watchdog']['Get'][21]}
68
69Test IPMI Watchdog Timer Timeout Action Bits
70 [Documentation] Execute out of band set/get timer timeout bits for watchdog timer.
71 [Tags] Test_IPMI_Watchdog_Timer_Timeout_Action_Bits
72 [Template] Execute IPMI Raw Command And Verify Response Data
73
74 # Timer Action set_raw_cmd get_raw_cmd resp_expect
75 None ${IPMI_RAW_CMD['Watchdog']['Set'][33]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
76 ... ${IPMI_RAW_CMD['Watchdog']['Get'][23]}
77 Reset ${IPMI_RAW_CMD['Watchdog']['Set'][36]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
78 ... ${IPMI_RAW_CMD['Watchdog']['Get'][25]}
79 Power Down ${IPMI_RAW_CMD['Watchdog']['Set'][39]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
80 ... ${IPMI_RAW_CMD['Watchdog']['Get'][27]}
81 Power Cycle ${IPMI_RAW_CMD['Watchdog']['Set'][42]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
82 ... ${IPMI_RAW_CMD['Watchdog']['Get'][29]}
83
84Test IPMI Watchdog Timer Timeout Flag Bits
85 [Documentation] Execute out of band set/get timer timeout flag bits for watchdog timer.
86 [Tags] Test_IPMI_Watchdog_Timer_Timeout_Flag_Bits
87 [Template] Execute IPMI Raw Command And Verify Response Data
88
89 # Timeout Flag set_raw_cmd get_raw_cmd resp_expect
90 FRB2 ${IPMI_RAW_CMD['Watchdog']['Set'][45]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
91 ... ${IPMI_RAW_CMD['Watchdog']['Get'][31]}
92 POST ${IPMI_RAW_CMD['Watchdog']['Set'][48]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
93 ... ${IPMI_RAW_CMD['Watchdog']['Get'][33]}
94 OS ${IPMI_RAW_CMD['Watchdog']['Set'][51]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
95 ... ${IPMI_RAW_CMD['Watchdog']['Get'][35]}
96 SMS ${IPMI_RAW_CMD['Watchdog']['Set'][54]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
97 ... ${IPMI_RAW_CMD['Watchdog']['Get'][37]}
98 OEM ${IPMI_RAW_CMD['Watchdog']['Set'][57]} ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
99 ... ${IPMI_RAW_CMD['Watchdog']['Get'][39]}
100
101
102Verify Timer Action Actions
103 [Documentation] Set Watchdog via IPMI raw command and verify timer actions.
104 [Tags] Verify_Timer_Action_Power_Down
105 [Template] Validate Watchdog Timer Actions And SEL Events
106
107 # Timer action set action command power state SEL event
108 Power down ${IPMI_RAW_CMD['Watchdog']['Set'][60]} ['off'] Power done
109 Hard reset ${IPMI_RAW_CMD['Watchdog']['Set'][63]} ['on'] Hard Reset
110 Power Cycle ${IPMI_RAW_CMD['Watchdog']['Set'][66]} ['on'] Power cycle
111 No action ${IPMI_RAW_CMD['Watchdog']['Set'][69]} ['on'] Timer expired
112
113
114Verify Reset Timer
115 [Documentation] Set Watchdog via IPMI raw command and verify Reset Timer functions as expected.
116 [Tags] Verify_Reset_Timer
117
118 # Check the chassis status.
119 Power On Host And Verify
120
121 # Set Watchdog Timer initCount(0x3530).
122 Run IPMI Standard Command raw ${IPMI_RAW_CMD['Watchdog']['Set'][72]}
123
124 # Get Watchdog Timer.
125 ${resp}= Run IPMI Standard Command raw ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
126 Should Contain ${resp} ${IPMI_RAW_CMD['Watchdog']['Get'][41]}
127
128 @{start_timer_value}= Split String ${resp}
129 FOR ${value} IN @{start_timer_value}
130 Log Many ${value}
131 END
132
133 # Convert start value to integer.
134 # Example: Get watchdog response is 0x06 0x24 0x05 0x00 0x64 0x00 0x64 0x00.
135 # Start_timer_value is bits 6 - 7; set to 0x64 0x00 (100 ms decimal).
136 # Reverse bits 6 - 7 due to BMC being little endian; new value is 0x00 0x64.
137 # Convert hex value 0x00 0x64 to integer; start_timer_integer = 100.
138 ${value}= Get Slice From List ${start_timer_value} 6
139 Reverse List ${value}
140 ${start_timer_string}= Evaluate "".join(${value})
141 ${start_timer_integer} = Convert To Integer ${start_timer_string} 16
142
143 # Delay.
144 Sleep ${timer_delay}
145
146 # Get Watchdog Timer before reset watchdog timer.
147 ${resp}= Run IPMI Standard Command raw ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
148 Should Contain ${resp} ${IPMI_RAW_CMD['Watchdog']['Get'][41]}
149
150 FOR ${1} IN ${3}
151
152 # Reset Watchdog Timer.
153 Run IPMI Standard Command raw ${IPMI_RAW_CMD['Watchdog']['Reset'][0]}
154 # Delay.
155 Sleep ${timer_delay}
156 Get Watchdog Timer And Compare To Start Value ${start_timer_integer}
157
158 END
159
160
161Verify Pre-timeout Values
162 [Documentation] Set Watchdog Pre-timeout via IPMI raw command and verify via Get Watchdog Timer.
163 [Tags] Verify_Pre-timeout_Values
164 [Template] Validate Watchdog Pre-timeout
165
166 # interval command response
167 Less than initial ${IPMI_RAW_CMD['Watchdog']['Set'][75]} ${EMPTY}
168 Maximum ${IPMI_RAW_CMD['Watchdog']['Set'][81]} ${EMPTY}
169 Bit 6 not set ${IPMI_RAW_CMD['Watchdog']['Get'][0]} ${IPMI_RAW_CMD['Watchdog']['Get'][43]}
170
171Verify Failure For Pre-Timeout Interval > Initial Count
172 [Documentation] Set Watchdog Pre-timeout via IPMI raw command and verify via Get Watchdog Timer.
173 [Tags] Verify_Pre-timeout_Values
174
175 # Expected to fail: pre-timeout interval (4000) > initial count (1000).
176 Run Keyword and Expect Error *Invalid data field*
177 ... Run IPMI Standard Command raw ${IPMI_RAW_CMD['Watchdog']['Set'][78]}
178
179Verify Invalid Request Data Length
180 [Documentation] Set Watchdog via IPMI raw command and verify via Get Watchdog Timer.
181 [Tags] Verify_Invalid_Request_Data_Length
182 [Template] Watchdog Invalid Request Data Length
183
184 # Number of bytes command
185 One less byte ${IPMI_RAW_CMD['Watchdog']['Set'][84]}
186 One extra byte ${IPMI_RAW_CMD['Watchdog']['Set'][87]}
187 One extra byte ${IPMI_RAW_CMD['Watchdog']['Get'][45]}
188
189Verify Invalid Reset Timer Request Data
190 [Documentation] Set Watchdog via IPMI raw command and verify via Get Watchdog Timer.
191 [Tags] Verify_Invalid_Request_Data_Length
192
193 # Reset Watchdog Timer with one extra byte.
194 Run Keyword and Expect Error *Request data length*
195 ... Run IPMI Standard Command raw ${IPMI_RAW_CMD['Watchdog']['Reset'][3]}
196
197 # Reset BMC.
198 Run External IPMI Standard Command mc reset cold -N 10 -R 1
199 Check If BMC is Up
200
201 # Reset Watchdog Timer without initialized watchdog.
202 Run Keyword and Expect Error *Unknown*
203 ... Run IPMI Standard Command raw ${IPMI_RAW_CMD['Watchdog']['Reset'][6]}
204
205*** Keywords ***
206
207Execute IPMI Raw Command And Verify Response Data
208 [Documentation] Execute out of band IPMI raw command and verify response data.
209 [Arguments] ${bit_purpose} ${set_raw_cmd} ${get_raw_cmd} ${resp_expect}
210
211 # Description of argument(s):
212 # bit_purpose Purpose of the associated bit(s).
213 # set_raw_cmd The request bytes for the command.
214 # get_raw_cmd The response bytes for the command.
215 # resp_expect The expected response bytes for the command.
216
217 Run IPMI Standard Command raw ${set_raw_cmd}
218 ${resp}= Run IPMI Standard Command raw ${get_raw_cmd}
219 Should Contain ${resp} ${resp_expect} msg=Expecting ${resp_expect} but got ${resp}.
220
221Validate Watchdog Timer Actions And SEL Events
222 [Documentation] Verify the watchdog timer actions and the associated SEL events.
223 [Arguments] ${timer_action} ${set_raw_cmd} ${power_state} ${sel_event}
224
225 # Description of argument(s):
226 # timer_action Action when watchdog timer expires.
227 # set_raw_cmd The set timeout action request bytes for the command.
228 # power_state The expected power state of the host.
229 # sel_event The response bytes for the command.
230
231 # Check the chassis status.
232 Power On Host And Verify
233
234 # Clear SEL.
235 Run IPMI Standard Command sel clear
236
237 # Set watchdog timer action to perform action.
238 Run IPMI Standard Command raw ${set_raw_cmd}
239
240 # Reset Watchdog Timer.
241 Run IPMI Standard Command raw ${IPMI_RAW_CMD['Watchdog']['Reset'][0]}
242
243 # Delay for power state.
244 Sleep ${power_state_change}
245
246 Verify Host Power State ${power_state}
247 Verify Watchdog Timer Action SEL Event ${sel_event}
248
249
250Verify Host Power State
251 [Documentation] Get host power state using external IPMI command and verify.
252 [Arguments] ${power_state}
253
254 # Description of argument(s):
255 # ipmi_value Value of Host power state: "on" or "off".
256
257 ${ipmi_state}= Get Host State Via External IPMI
258 Valid Value ipmi_state ${power_state}
259
260Verify Watchdog Timer Action SEL Event
261 [Documentation] Verify_Watchdog_Timer_Action_SEL_Event.
262 [Arguments] ${sel_event}
263
264 # Description of argument(s):
265 # state_string Text of SEL event after timer action.
266
267 ${resp}= Run IPMI Standard Command sel elist
268 ${power_status}= Get Lines Containing String ${resp} Watchdog
269 Should Contain ${power_status} ${sel_event}
270
271Power On Host And Verify
272 [Documentation] Power the host on and verify.
273
274 IPMI Power On stack_mode=skip quiet=1
275 ${ipmi_state}= Get Host State Via External IPMI
276 Valid Value ipmi_state ['on']
277
278Watchdog Invalid Request Data Length
279 [Documentation] Get watchdog value, convert to integer, and compare to original start value.
280 [Arguments] ${byte_length} ${watchdog_command}
281
282 # Description of argument(s):
283 # byte_length The request byte length, which is used for explaining the command in the test case.
284 # watchdog_command The raw watchdog IPMI command request bytes.
285
286 Run Keyword and Expect Error *Request data length*
287 ... Run IPMI Standard Command raw ${watchdog_command}
288
289Validate Watchdog Pre-timeout
290 [Documentation] Get watchdog value, convert to integer, and compare to original start value.
291 [Arguments] ${byte_length} ${watchdog_command} ${response}
292
293 ${resp}= Run IPMI Standard Command raw ${watchdog_command}
294 Should Contain ${resp} ${response}
295
296Get Watchdog Timer And Compare To Start Value
297 [Documentation] Get watchdog value, convert to integer, and compare to original start value.
298 [Arguments] ${start_timer_integer}
299
300 # Description of argument(s):
301 # start_timer_integer The initial value for the watchdog timer.
302
303 # Get Watchdog Timer.
304 ${resp}= Run IPMI Standard Command raw ${IPMI_RAW_CMD['Watchdog']['Get'][0]}
305 @{timer_value}= Split String ${resp}
306
307 FOR ${value} IN @{timer_value}
308 Log Many ${value}
309 END
310
311 # Convert to integer and compare with start value.
312 # Example: Get watchdog response is 0x06 0x24 0x05 0x00 0x64 0x00 0x64 0x00.
313 # Start_timer_value is bits 6 - 7; set to 0x64 0x00 (100 ms decimal).
314 # Reverse bits 6 - 7 due to BMC being little endian; new value is 0x00 0x64.
315 # Convert hex value 0x00 0x64 to integer; start_timer_integer = 100.
316 ${value}= Get Slice From List ${timer_value} 6
317 Reverse List ${value}
318 ${timer_string}= Evaluate "".join(${value})
319 ${current_timer_integer}= Convert To Integer ${timer_string} 16
320 Should Be True ${current_timer_integer} < ${start_timer_integer}