def obmc_boot_test_teardown(): r""" Clean up after the Main keyword. """ if cp_setup_called: plug_in_setup() rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages( call_point='cleanup', stop_on_plug_in_failure=0) if 'boot_results_file_path' in globals(): # Save boot_results object to a file in case it is needed again. gp.qprint_timen("Saving boot_results to the following path.") gp.qprint_var(boot_results_file_path) pickle.dump(boot_results, open(boot_results_file_path, 'wb'), pickle.HIGHEST_PROTOCOL) global save_stack # Restore any global values saved on the save_stack. for parm_name in main_func_parm_list: # Get the parm_value if it was saved on the stack. try: parm_value = save_stack.pop(parm_name) except: # If it was not saved, no further action is required. continue # Restore the saved value. cmd_buf = "BuiltIn().set_global_variable(\"${" + parm_name +\ "}\", parm_value)" gp.dpissuing(cmd_buf) exec(cmd_buf) gp.dprintn(save_stack.sprint_obj())
def obmc_boot_test_teardown(): r""" Clean up after the Main keyword. """ if cp_setup_called: plug_in_setup() rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages( call_point='cleanup', stop_on_plug_in_failure=0) if 'boot_results_file_path' in globals(): # Save boot_results object to a file in case it is needed again. gp.qprint_timen("Saving boot_results to the following path.") gp.qprint_var(boot_results_file_path) pickle.dump(boot_results, open(boot_results_file_path, 'wb'), pickle.HIGHEST_PROTOCOL) global save_stack # Restore any global values saved on the save_stack. for parm_name in main_func_parm_list: # Get the parm_value if it was saved on the stack. try: parm_value = save_stack.pop(parm_name) except BaseException: # If it was not saved, no further action is required. continue # Restore the saved value. cmd_buf = "BuiltIn().set_global_variable(\"${" + parm_name +\ "}\", parm_value)" gp.dpissuing(cmd_buf) exec(cmd_buf) gp.dprintn(save_stack.sprint_obj())
def obmc_boot_test_py(loc_boot_stack=None, loc_stack_mode=None, loc_quiet=None): r""" Do main program processing. """ global save_stack # Process function parms. for parm_name in main_func_parm_list: # Get parm's value. cmd_buf = "parm_value = loc_" + parm_name exec(cmd_buf) gp.dpvar(parm_name) gp.dpvar(parm_value) if parm_value is None: # Parm was not specified by the calling function so set it to its # corresponding global value. cmd_buf = "loc_" + parm_name + " = BuiltIn().get_variable_value" +\ "(\"${" + parm_name + "}\")" gp.dpissuing(cmd_buf) exec(cmd_buf) else: # Save the global value on a stack. cmd_buf = "save_stack.push(BuiltIn().get_variable_value(\"${" +\ parm_name + "}\"), \"" + parm_name + "\")" gp.dpissuing(cmd_buf) exec(cmd_buf) # Set the global value to the passed value. cmd_buf = "BuiltIn().set_global_variable(\"${" + parm_name +\ "}\", loc_" + parm_name + ")" gp.dpissuing(cmd_buf) exec(cmd_buf) gp.dprintn(save_stack.sprint_obj()) setup() if ffdc_only: gp.qprint_timen("Caller requested ffdc_only.") pre_boot_plug_in_setup() grk.run_key_u("my_ffdc") return # Process caller's boot_stack. while (len(boot_stack) > 0): test_loop_body() gp.qprint_timen("Finished processing stack.") # Process caller's boot_list. if len(boot_list) > 0: for ix in range(1, max_num_tests + 1): test_loop_body() gp.qprint_timen("Completed all requested boot tests.") boot_pass, boot_fail = boot_results.return_total_pass_fail() if boot_fail > boot_fail_threshold: error_message = "Boot failures exceed the boot failure" +\ " threshold:\n" +\ gp.sprint_var(boot_fail) +\ gp.sprint_var(boot_fail_threshold) BuiltIn().fail(gp.sprint_error(error_message))
def process_pgm_parms(): r""" Process the program parameters by assigning them all to corresponding globals. Also, set some global values that depend on program parameters. """ # Program parameter processing. # Assign all program parms to python variables which are global to this # module. global parm_list parm_list = BuiltIn().get_variable_value("${parm_list}") # The following subset of parms should be processed as integers. int_list = [ 'max_num_tests', 'boot_pass', 'boot_fail', 'ffdc_only', 'boot_fail_threshold', 'quiet', 'test_mode', 'debug' ] for parm in parm_list: if parm in int_list: sub_cmd = "int(BuiltIn().get_variable_value(\"${" + parm +\ "}\", \"0\"))" else: sub_cmd = "BuiltIn().get_variable_value(\"${" + parm + "}\")" cmd_buf = "global " + parm + " ; " + parm + " = " + sub_cmd gp.dpissuing(cmd_buf) exec(cmd_buf) if re.match(r".*_host$", parm): cmd_buf = "process_host(" + parm + ", '" + parm + "')" exec(cmd_buf) if re.match(r".*_password$", parm): # Register the value of any parm whose name ends in _password. # This will cause the print functions to replace passwords with # asterisks in the output. cmd_buf = "gp.register_passwords(" + parm + ")" exec(cmd_buf) global ffdc_dir_path_style global boot_list global boot_stack global boot_results_file_path global boot_results global ffdc_list_file_path global ffdc_report_list_path global ffdc_summary_list_path if ffdc_dir_path_style == "": ffdc_dir_path_style = int(os.environ.get('FFDC_DIR_PATH_STYLE', '0')) # Convert these program parms to lists for easier processing.. boot_list = filter(None, boot_list.split(":")) boot_stack = filter(None, boot_stack.split(":")) boot_results_file_path = "/tmp/" + openbmc_nickname + ":pid_" +\ str(master_pid) + ":boot_results" if os.path.isfile(boot_results_file_path): # We've been called before in this run so we'll load the saved # boot_results object. boot_results = pickle.load(open(boot_results_file_path, 'rb')) else: boot_results = boot_results(boot_table, boot_pass, boot_fail) ffdc_list_file_path = base_tool_dir_path + openbmc_nickname +\ "/FFDC_FILE_LIST" ffdc_report_list_path = base_tool_dir_path + openbmc_nickname +\ "/FFDC_REPORT_FILE_LIST" ffdc_summary_list_path = base_tool_dir_path + openbmc_nickname +\ "/FFDC_SUMMARY_FILE_LIST"
def obmc_boot_test_py(loc_boot_stack=None, loc_stack_mode=None, loc_quiet=None): r""" Do main program processing. """ global save_stack ga.set_term_options(term_requests={'pgm_names': ['process_plug_in_packages.py']}) gp.dprintn() # Process function parms. for parm_name in main_func_parm_list: # Get parm's value. parm_value = eval("loc_" + parm_name) gp.dpvars(parm_name, parm_value) if parm_value is not None: # Save the global value on a stack. cmd_buf = "save_stack.push(BuiltIn().get_variable_value(\"${" +\ parm_name + "}\"), \"" + parm_name + "\")" gp.dpissuing(cmd_buf) exec(cmd_buf) # Set the global value to the passed value. cmd_buf = "BuiltIn().set_global_variable(\"${" + parm_name +\ "}\", loc_" + parm_name + ")" gp.dpissuing(cmd_buf) exec(cmd_buf) gp.dprintn(save_stack.sprint_obj()) setup() init_boot_pass, init_boot_fail = boot_results.return_total_pass_fail() if ffdc_only: gp.qprint_timen("Caller requested ffdc_only.") if do_pre_boot_plug_in_setup: pre_boot_plug_in_setup() grk.run_key_u("my_ffdc") return if delete_errlogs: # print error logs before delete status, error_logs = grk.run_key_u("Get Error Logs") pels = pel.peltool("-l", ignore_err=1) log.print_error_logs(error_logs, "AdditionalData Message Severity") gp.qprint_var(pels) # Delete errlogs prior to doing any boot tests. grk.run_key(delete_errlogs_cmd, ignore=1) grk.run_key(delete_bmcdump_cmd, ignore=1) # Process caller's boot_stack. while (len(boot_stack) > 0): test_loop_body() gp.qprint_timen("Finished processing stack.") post_stack() # Process caller's boot_list. if len(boot_list) > 0: for ix in range(1, max_num_tests + 1): test_loop_body() gp.qprint_timen("Completed all requested boot tests.") boot_pass, boot_fail = boot_results.return_total_pass_fail() new_fail = boot_fail - init_boot_fail if new_fail > boot_fail_threshold: error_message = "Boot failures exceed the boot failure" +\ " threshold:\n" +\ gp.sprint_var(new_fail) +\ gp.sprint_var(boot_fail_threshold) BuiltIn().fail(gp.sprint_error(error_message))
def obmc_boot_test_py(loc_boot_stack=None, loc_stack_mode=None, loc_quiet=None): r""" Do main program processing. """ global save_stack # Process function parms. for parm_name in main_func_parm_list: # Get parm's value. cmd_buf = "parm_value = loc_" + parm_name exec(cmd_buf) gp.dpvar(parm_name) gp.dpvar(parm_value) if parm_value is None: # Parm was not specified by the calling function so set it to its # corresponding global value. cmd_buf = "loc_" + parm_name + " = BuiltIn().get_variable_value" +\ "(\"${" + parm_name + "}\")" gp.dpissuing(cmd_buf) exec(cmd_buf) else: # Save the global value on a stack. cmd_buf = "save_stack.push(BuiltIn().get_variable_value(\"${" +\ parm_name + "}\"), \"" + parm_name + "\")" gp.dpissuing(cmd_buf) exec(cmd_buf) # Set the global value to the passed value. cmd_buf = "BuiltIn().set_global_variable(\"${" + parm_name +\ "}\", loc_" + parm_name + ")" gp.dpissuing(cmd_buf) exec(cmd_buf) gp.dprintn(save_stack.sprint_obj()) setup() init_boot_pass, init_boot_fail = boot_results.return_total_pass_fail() if ffdc_only: gp.qprint_timen("Caller requested ffdc_only.") pre_boot_plug_in_setup() grk.run_key_u("my_ffdc") return # Process caller's boot_stack. while (len(boot_stack) > 0): test_loop_body() gp.qprint_timen("Finished processing stack.") # Process caller's boot_list. if len(boot_list) > 0: for ix in range(1, max_num_tests + 1): test_loop_body() gp.qprint_timen("Completed all requested boot tests.") boot_pass, boot_fail = boot_results.return_total_pass_fail() new_fail = boot_fail - init_boot_fail if new_fail > boot_fail_threshold: error_message = "Boot failures exceed the boot failure" +\ " threshold:\n" +\ gp.sprint_var(new_fail) +\ gp.sprint_var(boot_fail_threshold) BuiltIn().fail(gp.sprint_error(error_message))
def process_pgm_parms(): r""" Process the program parameters by assigning them all to corresponding globals. Also, set some global values that depend on program parameters. """ # Program parameter processing. # Assign all program parms to python variables which are global to this # module. global parm_list parm_list = BuiltIn().get_variable_value("${parm_list}") # The following subset of parms should be processed as integers. int_list = ['max_num_tests', 'boot_pass', 'boot_fail', 'ffdc_only', 'boot_fail_threshold', 'delete_errlogs', 'quiet', 'test_mode', 'debug'] for parm in parm_list: if parm in int_list: sub_cmd = "int(BuiltIn().get_variable_value(\"${" + parm +\ "}\", \"0\"))" else: sub_cmd = "BuiltIn().get_variable_value(\"${" + parm + "}\")" cmd_buf = "global " + parm + " ; " + parm + " = " + sub_cmd gp.dpissuing(cmd_buf) exec(cmd_buf) if re.match(r".*_host$", parm): cmd_buf = "process_host(" + parm + ", '" + parm + "')" exec(cmd_buf) if re.match(r".*_password$", parm): # Register the value of any parm whose name ends in _password. # This will cause the print functions to replace passwords with # asterisks in the output. cmd_buf = "gp.register_passwords(" + parm + ")" exec(cmd_buf) global ffdc_dir_path_style global boot_list global boot_stack global boot_results_file_path global boot_results global ffdc_list_file_path global ffdc_report_list_path global ffdc_summary_list_path if ffdc_dir_path_style == "": ffdc_dir_path_style = int(os.environ.get('FFDC_DIR_PATH_STYLE', '0')) # Convert these program parms to lists for easier processing.. boot_list = filter(None, boot_list.split(":")) boot_stack = filter(None, boot_stack.split(":")) cleanup_boot_results_file() boot_results_file_path = create_boot_results_file_path(pgm_name, openbmc_nickname, master_pid) if os.path.isfile(boot_results_file_path): # We've been called before in this run so we'll load the saved # boot_results object. boot_results = pickle.load(open(boot_results_file_path, 'rb')) else: boot_results = boot_results(boot_table, boot_pass, boot_fail) ffdc_list_file_path = base_tool_dir_path + openbmc_nickname +\ "/FFDC_FILE_LIST" ffdc_report_list_path = base_tool_dir_path + openbmc_nickname +\ "/FFDC_REPORT_FILE_LIST" ffdc_summary_list_path = base_tool_dir_path + openbmc_nickname +\ "/FFDC_SUMMARY_FILE_LIST"