1*e7e9171eSGeorge Keishing#!/usr/bin/env python3 2642b3552SMichael Walsh 3642b3552SMichael Walshfrom gen_print import * 4642b3552SMichael Walshfrom gen_valid import * 5642b3552SMichael Walshfrom gen_arg import * 6642b3552SMichael Walshfrom gen_misc import * 7642b3552SMichael Walshfrom gen_cmd import * 8642b3552SMichael Walshfrom gen_plug_in_utils import * 9642b3552SMichael Walshfrom gen_call_robot import * 10642b3552SMichael Walsh 11642b3552SMichael Walsh# Set exit_on_error for gen_valid functions. 12642b3552SMichael Walshset_exit_on_error(True) 13642b3552SMichael Walsh 14642b3552SMichael Walshparser = argparse.ArgumentParser( 15642b3552SMichael Walsh usage='%(prog)s [OPTIONS]', 16642b3552SMichael Walsh description="%(prog)s will determine whether FFDC should be collected. If so, it will return " 17642b3552SMichael Walsh + repr(dump_ffdc_rc()) + ".", 18642b3552SMichael Walsh formatter_class=argparse.ArgumentDefaultsHelpFormatter, 19642b3552SMichael Walsh prefix_chars='-+') 20642b3552SMichael Walsh 21642b3552SMichael Walsh# The stock_list will be passed to gen_get_options. We populate it with the names of stock parm options we 22642b3552SMichael Walsh# want. These stock parms are pre-defined by gen_get_options. 23642b3552SMichael Walshstock_list = [("test_mode", get_plug_default("test_mode", 0)), 24642b3552SMichael Walsh ("quiet", get_plug_default("quiet", 0)), 25642b3552SMichael Walsh ("debug", get_plug_default("debug", 0))] 26642b3552SMichael Walsh 27642b3552SMichael Walsh# For now we are hard-coding this value vs adding a soft_errors=boolean entry in the parm_def file. 28642b3552SMichael WalshFFDC_SOFT_ERRORS = 1 29642b3552SMichael Walsh 30642b3552SMichael Walsh 31642b3552SMichael Walshdef exit_function(signal_number=0, 32642b3552SMichael Walsh frame=None): 33642b3552SMichael Walsh r""" 34642b3552SMichael Walsh Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT). 35642b3552SMichael Walsh 36642b3552SMichael Walsh This function will be called by gen_exit_function(). 37642b3552SMichael Walsh """ 38642b3552SMichael Walsh 39642b3552SMichael Walsh process_robot_output_files() 40642b3552SMichael Walsh 41642b3552SMichael Walsh 42642b3552SMichael Walshdef validate_parms(): 43642b3552SMichael Walsh r""" 44642b3552SMichael Walsh Validate program parameters, etc. 45642b3552SMichael Walsh 46642b3552SMichael Walsh This function will be called by gen_setup(). 47642b3552SMichael Walsh """ 48642b3552SMichael Walsh 49642b3552SMichael Walsh get_plug_vars() 50642b3552SMichael Walsh 51642b3552SMichael Walsh valid_value(AUTOBOOT_OPENBMC_HOST) 52642b3552SMichael Walsh 53642b3552SMichael Walsh 54642b3552SMichael Walshdef main(): 55642b3552SMichael Walsh 56642b3552SMichael Walsh gen_setup() 57642b3552SMichael Walsh 58642b3552SMichael Walsh print_plug_in_header() 59642b3552SMichael Walsh 60642b3552SMichael Walsh if FFDC_COMMAND.upper() == "FAIL": 61642b3552SMichael Walsh if AUTOBOOT_BOOT_SUCCESS == "0": 62642b3552SMichael Walsh print_timen("The caller wishes to dump FFDC after each boot failure.") 63642b3552SMichael Walsh exit(dump_ffdc_rc()) 64642b3552SMichael Walsh elif FFDC_COMMAND.upper() == "ALL": 65642b3552SMichael Walsh print_timen("The caller wishes to dump FFDC after each boot test.") 66642b3552SMichael Walsh exit(dump_ffdc_rc()) 67642b3552SMichael Walsh elif len(FFDC_COMMAND) > 0: 68642b3552SMichael Walsh shell_rc, out_buf = shell_cmd(FFDC_COMMAND, quiet=quiet) 69642b3552SMichael Walsh if shell_rc != 0: 70642b3552SMichael Walsh print_timen("The caller wishes to dump FFDC.") 71642b3552SMichael Walsh exit(dump_ffdc_rc()) 72642b3552SMichael Walsh if FFDC_SOFT_ERRORS: 73642b3552SMichael Walsh # Check the num_error_logs value left by the Soft_errors plug-in. 74642b3552SMichael Walsh num_error_logs = int(restore_plug_in_value(0, "Soft_errors")) 75642b3552SMichael Walsh if num_error_logs > 0: 76642b3552SMichael Walsh print_timen("The \"Soft_errors\" plug-in found soft_errors and the" 77642b3552SMichael Walsh + " caller wishes to dump FFDC on soft errors.") 78642b3552SMichael Walsh exit(dump_ffdc_rc()) 79642b3552SMichael Walsh 80642b3552SMichael Walsh print_timen("The caller does not wish for any FFDC to be collected.") 81642b3552SMichael Walsh 82642b3552SMichael Walsh 83642b3552SMichael Walshmain() 84