blob: db9dcd156dad96d4cfa32e8d8830bff574087893 [file] [log] [blame]
Michael Walsh0bbd8602016-11-22 11:31:49 -06001#!/usr/bin/env python
2
3r"""
4This module is the python counterpart to obmc_boot_test.
5"""
6
Michael Walsh0b93fbf2017-03-02 14:42:41 -06007import os
8import imp
9import time
10import glob
11import random
12import cPickle as pickle
13
14from robot.utils import DotDict
15from robot.libraries.BuiltIn import BuiltIn
16
Michael Walsh6741f742017-02-20 16:16:38 -060017from boot_data import *
Michael Walshc9116812017-03-10 14:23:06 -060018import gen_print as gp
Michael Walsh0bbd8602016-11-22 11:31:49 -060019import gen_robot_print as grp
Michael Walsh55302292017-01-10 11:43:02 -060020import gen_robot_plug_in as grpi
Michael Walsh6741f742017-02-20 16:16:38 -060021import gen_robot_valid as grv
22import gen_misc as gm
23import gen_cmd as gc
Michael Walsh55302292017-01-10 11:43:02 -060024import state as st
Michael Walsh0bbd8602016-11-22 11:31:49 -060025
Michael Walsh0b93fbf2017-03-02 14:42:41 -060026base_path = os.path.dirname(os.path.dirname(
27 imp.find_module("gen_robot_print")[1])) +\
Michael Walshc9116812017-03-10 14:23:06 -060028 os.sep
Michael Walsh0b93fbf2017-03-02 14:42:41 -060029sys.path.append(base_path + "extended/")
30import run_keyword as rk
Michael Walsh0bbd8602016-11-22 11:31:49 -060031
Michael Walsh6741f742017-02-20 16:16:38 -060032# Program parameter processing.
33# Assign all program parms to python variables which are global to this module.
34parm_list = BuiltIn().get_variable_value("${parm_list}")
35int_list = ['max_num_tests', 'boot_pass', 'boot_fail', 'quiet', 'test_mode',
36 'debug']
37for parm in parm_list:
38 if parm in int_list:
39 sub_cmd = "int(BuiltIn().get_variable_value(\"${" + parm +\
40 "}\", \"0\"))"
41 else:
42 sub_cmd = "BuiltIn().get_variable_value(\"${" + parm + "}\")"
43 cmd_buf = parm + " = " + sub_cmd
44 exec(cmd_buf)
Michael Walsh0bbd8602016-11-22 11:31:49 -060045
Michael Walsh6741f742017-02-20 16:16:38 -060046if ffdc_dir_path_style == "":
47 ffdc_dir_path_style = int(os.environ.get('FFDC_DIR_PATH_STYLE', '0'))
48
49# Set up boot data structures.
50boot_table = create_boot_table()
51valid_boot_types = create_valid_boot_list(boot_table)
Michael Walsh0b93fbf2017-03-02 14:42:41 -060052
Michael Walshe1e26442017-03-06 17:50:07 -060053# Setting master_pid correctly influences the behavior of plug-ins like
54# DB_Logging
55program_pid = os.getpid()
56master_pid = os.environ.get('AUTOBOOT_MASTER_PID', program_pid)
57
58boot_results_file_path = "/tmp/" + openbmc_nickname + ":pid_" +\
Michael Walshc9116812017-03-10 14:23:06 -060059 str(master_pid) + ":boot_results"
Michael Walshe1e26442017-03-06 17:50:07 -060060if os.path.isfile(boot_results_file_path):
Michael Walsh0b93fbf2017-03-02 14:42:41 -060061 # We've been called before in this run so we'll load the saved
62 # boot_results object.
63 boot_results = pickle.load(open(boot_results_file_path, 'rb'))
64else:
65 boot_results = boot_results(boot_table, boot_pass, boot_fail)
66
Michael Walsh6741f742017-02-20 16:16:38 -060067boot_lists = read_boot_lists()
68last_ten = []
69# Convert these program parms to more useable lists.
70boot_list = filter(None, boot_list.split(":"))
71boot_stack = filter(None, boot_stack.split(":"))
72
73state = st.return_default_state()
74cp_setup_called = 0
75next_boot = ""
76base_tool_dir_path = os.path.normpath(os.environ.get(
77 'AUTOBOOT_BASE_TOOL_DIR_PATH', "/tmp")) + os.sep
78ffdc_dir_path = os.path.normpath(os.environ.get('FFDC_DIR_PATH', '')) + os.sep
79ffdc_list_file_path = base_tool_dir_path + openbmc_nickname + "/FFDC_FILE_LIST"
80boot_success = 0
Michael Walsh6741f742017-02-20 16:16:38 -060081status_dir_path = os.environ.get('STATUS_DIR_PATH', "")
82if status_dir_path != "":
83 status_dir_path = os.path.normpath(status_dir_path) + os.sep
Michael Walsh0b93fbf2017-03-02 14:42:41 -060084default_power_on = "REST Power On"
85default_power_off = "REST Power Off"
Michael Walsh6741f742017-02-20 16:16:38 -060086boot_count = 0
Michael Walsh0bbd8602016-11-22 11:31:49 -060087
88
89###############################################################################
Michael Walsh0bbd8602016-11-22 11:31:49 -060090def plug_in_setup():
91
92 r"""
93 Initialize all plug-in environment variables for use by the plug-in
94 programs.
95 """
96
Michael Walsh6741f742017-02-20 16:16:38 -060097 boot_pass, boot_fail = boot_results.return_total_pass_fail()
Michael Walsh0bbd8602016-11-22 11:31:49 -060098 if boot_pass > 1:
99 test_really_running = 1
100 else:
101 test_really_running = 0
102
Michael Walsh0bbd8602016-11-22 11:31:49 -0600103 seconds = time.time()
104 loc_time = time.localtime(seconds)
105 time_string = time.strftime("%y%m%d.%H%M%S.", loc_time)
106
Michael Walsh6741f742017-02-20 16:16:38 -0600107 ffdc_prefix = openbmc_nickname + "." + time_string
Michael Walsh0bbd8602016-11-22 11:31:49 -0600108
Michael Walsh6741f742017-02-20 16:16:38 -0600109 BuiltIn().set_global_variable("${test_really_running}",
110 test_really_running)
111 BuiltIn().set_global_variable("${boot_type_desc}", next_boot)
112 BuiltIn().set_global_variable("${master_pid}", master_pid)
Michael Walsh0bbd8602016-11-22 11:31:49 -0600113 BuiltIn().set_global_variable("${FFDC_DIR_PATH}", ffdc_dir_path)
Michael Walsh55302292017-01-10 11:43:02 -0600114 BuiltIn().set_global_variable("${STATUS_DIR_PATH}", status_dir_path)
Michael Walsh4c9a6452016-12-13 16:03:11 -0600115 BuiltIn().set_global_variable("${BASE_TOOL_DIR_PATH}", base_tool_dir_path)
Michael Walsh4c9a6452016-12-13 16:03:11 -0600116 BuiltIn().set_global_variable("${FFDC_LIST_FILE_PATH}",
117 ffdc_list_file_path)
Michael Walsh6741f742017-02-20 16:16:38 -0600118 BuiltIn().set_global_variable("${FFDC_DIR_PATH_STYLE}",
119 ffdc_dir_path_style)
120 BuiltIn().set_global_variable("${FFDC_CHECK}",
121 ffdc_check)
122 BuiltIn().set_global_variable("${boot_pass}", boot_pass)
123 BuiltIn().set_global_variable("${boot_fail}", boot_fail)
124 BuiltIn().set_global_variable("${boot_success}", boot_success)
125 BuiltIn().set_global_variable("${ffdc_prefix}", ffdc_prefix)
Michael Walsh4c9a6452016-12-13 16:03:11 -0600126
Michael Walsh0bbd8602016-11-22 11:31:49 -0600127 # For each program parameter, set the corresponding AUTOBOOT_ environment
128 # variable value. Also, set an AUTOBOOT_ environment variable for every
129 # element in additional_values.
130 additional_values = ["boot_type_desc", "boot_success", "boot_pass",
131 "boot_fail", "test_really_running", "program_pid",
Michael Walsh4c9a6452016-12-13 16:03:11 -0600132 "master_pid", "ffdc_prefix", "ffdc_dir_path",
Michael Walsh55302292017-01-10 11:43:02 -0600133 "status_dir_path", "base_tool_dir_path",
134 "ffdc_list_file_path"]
Michael Walsh0bbd8602016-11-22 11:31:49 -0600135
136 plug_in_vars = parm_list + additional_values
137
138 for var_name in plug_in_vars:
139 var_value = BuiltIn().get_variable_value("${" + var_name + "}")
140 var_name = var_name.upper()
141 if var_value is None:
142 var_value = ""
Michael Walsh6741f742017-02-20 16:16:38 -0600143 os.environ["AUTOBOOT_" + var_name] = str(var_value)
Michael Walsh0bbd8602016-11-22 11:31:49 -0600144
Michael Walsh0bbd8602016-11-22 11:31:49 -0600145 if debug:
Michael Walsh6741f742017-02-20 16:16:38 -0600146 shell_rc, out_buf = \
147 gc.cmd_fnc_u("printenv | egrep AUTOBOOT_ | sort -u")
Michael Walsh0bbd8602016-11-22 11:31:49 -0600148
149###############################################################################
150
151
152###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600153def setup():
Michael Walsh0bbd8602016-11-22 11:31:49 -0600154
155 r"""
Michael Walsh6741f742017-02-20 16:16:38 -0600156 Do general program setup tasks.
Michael Walsh0bbd8602016-11-22 11:31:49 -0600157 """
158
Michael Walsh6741f742017-02-20 16:16:38 -0600159 global cp_setup_called
Michael Walsh0bbd8602016-11-22 11:31:49 -0600160
Michael Walsh6741f742017-02-20 16:16:38 -0600161 grp.rqprintn()
162
163 validate_parms()
164
165 grp.rqprint_pgm_header()
166
167 plug_in_setup()
168 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
169 call_point='setup')
170 if rc != 0:
171 error_message = "Plug-in setup failed.\n"
172 grp.rprint_error_report(error_message)
173 BuiltIn().fail(error_message)
174 # Setting cp_setup_called lets our Teardown know that it needs to call
175 # the cleanup plug-in call point.
176 cp_setup_called = 1
177
178 # Keyword "FFDC" will fail if TEST_MESSAGE is not set.
179 BuiltIn().set_global_variable("${TEST_MESSAGE}", "${EMPTY}")
180
181 grp.rdprint_var(boot_table, 1)
182 grp.rdprint_var(boot_lists)
Michael Walsh0bbd8602016-11-22 11:31:49 -0600183
184###############################################################################
185
186
187###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600188def validate_parms():
Michael Walsh0bbd8602016-11-22 11:31:49 -0600189
190 r"""
Michael Walsh6741f742017-02-20 16:16:38 -0600191 Validate all program parameters.
Michael Walsh0bbd8602016-11-22 11:31:49 -0600192 """
193
Michael Walsh6741f742017-02-20 16:16:38 -0600194 grp.rqprintn()
Michael Walsh0bbd8602016-11-22 11:31:49 -0600195
Michael Walsh6741f742017-02-20 16:16:38 -0600196 grv.rvalid_value("openbmc_host")
197 grv.rvalid_value("openbmc_username")
198 grv.rvalid_value("openbmc_password")
199 if os_host != "":
200 grv.rvalid_value("os_username")
201 grv.rvalid_value("os_password")
Michael Walsh0bbd8602016-11-22 11:31:49 -0600202
Michael Walsh6741f742017-02-20 16:16:38 -0600203 if pdu_host != "":
204 grv.rvalid_value("pdu_username")
205 grv.rvalid_value("pdu_password")
206 grv.rvalid_integer("pdu_slot_no")
207 if openbmc_serial_host != "":
208 grv.rvalid_integer("openbmc_serial_port")
209 grv.rvalid_integer("max_num_tests")
210 grv.rvalid_value("openbmc_model")
211 grv.rvalid_integer("boot_pass")
212 grv.rvalid_integer("boot_fail")
213
214 plug_in_packages_list = grpi.rvalidate_plug_ins(plug_in_dir_paths)
215 BuiltIn().set_global_variable("${plug_in_packages_list}",
216 plug_in_packages_list)
217
218 if len(boot_list) == 0 and len(boot_stack) == 0:
219 error_message = "You must provide either a value for either the" +\
220 " boot_list or the boot_stack parm.\n"
221 BuiltIn().fail(gp.sprint_error(error_message))
222
223 valid_boot_list(boot_list, valid_boot_types)
224 valid_boot_list(boot_stack, valid_boot_types)
225
226 return
Michael Walsh0bbd8602016-11-22 11:31:49 -0600227
228###############################################################################
229
230
231###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600232def my_get_state():
Michael Walsh0bbd8602016-11-22 11:31:49 -0600233
234 r"""
Michael Walsh6741f742017-02-20 16:16:38 -0600235 Get the system state plus a little bit of wrapping.
Michael Walsh0bbd8602016-11-22 11:31:49 -0600236 """
237
Michael Walsh6741f742017-02-20 16:16:38 -0600238 global state
239
240 req_states = ['epoch_seconds'] + st.default_req_states
241
242 grp.rqprint_timen("Getting system state.")
243 if test_mode:
244 state['epoch_seconds'] = int(time.time())
245 else:
246 state = st.get_state(req_states=req_states, quiet=0)
247 grp.rprint_var(state)
Michael Walsh341c21e2017-01-17 16:25:20 -0600248
249###############################################################################
250
251
252###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600253def select_boot():
Michael Walsh341c21e2017-01-17 16:25:20 -0600254
255 r"""
256 Select a boot test to be run based on our current state and return the
257 chosen boot type.
258
259 Description of arguments:
Michael Walsh6741f742017-02-20 16:16:38 -0600260 state The state of the machine.
Michael Walsh341c21e2017-01-17 16:25:20 -0600261 """
262
Michael Walsh30dadae2017-02-27 14:25:52 -0600263 global boot_stack
264
Michael Walsh6741f742017-02-20 16:16:38 -0600265 grp.rprint_timen("Selecting a boot test.")
266
267 my_get_state()
268
269 stack_popped = 0
270 if len(boot_stack) > 0:
271 stack_popped = 1
272 grp.rprint_dashes()
273 grp.rprint_var(boot_stack)
274 grp.rprint_dashes()
275 boot_candidate = boot_stack.pop()
276 if st.compare_states(state, boot_table[boot_candidate]['start']):
277 grp.rprint_timen("The machine state is valid for a '" +
278 boot_candidate + "' boot test.")
279 grp.rprint_dashes()
280 grp.rprint_var(boot_stack)
281 grp.rprint_dashes()
282 return boot_candidate
Michael Walsh341c21e2017-01-17 16:25:20 -0600283 else:
Michael Walsh6741f742017-02-20 16:16:38 -0600284 grp.rprint_timen("The machine state is not valid for a '" +
285 boot_candidate + "' boot test.")
286 boot_stack.append(boot_candidate)
287 popped_boot = boot_candidate
288
289 # Loop through your list selecting a boot_candidates
290 boot_candidates = []
291 for boot_candidate in boot_list:
292 if st.compare_states(state, boot_table[boot_candidate]['start']):
293 if stack_popped:
294 if st.compare_states(boot_table[boot_candidate]['end'],
295 boot_table[popped_boot]['start']):
296 boot_candidates.append(boot_candidate)
297 else:
298 boot_candidates.append(boot_candidate)
299
300 if len(boot_candidates) == 0:
301 grp.rprint_timen("The user's boot list contained no boot tests" +
302 " which are valid for the current machine state.")
303 boot_candidate = default_power_on
304 if not st.compare_states(state, boot_table[default_power_on]['start']):
305 boot_candidate = default_power_off
306 boot_candidates.append(boot_candidate)
307 grp.rprint_timen("Using default '" + boot_candidate +
308 "' boot type to transtion to valid state.")
309
310 grp.rdprint_var(boot_candidates)
311
312 # Randomly select a boot from the candidate list.
313 boot = random.choice(boot_candidates)
Michael Walsh341c21e2017-01-17 16:25:20 -0600314
315 return boot
Michael Walsh0bbd8602016-11-22 11:31:49 -0600316
317###############################################################################
Michael Walsh55302292017-01-10 11:43:02 -0600318
319
320###############################################################################
Michael Walsh341c21e2017-01-17 16:25:20 -0600321def print_last_boots():
322
323 r"""
324 Print the last ten boots done with their time stamps.
325 """
326
327 # indent 0, 90 chars wide, linefeed, char is "="
328 grp.rqprint_dashes(0, 90)
329 grp.rqprintn("Last 10 boots:\n")
Michael Walsh341c21e2017-01-17 16:25:20 -0600330
331 for boot_entry in last_ten:
332 grp.rqprint(boot_entry)
333 grp.rqprint_dashes(0, 90)
334
335###############################################################################
336
337
338###############################################################################
Michael Walsh341c21e2017-01-17 16:25:20 -0600339def print_defect_report():
340
341 r"""
342 Print a defect report.
343 """
344
345 grp.rqprintn()
346 # indent=0, width=90, linefeed=1, char="="
347 grp.rqprint_dashes(0, 90, 1, "=")
348 grp.rqprintn("Copy this data to the defect:\n")
349
Michael Walsh341c21e2017-01-17 16:25:20 -0600350 grp.rqpvars(*parm_list)
351
352 grp.rqprintn()
353
354 print_last_boots()
355 grp.rqprintn()
Michael Walsh341c21e2017-01-17 16:25:20 -0600356 grp.rqpvar(state)
357
358 # At some point I'd like to have the 'Call FFDC Methods' return a list
359 # of files it has collected. In that case, the following "ls" command
360 # would no longer be needed. For now, however, glob shows the files
361 # named in FFDC_LIST_FILE_PATH so I will refrain from printing those
362 # out (so we don't see duplicates in the list).
363
364 LOG_PREFIX = BuiltIn().get_variable_value("${LOG_PREFIX}")
365
366 output = '\n'.join(glob.glob(LOG_PREFIX + '*'))
Michael Walsh341c21e2017-01-17 16:25:20 -0600367 try:
Michael Walsh6741f742017-02-20 16:16:38 -0600368 ffdc_list = open(ffdc_list_file_path, 'r')
Michael Walsh341c21e2017-01-17 16:25:20 -0600369 except IOError:
370 ffdc_list = ""
371
Michael Walsh341c21e2017-01-17 16:25:20 -0600372 grp.rqprintn()
373 grp.rqprintn("FFDC data files:")
374 if status_file_path != "":
375 grp.rqprintn(status_file_path)
376
377 grp.rqprintn(output)
378 # grp.rqprintn(ffdc_list)
379 grp.rqprintn()
380
381 grp.rqprint_dashes(0, 90, 1, "=")
382
383###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600384
385
386###############################################################################
387def my_ffdc():
388
389 r"""
390 Collect FFDC data.
391 """
392
393 global state
394
395 plug_in_setup()
396 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
397 call_point='ffdc', stop_on_plug_in_failure=1)
398
399 AUTOBOOT_FFDC_PREFIX = os.environ['AUTOBOOT_FFDC_PREFIX']
400
401 # FFDC_LOG_PATH is used by "FFDC" keyword.
402 BuiltIn().set_global_variable("${FFDC_LOG_PATH}", ffdc_dir_path)
403
404 cmd_buf = ["FFDC", "ffdc_prefix=" + AUTOBOOT_FFDC_PREFIX]
405 grp.rpissuing_keyword(cmd_buf)
Michael Walsh3328caf2017-03-21 17:04:08 -0500406 try:
407 BuiltIn().run_keyword_and_continue_on_failure(*cmd_buf)
408 except:
409 gp.print_error("Call to ffdc failed.\n")
Michael Walsh6741f742017-02-20 16:16:38 -0600410
411 my_get_state()
412
413 print_defect_report()
414
415###############################################################################
416
417
418###############################################################################
419def print_test_start_message(boot_keyword):
420
421 r"""
422 Print a message indicating what boot test is about to run.
423
424 Description of arguments:
425 boot_keyword The name of the boot which is to be run
426 (e.g. "BMC Power On").
427 """
428
429 global last_ten
430
431 doing_msg = gp.sprint_timen("Doing \"" + boot_keyword + "\".")
432 grp.rqprint(doing_msg)
433
434 last_ten.append(doing_msg)
435
436 if len(last_ten) > 10:
437 del last_ten[0]
438
439###############################################################################
440
441
442###############################################################################
443def run_boot(boot):
444
445 r"""
446 Run the specified boot.
447
448 Description of arguments:
449 boot The name of the boot test to be performed.
450 """
451
452 global state
453
454 print_test_start_message(boot)
455
456 plug_in_setup()
457 rc, shell_rc, failed_plug_in_name = \
458 grpi.rprocess_plug_in_packages(call_point="pre_boot")
459 if rc != 0:
460 error_message = "Plug-in failed with non-zero return code.\n" +\
461 gp.sprint_var(rc, 1)
462 BuiltIn().fail(gp.sprint_error(error_message))
463
464 if test_mode:
465 # In test mode, we'll pretend the boot worked by assigning its
466 # required end state to the default state value.
Michael Walsh30dadae2017-02-27 14:25:52 -0600467 state = st.strip_anchor_state(boot_table[boot]['end'])
Michael Walsh6741f742017-02-20 16:16:38 -0600468 else:
469 # Assertion: We trust that the state data was made fresh by the
470 # caller.
471
472 grp.rprintn()
473
474 if boot_table[boot]['method_type'] == "keyword":
Michael Walsh0b93fbf2017-03-02 14:42:41 -0600475 rk.my_run_keywords(boot_table[boot].get('lib_file_path', ''),
476 boot_table[boot]['method'])
Michael Walsh6741f742017-02-20 16:16:38 -0600477
478 if boot_table[boot]['bmc_reboot']:
479 st.wait_for_comm_cycle(int(state['epoch_seconds']))
Michael Walsh30dadae2017-02-27 14:25:52 -0600480 plug_in_setup()
481 rc, shell_rc, failed_plug_in_name = \
482 grpi.rprocess_plug_in_packages(call_point="post_reboot")
483 if rc != 0:
Michael Walsh0b93fbf2017-03-02 14:42:41 -0600484 error_message = "Plug-in failed with non-zero return code.\n"
485 error_message += gp.sprint_var(rc, 1)
Michael Walsh30dadae2017-02-27 14:25:52 -0600486 BuiltIn().fail(gp.sprint_error(error_message))
Michael Walsh6741f742017-02-20 16:16:38 -0600487 else:
488 match_state = st.anchor_state(state)
489 del match_state['epoch_seconds']
490 # Wait for the state to change in any way.
491 st.wait_state(match_state, wait_time=state_change_timeout,
492 interval="3 seconds", invert=1)
493
494 grp.rprintn()
495 if boot_table[boot]['end']['chassis'] == "Off":
496 boot_timeout = power_off_timeout
497 else:
498 boot_timeout = power_on_timeout
499 st.wait_state(boot_table[boot]['end'], wait_time=boot_timeout,
500 interval="3 seconds")
501
502 plug_in_setup()
503 rc, shell_rc, failed_plug_in_name = \
504 grpi.rprocess_plug_in_packages(call_point="post_boot")
505 if rc != 0:
506 error_message = "Plug-in failed with non-zero return code.\n" +\
507 gp.sprint_var(rc, 1)
508 BuiltIn().fail(gp.sprint_error(error_message))
509
510###############################################################################
511
512
513###############################################################################
514def test_loop_body():
515
516 r"""
517 The main loop body for the loop in main_py.
518
519 Description of arguments:
520 boot_count The iteration number (starts at 1).
521 """
522
523 global boot_count
524 global state
525 global next_boot
526 global boot_success
527
528 grp.rqprintn()
529
530 boot_count += 1
531
532 next_boot = select_boot()
533
534 grp.rqprint_timen("Starting boot " + str(boot_count) + ".")
535
536 # Clear the ffdc_list_file_path file. Plug-ins may now write to it.
537 try:
538 os.remove(ffdc_list_file_path)
539 except OSError:
540 pass
541
542 cmd_buf = ["run_boot", next_boot]
543 boot_status, msg = BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
544 if boot_status == "FAIL":
545 grp.rprint(msg)
546
547 grp.rqprintn()
548 if boot_status == "PASS":
549 boot_success = 1
550 grp.rqprint_timen("BOOT_SUCCESS: \"" + next_boot + "\" succeeded.")
551 else:
552 boot_success = 0
553 grp.rqprint_timen("BOOT_FAILED: \"" + next_boot + "\" failed.")
554
555 boot_results.update(next_boot, boot_status)
556
557 plug_in_setup()
558 # NOTE: A post_test_case call point failure is NOT counted as a boot
559 # failure.
560 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
561 call_point='post_test_case', stop_on_plug_in_failure=1)
562
563 plug_in_setup()
564 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
565 call_point='ffdc_check', shell_rc=0x00000200,
566 stop_on_plug_in_failure=1, stop_on_non_zero_rc=1)
567 if boot_status != "PASS" or ffdc_check == "All" or shell_rc == 0x00000200:
568 cmd_buf = ["my_ffdc"]
569 grp.rpissuing_keyword(cmd_buf)
Michael Walsh3328caf2017-03-21 17:04:08 -0500570 try:
571 BuiltIn().run_keyword_and_continue_on_failure(*cmd_buf)
572 except:
573 gp.print_error("Call to my_ffdc failed.\n")
Michael Walsh6741f742017-02-20 16:16:38 -0600574
Michael Walsh952f9b02017-03-09 13:11:14 -0600575 boot_results.print_report()
576 grp.rqprint_timen("Finished boot " + str(boot_count) + ".")
577
Michael Walsh6741f742017-02-20 16:16:38 -0600578 plug_in_setup()
579 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
580 call_point='stop_check')
581 if rc != 0:
582 error_message = "Stopping as requested by user.\n"
583 grp.rprint_error_report(error_message)
584 BuiltIn().fail(error_message)
585
Michael Walsh6741f742017-02-20 16:16:38 -0600586 return True
587
588###############################################################################
589
590
591###############################################################################
Michael Walshc9116812017-03-10 14:23:06 -0600592def main_keyword_teardown():
Michael Walsh6741f742017-02-20 16:16:38 -0600593
594 r"""
Michael Walshc9116812017-03-10 14:23:06 -0600595 Clean up after the Main keyword.
Michael Walsh6741f742017-02-20 16:16:38 -0600596 """
597
598 if cp_setup_called:
599 plug_in_setup()
600 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
601 call_point='cleanup', stop_on_plug_in_failure=1)
602
Michael Walsh0b93fbf2017-03-02 14:42:41 -0600603 # Save boot_results object to a file in case it is needed again.
604 grp.rprint_timen("Saving boot_results to the following path.")
605 grp.rprint_var(boot_results_file_path)
606 pickle.dump(boot_results, open(boot_results_file_path, 'wb'),
607 pickle.HIGHEST_PROTOCOL)
608
Michael Walsh6741f742017-02-20 16:16:38 -0600609###############################################################################
610
611
612###############################################################################
Michael Walshc9116812017-03-10 14:23:06 -0600613def test_teardown():
614
615 r"""
616 Clean up after this test case.
617 """
618
619 gp.qprintn()
620 cmd_buf = ["Print Error",
621 "A keyword timeout occurred ending this program.\n"]
622 BuiltIn().run_keyword_if_timeout_occurred(*cmd_buf)
623
624###############################################################################
625
626
627###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600628def main_py():
629
630 r"""
631 Do main program processing.
632 """
633
634 setup()
635
636 # Process caller's boot_stack.
637 while (len(boot_stack) > 0):
638 test_loop_body()
639
Michael Walsh30dadae2017-02-27 14:25:52 -0600640 grp.rprint_timen("Finished processing stack.")
641
Michael Walsh6741f742017-02-20 16:16:38 -0600642 # Process caller's boot_list.
643 if len(boot_list) > 0:
644 for ix in range(1, max_num_tests + 1):
645 test_loop_body()
646
647 grp.rqprint_timen("Completed all requested boot tests.")
648
649###############################################################################