Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | r""" |
| 4 | This module is the python counterpart to obmc_boot_test. |
| 5 | """ |
| 6 | |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 7 | import os |
| 8 | import imp |
| 9 | import time |
| 10 | import glob |
| 11 | import random |
Michael Walsh | 0ad0f7f | 2017-05-04 14:39:58 -0500 | [diff] [blame] | 12 | import re |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 13 | import cPickle as pickle |
Michael Walsh | dc80d67 | 2017-05-09 12:58:32 -0500 | [diff] [blame] | 14 | import socket |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 15 | |
| 16 | from robot.utils import DotDict |
| 17 | from robot.libraries.BuiltIn import BuiltIn |
| 18 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 19 | from boot_data import * |
Michael Walsh | c911681 | 2017-03-10 14:23:06 -0600 | [diff] [blame] | 20 | import gen_print as gp |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 21 | import gen_robot_print as grp |
Michael Walsh | 5530229 | 2017-01-10 11:43:02 -0600 | [diff] [blame] | 22 | import gen_robot_plug_in as grpi |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 23 | import gen_robot_valid as grv |
| 24 | import gen_misc as gm |
| 25 | import gen_cmd as gc |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 26 | import gen_robot_keyword as grk |
Michael Walsh | 5530229 | 2017-01-10 11:43:02 -0600 | [diff] [blame] | 27 | import state as st |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 28 | import var_stack as vs |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 29 | |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 30 | base_path = os.path.dirname(os.path.dirname( |
| 31 | imp.find_module("gen_robot_print")[1])) +\ |
Michael Walsh | c911681 | 2017-03-10 14:23:06 -0600 | [diff] [blame] | 32 | os.sep |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 33 | sys.path.append(base_path + "extended/") |
| 34 | import run_keyword as rk |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 35 | |
Michael Walsh | e1e2644 | 2017-03-06 17:50:07 -0600 | [diff] [blame] | 36 | # Setting master_pid correctly influences the behavior of plug-ins like |
| 37 | # DB_Logging |
| 38 | program_pid = os.getpid() |
| 39 | master_pid = os.environ.get('AUTOBOOT_MASTER_PID', program_pid) |
Michael Walsh | 903e0b2 | 2017-09-19 17:00:33 -0500 | [diff] [blame^] | 40 | pgm_name = re.sub('\.py$', '', os.path.basename(__file__)) |
Michael Walsh | e1e2644 | 2017-03-06 17:50:07 -0600 | [diff] [blame] | 41 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 42 | # Set up boot data structures. |
| 43 | boot_table = create_boot_table() |
| 44 | valid_boot_types = create_valid_boot_list(boot_table) |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 45 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 46 | boot_lists = read_boot_lists() |
| 47 | last_ten = [] |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 48 | |
| 49 | state = st.return_default_state() |
| 50 | cp_setup_called = 0 |
| 51 | next_boot = "" |
| 52 | base_tool_dir_path = os.path.normpath(os.environ.get( |
| 53 | 'AUTOBOOT_BASE_TOOL_DIR_PATH', "/tmp")) + os.sep |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 54 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 55 | ffdc_dir_path = os.path.normpath(os.environ.get('FFDC_DIR_PATH', '')) + os.sep |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 56 | boot_success = 0 |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 57 | status_dir_path = os.environ.get('STATUS_DIR_PATH', "") |
| 58 | if status_dir_path != "": |
| 59 | status_dir_path = os.path.normpath(status_dir_path) + os.sep |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 60 | default_power_on = "REST Power On" |
| 61 | default_power_off = "REST Power Off" |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 62 | boot_count = 0 |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 63 | |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 64 | LOG_LEVEL = BuiltIn().get_variable_value("${LOG_LEVEL}") |
Michael Walsh | e1974b9 | 2017-08-03 13:39:51 -0500 | [diff] [blame] | 65 | ffdc_prefix = "" |
Sunil M | 325eb54 | 2017-08-10 07:09:43 -0500 | [diff] [blame] | 66 | boot_start_time = "" |
| 67 | boot_end_time = "" |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 68 | save_stack = vs.var_stack('save_stack') |
| 69 | main_func_parm_list = ['boot_stack', 'stack_mode', 'quiet'] |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 70 | |
| 71 | |
| 72 | ############################################################################### |
Michael Walsh | 0ad0f7f | 2017-05-04 14:39:58 -0500 | [diff] [blame] | 73 | def process_host(host, |
| 74 | host_var_name=""): |
| 75 | |
| 76 | r""" |
| 77 | Process a host by getting the associated host name and IP address and |
| 78 | setting them in global variables. |
| 79 | |
| 80 | If the caller does not pass the host_var_name, this function will try to |
| 81 | figure out the name of the variable used by the caller for the host parm. |
| 82 | Callers are advised to explicitly specify the host_var_name when calling |
| 83 | with an exec command. In such cases, the get_arg_name cannot figure out |
| 84 | the host variable name. |
| 85 | |
| 86 | This function will then create similar global variable names by |
| 87 | removing "_host" and appending "_host_name" or "_ip" to the host variable |
| 88 | name. |
| 89 | |
| 90 | Example: |
| 91 | |
| 92 | If a call is made like this: |
| 93 | process_host(openbmc_host) |
| 94 | |
| 95 | Global variables openbmc_host_name and openbmc_ip will be set. |
| 96 | |
| 97 | Description of argument(s): |
| 98 | host A host name or IP. The name of the variable used should |
| 99 | have a suffix of "_host". |
| 100 | host_var_name The name of the variable being used as the host parm. |
| 101 | """ |
| 102 | |
| 103 | if host_var_name == "": |
| 104 | host_var_name = gp.get_arg_name(0, 1, stack_frame_ix=2) |
| 105 | |
| 106 | host_name_var_name = re.sub("host", "host_name", host_var_name) |
| 107 | ip_var_name = re.sub("host", "ip", host_var_name) |
| 108 | cmd_buf = "global " + host_name_var_name + ", " + ip_var_name + " ; " +\ |
| 109 | host_name_var_name + ", " + ip_var_name + " = gm.get_host_name_ip('" +\ |
| 110 | host + "')" |
| 111 | exec(cmd_buf) |
| 112 | |
| 113 | ############################################################################### |
| 114 | |
| 115 | |
| 116 | ############################################################################### |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 117 | def process_pgm_parms(): |
| 118 | |
| 119 | r""" |
| 120 | Process the program parameters by assigning them all to corresponding |
| 121 | globals. Also, set some global values that depend on program parameters. |
| 122 | """ |
| 123 | |
| 124 | # Program parameter processing. |
| 125 | # Assign all program parms to python variables which are global to this |
| 126 | # module. |
| 127 | |
| 128 | global parm_list |
| 129 | parm_list = BuiltIn().get_variable_value("${parm_list}") |
| 130 | # The following subset of parms should be processed as integers. |
| 131 | int_list = ['max_num_tests', 'boot_pass', 'boot_fail', 'ffdc_only', |
| 132 | 'boot_fail_threshold', 'quiet', 'test_mode', 'debug'] |
| 133 | for parm in parm_list: |
| 134 | if parm in int_list: |
| 135 | sub_cmd = "int(BuiltIn().get_variable_value(\"${" + parm +\ |
| 136 | "}\", \"0\"))" |
| 137 | else: |
| 138 | sub_cmd = "BuiltIn().get_variable_value(\"${" + parm + "}\")" |
| 139 | cmd_buf = "global " + parm + " ; " + parm + " = " + sub_cmd |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 140 | gp.dpissuing(cmd_buf) |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 141 | exec(cmd_buf) |
Michael Walsh | 0ad0f7f | 2017-05-04 14:39:58 -0500 | [diff] [blame] | 142 | if re.match(r".*_host$", parm): |
| 143 | cmd_buf = "process_host(" + parm + ", '" + parm + "')" |
| 144 | exec(cmd_buf) |
| 145 | if re.match(r".*_password$", parm): |
| 146 | # Register the value of any parm whose name ends in _password. |
| 147 | # This will cause the print functions to replace passwords with |
| 148 | # asterisks in the output. |
| 149 | cmd_buf = "gp.register_passwords(" + parm + ")" |
| 150 | exec(cmd_buf) |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 151 | |
| 152 | global ffdc_dir_path_style |
| 153 | global boot_list |
| 154 | global boot_stack |
| 155 | global boot_results_file_path |
| 156 | global boot_results |
| 157 | global ffdc_list_file_path |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 158 | global ffdc_report_list_path |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 159 | global ffdc_summary_list_path |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 160 | |
| 161 | if ffdc_dir_path_style == "": |
| 162 | ffdc_dir_path_style = int(os.environ.get('FFDC_DIR_PATH_STYLE', '0')) |
| 163 | |
| 164 | # Convert these program parms to lists for easier processing.. |
| 165 | boot_list = filter(None, boot_list.split(":")) |
| 166 | boot_stack = filter(None, boot_stack.split(":")) |
| 167 | |
Michael Walsh | 903e0b2 | 2017-09-19 17:00:33 -0500 | [diff] [blame^] | 168 | cleanup_boot_results_file() |
| 169 | boot_results_file_path = create_boot_results_file_path(pgm_name, |
| 170 | openbmc_nickname, |
| 171 | master_pid) |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 172 | |
| 173 | if os.path.isfile(boot_results_file_path): |
| 174 | # We've been called before in this run so we'll load the saved |
| 175 | # boot_results object. |
| 176 | boot_results = pickle.load(open(boot_results_file_path, 'rb')) |
| 177 | else: |
| 178 | boot_results = boot_results(boot_table, boot_pass, boot_fail) |
| 179 | |
| 180 | ffdc_list_file_path = base_tool_dir_path + openbmc_nickname +\ |
| 181 | "/FFDC_FILE_LIST" |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 182 | ffdc_report_list_path = base_tool_dir_path + openbmc_nickname +\ |
| 183 | "/FFDC_REPORT_FILE_LIST" |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 184 | |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 185 | ffdc_summary_list_path = base_tool_dir_path + openbmc_nickname +\ |
| 186 | "/FFDC_SUMMARY_FILE_LIST" |
| 187 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 188 | ############################################################################### |
| 189 | |
| 190 | |
| 191 | ############################################################################### |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 192 | def initial_plug_in_setup(): |
| 193 | |
| 194 | r""" |
| 195 | Initialize all plug-in environment variables which do not change for the |
| 196 | duration of the program. |
| 197 | |
| 198 | """ |
| 199 | |
| 200 | global LOG_LEVEL |
| 201 | BuiltIn().set_log_level("NONE") |
| 202 | |
| 203 | BuiltIn().set_global_variable("${master_pid}", master_pid) |
| 204 | BuiltIn().set_global_variable("${FFDC_DIR_PATH}", ffdc_dir_path) |
| 205 | BuiltIn().set_global_variable("${STATUS_DIR_PATH}", status_dir_path) |
| 206 | BuiltIn().set_global_variable("${BASE_TOOL_DIR_PATH}", base_tool_dir_path) |
| 207 | BuiltIn().set_global_variable("${FFDC_LIST_FILE_PATH}", |
| 208 | ffdc_list_file_path) |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 209 | BuiltIn().set_global_variable("${FFDC_REPORT_LIST_PATH}", |
| 210 | ffdc_report_list_path) |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 211 | BuiltIn().set_global_variable("${FFDC_SUMMARY_LIST_PATH}", |
| 212 | ffdc_summary_list_path) |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 213 | |
| 214 | BuiltIn().set_global_variable("${FFDC_DIR_PATH_STYLE}", |
| 215 | ffdc_dir_path_style) |
| 216 | BuiltIn().set_global_variable("${FFDC_CHECK}", |
| 217 | ffdc_check) |
| 218 | |
| 219 | # For each program parameter, set the corresponding AUTOBOOT_ environment |
| 220 | # variable value. Also, set an AUTOBOOT_ environment variable for every |
| 221 | # element in additional_values. |
| 222 | additional_values = ["program_pid", "master_pid", "ffdc_dir_path", |
| 223 | "status_dir_path", "base_tool_dir_path", |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 224 | "ffdc_list_file_path", "ffdc_report_list_path", |
| 225 | "ffdc_summary_list_path"] |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 226 | |
| 227 | plug_in_vars = parm_list + additional_values |
| 228 | |
| 229 | for var_name in plug_in_vars: |
| 230 | var_value = BuiltIn().get_variable_value("${" + var_name + "}") |
| 231 | var_name = var_name.upper() |
| 232 | if var_value is None: |
| 233 | var_value = "" |
| 234 | os.environ["AUTOBOOT_" + var_name] = str(var_value) |
| 235 | |
| 236 | BuiltIn().set_log_level(LOG_LEVEL) |
| 237 | |
Michael Walsh | 68a6116 | 2017-04-25 11:54:06 -0500 | [diff] [blame] | 238 | # Make sure the ffdc list directory exists. |
| 239 | ffdc_list_dir_path = os.path.dirname(ffdc_list_file_path) + os.sep |
| 240 | if not os.path.exists(ffdc_list_dir_path): |
| 241 | os.makedirs(ffdc_list_dir_path) |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 242 | |
| 243 | ############################################################################### |
| 244 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 245 | |
| 246 | ############################################################################### |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 247 | def plug_in_setup(): |
| 248 | |
| 249 | r""" |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 250 | Initialize all changing plug-in environment variables for use by the |
| 251 | plug-in programs. |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 252 | """ |
| 253 | |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 254 | global LOG_LEVEL |
| 255 | global test_really_running |
| 256 | |
| 257 | BuiltIn().set_log_level("NONE") |
| 258 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 259 | boot_pass, boot_fail = boot_results.return_total_pass_fail() |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 260 | if boot_pass > 1: |
| 261 | test_really_running = 1 |
| 262 | else: |
| 263 | test_really_running = 0 |
| 264 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 265 | BuiltIn().set_global_variable("${test_really_running}", |
| 266 | test_really_running) |
| 267 | BuiltIn().set_global_variable("${boot_type_desc}", next_boot) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 268 | BuiltIn().set_global_variable("${boot_pass}", boot_pass) |
| 269 | BuiltIn().set_global_variable("${boot_fail}", boot_fail) |
| 270 | BuiltIn().set_global_variable("${boot_success}", boot_success) |
| 271 | BuiltIn().set_global_variable("${ffdc_prefix}", ffdc_prefix) |
Sunil M | 325eb54 | 2017-08-10 07:09:43 -0500 | [diff] [blame] | 272 | BuiltIn().set_global_variable("${boot_start_time}", boot_start_time) |
| 273 | BuiltIn().set_global_variable("${boot_end_time}", boot_end_time) |
Michael Walsh | 4c9a645 | 2016-12-13 16:03:11 -0600 | [diff] [blame] | 274 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 275 | # For each program parameter, set the corresponding AUTOBOOT_ environment |
| 276 | # variable value. Also, set an AUTOBOOT_ environment variable for every |
| 277 | # element in additional_values. |
| 278 | additional_values = ["boot_type_desc", "boot_success", "boot_pass", |
Sunil M | 325eb54 | 2017-08-10 07:09:43 -0500 | [diff] [blame] | 279 | "boot_fail", "test_really_running", "ffdc_prefix", |
| 280 | "boot_start_time", "boot_end_time"] |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 281 | |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 282 | plug_in_vars = additional_values |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 283 | |
| 284 | for var_name in plug_in_vars: |
| 285 | var_value = BuiltIn().get_variable_value("${" + var_name + "}") |
| 286 | var_name = var_name.upper() |
| 287 | if var_value is None: |
| 288 | var_value = "" |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 289 | os.environ["AUTOBOOT_" + var_name] = str(var_value) |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 290 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 291 | if debug: |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 292 | shell_rc, out_buf = \ |
| 293 | gc.cmd_fnc_u("printenv | egrep AUTOBOOT_ | sort -u") |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 294 | |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 295 | BuiltIn().set_log_level(LOG_LEVEL) |
| 296 | |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 297 | ############################################################################### |
| 298 | |
| 299 | |
| 300 | ############################################################################### |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 301 | def pre_boot_plug_in_setup(): |
| 302 | |
| 303 | # Clear the ffdc_list_file_path file. Plug-ins may now write to it. |
| 304 | try: |
| 305 | os.remove(ffdc_list_file_path) |
| 306 | except OSError: |
| 307 | pass |
| 308 | |
| 309 | # Clear the ffdc_report_list_path file. Plug-ins may now write to it. |
| 310 | try: |
| 311 | os.remove(ffdc_report_list_path) |
| 312 | except OSError: |
| 313 | pass |
| 314 | |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 315 | # Clear the ffdc_summary_list_path file. Plug-ins may now write to it. |
| 316 | try: |
| 317 | os.remove(ffdc_summary_list_path) |
| 318 | except OSError: |
| 319 | pass |
| 320 | |
Michael Walsh | e1974b9 | 2017-08-03 13:39:51 -0500 | [diff] [blame] | 321 | global ffdc_prefix |
| 322 | |
| 323 | seconds = time.time() |
| 324 | loc_time = time.localtime(seconds) |
| 325 | time_string = time.strftime("%y%m%d.%H%M%S.", loc_time) |
| 326 | |
| 327 | ffdc_prefix = openbmc_nickname + "." + time_string |
| 328 | |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 329 | ############################################################################### |
| 330 | |
| 331 | |
| 332 | ############################################################################### |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 333 | def setup(): |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 334 | |
| 335 | r""" |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 336 | Do general program setup tasks. |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 337 | """ |
| 338 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 339 | global cp_setup_called |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 340 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 341 | gp.qprintn() |
| 342 | |
Michael Walsh | 83f4bc7 | 2017-04-20 16:49:43 -0500 | [diff] [blame] | 343 | robot_pgm_dir_path = os.path.dirname(__file__) + os.sep |
| 344 | repo_bin_path = robot_pgm_dir_path.replace("/lib/", "/bin/") |
Michael Walsh | d061c04 | 2017-05-23 14:46:57 -0500 | [diff] [blame] | 345 | # If we can't find process_plug_in_packages.py, ssh_pw or |
| 346 | # validate_plug_ins.py, then we don't have our repo bin in PATH. |
| 347 | shell_rc, out_buf = gc.cmd_fnc_u("which process_plug_in_packages.py" + |
| 348 | " ssh_pw validate_plug_ins.py", quiet=1, |
| 349 | print_output=0, show_err=0) |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 350 | if shell_rc != 0: |
Michael Walsh | 83f4bc7 | 2017-04-20 16:49:43 -0500 | [diff] [blame] | 351 | os.environ['PATH'] = repo_bin_path + ":" + os.environ.get('PATH', "") |
| 352 | # Likewise, our repo lib subdir needs to be in sys.path and PYTHONPATH. |
| 353 | if robot_pgm_dir_path not in sys.path: |
| 354 | sys.path.append(robot_pgm_dir_path) |
| 355 | PYTHONPATH = os.environ.get("PYTHONPATH", "") |
| 356 | if PYTHONPATH == "": |
| 357 | os.environ['PYTHONPATH'] = robot_pgm_dir_path |
| 358 | else: |
| 359 | os.environ['PYTHONPATH'] = robot_pgm_dir_path + ":" + PYTHONPATH |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 360 | |
| 361 | validate_parms() |
| 362 | |
| 363 | grp.rqprint_pgm_header() |
| 364 | |
Michael Walsh | fdc5ced | 2017-08-17 13:15:15 -0500 | [diff] [blame] | 365 | grk.run_key("Set BMC Power Policy RESTORE_LAST_STATE") |
Michael Walsh | 11cfc8c | 2017-03-31 09:40:55 -0500 | [diff] [blame] | 366 | |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 367 | initial_plug_in_setup() |
| 368 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 369 | plug_in_setup() |
| 370 | rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages( |
| 371 | call_point='setup') |
| 372 | if rc != 0: |
| 373 | error_message = "Plug-in setup failed.\n" |
| 374 | grp.rprint_error_report(error_message) |
| 375 | BuiltIn().fail(error_message) |
| 376 | # Setting cp_setup_called lets our Teardown know that it needs to call |
| 377 | # the cleanup plug-in call point. |
| 378 | cp_setup_called = 1 |
| 379 | |
| 380 | # Keyword "FFDC" will fail if TEST_MESSAGE is not set. |
| 381 | BuiltIn().set_global_variable("${TEST_MESSAGE}", "${EMPTY}") |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 382 | # FFDC_LOG_PATH is used by "FFDC" keyword. |
| 383 | BuiltIn().set_global_variable("${FFDC_LOG_PATH}", ffdc_dir_path) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 384 | |
Michael Walsh | dc80d67 | 2017-05-09 12:58:32 -0500 | [diff] [blame] | 385 | # Also printed by FFDC. |
| 386 | global host_name |
| 387 | global host_ip |
| 388 | host = socket.gethostname() |
| 389 | host_name, host_ip = gm.get_host_name_ip(host) |
| 390 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 391 | gp.dprint_var(boot_table, 1) |
| 392 | gp.dprint_var(boot_lists) |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 393 | |
| 394 | ############################################################################### |
| 395 | |
| 396 | |
| 397 | ############################################################################### |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 398 | def validate_parms(): |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 399 | |
| 400 | r""" |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 401 | Validate all program parameters. |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 402 | """ |
| 403 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 404 | process_pgm_parms() |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 405 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 406 | gp.qprintn() |
| 407 | |
| 408 | global openbmc_model |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 409 | grv.rvalid_value("openbmc_host") |
| 410 | grv.rvalid_value("openbmc_username") |
| 411 | grv.rvalid_value("openbmc_password") |
| 412 | if os_host != "": |
| 413 | grv.rvalid_value("os_username") |
| 414 | grv.rvalid_value("os_password") |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 415 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 416 | if pdu_host != "": |
| 417 | grv.rvalid_value("pdu_username") |
| 418 | grv.rvalid_value("pdu_password") |
Michael Walsh | 8567894 | 2017-03-27 14:34:22 -0500 | [diff] [blame] | 419 | grv.rvalid_integer("pdu_slot_no") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 420 | if openbmc_serial_host != "": |
| 421 | grv.rvalid_integer("openbmc_serial_port") |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 422 | if openbmc_model == "": |
| 423 | status, ret_values =\ |
| 424 | grk.run_key_u("Get BMC System Model") |
| 425 | openbmc_model = ret_values |
| 426 | BuiltIn().set_global_variable("${openbmc_model}", openbmc_model) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 427 | grv.rvalid_value("openbmc_model") |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 428 | grv.rvalid_integer("max_num_tests") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 429 | grv.rvalid_integer("boot_pass") |
| 430 | grv.rvalid_integer("boot_fail") |
| 431 | |
| 432 | plug_in_packages_list = grpi.rvalidate_plug_ins(plug_in_dir_paths) |
| 433 | BuiltIn().set_global_variable("${plug_in_packages_list}", |
| 434 | plug_in_packages_list) |
| 435 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 436 | grv.rvalid_value("stack_mode", valid_values=['normal', 'skip']) |
Michael Walsh | a20da40 | 2017-03-31 16:27:45 -0500 | [diff] [blame] | 437 | if len(boot_list) == 0 and len(boot_stack) == 0 and not ffdc_only: |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 438 | error_message = "You must provide either a value for either the" +\ |
| 439 | " boot_list or the boot_stack parm.\n" |
| 440 | BuiltIn().fail(gp.sprint_error(error_message)) |
| 441 | |
| 442 | valid_boot_list(boot_list, valid_boot_types) |
| 443 | valid_boot_list(boot_stack, valid_boot_types) |
| 444 | |
Michael Walsh | 11cfc8c | 2017-03-31 09:40:55 -0500 | [diff] [blame] | 445 | selected_PDU_boots = list(set(boot_list + boot_stack) & |
| 446 | set(boot_lists['PDU_reboot'])) |
| 447 | |
| 448 | if len(selected_PDU_boots) > 0 and pdu_host == "": |
| 449 | error_message = "You have selected the following boots which" +\ |
| 450 | " require a PDU host but no value for pdu_host:\n" |
| 451 | error_message += gp.sprint_var(selected_PDU_boots) |
| 452 | error_message += gp.sprint_var(pdu_host, 2) |
| 453 | BuiltIn().fail(gp.sprint_error(error_message)) |
| 454 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 455 | return |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 456 | |
| 457 | ############################################################################### |
| 458 | |
| 459 | |
| 460 | ############################################################################### |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 461 | def my_get_state(): |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 462 | |
| 463 | r""" |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 464 | Get the system state plus a little bit of wrapping. |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 465 | """ |
| 466 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 467 | global state |
| 468 | |
| 469 | req_states = ['epoch_seconds'] + st.default_req_states |
| 470 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 471 | gp.qprint_timen("Getting system state.") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 472 | if test_mode: |
| 473 | state['epoch_seconds'] = int(time.time()) |
| 474 | else: |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 475 | state = st.get_state(req_states=req_states, quiet=quiet) |
| 476 | gp.qprint_var(state) |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 477 | |
| 478 | ############################################################################### |
| 479 | |
| 480 | |
| 481 | ############################################################################### |
Michael Walsh | 45ca6e4 | 2017-09-14 17:29:12 -0500 | [diff] [blame] | 482 | def valid_state(): |
| 483 | |
| 484 | r""" |
| 485 | Verify that our state dictionary contains no blank values. If we don't get |
| 486 | valid state data, we cannot continue to work. |
| 487 | """ |
| 488 | |
| 489 | if st.compare_states(state, st.invalid_state_match, 'or'): |
| 490 | error_message = "The state dictionary contains blank fields which" +\ |
| 491 | " is illegal.\n" + gp.sprint_var(state) |
| 492 | BuiltIn().fail(gp.sprint_error(error_message)) |
| 493 | |
| 494 | ############################################################################### |
| 495 | |
| 496 | |
| 497 | ############################################################################### |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 498 | def select_boot(): |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 499 | |
| 500 | r""" |
| 501 | Select a boot test to be run based on our current state and return the |
| 502 | chosen boot type. |
| 503 | |
| 504 | Description of arguments: |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 505 | state The state of the machine. |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 506 | """ |
| 507 | |
Michael Walsh | 30dadae | 2017-02-27 14:25:52 -0600 | [diff] [blame] | 508 | global boot_stack |
| 509 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 510 | gp.qprint_timen("Selecting a boot test.") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 511 | |
| 512 | my_get_state() |
Michael Walsh | 45ca6e4 | 2017-09-14 17:29:12 -0500 | [diff] [blame] | 513 | valid_state() |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 514 | |
| 515 | stack_popped = 0 |
| 516 | if len(boot_stack) > 0: |
| 517 | stack_popped = 1 |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 518 | gp.qprint_dashes() |
| 519 | gp.qprint_var(boot_stack) |
| 520 | gp.qprint_dashes() |
| 521 | skip_boot_printed = 0 |
| 522 | while len(boot_stack) > 0: |
| 523 | boot_candidate = boot_stack.pop() |
| 524 | if stack_mode == 'normal': |
| 525 | break |
| 526 | else: |
| 527 | if st.compare_states(state, boot_table[boot_candidate]['end']): |
| 528 | if not skip_boot_printed: |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 529 | gp.qprint_var(stack_mode) |
| 530 | gp.qprintn() |
| 531 | gp.qprint_timen("Skipping the following boot tests" + |
| 532 | " which are unnecessary since their" + |
| 533 | " required end states match the" + |
| 534 | " current machine state:") |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 535 | skip_boot_printed = 1 |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 536 | gp.qprint_var(boot_candidate) |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 537 | boot_candidate = "" |
| 538 | if boot_candidate == "": |
| 539 | gp.qprint_dashes() |
| 540 | gp.qprint_var(boot_stack) |
| 541 | gp.qprint_dashes() |
| 542 | return boot_candidate |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 543 | if st.compare_states(state, boot_table[boot_candidate]['start']): |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 544 | gp.qprint_timen("The machine state is valid for a '" + |
| 545 | boot_candidate + "' boot test.") |
| 546 | gp.qprint_dashes() |
| 547 | gp.qprint_var(boot_stack) |
| 548 | gp.qprint_dashes() |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 549 | return boot_candidate |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 550 | else: |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 551 | gp.qprint_timen("The machine state does not match the required" + |
| 552 | " starting state for a '" + boot_candidate + |
| 553 | "' boot test:") |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 554 | gp.qprint_varx("boot_table[" + boot_candidate + "][start]", |
| 555 | boot_table[boot_candidate]['start'], 1) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 556 | boot_stack.append(boot_candidate) |
| 557 | popped_boot = boot_candidate |
| 558 | |
| 559 | # Loop through your list selecting a boot_candidates |
| 560 | boot_candidates = [] |
| 561 | for boot_candidate in boot_list: |
| 562 | if st.compare_states(state, boot_table[boot_candidate]['start']): |
| 563 | if stack_popped: |
| 564 | if st.compare_states(boot_table[boot_candidate]['end'], |
| 565 | boot_table[popped_boot]['start']): |
| 566 | boot_candidates.append(boot_candidate) |
| 567 | else: |
| 568 | boot_candidates.append(boot_candidate) |
| 569 | |
| 570 | if len(boot_candidates) == 0: |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 571 | gp.qprint_timen("The user's boot list contained no boot tests" + |
| 572 | " which are valid for the current machine state.") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 573 | boot_candidate = default_power_on |
| 574 | if not st.compare_states(state, boot_table[default_power_on]['start']): |
| 575 | boot_candidate = default_power_off |
| 576 | boot_candidates.append(boot_candidate) |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 577 | gp.qprint_timen("Using default '" + boot_candidate + |
| 578 | "' boot type to transition to valid state.") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 579 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 580 | gp.dprint_var(boot_candidates) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 581 | |
| 582 | # Randomly select a boot from the candidate list. |
| 583 | boot = random.choice(boot_candidates) |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 584 | |
| 585 | return boot |
Michael Walsh | 0bbd860 | 2016-11-22 11:31:49 -0600 | [diff] [blame] | 586 | |
| 587 | ############################################################################### |
Michael Walsh | 5530229 | 2017-01-10 11:43:02 -0600 | [diff] [blame] | 588 | |
| 589 | |
| 590 | ############################################################################### |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 591 | def print_last_boots(): |
| 592 | |
| 593 | r""" |
| 594 | Print the last ten boots done with their time stamps. |
| 595 | """ |
| 596 | |
| 597 | # indent 0, 90 chars wide, linefeed, char is "=" |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 598 | gp.qprint_dashes(0, 90) |
| 599 | gp.qprintn("Last 10 boots:\n") |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 600 | |
| 601 | for boot_entry in last_ten: |
| 602 | grp.rqprint(boot_entry) |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 603 | gp.qprint_dashes(0, 90) |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 604 | |
| 605 | ############################################################################### |
| 606 | |
| 607 | |
| 608 | ############################################################################### |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 609 | def print_defect_report(): |
| 610 | |
| 611 | r""" |
| 612 | Print a defect report. |
| 613 | """ |
| 614 | |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 615 | # Making deliberate choice to NOT run plug_in_setup(). We don't want |
| 616 | # ffdc_prefix updated. |
| 617 | rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages( |
| 618 | call_point='ffdc_report', stop_on_plug_in_failure=0) |
| 619 | |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 620 | # At some point I'd like to have the 'Call FFDC Methods' return a list |
| 621 | # of files it has collected. In that case, the following "ls" command |
| 622 | # would no longer be needed. For now, however, glob shows the files |
| 623 | # named in FFDC_LIST_FILE_PATH so I will refrain from printing those |
| 624 | # out (so we don't see duplicates in the list). |
| 625 | |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 626 | # Get additional header data which may have been created by ffdc plug-ins. |
| 627 | # Also, delete the individual header files to cleanup. |
| 628 | cmd_buf = "file_list=$(cat " + ffdc_report_list_path + " 2>/dev/null)" +\ |
| 629 | " ; [ ! -z \"${file_list}\" ] && cat ${file_list}" +\ |
| 630 | " 2>/dev/null ; rm -rf ${file_list} 2>/dev/null || :" |
| 631 | shell_rc, more_header_info = gc.cmd_fnc_u(cmd_buf, print_output=0, |
| 632 | show_err=0) |
| 633 | |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 634 | # Get additional header data which may have been created by ffdc plug-ins. |
| 635 | # Also, delete the individual header files to cleanup. |
| 636 | cmd_buf = "file_list=$(cat " + ffdc_summary_list_path + " 2>/dev/null)" +\ |
| 637 | " ; [ ! -z \"${file_list}\" ] && cat ${file_list}" +\ |
| 638 | " 2>/dev/null ; rm -rf ${file_list} 2>/dev/null || :" |
| 639 | shell_rc, ffdc_summary_info = gc.cmd_fnc_u(cmd_buf, print_output=0, |
| 640 | show_err=0) |
| 641 | |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 642 | LOG_PREFIX = BuiltIn().get_variable_value("${LOG_PREFIX}") |
| 643 | |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 644 | output = '\n'.join(sorted(glob.glob(LOG_PREFIX + '*'))) |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 645 | try: |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 646 | ffdc_list = open(ffdc_list_file_path, 'r') |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 647 | except IOError: |
| 648 | ffdc_list = "" |
| 649 | |
Michael Walsh | 68a6116 | 2017-04-25 11:54:06 -0500 | [diff] [blame] | 650 | # Open ffdc_file_list for writing. We will write a complete list of |
| 651 | # FFDC files to it for possible use by plug-ins like cp_stop_check. |
| 652 | ffdc_list_file = open(ffdc_list_file_path, 'w') |
| 653 | |
| 654 | gp.qprintn() |
| 655 | # indent=0, width=90, linefeed=1, char="=" |
| 656 | gp.qprint_dashes(0, 90, 1, "=") |
| 657 | gp.qprintn("Copy this data to the defect:\n") |
| 658 | |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 659 | if len(more_header_info) > 0: |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 660 | gp.qprintn(more_header_info) |
Michael Walsh | dc80d67 | 2017-05-09 12:58:32 -0500 | [diff] [blame] | 661 | gp.qpvars(host_name, host_ip, openbmc_nickname, openbmc_host, |
| 662 | openbmc_host_name, openbmc_ip, openbmc_username, |
| 663 | openbmc_password, os_host, os_host_name, os_ip, os_username, |
| 664 | os_password, pdu_host, pdu_host_name, pdu_ip, pdu_username, |
| 665 | pdu_password, pdu_slot_no, openbmc_serial_host, |
| 666 | openbmc_serial_host_name, openbmc_serial_ip, openbmc_serial_port) |
Michael Walsh | 68a6116 | 2017-04-25 11:54:06 -0500 | [diff] [blame] | 667 | |
| 668 | gp.qprintn() |
| 669 | |
| 670 | print_last_boots() |
| 671 | gp.qprintn() |
| 672 | gp.qprint_var(state) |
| 673 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 674 | gp.qprintn() |
| 675 | gp.qprintn("FFDC data files:") |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 676 | if status_file_path != "": |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 677 | gp.qprintn(status_file_path) |
Michael Walsh | 68a6116 | 2017-04-25 11:54:06 -0500 | [diff] [blame] | 678 | ffdc_list_file.write(status_file_path + "\n") |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 679 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 680 | gp.qprintn(output) |
| 681 | # gp.qprintn(ffdc_list) |
| 682 | gp.qprintn() |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 683 | |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 684 | if len(ffdc_summary_info) > 0: |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 685 | gp.qprintn(ffdc_summary_info) |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 686 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 687 | gp.qprint_dashes(0, 90, 1, "=") |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 688 | |
Michael Walsh | 68a6116 | 2017-04-25 11:54:06 -0500 | [diff] [blame] | 689 | ffdc_list_file.write(output + "\n") |
| 690 | ffdc_list_file.close() |
| 691 | |
Michael Walsh | 341c21e | 2017-01-17 16:25:20 -0600 | [diff] [blame] | 692 | ############################################################################### |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 693 | |
| 694 | |
| 695 | ############################################################################### |
| 696 | def my_ffdc(): |
| 697 | |
| 698 | r""" |
| 699 | Collect FFDC data. |
| 700 | """ |
| 701 | |
| 702 | global state |
| 703 | |
| 704 | plug_in_setup() |
| 705 | rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages( |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 706 | call_point='ffdc', stop_on_plug_in_failure=0) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 707 | |
| 708 | AUTOBOOT_FFDC_PREFIX = os.environ['AUTOBOOT_FFDC_PREFIX'] |
Michael Walsh | 83f4bc7 | 2017-04-20 16:49:43 -0500 | [diff] [blame] | 709 | status, ret_values = grk.run_key_u("FFDC ffdc_prefix=" + |
| 710 | AUTOBOOT_FFDC_PREFIX + |
| 711 | " ffdc_function_list=" + |
| 712 | ffdc_function_list, ignore=1) |
| 713 | if status != 'PASS': |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 714 | gp.qprint_error("Call to ffdc failed.\n") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 715 | |
| 716 | my_get_state() |
| 717 | |
| 718 | print_defect_report() |
| 719 | |
| 720 | ############################################################################### |
| 721 | |
| 722 | |
| 723 | ############################################################################### |
| 724 | def print_test_start_message(boot_keyword): |
| 725 | |
| 726 | r""" |
| 727 | Print a message indicating what boot test is about to run. |
| 728 | |
| 729 | Description of arguments: |
| 730 | boot_keyword The name of the boot which is to be run |
| 731 | (e.g. "BMC Power On"). |
| 732 | """ |
| 733 | |
| 734 | global last_ten |
Sunil M | 325eb54 | 2017-08-10 07:09:43 -0500 | [diff] [blame] | 735 | global boot_start_time |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 736 | |
| 737 | doing_msg = gp.sprint_timen("Doing \"" + boot_keyword + "\".") |
Sunil M | 325eb54 | 2017-08-10 07:09:43 -0500 | [diff] [blame] | 738 | |
| 739 | # Set boot_start_time for use by plug-ins. |
| 740 | boot_start_time = doing_msg[1:33] |
| 741 | gp.qprint_var(boot_start_time) |
| 742 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 743 | gp.qprint(doing_msg) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 744 | |
| 745 | last_ten.append(doing_msg) |
| 746 | |
| 747 | if len(last_ten) > 10: |
| 748 | del last_ten[0] |
| 749 | |
| 750 | ############################################################################### |
| 751 | |
| 752 | |
| 753 | ############################################################################### |
| 754 | def run_boot(boot): |
| 755 | |
| 756 | r""" |
| 757 | Run the specified boot. |
| 758 | |
| 759 | Description of arguments: |
| 760 | boot The name of the boot test to be performed. |
| 761 | """ |
| 762 | |
| 763 | global state |
| 764 | |
| 765 | print_test_start_message(boot) |
| 766 | |
| 767 | plug_in_setup() |
| 768 | rc, shell_rc, failed_plug_in_name = \ |
| 769 | grpi.rprocess_plug_in_packages(call_point="pre_boot") |
| 770 | if rc != 0: |
| 771 | error_message = "Plug-in failed with non-zero return code.\n" +\ |
| 772 | gp.sprint_var(rc, 1) |
| 773 | BuiltIn().fail(gp.sprint_error(error_message)) |
| 774 | |
| 775 | if test_mode: |
| 776 | # In test mode, we'll pretend the boot worked by assigning its |
| 777 | # required end state to the default state value. |
Michael Walsh | 30dadae | 2017-02-27 14:25:52 -0600 | [diff] [blame] | 778 | state = st.strip_anchor_state(boot_table[boot]['end']) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 779 | else: |
| 780 | # Assertion: We trust that the state data was made fresh by the |
| 781 | # caller. |
| 782 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 783 | gp.qprintn() |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 784 | |
| 785 | if boot_table[boot]['method_type'] == "keyword": |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 786 | rk.my_run_keywords(boot_table[boot].get('lib_file_path', ''), |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 787 | boot_table[boot]['method'], |
| 788 | quiet=quiet) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 789 | |
| 790 | if boot_table[boot]['bmc_reboot']: |
| 791 | st.wait_for_comm_cycle(int(state['epoch_seconds'])) |
Michael Walsh | 30dadae | 2017-02-27 14:25:52 -0600 | [diff] [blame] | 792 | plug_in_setup() |
| 793 | rc, shell_rc, failed_plug_in_name = \ |
| 794 | grpi.rprocess_plug_in_packages(call_point="post_reboot") |
| 795 | if rc != 0: |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 796 | error_message = "Plug-in failed with non-zero return code.\n" |
| 797 | error_message += gp.sprint_var(rc, 1) |
Michael Walsh | 30dadae | 2017-02-27 14:25:52 -0600 | [diff] [blame] | 798 | BuiltIn().fail(gp.sprint_error(error_message)) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 799 | else: |
| 800 | match_state = st.anchor_state(state) |
| 801 | del match_state['epoch_seconds'] |
| 802 | # Wait for the state to change in any way. |
| 803 | st.wait_state(match_state, wait_time=state_change_timeout, |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 804 | interval="10 seconds", invert=1) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 805 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 806 | gp.qprintn() |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 807 | if boot_table[boot]['end']['chassis'] == "Off": |
| 808 | boot_timeout = power_off_timeout |
| 809 | else: |
| 810 | boot_timeout = power_on_timeout |
| 811 | st.wait_state(boot_table[boot]['end'], wait_time=boot_timeout, |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 812 | interval="10 seconds") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 813 | |
| 814 | plug_in_setup() |
| 815 | rc, shell_rc, failed_plug_in_name = \ |
| 816 | grpi.rprocess_plug_in_packages(call_point="post_boot") |
| 817 | if rc != 0: |
| 818 | error_message = "Plug-in failed with non-zero return code.\n" +\ |
| 819 | gp.sprint_var(rc, 1) |
| 820 | BuiltIn().fail(gp.sprint_error(error_message)) |
| 821 | |
| 822 | ############################################################################### |
| 823 | |
| 824 | |
| 825 | ############################################################################### |
| 826 | def test_loop_body(): |
| 827 | |
| 828 | r""" |
| 829 | The main loop body for the loop in main_py. |
| 830 | |
| 831 | Description of arguments: |
| 832 | boot_count The iteration number (starts at 1). |
| 833 | """ |
| 834 | |
| 835 | global boot_count |
| 836 | global state |
| 837 | global next_boot |
| 838 | global boot_success |
Sunil M | 325eb54 | 2017-08-10 07:09:43 -0500 | [diff] [blame] | 839 | global boot_end_time |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 840 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 841 | gp.qprintn() |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 842 | |
| 843 | next_boot = select_boot() |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 844 | if next_boot == "": |
| 845 | return True |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 846 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 847 | boot_count += 1 |
| 848 | gp.qprint_timen("Starting boot " + str(boot_count) + ".") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 849 | |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 850 | pre_boot_plug_in_setup() |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 851 | |
| 852 | cmd_buf = ["run_boot", next_boot] |
| 853 | boot_status, msg = BuiltIn().run_keyword_and_ignore_error(*cmd_buf) |
| 854 | if boot_status == "FAIL": |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 855 | gp.qprint(msg) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 856 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 857 | gp.qprintn() |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 858 | if boot_status == "PASS": |
| 859 | boot_success = 1 |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 860 | completion_msg = gp.sprint_timen("BOOT_SUCCESS: \"" + next_boot + |
| 861 | "\" succeeded.") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 862 | else: |
| 863 | boot_success = 0 |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 864 | completion_msg = gp.sprint_timen("BOOT_FAILED: \"" + next_boot + |
| 865 | "\" failed.") |
Sunil M | 325eb54 | 2017-08-10 07:09:43 -0500 | [diff] [blame] | 866 | |
| 867 | # Set boot_end_time for use by plug-ins. |
| 868 | boot_end_time = completion_msg[1:33] |
| 869 | gp.qprint_var(boot_end_time) |
| 870 | |
| 871 | gp.qprint(completion_msg) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 872 | |
| 873 | boot_results.update(next_boot, boot_status) |
| 874 | |
| 875 | plug_in_setup() |
| 876 | # NOTE: A post_test_case call point failure is NOT counted as a boot |
| 877 | # failure. |
| 878 | rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages( |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 879 | call_point='post_test_case', stop_on_plug_in_failure=0) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 880 | |
| 881 | plug_in_setup() |
| 882 | rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages( |
| 883 | call_point='ffdc_check', shell_rc=0x00000200, |
| 884 | stop_on_plug_in_failure=1, stop_on_non_zero_rc=1) |
| 885 | if boot_status != "PASS" or ffdc_check == "All" or shell_rc == 0x00000200: |
Michael Walsh | 83f4bc7 | 2017-04-20 16:49:43 -0500 | [diff] [blame] | 886 | status, ret_values = grk.run_key_u("my_ffdc", ignore=1) |
| 887 | if status != 'PASS': |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 888 | gp.qprint_error("Call to my_ffdc failed.\n") |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 889 | |
Michael Walsh | d139f28 | 2017-04-04 18:00:23 -0500 | [diff] [blame] | 890 | # We need to purge error logs between boots or they build up. |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 891 | grk.run_key("Delete Error logs", ignore=1) |
Michael Walsh | d139f28 | 2017-04-04 18:00:23 -0500 | [diff] [blame] | 892 | |
Michael Walsh | 952f9b0 | 2017-03-09 13:11:14 -0600 | [diff] [blame] | 893 | boot_results.print_report() |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 894 | gp.qprint_timen("Finished boot " + str(boot_count) + ".") |
Michael Walsh | 952f9b0 | 2017-03-09 13:11:14 -0600 | [diff] [blame] | 895 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 896 | plug_in_setup() |
| 897 | rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages( |
| 898 | call_point='stop_check') |
| 899 | if rc != 0: |
| 900 | error_message = "Stopping as requested by user.\n" |
| 901 | grp.rprint_error_report(error_message) |
| 902 | BuiltIn().fail(error_message) |
| 903 | |
Michael Walsh | d139f28 | 2017-04-04 18:00:23 -0500 | [diff] [blame] | 904 | # This should help prevent ConnectionErrors. |
Michael Walsh | 0960b38 | 2017-06-22 16:23:37 -0500 | [diff] [blame] | 905 | grk.run_key_u("Close All Connections") |
Michael Walsh | d139f28 | 2017-04-04 18:00:23 -0500 | [diff] [blame] | 906 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 907 | return True |
| 908 | |
| 909 | ############################################################################### |
| 910 | |
| 911 | |
| 912 | ############################################################################### |
Michael Walsh | 83f4bc7 | 2017-04-20 16:49:43 -0500 | [diff] [blame] | 913 | def obmc_boot_test_teardown(): |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 914 | |
| 915 | r""" |
Michael Walsh | c911681 | 2017-03-10 14:23:06 -0600 | [diff] [blame] | 916 | Clean up after the Main keyword. |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 917 | """ |
| 918 | |
| 919 | if cp_setup_called: |
| 920 | plug_in_setup() |
| 921 | rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages( |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 922 | call_point='cleanup', stop_on_plug_in_failure=0) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 923 | |
Michael Walsh | 600876d | 2017-05-30 17:58:58 -0500 | [diff] [blame] | 924 | if 'boot_results_file_path' in globals(): |
| 925 | # Save boot_results object to a file in case it is needed again. |
| 926 | gp.qprint_timen("Saving boot_results to the following path.") |
| 927 | gp.qprint_var(boot_results_file_path) |
| 928 | pickle.dump(boot_results, open(boot_results_file_path, 'wb'), |
| 929 | pickle.HIGHEST_PROTOCOL) |
Michael Walsh | 0b93fbf | 2017-03-02 14:42:41 -0600 | [diff] [blame] | 930 | |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 931 | global save_stack |
| 932 | # Restore any global values saved on the save_stack. |
| 933 | for parm_name in main_func_parm_list: |
| 934 | # Get the parm_value if it was saved on the stack. |
| 935 | try: |
| 936 | parm_value = save_stack.pop(parm_name) |
| 937 | except: |
| 938 | # If it was not saved, no further action is required. |
| 939 | continue |
| 940 | |
| 941 | # Restore the saved value. |
| 942 | cmd_buf = "BuiltIn().set_global_variable(\"${" + parm_name +\ |
| 943 | "}\", parm_value)" |
| 944 | gp.dpissuing(cmd_buf) |
| 945 | exec(cmd_buf) |
| 946 | |
| 947 | gp.dprintn(save_stack.sprint_obj()) |
| 948 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 949 | ############################################################################### |
| 950 | |
| 951 | |
| 952 | ############################################################################### |
Michael Walsh | c911681 | 2017-03-10 14:23:06 -0600 | [diff] [blame] | 953 | def test_teardown(): |
| 954 | |
| 955 | r""" |
| 956 | Clean up after this test case. |
| 957 | """ |
| 958 | |
| 959 | gp.qprintn() |
| 960 | cmd_buf = ["Print Error", |
| 961 | "A keyword timeout occurred ending this program.\n"] |
| 962 | BuiltIn().run_keyword_if_timeout_occurred(*cmd_buf) |
| 963 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 964 | grp.rqprint_pgm_footer() |
| 965 | |
Michael Walsh | c911681 | 2017-03-10 14:23:06 -0600 | [diff] [blame] | 966 | ############################################################################### |
| 967 | |
| 968 | |
| 969 | ############################################################################### |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 970 | def obmc_boot_test_py(loc_boot_stack=None, |
| 971 | loc_stack_mode=None, |
| 972 | loc_quiet=None): |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 973 | |
| 974 | r""" |
| 975 | Do main program processing. |
| 976 | """ |
| 977 | |
Michael Walsh | ff34000 | 2017-08-29 11:18:27 -0500 | [diff] [blame] | 978 | global save_stack |
| 979 | |
| 980 | # Process function parms. |
| 981 | for parm_name in main_func_parm_list: |
| 982 | # Get parm's value. |
| 983 | cmd_buf = "parm_value = loc_" + parm_name |
| 984 | exec(cmd_buf) |
| 985 | gp.dpvar(parm_name) |
| 986 | gp.dpvar(parm_value) |
| 987 | |
| 988 | if parm_value is None: |
| 989 | # Parm was not specified by the calling function so set it to its |
| 990 | # corresponding global value. |
| 991 | cmd_buf = "loc_" + parm_name + " = BuiltIn().get_variable_value" +\ |
| 992 | "(\"${" + parm_name + "}\")" |
| 993 | gp.dpissuing(cmd_buf) |
| 994 | exec(cmd_buf) |
| 995 | else: |
| 996 | # Save the global value on a stack. |
| 997 | cmd_buf = "save_stack.push(BuiltIn().get_variable_value(\"${" +\ |
| 998 | parm_name + "}\"), \"" + parm_name + "\")" |
| 999 | gp.dpissuing(cmd_buf) |
| 1000 | exec(cmd_buf) |
| 1001 | |
| 1002 | # Set the global value to the passed value. |
| 1003 | cmd_buf = "BuiltIn().set_global_variable(\"${" + parm_name +\ |
| 1004 | "}\", loc_" + parm_name + ")" |
| 1005 | gp.dpissuing(cmd_buf) |
| 1006 | exec(cmd_buf) |
| 1007 | |
| 1008 | gp.dprintn(save_stack.sprint_obj()) |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 1009 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 1010 | setup() |
| 1011 | |
Michael Walsh | cd9fbfd | 2017-09-19 12:00:08 -0500 | [diff] [blame] | 1012 | init_boot_pass, init_boot_fail = boot_results.return_total_pass_fail() |
| 1013 | |
Michael Walsh | a20da40 | 2017-03-31 16:27:45 -0500 | [diff] [blame] | 1014 | if ffdc_only: |
| 1015 | gp.qprint_timen("Caller requested ffdc_only.") |
Michael Walsh | e0cf8d7 | 2017-05-17 13:20:46 -0500 | [diff] [blame] | 1016 | pre_boot_plug_in_setup() |
Michael Walsh | 83f4bc7 | 2017-04-20 16:49:43 -0500 | [diff] [blame] | 1017 | grk.run_key_u("my_ffdc") |
Michael Walsh | 764d2f8 | 2017-04-27 16:01:08 -0500 | [diff] [blame] | 1018 | return |
Michael Walsh | a20da40 | 2017-03-31 16:27:45 -0500 | [diff] [blame] | 1019 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 1020 | # Process caller's boot_stack. |
| 1021 | while (len(boot_stack) > 0): |
| 1022 | test_loop_body() |
| 1023 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 1024 | gp.qprint_timen("Finished processing stack.") |
Michael Walsh | 30dadae | 2017-02-27 14:25:52 -0600 | [diff] [blame] | 1025 | |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 1026 | # Process caller's boot_list. |
| 1027 | if len(boot_list) > 0: |
| 1028 | for ix in range(1, max_num_tests + 1): |
| 1029 | test_loop_body() |
| 1030 | |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 1031 | gp.qprint_timen("Completed all requested boot tests.") |
| 1032 | |
| 1033 | boot_pass, boot_fail = boot_results.return_total_pass_fail() |
Michael Walsh | cd9fbfd | 2017-09-19 12:00:08 -0500 | [diff] [blame] | 1034 | new_fail = boot_fail - init_boot_fail |
| 1035 | if new_fail > boot_fail_threshold: |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 1036 | error_message = "Boot failures exceed the boot failure" +\ |
| 1037 | " threshold:\n" +\ |
Michael Walsh | cd9fbfd | 2017-09-19 12:00:08 -0500 | [diff] [blame] | 1038 | gp.sprint_var(new_fail) +\ |
Michael Walsh | b5839d0 | 2017-04-12 16:11:20 -0500 | [diff] [blame] | 1039 | gp.sprint_var(boot_fail_threshold) |
| 1040 | BuiltIn().fail(gp.sprint_error(error_message)) |
Michael Walsh | 6741f74 | 2017-02-20 16:16:38 -0600 | [diff] [blame] | 1041 | |
| 1042 | ############################################################################### |