blob: b17e0c6e710f3f0fc43b8b3ef4abd437b7a7cd55 [file] [log] [blame]
Leah McNuttc9c9cde2016-10-07 16:53:52 +00001*** Settings ***
Michael Walsh0bbd8602016-11-22 11:31:49 -06002Documentation Do random repeated boots based on the state of the BMC machine.
3... The number of repetitions is designated by ${max_num_tests}. Keyword
4... names that are listed in @{AVAIL_BOOTS} become the selection of possible
5... boots for the test.
Leah McNuttc9c9cde2016-10-07 16:53:52 +00006
Leah McNuttc9c9cde2016-10-07 16:53:52 +00007Resource ../lib/dvt/obmc_driver_vars.txt
8Resource ../lib/list_utils.robot
Michael Walsh0bbd8602016-11-22 11:31:49 -06009Resource ../lib/openbmc_ffdc.robot
10
11Library ../lib/gen_robot_print.py
12Library ../lib/gen_robot_plug_in.py
13Library ../lib/gen_robot_valid.py
14Library ../lib/state.py
15Library ../lib/boot/powerons.py
16Library ../lib/boot/poweroffs.py
17Library ../lib/obmc_boot_test.py
18
19# WITH NAME boot_results
20
21*** Variables ***
22# Initialize program parameters variables.
23# Create parm_list containing all of our program parameters. This is used by
24# 'Rqprint Pgm Header'
25@{parm_list} openbmc_nickname openbmc_host openbmc_username
26... openbmc_password os_host os_username os_password pdu_host
27... pdu_username pdu_password pdu_slot_no openbmc_serial_host
28... openbmc_serial_port boot_stack boot_list max_num_tests
29... plug_in_dir_paths status_file_path openbmc_model boot_pass boot_fail
30... test_mode quiet debug
31
32# Initialize each program parameter.
33${openbmc_nickname} ${EMPTY}
34${openbmc_host} ${EMPTY}
35${openbmc_username} root
36${openbmc_password} 0penBmc
37${os_host} ${EMPTY}
38${os_username} root
39${os_password} P@ssw0rd
40${pdu_host} ${EMPTY}
41${pdu_username} admin
42${pdu_password} admin
43${pdu_slot_no} ${EMPTY}
44${openbmc_serial_host} ${EMPTY}
45${openbmc_serial_port} ${EMPTY}
46${boot_stack} ${EMPTY}
47${boot_list} ${EMPTY}
48${max_num_tests} 0
49${plug_in_dir_paths} ${EMPTY}
50${status_file_path} ${EMPTY}
51${openbmc_model} ${EMPTY}
52# The reason boot_pass and boot_fail are parameters is that it is possible to
53# be called by a program that has already done some tests. This allows us to
54# keep the grand total.
55${boot_pass} ${0}
56${boot_fail} ${0}
57${test_mode} 0
58${quiet} 0
59${debug} 0
60
61# Plug-in variables.
62${shell_rc} 0x00000000
63${fail_on_plug_in_failure} 1
64${return_on_non_zero_rc} 0
65
66${next_boot} ${EMPTY}
67# State dictionary. Initializing to a realistic state for testing in
68# test_mode.
69&{default_state} power=1
70... bmc=HOST_BOOTED
71... boot_progress=FW Progress, Starting OS
72... os_ping=1
73... os_login=1
74... os_run_cmd=1
75&{state} &{default_state}
76
77# Flag variables.
78${cp_setup_called} ${0}
79# test_really_running is needed by DB_Logging plug-in.
80${test_really_running} ${1}
Leah McNuttc9c9cde2016-10-07 16:53:52 +000081
82*** Test Cases ***
Michael Walsh0bbd8602016-11-22 11:31:49 -060083Randomized Boot Testing
84 [Documentation] Performs random, repeated boots.
85 [Tags] Randomized_boot_testing
Leah McNuttc9c9cde2016-10-07 16:53:52 +000086
87 # Call the Main keyword to prevent any dots from appearing in the console
88 # due to top level keywords.
89 Main
90
91*** Keywords ***
Michael Walsh0bbd8602016-11-22 11:31:49 -060092###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +000093Main
Michael Walsh0bbd8602016-11-22 11:31:49 -060094 [Teardown] Program Teardown
Leah McNuttc9c9cde2016-10-07 16:53:52 +000095
Michael Walsh0bbd8602016-11-22 11:31:49 -060096 Setup
Leah McNuttc9c9cde2016-10-07 16:53:52 +000097
Michael Walsh0bbd8602016-11-22 11:31:49 -060098 :For ${BOOT_COUNT} IN RANGE ${max_num_tests}
99 \ Test Loop Body ${BOOT_COUNT}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000100
Michael Walsh0bbd8602016-11-22 11:31:49 -0600101 Rprint Timen Completed all requested boot tests.
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000102
Michael Walsh0bbd8602016-11-22 11:31:49 -0600103###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000104
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000105
Michael Walsh0bbd8602016-11-22 11:31:49 -0600106###############################################################################
107Setup
108 [Documentation] Do general program setup tasks.
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000109
Michael Walsh0bbd8602016-11-22 11:31:49 -0600110 Rprintn
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000111
Michael Walsh0bbd8602016-11-22 11:31:49 -0600112 Validate Parms
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000113
Michael Walsh0bbd8602016-11-22 11:31:49 -0600114 Rqprint Pgm Header
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000115
Michael Walsh0bbd8602016-11-22 11:31:49 -0600116 Create Boot Results Table
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000117
Michael Walsh0bbd8602016-11-22 11:31:49 -0600118 # Preserve the values of boot_pass/boot_fail that were passed in.
119 Set Global Variable ${initial_boot_pass} ${boot_pass}
120 Set Global Variable ${initial_boot_fail} ${boot_fail}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000121
Michael Walsh0bbd8602016-11-22 11:31:49 -0600122 # Call "setup" plug-ins, if any.
123 Plug In Setup
124 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
125 ... call_point=setup
126 Should Be Equal '${rc}' '${0}'
127
128 # Keyword "FFDC" will fail if TEST_MESSAGE is not set.
129 Set Global Variable ${TEST_MESSAGE} ${EMPTY}
130
131 # Setting cp_setup_called lets our Teardown know that it needs to call
132 # the cleanup plug-in call point.
133 Set Global Variable ${cp_setup_called} ${1}
134
135 Rqprint Timen Getting system state.
136 # The state dictionary must be primed before calling Test Loop Body.
137 ${temp_state}= Run Keyword If '${test_mode}' == '0' Get State
138 ... ELSE Create Dictionary &{default_state}
139 Set Global Variable &{state} &{temp_state}
140 rpvars state
141
142###############################################################################
143
144
145###############################################################################
146Validate Parms
147 [Documentation] Validate all program parameters.
148
149 rprintn
150
151 Rvalid Value AVAIL_BOOTS
152 Rvalid Value openbmc_host
153 Rvalid Value openbmc_username
154 Rvalid Value openbmc_password
155 # os_host is optional so no validation is being done.
156 Rvalid Value os_username
157 Rvalid Value os_password
158 Rvalid Value pdu_host
159 Rvalid Value pdu_username
160 Rvalid Value pdu_password
161 Rvalid Integer pdu_slot_no
162 Rvalid Value openbmc_serial_host
163 Rvalid Integer openbmc_serial_port
164 Rvalid Integer max_num_tests
165 Rvalid Value openbmc_model
166 Rvalid Integer boot_pass
167 Rvalid Integer boot_fail
168
169 ${boot_pass_temp}= Convert To Integer ${boot_pass}
170 Set Global Variable ${boot_pass} ${boot_pass_temp}
171 ${boot_fail_temp}= Convert To Integer ${boot_fail}
172 Set Global Variable ${boot_fail} ${boot_fail_temp}
173
174 ${temp_arr}= Rvalidate Plug Ins ${plug_in_dir_paths}
175 Set Global Variable @{plug_in_packages_list} @{temp_arr}
176
177###############################################################################
178
179
180###############################################################################
181Program Teardown
182 [Documentation] Clean up after this program.
183
184 Run Keyword If '${cp_setup_called}' == '1' Run Keywords
185 ... Plug In Setup AND
186 ... Rprocess Plug In Packages call_point=cleanup
187 ... stop_on_plug_in_failure=1
188
189 Rqprint Pgm Footer
190
191###############################################################################
192
193
194###############################################################################
195Test Loop Body
196 [Documentation] The main loop body for the loop in "main".
197 [Arguments] ${BOOT_COUNT}
198
199 Rqprintn
200 Rqprint Timen Starting boot ${BOOT_COUNT+1} of ${max_num_tests}.
201
202 ${loc_next_boot}= Select Boot ${state['power']}
203 Set Global Variable ${next_boot} ${loc_next_boot}
204
205 ${status} ${msg}= Run Keyword And Ignore Error Run Boot ${next_boot}
206 Run Keyword If '${status}' == 'FAIL' rprint ${msg}
207
208 rprintn
209 Run Keyword If '${BOOT_STATUS}' == 'PASS' Run Keywords
210 ... Set Global Variable ${boot_success} ${1} AND
211 ... Rqprint Timen BOOT_SUCCESS: "${next_boot}" succeeded.
212 ... ELSE Run Keywords
213 ... Set Global Variable ${boot_success} ${0} AND
214 ... Rqprint Timen BOOT_FAILED: ${next_boot} failed.
215
216 Update Boot Results Table ${next_boot} ${BOOT_STATUS}
217
218 # NOTE: A post_test_case call point failure is NOT counted as a boot
219 # failure.
220 Plug In Setup
221 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
222 ... call_point=post_test_case stop_on_plug_in_failure=1
223
224 Run Keyword If '${BOOT_STATUS}' != 'PASS'
225 ... Run Keyword and Continue On Failure My FFDC
226
227 # Run plug-ins to see if we ought to stop execution.
228 Plug In Setup
229 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
230 ... call_point=stop_check
231 Run Keyword If '${rc}' != '${0}' Run Keywords
232 ... Rprint Error Report Stopping as requested by user.
233 ... Fail
234
235 Print Boot Results Table
236 Rqprint Timen Finished boot ${BOOT_COUNT+1} of ${max_num_tests}.
237
238 Rqprint Timen Getting system state.
239 # The state must be refreshed before calling Test Loop Body again.
240 ${temp_state}= Run Keyword If '${test_mode}' == '0' Get State
241 ... quiet=${1}
242 ... ELSE Create Dictionary &{default_state}
243 Set Global Variable &{state} &{temp_state}
244 rpvars state
245
246###############################################################################
247
248
249###############################################################################
250Select Boot
251 [Documentation] Select a boot test to be run based on our current state.
252 ... Return the chosen boot type.
253 [Arguments] ${power}
254
255 # power The power state of the machine, either zero or one.
256
257 ${boot}= Run Keyword If ${power} == ${0} Select Power On
258 ... ELSE Run Keyword If ${power} == ${1} Select Power Off
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000259 ... ELSE Run Keywords Log to Console
Michael Walsh0bbd8602016-11-22 11:31:49 -0600260 ... **ERROR** BMC not in state to power on or off: "${power}" AND
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000261 ... Fatal Error
262
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600263 [Return] ${boot}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000264
Michael Walsh0bbd8602016-11-22 11:31:49 -0600265###############################################################################
266
267
268###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000269Select Power On
Michael Walsh0bbd8602016-11-22 11:31:49 -0600270 [Documentation] Randomly chooses a boot from the list of Power On boots.
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000271
Michael Walsh0bbd8602016-11-22 11:31:49 -0600272 @{power_on_choices}= Intersect Lists ${VALID_POWER_ON} ${AVAIL_BOOTS}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000273
274 ${length}= Get Length ${power_on_choices}
275
Michael Walsh0bbd8602016-11-22 11:31:49 -0600276 # Currently selects the first boot in the list of options, rather than
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000277 # selecting randomly.
278 ${chosen}= Set Variable @{power_on_choices}[0]
279
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600280 [Return] ${chosen}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000281
Michael Walsh0bbd8602016-11-22 11:31:49 -0600282###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000283
Michael Walsh0bbd8602016-11-22 11:31:49 -0600284
285###############################################################################
286Select Power Off
287 [Documentation] Randomly chooses an boot from the list of Power Off boots.
288
289 @{power_off_choices}= Intersect Lists ${VALID_POWER_OFF} ${AVAIL_BOOTS}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000290
291 ${length}= Get Length ${power_off_choices}
292
Michael Walsh0bbd8602016-11-22 11:31:49 -0600293 # Currently selects the first boot in the list of options, rather than
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000294 # selecting randomly.
295 ${chosen}= Set Variable @{power_off_choices}[0]
296
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600297 [Return] ${chosen}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000298
Michael Walsh0bbd8602016-11-22 11:31:49 -0600299###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000300
Michael Walsh0bbd8602016-11-22 11:31:49 -0600301
302###############################################################################
303Run Boot
304 [Documentation] Run the selected boot and mark the status when complete.
305 [Arguments] ${boot_keyword}
306 [Teardown] Set Global Variable ${BOOT_STATUS} ${KEYWORD STATUS}
307
308 # boot_keyword The name of the boot to run, which corresponds to the
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000309 # keyword to run. (i.e "BMC Power On")
310
Michael Walsh0bbd8602016-11-22 11:31:49 -0600311 Print Test Start Message ${boot_keyword}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000312
Michael Walsh0bbd8602016-11-22 11:31:49 -0600313 Plug In Setup
314 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
315 ... call_point=pre_boot
316 Should Be Equal '${rc}' '${0}'
317
318 @{cmd_buf}= Create List ${boot_keyword}
319 rqpissuing_keyword ${cmd_buf} ${test_mode}
320 Run Keyword If '${test_mode}' == '0' Run Keyword @{cmd_buf}
321
322 Plug In Setup
323 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
324 ... call_point=post_boot
325 Should Be Equal '${rc}' '${0}'
326
327###############################################################################
328
329
330###############################################################################
331Print Test Start Message
332 [Documentation] Print a message indicating what boot test is about to run.
333 [Arguments] ${boot_keyword}
334
335 ${doing_msg}= Sprint Timen Doing "${boot_keyword}".
336 rqprint ${doing_msg}
337
338 Append to List ${LAST_TEN} ${doing_msg}
339 ${length}= Get Length ${LAST_TEN}
340
341 Run Keyword If '${length}' > '${10}' Remove From List ${LAST_TEN} 0
342
343###############################################################################
344
345
346###############################################################################
347My FFDC
348 [Documentation] Collect FFDC data.
349
350 Rqprint Timen FFDC Dump requested.
351 Rqprint Timen Starting dump of FFDC.
352 ${FFDC_DIR_PATH}= Add Trailing Slash ${FFDC_DIR_PATH}
353 # FFDC_LOG_PATH is used by "FFDC" keyword.
354 Set Global Variable ${FFDC_LOG_PATH} ${FFDC_DIR_PATH}
355
356 @{cmd_buf}= Create List FFDC
357 rqpissuing_keyword ${cmd_buf} ${test_mode}
358 Run Keyword If '${test_mode}' == '0' @{cmd_buf}
359
360 Plug In Setup
361 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
362 ... call_point=ffdc stop_on_plug_in_failure=1
363
364 Rqprint Timen Finished dumping of FFDC.
365 Log FFDC Summary
366 Log Defect Information
367
368###############################################################################
369
370
371###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000372Log Defect Information
373 [Documentation] Logs information needed for a defect. This information
374 ... can also be found within the FFDC gathered.
375
Michael Walsh0bbd8602016-11-22 11:31:49 -0600376 Rqprintn
377 # indent=0, width=90, linefeed=1, char="="
378 Rqprint Dashes ${0} ${90} ${1} =
379 Rqprintn Copy this data to the defect:
380 Rqprintn
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000381
Michael Walsh0bbd8602016-11-22 11:31:49 -0600382 Rqpvars @{parm_list}
383 Print Last Ten Boots
384
385 ${rc} ${output}= Run Keyword If '${test_mode}' == '0'
386 ... Run and return RC and Output ls ${LOG_PREFIX}*
387 ... ELSE Set Variable ${0} ${EMPTY}
388
389 Run Keyword If '${rc}' != '${0}' and '${rc}' != 'None' rqpvars rc
390
391 Rqprintn
392 Rqprintn FFDC data files:
393 Rqprintn ${output}
394
395 Rqprintn
396 Rqprint Dashes ${0} ${90} ${1} =
397
398###############################################################################
399
400
401###############################################################################
402Print Last Ten Boots
403 [Documentation] Logs the last ten boots that were performed with their
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000404 ... starting time stamp.
405
Michael Walsh0bbd8602016-11-22 11:31:49 -0600406 # indent 0, 90 chars wide, linefeed, char is "="
407 Rqprint Dashes ${0} ${90}
408 Rqprintn Last 10 boots:
409 Rqprintn
410 :FOR ${boot_entry} IN @{LAST_TEN}
411 \ rqprint ${boot_entry}
412 Rqprint Dashes ${0} ${90}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000413
Michael Walsh0bbd8602016-11-22 11:31:49 -0600414###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000415
Michael Walsh0bbd8602016-11-22 11:31:49 -0600416
417###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000418Log FFDC Summary
419 [Documentation] Logs finding from within the FFDC files gathered.
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000420
Michael Walsh0bbd8602016-11-22 11:31:49 -0600421 Rqprint Timen This is where the FFDC summary would go...
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000422
Michael Walsh0bbd8602016-11-22 11:31:49 -0600423###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000424
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000425