blob: 265d7eec7e0e7b6c841599011bd220f416191966 [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
Michael Walsh0ad0f7f2017-05-04 14:39:58 -050012import re
Michael Walsh0b93fbf2017-03-02 14:42:41 -060013import cPickle as pickle
Michael Walshdc80d672017-05-09 12:58:32 -050014import socket
Michael Walsh0b93fbf2017-03-02 14:42:41 -060015
16from robot.utils import DotDict
17from robot.libraries.BuiltIn import BuiltIn
18
Michael Walsh6741f742017-02-20 16:16:38 -060019from boot_data import *
Michael Walshc9116812017-03-10 14:23:06 -060020import gen_print as gp
Michael Walsh0bbd8602016-11-22 11:31:49 -060021import gen_robot_print as grp
Michael Walsh55302292017-01-10 11:43:02 -060022import gen_robot_plug_in as grpi
Michael Walsh6741f742017-02-20 16:16:38 -060023import gen_robot_valid as grv
24import gen_misc as gm
25import gen_cmd as gc
Michael Walshb5839d02017-04-12 16:11:20 -050026import gen_robot_keyword as grk
Michael Walsh55302292017-01-10 11:43:02 -060027import state as st
Michael Walsh0bbd8602016-11-22 11:31:49 -060028
Michael Walsh0b93fbf2017-03-02 14:42:41 -060029base_path = os.path.dirname(os.path.dirname(
30 imp.find_module("gen_robot_print")[1])) +\
Michael Walshc9116812017-03-10 14:23:06 -060031 os.sep
Michael Walsh0b93fbf2017-03-02 14:42:41 -060032sys.path.append(base_path + "extended/")
33import run_keyword as rk
Michael Walsh0bbd8602016-11-22 11:31:49 -060034
Michael Walshe1e26442017-03-06 17:50:07 -060035# Setting master_pid correctly influences the behavior of plug-ins like
36# DB_Logging
37program_pid = os.getpid()
38master_pid = os.environ.get('AUTOBOOT_MASTER_PID', program_pid)
39
Michael Walshb5839d02017-04-12 16:11:20 -050040# Set up boot data structures.
41boot_table = create_boot_table()
42valid_boot_types = create_valid_boot_list(boot_table)
Michael Walsh0b93fbf2017-03-02 14:42:41 -060043
Michael Walsh6741f742017-02-20 16:16:38 -060044boot_lists = read_boot_lists()
45last_ten = []
Michael Walsh6741f742017-02-20 16:16:38 -060046
47state = st.return_default_state()
48cp_setup_called = 0
49next_boot = ""
50base_tool_dir_path = os.path.normpath(os.environ.get(
51 'AUTOBOOT_BASE_TOOL_DIR_PATH', "/tmp")) + os.sep
Michael Walshb5839d02017-04-12 16:11:20 -050052
Michael Walsh6741f742017-02-20 16:16:38 -060053ffdc_dir_path = os.path.normpath(os.environ.get('FFDC_DIR_PATH', '')) + os.sep
Michael Walsh6741f742017-02-20 16:16:38 -060054boot_success = 0
Michael Walsh6741f742017-02-20 16:16:38 -060055status_dir_path = os.environ.get('STATUS_DIR_PATH', "")
56if status_dir_path != "":
57 status_dir_path = os.path.normpath(status_dir_path) + os.sep
Michael Walsh0b93fbf2017-03-02 14:42:41 -060058default_power_on = "REST Power On"
59default_power_off = "REST Power Off"
Michael Walsh6741f742017-02-20 16:16:38 -060060boot_count = 0
Michael Walsh0bbd8602016-11-22 11:31:49 -060061
Michael Walsh85678942017-03-27 14:34:22 -050062LOG_LEVEL = BuiltIn().get_variable_value("${LOG_LEVEL}")
Michael Walshe1974b92017-08-03 13:39:51 -050063ffdc_prefix = ""
Sunil M325eb542017-08-10 07:09:43 -050064boot_start_time = ""
65boot_end_time = ""
Michael Walsh85678942017-03-27 14:34:22 -050066
67
68###############################################################################
Michael Walsh0ad0f7f2017-05-04 14:39:58 -050069def process_host(host,
70 host_var_name=""):
71
72 r"""
73 Process a host by getting the associated host name and IP address and
74 setting them in global variables.
75
76 If the caller does not pass the host_var_name, this function will try to
77 figure out the name of the variable used by the caller for the host parm.
78 Callers are advised to explicitly specify the host_var_name when calling
79 with an exec command. In such cases, the get_arg_name cannot figure out
80 the host variable name.
81
82 This function will then create similar global variable names by
83 removing "_host" and appending "_host_name" or "_ip" to the host variable
84 name.
85
86 Example:
87
88 If a call is made like this:
89 process_host(openbmc_host)
90
91 Global variables openbmc_host_name and openbmc_ip will be set.
92
93 Description of argument(s):
94 host A host name or IP. The name of the variable used should
95 have a suffix of "_host".
96 host_var_name The name of the variable being used as the host parm.
97 """
98
99 if host_var_name == "":
100 host_var_name = gp.get_arg_name(0, 1, stack_frame_ix=2)
101
102 host_name_var_name = re.sub("host", "host_name", host_var_name)
103 ip_var_name = re.sub("host", "ip", host_var_name)
104 cmd_buf = "global " + host_name_var_name + ", " + ip_var_name + " ; " +\
105 host_name_var_name + ", " + ip_var_name + " = gm.get_host_name_ip('" +\
106 host + "')"
107 exec(cmd_buf)
108
109###############################################################################
110
111
112###############################################################################
Michael Walshb5839d02017-04-12 16:11:20 -0500113def process_pgm_parms():
114
115 r"""
116 Process the program parameters by assigning them all to corresponding
117 globals. Also, set some global values that depend on program parameters.
118 """
119
120 # Program parameter processing.
121 # Assign all program parms to python variables which are global to this
122 # module.
123
124 global parm_list
125 parm_list = BuiltIn().get_variable_value("${parm_list}")
126 # The following subset of parms should be processed as integers.
127 int_list = ['max_num_tests', 'boot_pass', 'boot_fail', 'ffdc_only',
128 'boot_fail_threshold', 'quiet', 'test_mode', 'debug']
129 for parm in parm_list:
130 if parm in int_list:
131 sub_cmd = "int(BuiltIn().get_variable_value(\"${" + parm +\
132 "}\", \"0\"))"
133 else:
134 sub_cmd = "BuiltIn().get_variable_value(\"${" + parm + "}\")"
135 cmd_buf = "global " + parm + " ; " + parm + " = " + sub_cmd
136 exec(cmd_buf)
Michael Walsh0ad0f7f2017-05-04 14:39:58 -0500137 if re.match(r".*_host$", parm):
138 cmd_buf = "process_host(" + parm + ", '" + parm + "')"
139 exec(cmd_buf)
140 if re.match(r".*_password$", parm):
141 # Register the value of any parm whose name ends in _password.
142 # This will cause the print functions to replace passwords with
143 # asterisks in the output.
144 cmd_buf = "gp.register_passwords(" + parm + ")"
145 exec(cmd_buf)
Michael Walshb5839d02017-04-12 16:11:20 -0500146
147 global ffdc_dir_path_style
148 global boot_list
149 global boot_stack
150 global boot_results_file_path
151 global boot_results
152 global ffdc_list_file_path
Michael Walshe0cf8d72017-05-17 13:20:46 -0500153 global ffdc_report_list_path
Michael Walsh600876d2017-05-30 17:58:58 -0500154 global ffdc_summary_list_path
Michael Walshb5839d02017-04-12 16:11:20 -0500155
156 if ffdc_dir_path_style == "":
157 ffdc_dir_path_style = int(os.environ.get('FFDC_DIR_PATH_STYLE', '0'))
158
159 # Convert these program parms to lists for easier processing..
160 boot_list = filter(None, boot_list.split(":"))
161 boot_stack = filter(None, boot_stack.split(":"))
162
163 boot_results_file_path = "/tmp/" + openbmc_nickname + ":pid_" +\
164 str(master_pid) + ":boot_results"
165
166 if os.path.isfile(boot_results_file_path):
167 # We've been called before in this run so we'll load the saved
168 # boot_results object.
169 boot_results = pickle.load(open(boot_results_file_path, 'rb'))
170 else:
171 boot_results = boot_results(boot_table, boot_pass, boot_fail)
172
173 ffdc_list_file_path = base_tool_dir_path + openbmc_nickname +\
174 "/FFDC_FILE_LIST"
Michael Walshe0cf8d72017-05-17 13:20:46 -0500175 ffdc_report_list_path = base_tool_dir_path + openbmc_nickname +\
176 "/FFDC_REPORT_FILE_LIST"
Michael Walshb5839d02017-04-12 16:11:20 -0500177
Michael Walsh600876d2017-05-30 17:58:58 -0500178 ffdc_summary_list_path = base_tool_dir_path + openbmc_nickname +\
179 "/FFDC_SUMMARY_FILE_LIST"
180
Michael Walshb5839d02017-04-12 16:11:20 -0500181###############################################################################
182
183
184###############################################################################
Michael Walsh85678942017-03-27 14:34:22 -0500185def initial_plug_in_setup():
186
187 r"""
188 Initialize all plug-in environment variables which do not change for the
189 duration of the program.
190
191 """
192
193 global LOG_LEVEL
194 BuiltIn().set_log_level("NONE")
195
196 BuiltIn().set_global_variable("${master_pid}", master_pid)
197 BuiltIn().set_global_variable("${FFDC_DIR_PATH}", ffdc_dir_path)
198 BuiltIn().set_global_variable("${STATUS_DIR_PATH}", status_dir_path)
199 BuiltIn().set_global_variable("${BASE_TOOL_DIR_PATH}", base_tool_dir_path)
200 BuiltIn().set_global_variable("${FFDC_LIST_FILE_PATH}",
201 ffdc_list_file_path)
Michael Walshe0cf8d72017-05-17 13:20:46 -0500202 BuiltIn().set_global_variable("${FFDC_REPORT_LIST_PATH}",
203 ffdc_report_list_path)
Michael Walsh600876d2017-05-30 17:58:58 -0500204 BuiltIn().set_global_variable("${FFDC_SUMMARY_LIST_PATH}",
205 ffdc_summary_list_path)
Michael Walsh85678942017-03-27 14:34:22 -0500206
207 BuiltIn().set_global_variable("${FFDC_DIR_PATH_STYLE}",
208 ffdc_dir_path_style)
209 BuiltIn().set_global_variable("${FFDC_CHECK}",
210 ffdc_check)
211
212 # For each program parameter, set the corresponding AUTOBOOT_ environment
213 # variable value. Also, set an AUTOBOOT_ environment variable for every
214 # element in additional_values.
215 additional_values = ["program_pid", "master_pid", "ffdc_dir_path",
216 "status_dir_path", "base_tool_dir_path",
Michael Walsh600876d2017-05-30 17:58:58 -0500217 "ffdc_list_file_path", "ffdc_report_list_path",
218 "ffdc_summary_list_path"]
Michael Walsh85678942017-03-27 14:34:22 -0500219
220 plug_in_vars = parm_list + additional_values
221
222 for var_name in plug_in_vars:
223 var_value = BuiltIn().get_variable_value("${" + var_name + "}")
224 var_name = var_name.upper()
225 if var_value is None:
226 var_value = ""
227 os.environ["AUTOBOOT_" + var_name] = str(var_value)
228
229 BuiltIn().set_log_level(LOG_LEVEL)
230
Michael Walsh68a61162017-04-25 11:54:06 -0500231 # Make sure the ffdc list directory exists.
232 ffdc_list_dir_path = os.path.dirname(ffdc_list_file_path) + os.sep
233 if not os.path.exists(ffdc_list_dir_path):
234 os.makedirs(ffdc_list_dir_path)
Michael Walsh85678942017-03-27 14:34:22 -0500235
236###############################################################################
237
Michael Walsh0bbd8602016-11-22 11:31:49 -0600238
239###############################################################################
Michael Walsh0bbd8602016-11-22 11:31:49 -0600240def plug_in_setup():
241
242 r"""
Michael Walsh85678942017-03-27 14:34:22 -0500243 Initialize all changing plug-in environment variables for use by the
244 plug-in programs.
Michael Walsh0bbd8602016-11-22 11:31:49 -0600245 """
246
Michael Walsh85678942017-03-27 14:34:22 -0500247 global LOG_LEVEL
248 global test_really_running
249
250 BuiltIn().set_log_level("NONE")
251
Michael Walsh6741f742017-02-20 16:16:38 -0600252 boot_pass, boot_fail = boot_results.return_total_pass_fail()
Michael Walsh0bbd8602016-11-22 11:31:49 -0600253 if boot_pass > 1:
254 test_really_running = 1
255 else:
256 test_really_running = 0
257
Michael Walsh6741f742017-02-20 16:16:38 -0600258 BuiltIn().set_global_variable("${test_really_running}",
259 test_really_running)
260 BuiltIn().set_global_variable("${boot_type_desc}", next_boot)
Michael Walsh6741f742017-02-20 16:16:38 -0600261 BuiltIn().set_global_variable("${boot_pass}", boot_pass)
262 BuiltIn().set_global_variable("${boot_fail}", boot_fail)
263 BuiltIn().set_global_variable("${boot_success}", boot_success)
264 BuiltIn().set_global_variable("${ffdc_prefix}", ffdc_prefix)
Sunil M325eb542017-08-10 07:09:43 -0500265 BuiltIn().set_global_variable("${boot_start_time}", boot_start_time)
266 BuiltIn().set_global_variable("${boot_end_time}", boot_end_time)
Michael Walsh4c9a6452016-12-13 16:03:11 -0600267
Michael Walsh0bbd8602016-11-22 11:31:49 -0600268 # For each program parameter, set the corresponding AUTOBOOT_ environment
269 # variable value. Also, set an AUTOBOOT_ environment variable for every
270 # element in additional_values.
271 additional_values = ["boot_type_desc", "boot_success", "boot_pass",
Sunil M325eb542017-08-10 07:09:43 -0500272 "boot_fail", "test_really_running", "ffdc_prefix",
273 "boot_start_time", "boot_end_time"]
Michael Walsh0bbd8602016-11-22 11:31:49 -0600274
Michael Walsh85678942017-03-27 14:34:22 -0500275 plug_in_vars = additional_values
Michael Walsh0bbd8602016-11-22 11:31:49 -0600276
277 for var_name in plug_in_vars:
278 var_value = BuiltIn().get_variable_value("${" + var_name + "}")
279 var_name = var_name.upper()
280 if var_value is None:
281 var_value = ""
Michael Walsh6741f742017-02-20 16:16:38 -0600282 os.environ["AUTOBOOT_" + var_name] = str(var_value)
Michael Walsh0bbd8602016-11-22 11:31:49 -0600283
Michael Walsh0bbd8602016-11-22 11:31:49 -0600284 if debug:
Michael Walsh6741f742017-02-20 16:16:38 -0600285 shell_rc, out_buf = \
286 gc.cmd_fnc_u("printenv | egrep AUTOBOOT_ | sort -u")
Michael Walsh0bbd8602016-11-22 11:31:49 -0600287
Michael Walsh85678942017-03-27 14:34:22 -0500288 BuiltIn().set_log_level(LOG_LEVEL)
289
Michael Walsh0bbd8602016-11-22 11:31:49 -0600290###############################################################################
291
292
293###############################################################################
Michael Walshe0cf8d72017-05-17 13:20:46 -0500294def pre_boot_plug_in_setup():
295
296 # Clear the ffdc_list_file_path file. Plug-ins may now write to it.
297 try:
298 os.remove(ffdc_list_file_path)
299 except OSError:
300 pass
301
302 # Clear the ffdc_report_list_path file. Plug-ins may now write to it.
303 try:
304 os.remove(ffdc_report_list_path)
305 except OSError:
306 pass
307
Michael Walsh600876d2017-05-30 17:58:58 -0500308 # Clear the ffdc_summary_list_path file. Plug-ins may now write to it.
309 try:
310 os.remove(ffdc_summary_list_path)
311 except OSError:
312 pass
313
Michael Walshe1974b92017-08-03 13:39:51 -0500314 global ffdc_prefix
315
316 seconds = time.time()
317 loc_time = time.localtime(seconds)
318 time_string = time.strftime("%y%m%d.%H%M%S.", loc_time)
319
320 ffdc_prefix = openbmc_nickname + "." + time_string
321
Michael Walshe0cf8d72017-05-17 13:20:46 -0500322###############################################################################
323
324
325###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600326def setup():
Michael Walsh0bbd8602016-11-22 11:31:49 -0600327
328 r"""
Michael Walsh6741f742017-02-20 16:16:38 -0600329 Do general program setup tasks.
Michael Walsh0bbd8602016-11-22 11:31:49 -0600330 """
331
Michael Walsh6741f742017-02-20 16:16:38 -0600332 global cp_setup_called
Michael Walsh0bbd8602016-11-22 11:31:49 -0600333
Michael Walshb5839d02017-04-12 16:11:20 -0500334 gp.qprintn()
335
Michael Walsh83f4bc72017-04-20 16:49:43 -0500336 robot_pgm_dir_path = os.path.dirname(__file__) + os.sep
337 repo_bin_path = robot_pgm_dir_path.replace("/lib/", "/bin/")
Michael Walshd061c042017-05-23 14:46:57 -0500338 # If we can't find process_plug_in_packages.py, ssh_pw or
339 # validate_plug_ins.py, then we don't have our repo bin in PATH.
340 shell_rc, out_buf = gc.cmd_fnc_u("which process_plug_in_packages.py" +
341 " ssh_pw validate_plug_ins.py", quiet=1,
342 print_output=0, show_err=0)
Michael Walshb5839d02017-04-12 16:11:20 -0500343 if shell_rc != 0:
Michael Walsh83f4bc72017-04-20 16:49:43 -0500344 os.environ['PATH'] = repo_bin_path + ":" + os.environ.get('PATH', "")
345 # Likewise, our repo lib subdir needs to be in sys.path and PYTHONPATH.
346 if robot_pgm_dir_path not in sys.path:
347 sys.path.append(robot_pgm_dir_path)
348 PYTHONPATH = os.environ.get("PYTHONPATH", "")
349 if PYTHONPATH == "":
350 os.environ['PYTHONPATH'] = robot_pgm_dir_path
351 else:
352 os.environ['PYTHONPATH'] = robot_pgm_dir_path + ":" + PYTHONPATH
Michael Walsh6741f742017-02-20 16:16:38 -0600353
354 validate_parms()
355
356 grp.rqprint_pgm_header()
357
Michael Walshfdc5ced2017-08-17 13:15:15 -0500358 grk.run_key("Set BMC Power Policy RESTORE_LAST_STATE")
Michael Walsh11cfc8c2017-03-31 09:40:55 -0500359
Michael Walsh85678942017-03-27 14:34:22 -0500360 initial_plug_in_setup()
361
Michael Walsh6741f742017-02-20 16:16:38 -0600362 plug_in_setup()
363 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
364 call_point='setup')
365 if rc != 0:
366 error_message = "Plug-in setup failed.\n"
367 grp.rprint_error_report(error_message)
368 BuiltIn().fail(error_message)
369 # Setting cp_setup_called lets our Teardown know that it needs to call
370 # the cleanup plug-in call point.
371 cp_setup_called = 1
372
373 # Keyword "FFDC" will fail if TEST_MESSAGE is not set.
374 BuiltIn().set_global_variable("${TEST_MESSAGE}", "${EMPTY}")
Michael Walsh85678942017-03-27 14:34:22 -0500375 # FFDC_LOG_PATH is used by "FFDC" keyword.
376 BuiltIn().set_global_variable("${FFDC_LOG_PATH}", ffdc_dir_path)
Michael Walsh6741f742017-02-20 16:16:38 -0600377
Michael Walshdc80d672017-05-09 12:58:32 -0500378 # Also printed by FFDC.
379 global host_name
380 global host_ip
381 host = socket.gethostname()
382 host_name, host_ip = gm.get_host_name_ip(host)
383
Michael Walshb5839d02017-04-12 16:11:20 -0500384 gp.dprint_var(boot_table, 1)
385 gp.dprint_var(boot_lists)
Michael Walsh0bbd8602016-11-22 11:31:49 -0600386
387###############################################################################
388
389
390###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600391def validate_parms():
Michael Walsh0bbd8602016-11-22 11:31:49 -0600392
393 r"""
Michael Walsh6741f742017-02-20 16:16:38 -0600394 Validate all program parameters.
Michael Walsh0bbd8602016-11-22 11:31:49 -0600395 """
396
Michael Walshb5839d02017-04-12 16:11:20 -0500397 process_pgm_parms()
Michael Walsh0bbd8602016-11-22 11:31:49 -0600398
Michael Walshb5839d02017-04-12 16:11:20 -0500399 gp.qprintn()
400
401 global openbmc_model
Michael Walsh6741f742017-02-20 16:16:38 -0600402 grv.rvalid_value("openbmc_host")
403 grv.rvalid_value("openbmc_username")
404 grv.rvalid_value("openbmc_password")
405 if os_host != "":
406 grv.rvalid_value("os_username")
407 grv.rvalid_value("os_password")
Michael Walsh0bbd8602016-11-22 11:31:49 -0600408
Michael Walsh6741f742017-02-20 16:16:38 -0600409 if pdu_host != "":
410 grv.rvalid_value("pdu_username")
411 grv.rvalid_value("pdu_password")
Michael Walsh85678942017-03-27 14:34:22 -0500412 grv.rvalid_integer("pdu_slot_no")
Michael Walsh6741f742017-02-20 16:16:38 -0600413 if openbmc_serial_host != "":
414 grv.rvalid_integer("openbmc_serial_port")
Michael Walshb5839d02017-04-12 16:11:20 -0500415 if openbmc_model == "":
416 status, ret_values =\
417 grk.run_key_u("Get BMC System Model")
418 openbmc_model = ret_values
419 BuiltIn().set_global_variable("${openbmc_model}", openbmc_model)
Michael Walsh6741f742017-02-20 16:16:38 -0600420 grv.rvalid_value("openbmc_model")
Michael Walshb5839d02017-04-12 16:11:20 -0500421 grv.rvalid_integer("max_num_tests")
Michael Walsh6741f742017-02-20 16:16:38 -0600422 grv.rvalid_integer("boot_pass")
423 grv.rvalid_integer("boot_fail")
424
425 plug_in_packages_list = grpi.rvalidate_plug_ins(plug_in_dir_paths)
426 BuiltIn().set_global_variable("${plug_in_packages_list}",
427 plug_in_packages_list)
428
Michael Walshb5839d02017-04-12 16:11:20 -0500429 grv.rvalid_value("stack_mode", valid_values=['normal', 'skip'])
Michael Walsha20da402017-03-31 16:27:45 -0500430 if len(boot_list) == 0 and len(boot_stack) == 0 and not ffdc_only:
Michael Walsh6741f742017-02-20 16:16:38 -0600431 error_message = "You must provide either a value for either the" +\
432 " boot_list or the boot_stack parm.\n"
433 BuiltIn().fail(gp.sprint_error(error_message))
434
435 valid_boot_list(boot_list, valid_boot_types)
436 valid_boot_list(boot_stack, valid_boot_types)
437
Michael Walsh11cfc8c2017-03-31 09:40:55 -0500438 selected_PDU_boots = list(set(boot_list + boot_stack) &
439 set(boot_lists['PDU_reboot']))
440
441 if len(selected_PDU_boots) > 0 and pdu_host == "":
442 error_message = "You have selected the following boots which" +\
443 " require a PDU host but no value for pdu_host:\n"
444 error_message += gp.sprint_var(selected_PDU_boots)
445 error_message += gp.sprint_var(pdu_host, 2)
446 BuiltIn().fail(gp.sprint_error(error_message))
447
Michael Walsh6741f742017-02-20 16:16:38 -0600448 return
Michael Walsh0bbd8602016-11-22 11:31:49 -0600449
450###############################################################################
451
452
453###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600454def my_get_state():
Michael Walsh0bbd8602016-11-22 11:31:49 -0600455
456 r"""
Michael Walsh6741f742017-02-20 16:16:38 -0600457 Get the system state plus a little bit of wrapping.
Michael Walsh0bbd8602016-11-22 11:31:49 -0600458 """
459
Michael Walsh6741f742017-02-20 16:16:38 -0600460 global state
461
462 req_states = ['epoch_seconds'] + st.default_req_states
463
Michael Walshb5839d02017-04-12 16:11:20 -0500464 gp.qprint_timen("Getting system state.")
Michael Walsh6741f742017-02-20 16:16:38 -0600465 if test_mode:
466 state['epoch_seconds'] = int(time.time())
467 else:
Michael Walshb5839d02017-04-12 16:11:20 -0500468 state = st.get_state(req_states=req_states, quiet=quiet)
469 gp.qprint_var(state)
Michael Walsh341c21e2017-01-17 16:25:20 -0600470
471###############################################################################
472
473
474###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600475def select_boot():
Michael Walsh341c21e2017-01-17 16:25:20 -0600476
477 r"""
478 Select a boot test to be run based on our current state and return the
479 chosen boot type.
480
481 Description of arguments:
Michael Walsh6741f742017-02-20 16:16:38 -0600482 state The state of the machine.
Michael Walsh341c21e2017-01-17 16:25:20 -0600483 """
484
Michael Walsh30dadae2017-02-27 14:25:52 -0600485 global boot_stack
486
Michael Walshb5839d02017-04-12 16:11:20 -0500487 gp.qprint_timen("Selecting a boot test.")
Michael Walsh6741f742017-02-20 16:16:38 -0600488
489 my_get_state()
490
491 stack_popped = 0
492 if len(boot_stack) > 0:
493 stack_popped = 1
Michael Walshb5839d02017-04-12 16:11:20 -0500494 gp.qprint_dashes()
495 gp.qprint_var(boot_stack)
496 gp.qprint_dashes()
497 skip_boot_printed = 0
498 while len(boot_stack) > 0:
499 boot_candidate = boot_stack.pop()
500 if stack_mode == 'normal':
501 break
502 else:
503 if st.compare_states(state, boot_table[boot_candidate]['end']):
504 if not skip_boot_printed:
505 gp.print_var(stack_mode)
506 gp.printn()
507 gp.print_timen("Skipping the following boot tests" +
508 " which are unnecessary since their" +
509 " required end states match the" +
510 " current machine state:")
511 skip_boot_printed = 1
512 gp.print_var(boot_candidate)
513 boot_candidate = ""
514 if boot_candidate == "":
515 gp.qprint_dashes()
516 gp.qprint_var(boot_stack)
517 gp.qprint_dashes()
518 return boot_candidate
Michael Walsh6741f742017-02-20 16:16:38 -0600519 if st.compare_states(state, boot_table[boot_candidate]['start']):
Michael Walshb5839d02017-04-12 16:11:20 -0500520 gp.qprint_timen("The machine state is valid for a '" +
521 boot_candidate + "' boot test.")
522 gp.qprint_dashes()
523 gp.qprint_var(boot_stack)
524 gp.qprint_dashes()
Michael Walsh6741f742017-02-20 16:16:38 -0600525 return boot_candidate
Michael Walsh341c21e2017-01-17 16:25:20 -0600526 else:
Michael Walshb5839d02017-04-12 16:11:20 -0500527 gp.qprint_timen("The machine state does not match the required" +
528 " starting state for a '" + boot_candidate +
529 "' boot test:")
530 gp.print_varx("boot_table[" + boot_candidate + "][start]",
531 boot_table[boot_candidate]['start'], 1)
Michael Walsh6741f742017-02-20 16:16:38 -0600532 boot_stack.append(boot_candidate)
533 popped_boot = boot_candidate
534
535 # Loop through your list selecting a boot_candidates
536 boot_candidates = []
537 for boot_candidate in boot_list:
538 if st.compare_states(state, boot_table[boot_candidate]['start']):
539 if stack_popped:
540 if st.compare_states(boot_table[boot_candidate]['end'],
541 boot_table[popped_boot]['start']):
542 boot_candidates.append(boot_candidate)
543 else:
544 boot_candidates.append(boot_candidate)
545
546 if len(boot_candidates) == 0:
Michael Walshb5839d02017-04-12 16:11:20 -0500547 gp.qprint_timen("The user's boot list contained no boot tests" +
548 " which are valid for the current machine state.")
Michael Walsh6741f742017-02-20 16:16:38 -0600549 boot_candidate = default_power_on
550 if not st.compare_states(state, boot_table[default_power_on]['start']):
551 boot_candidate = default_power_off
552 boot_candidates.append(boot_candidate)
Michael Walshb5839d02017-04-12 16:11:20 -0500553 gp.qprint_timen("Using default '" + boot_candidate +
554 "' boot type to transition to valid state.")
Michael Walsh6741f742017-02-20 16:16:38 -0600555
Michael Walshb5839d02017-04-12 16:11:20 -0500556 gp.dprint_var(boot_candidates)
Michael Walsh6741f742017-02-20 16:16:38 -0600557
558 # Randomly select a boot from the candidate list.
559 boot = random.choice(boot_candidates)
Michael Walsh341c21e2017-01-17 16:25:20 -0600560
561 return boot
Michael Walsh0bbd8602016-11-22 11:31:49 -0600562
563###############################################################################
Michael Walsh55302292017-01-10 11:43:02 -0600564
565
566###############################################################################
Michael Walsh341c21e2017-01-17 16:25:20 -0600567def print_last_boots():
568
569 r"""
570 Print the last ten boots done with their time stamps.
571 """
572
573 # indent 0, 90 chars wide, linefeed, char is "="
Michael Walshb5839d02017-04-12 16:11:20 -0500574 gp.qprint_dashes(0, 90)
575 gp.qprintn("Last 10 boots:\n")
Michael Walsh341c21e2017-01-17 16:25:20 -0600576
577 for boot_entry in last_ten:
578 grp.rqprint(boot_entry)
Michael Walshb5839d02017-04-12 16:11:20 -0500579 gp.qprint_dashes(0, 90)
Michael Walsh341c21e2017-01-17 16:25:20 -0600580
581###############################################################################
582
583
584###############################################################################
Michael Walsh341c21e2017-01-17 16:25:20 -0600585def print_defect_report():
586
587 r"""
588 Print a defect report.
589 """
590
Michael Walsh600876d2017-05-30 17:58:58 -0500591 # Making deliberate choice to NOT run plug_in_setup(). We don't want
592 # ffdc_prefix updated.
593 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
594 call_point='ffdc_report', stop_on_plug_in_failure=0)
595
Michael Walsh341c21e2017-01-17 16:25:20 -0600596 # At some point I'd like to have the 'Call FFDC Methods' return a list
597 # of files it has collected. In that case, the following "ls" command
598 # would no longer be needed. For now, however, glob shows the files
599 # named in FFDC_LIST_FILE_PATH so I will refrain from printing those
600 # out (so we don't see duplicates in the list).
601
Michael Walshe0cf8d72017-05-17 13:20:46 -0500602 # Get additional header data which may have been created by ffdc plug-ins.
603 # Also, delete the individual header files to cleanup.
604 cmd_buf = "file_list=$(cat " + ffdc_report_list_path + " 2>/dev/null)" +\
605 " ; [ ! -z \"${file_list}\" ] && cat ${file_list}" +\
606 " 2>/dev/null ; rm -rf ${file_list} 2>/dev/null || :"
607 shell_rc, more_header_info = gc.cmd_fnc_u(cmd_buf, print_output=0,
608 show_err=0)
609
Michael Walsh600876d2017-05-30 17:58:58 -0500610 # Get additional header data which may have been created by ffdc plug-ins.
611 # Also, delete the individual header files to cleanup.
612 cmd_buf = "file_list=$(cat " + ffdc_summary_list_path + " 2>/dev/null)" +\
613 " ; [ ! -z \"${file_list}\" ] && cat ${file_list}" +\
614 " 2>/dev/null ; rm -rf ${file_list} 2>/dev/null || :"
615 shell_rc, ffdc_summary_info = gc.cmd_fnc_u(cmd_buf, print_output=0,
616 show_err=0)
617
Michael Walsh341c21e2017-01-17 16:25:20 -0600618 LOG_PREFIX = BuiltIn().get_variable_value("${LOG_PREFIX}")
619
Michael Walshe0cf8d72017-05-17 13:20:46 -0500620 output = '\n'.join(sorted(glob.glob(LOG_PREFIX + '*')))
Michael Walsh341c21e2017-01-17 16:25:20 -0600621 try:
Michael Walsh6741f742017-02-20 16:16:38 -0600622 ffdc_list = open(ffdc_list_file_path, 'r')
Michael Walsh341c21e2017-01-17 16:25:20 -0600623 except IOError:
624 ffdc_list = ""
625
Michael Walsh68a61162017-04-25 11:54:06 -0500626 # Open ffdc_file_list for writing. We will write a complete list of
627 # FFDC files to it for possible use by plug-ins like cp_stop_check.
628 ffdc_list_file = open(ffdc_list_file_path, 'w')
629
630 gp.qprintn()
631 # indent=0, width=90, linefeed=1, char="="
632 gp.qprint_dashes(0, 90, 1, "=")
633 gp.qprintn("Copy this data to the defect:\n")
634
Michael Walshe0cf8d72017-05-17 13:20:46 -0500635 if len(more_header_info) > 0:
636 gp.printn(more_header_info)
Michael Walshdc80d672017-05-09 12:58:32 -0500637 gp.qpvars(host_name, host_ip, openbmc_nickname, openbmc_host,
638 openbmc_host_name, openbmc_ip, openbmc_username,
639 openbmc_password, os_host, os_host_name, os_ip, os_username,
640 os_password, pdu_host, pdu_host_name, pdu_ip, pdu_username,
641 pdu_password, pdu_slot_no, openbmc_serial_host,
642 openbmc_serial_host_name, openbmc_serial_ip, openbmc_serial_port)
Michael Walsh68a61162017-04-25 11:54:06 -0500643
644 gp.qprintn()
645
646 print_last_boots()
647 gp.qprintn()
648 gp.qprint_var(state)
649
Michael Walshb5839d02017-04-12 16:11:20 -0500650 gp.qprintn()
651 gp.qprintn("FFDC data files:")
Michael Walsh341c21e2017-01-17 16:25:20 -0600652 if status_file_path != "":
Michael Walshb5839d02017-04-12 16:11:20 -0500653 gp.qprintn(status_file_path)
Michael Walsh68a61162017-04-25 11:54:06 -0500654 ffdc_list_file.write(status_file_path + "\n")
Michael Walsh341c21e2017-01-17 16:25:20 -0600655
Michael Walshb5839d02017-04-12 16:11:20 -0500656 gp.qprintn(output)
657 # gp.qprintn(ffdc_list)
658 gp.qprintn()
Michael Walsh341c21e2017-01-17 16:25:20 -0600659
Michael Walsh600876d2017-05-30 17:58:58 -0500660 if len(ffdc_summary_info) > 0:
661 gp.printn(ffdc_summary_info)
662
Michael Walshb5839d02017-04-12 16:11:20 -0500663 gp.qprint_dashes(0, 90, 1, "=")
Michael Walsh341c21e2017-01-17 16:25:20 -0600664
Michael Walsh68a61162017-04-25 11:54:06 -0500665 ffdc_list_file.write(output + "\n")
666 ffdc_list_file.close()
667
Michael Walsh341c21e2017-01-17 16:25:20 -0600668###############################################################################
Michael Walsh6741f742017-02-20 16:16:38 -0600669
670
671###############################################################################
672def my_ffdc():
673
674 r"""
675 Collect FFDC data.
676 """
677
678 global state
679
680 plug_in_setup()
681 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
Michael Walsh600876d2017-05-30 17:58:58 -0500682 call_point='ffdc', stop_on_plug_in_failure=0)
Michael Walsh6741f742017-02-20 16:16:38 -0600683
684 AUTOBOOT_FFDC_PREFIX = os.environ['AUTOBOOT_FFDC_PREFIX']
Michael Walsh83f4bc72017-04-20 16:49:43 -0500685 status, ret_values = grk.run_key_u("FFDC ffdc_prefix=" +
686 AUTOBOOT_FFDC_PREFIX +
687 " ffdc_function_list=" +
688 ffdc_function_list, ignore=1)
689 if status != 'PASS':
Michael Walsh3328caf2017-03-21 17:04:08 -0500690 gp.print_error("Call to ffdc failed.\n")
Michael Walsh6741f742017-02-20 16:16:38 -0600691
692 my_get_state()
693
694 print_defect_report()
695
696###############################################################################
697
698
699###############################################################################
700def print_test_start_message(boot_keyword):
701
702 r"""
703 Print a message indicating what boot test is about to run.
704
705 Description of arguments:
706 boot_keyword The name of the boot which is to be run
707 (e.g. "BMC Power On").
708 """
709
710 global last_ten
Sunil M325eb542017-08-10 07:09:43 -0500711 global boot_start_time
Michael Walsh6741f742017-02-20 16:16:38 -0600712
713 doing_msg = gp.sprint_timen("Doing \"" + boot_keyword + "\".")
Sunil M325eb542017-08-10 07:09:43 -0500714
715 # Set boot_start_time for use by plug-ins.
716 boot_start_time = doing_msg[1:33]
717 gp.qprint_var(boot_start_time)
718
Michael Walshb5839d02017-04-12 16:11:20 -0500719 gp.qprint(doing_msg)
Michael Walsh6741f742017-02-20 16:16:38 -0600720
721 last_ten.append(doing_msg)
722
723 if len(last_ten) > 10:
724 del last_ten[0]
725
726###############################################################################
727
728
729###############################################################################
730def run_boot(boot):
731
732 r"""
733 Run the specified boot.
734
735 Description of arguments:
736 boot The name of the boot test to be performed.
737 """
738
739 global state
740
741 print_test_start_message(boot)
742
743 plug_in_setup()
744 rc, shell_rc, failed_plug_in_name = \
745 grpi.rprocess_plug_in_packages(call_point="pre_boot")
746 if rc != 0:
747 error_message = "Plug-in failed with non-zero return code.\n" +\
748 gp.sprint_var(rc, 1)
749 BuiltIn().fail(gp.sprint_error(error_message))
750
751 if test_mode:
752 # In test mode, we'll pretend the boot worked by assigning its
753 # required end state to the default state value.
Michael Walsh30dadae2017-02-27 14:25:52 -0600754 state = st.strip_anchor_state(boot_table[boot]['end'])
Michael Walsh6741f742017-02-20 16:16:38 -0600755 else:
756 # Assertion: We trust that the state data was made fresh by the
757 # caller.
758
Michael Walshb5839d02017-04-12 16:11:20 -0500759 gp.qprintn()
Michael Walsh6741f742017-02-20 16:16:38 -0600760
761 if boot_table[boot]['method_type'] == "keyword":
Michael Walsh0b93fbf2017-03-02 14:42:41 -0600762 rk.my_run_keywords(boot_table[boot].get('lib_file_path', ''),
Michael Walshb5839d02017-04-12 16:11:20 -0500763 boot_table[boot]['method'],
764 quiet=quiet)
Michael Walsh6741f742017-02-20 16:16:38 -0600765
766 if boot_table[boot]['bmc_reboot']:
767 st.wait_for_comm_cycle(int(state['epoch_seconds']))
Michael Walsh30dadae2017-02-27 14:25:52 -0600768 plug_in_setup()
769 rc, shell_rc, failed_plug_in_name = \
770 grpi.rprocess_plug_in_packages(call_point="post_reboot")
771 if rc != 0:
Michael Walsh0b93fbf2017-03-02 14:42:41 -0600772 error_message = "Plug-in failed with non-zero return code.\n"
773 error_message += gp.sprint_var(rc, 1)
Michael Walsh30dadae2017-02-27 14:25:52 -0600774 BuiltIn().fail(gp.sprint_error(error_message))
Michael Walsh6741f742017-02-20 16:16:38 -0600775 else:
776 match_state = st.anchor_state(state)
777 del match_state['epoch_seconds']
778 # Wait for the state to change in any way.
779 st.wait_state(match_state, wait_time=state_change_timeout,
Michael Walsh600876d2017-05-30 17:58:58 -0500780 interval="10 seconds", invert=1)
Michael Walsh6741f742017-02-20 16:16:38 -0600781
Michael Walshb5839d02017-04-12 16:11:20 -0500782 gp.qprintn()
Michael Walsh6741f742017-02-20 16:16:38 -0600783 if boot_table[boot]['end']['chassis'] == "Off":
784 boot_timeout = power_off_timeout
785 else:
786 boot_timeout = power_on_timeout
787 st.wait_state(boot_table[boot]['end'], wait_time=boot_timeout,
Michael Walsh600876d2017-05-30 17:58:58 -0500788 interval="10 seconds")
Michael Walsh6741f742017-02-20 16:16:38 -0600789
790 plug_in_setup()
791 rc, shell_rc, failed_plug_in_name = \
792 grpi.rprocess_plug_in_packages(call_point="post_boot")
793 if rc != 0:
794 error_message = "Plug-in failed with non-zero return code.\n" +\
795 gp.sprint_var(rc, 1)
796 BuiltIn().fail(gp.sprint_error(error_message))
797
798###############################################################################
799
800
801###############################################################################
802def test_loop_body():
803
804 r"""
805 The main loop body for the loop in main_py.
806
807 Description of arguments:
808 boot_count The iteration number (starts at 1).
809 """
810
811 global boot_count
812 global state
813 global next_boot
814 global boot_success
Sunil M325eb542017-08-10 07:09:43 -0500815 global boot_end_time
Michael Walsh6741f742017-02-20 16:16:38 -0600816
Michael Walshb5839d02017-04-12 16:11:20 -0500817 gp.qprintn()
Michael Walsh6741f742017-02-20 16:16:38 -0600818
819 next_boot = select_boot()
Michael Walshb5839d02017-04-12 16:11:20 -0500820 if next_boot == "":
821 return True
Michael Walsh6741f742017-02-20 16:16:38 -0600822
Michael Walshb5839d02017-04-12 16:11:20 -0500823 boot_count += 1
824 gp.qprint_timen("Starting boot " + str(boot_count) + ".")
Michael Walsh6741f742017-02-20 16:16:38 -0600825
Michael Walshe0cf8d72017-05-17 13:20:46 -0500826 pre_boot_plug_in_setup()
Michael Walsh6741f742017-02-20 16:16:38 -0600827
828 cmd_buf = ["run_boot", next_boot]
829 boot_status, msg = BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
830 if boot_status == "FAIL":
Michael Walshb5839d02017-04-12 16:11:20 -0500831 gp.qprint(msg)
Michael Walsh6741f742017-02-20 16:16:38 -0600832
Michael Walshb5839d02017-04-12 16:11:20 -0500833 gp.qprintn()
Michael Walsh6741f742017-02-20 16:16:38 -0600834 if boot_status == "PASS":
835 boot_success = 1
Sunil M325eb542017-08-10 07:09:43 -0500836 completion_msg = gp.sprint_time("BOOT_SUCCESS: \"" + next_boot +
837 "\" succeeded.")
Michael Walsh6741f742017-02-20 16:16:38 -0600838 else:
839 boot_success = 0
Sunil M325eb542017-08-10 07:09:43 -0500840 completion_msg = gp.sprint_time("BOOT_FAILED: \"" + next_boot +
841 "\" failed.")
842
843 # Set boot_end_time for use by plug-ins.
844 boot_end_time = completion_msg[1:33]
845 gp.qprint_var(boot_end_time)
846
847 gp.qprint(completion_msg)
Michael Walsh6741f742017-02-20 16:16:38 -0600848
849 boot_results.update(next_boot, boot_status)
850
851 plug_in_setup()
852 # NOTE: A post_test_case call point failure is NOT counted as a boot
853 # failure.
854 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
Michael Walsh600876d2017-05-30 17:58:58 -0500855 call_point='post_test_case', stop_on_plug_in_failure=0)
Michael Walsh6741f742017-02-20 16:16:38 -0600856
857 plug_in_setup()
858 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
859 call_point='ffdc_check', shell_rc=0x00000200,
860 stop_on_plug_in_failure=1, stop_on_non_zero_rc=1)
861 if boot_status != "PASS" or ffdc_check == "All" or shell_rc == 0x00000200:
Michael Walsh83f4bc72017-04-20 16:49:43 -0500862 status, ret_values = grk.run_key_u("my_ffdc", ignore=1)
863 if status != 'PASS':
Michael Walsh3328caf2017-03-21 17:04:08 -0500864 gp.print_error("Call to my_ffdc failed.\n")
Michael Walsh6741f742017-02-20 16:16:38 -0600865
Michael Walshd139f282017-04-04 18:00:23 -0500866 # We need to purge error logs between boots or they build up.
Michael Walshb5839d02017-04-12 16:11:20 -0500867 grk.run_key("Delete Error logs", ignore=1)
Michael Walshd139f282017-04-04 18:00:23 -0500868
Michael Walsh952f9b02017-03-09 13:11:14 -0600869 boot_results.print_report()
Michael Walshb5839d02017-04-12 16:11:20 -0500870 gp.qprint_timen("Finished boot " + str(boot_count) + ".")
Michael Walsh952f9b02017-03-09 13:11:14 -0600871
Michael Walsh6741f742017-02-20 16:16:38 -0600872 plug_in_setup()
873 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
874 call_point='stop_check')
875 if rc != 0:
876 error_message = "Stopping as requested by user.\n"
877 grp.rprint_error_report(error_message)
878 BuiltIn().fail(error_message)
879
Michael Walshd139f282017-04-04 18:00:23 -0500880 # This should help prevent ConnectionErrors.
Michael Walsh0960b382017-06-22 16:23:37 -0500881 grk.run_key_u("Close All Connections")
Michael Walshd139f282017-04-04 18:00:23 -0500882
Michael Walsh6741f742017-02-20 16:16:38 -0600883 return True
884
885###############################################################################
886
887
888###############################################################################
Michael Walsh83f4bc72017-04-20 16:49:43 -0500889def obmc_boot_test_teardown():
Michael Walsh6741f742017-02-20 16:16:38 -0600890
891 r"""
Michael Walshc9116812017-03-10 14:23:06 -0600892 Clean up after the Main keyword.
Michael Walsh6741f742017-02-20 16:16:38 -0600893 """
894
895 if cp_setup_called:
896 plug_in_setup()
897 rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
Michael Walsh600876d2017-05-30 17:58:58 -0500898 call_point='cleanup', stop_on_plug_in_failure=0)
Michael Walsh6741f742017-02-20 16:16:38 -0600899
Michael Walsh600876d2017-05-30 17:58:58 -0500900 if 'boot_results_file_path' in globals():
901 # Save boot_results object to a file in case it is needed again.
902 gp.qprint_timen("Saving boot_results to the following path.")
903 gp.qprint_var(boot_results_file_path)
904 pickle.dump(boot_results, open(boot_results_file_path, 'wb'),
905 pickle.HIGHEST_PROTOCOL)
Michael Walsh0b93fbf2017-03-02 14:42:41 -0600906
Michael Walsh6741f742017-02-20 16:16:38 -0600907###############################################################################
908
909
910###############################################################################
Michael Walshc9116812017-03-10 14:23:06 -0600911def test_teardown():
912
913 r"""
914 Clean up after this test case.
915 """
916
917 gp.qprintn()
918 cmd_buf = ["Print Error",
919 "A keyword timeout occurred ending this program.\n"]
920 BuiltIn().run_keyword_if_timeout_occurred(*cmd_buf)
921
Michael Walshb5839d02017-04-12 16:11:20 -0500922 grp.rqprint_pgm_footer()
923
Michael Walshc9116812017-03-10 14:23:06 -0600924###############################################################################
925
926
927###############################################################################
Michael Walsh83f4bc72017-04-20 16:49:43 -0500928def obmc_boot_test_py(alt_boot_stack=None):
Michael Walsh6741f742017-02-20 16:16:38 -0600929
930 r"""
931 Do main program processing.
932 """
933
Michael Walshb5839d02017-04-12 16:11:20 -0500934 if alt_boot_stack is not None:
935 BuiltIn().set_global_variable("${boot_stack}", alt_boot_stack)
936
Michael Walsh6741f742017-02-20 16:16:38 -0600937 setup()
938
Michael Walsha20da402017-03-31 16:27:45 -0500939 if ffdc_only:
940 gp.qprint_timen("Caller requested ffdc_only.")
Michael Walshe0cf8d72017-05-17 13:20:46 -0500941 pre_boot_plug_in_setup()
Michael Walsh83f4bc72017-04-20 16:49:43 -0500942 grk.run_key_u("my_ffdc")
Michael Walsh764d2f82017-04-27 16:01:08 -0500943 return
Michael Walsha20da402017-03-31 16:27:45 -0500944
Michael Walsh6741f742017-02-20 16:16:38 -0600945 # Process caller's boot_stack.
946 while (len(boot_stack) > 0):
947 test_loop_body()
948
Michael Walshb5839d02017-04-12 16:11:20 -0500949 gp.qprint_timen("Finished processing stack.")
Michael Walsh30dadae2017-02-27 14:25:52 -0600950
Michael Walsh6741f742017-02-20 16:16:38 -0600951 # Process caller's boot_list.
952 if len(boot_list) > 0:
953 for ix in range(1, max_num_tests + 1):
954 test_loop_body()
955
Michael Walshb5839d02017-04-12 16:11:20 -0500956 gp.qprint_timen("Completed all requested boot tests.")
957
958 boot_pass, boot_fail = boot_results.return_total_pass_fail()
959 if boot_fail > boot_fail_threshold:
960 error_message = "Boot failures exceed the boot failure" +\
961 " threshold:\n" +\
962 gp.sprint_var(boot_fail) +\
963 gp.sprint_var(boot_fail_threshold)
964 BuiltIn().fail(gp.sprint_error(error_message))
Michael Walsh6741f742017-02-20 16:16:38 -0600965
966###############################################################################