| George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 2 |  | 
| Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 3 | from gen_arg import * | 
 | 4 | from gen_call_robot import * | 
 | 5 | from gen_cmd import * | 
 | 6 | from gen_misc import * | 
 | 7 | from gen_plug_in_utils import * | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 8 | from gen_print import * | 
 | 9 | from gen_valid import * | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 10 |  | 
 | 11 | # Set exit_on_error for gen_valid functions. | 
 | 12 | set_exit_on_error(True) | 
 | 13 |  | 
 | 14 | parser = argparse.ArgumentParser( | 
| Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 15 |     usage="%(prog)s [OPTIONS]", | 
 | 16 |     description=( | 
 | 17 |         "%(prog)s will determine whether FFDC should be collected.  If so, it" | 
 | 18 |         " will return " | 
 | 19 |     ) | 
 | 20 |     + repr(dump_ffdc_rc()) | 
 | 21 |     + ".", | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 22 |     formatter_class=argparse.ArgumentDefaultsHelpFormatter, | 
| Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 23 |     prefix_chars="-+", | 
 | 24 | ) | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 25 |  | 
 | 26 | # The stock_list will be passed to gen_get_options.  We populate it with the names of stock parm options we | 
 | 27 | # want.  These stock parms are pre-defined by gen_get_options. | 
| Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 28 | stock_list = [ | 
 | 29 |     ("test_mode", get_plug_default("test_mode", 0)), | 
 | 30 |     ("quiet", get_plug_default("quiet", 0)), | 
 | 31 |     ("debug", get_plug_default("debug", 0)), | 
 | 32 | ] | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 33 |  | 
 | 34 | # For now we are hard-coding this value vs adding a soft_errors=boolean entry in the parm_def file. | 
 | 35 | FFDC_SOFT_ERRORS = 1 | 
 | 36 |  | 
 | 37 |  | 
| Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 38 | def exit_function(signal_number=0, frame=None): | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 39 |     r""" | 
 | 40 |     Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT). | 
 | 41 |  | 
 | 42 |     This function will be called by gen_exit_function(). | 
 | 43 |     """ | 
 | 44 |  | 
 | 45 |     process_robot_output_files() | 
 | 46 |  | 
 | 47 |  | 
 | 48 | def validate_parms(): | 
 | 49 |     r""" | 
 | 50 |     Validate program parameters, etc. | 
 | 51 |  | 
 | 52 |     This function will be called by gen_setup(). | 
 | 53 |     """ | 
 | 54 |  | 
 | 55 |     get_plug_vars() | 
 | 56 |  | 
 | 57 |     valid_value(AUTOBOOT_OPENBMC_HOST) | 
 | 58 |  | 
 | 59 |  | 
 | 60 | def main(): | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 61 |     gen_setup() | 
 | 62 |  | 
 | 63 |     print_plug_in_header() | 
 | 64 |  | 
 | 65 |     if FFDC_COMMAND.upper() == "FAIL": | 
 | 66 |         if AUTOBOOT_BOOT_SUCCESS == "0": | 
| Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 67 |             print_timen( | 
 | 68 |                 "The caller wishes to dump FFDC after each boot failure." | 
 | 69 |             ) | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 70 |             exit(dump_ffdc_rc()) | 
 | 71 |     elif FFDC_COMMAND.upper() == "ALL": | 
 | 72 |         print_timen("The caller wishes to dump FFDC after each boot test.") | 
 | 73 |         exit(dump_ffdc_rc()) | 
 | 74 |     elif len(FFDC_COMMAND) > 0: | 
 | 75 |         shell_rc, out_buf = shell_cmd(FFDC_COMMAND, quiet=quiet) | 
 | 76 |         if shell_rc != 0: | 
 | 77 |             print_timen("The caller wishes to dump FFDC.") | 
 | 78 |             exit(dump_ffdc_rc()) | 
 | 79 |     if FFDC_SOFT_ERRORS: | 
 | 80 |         # Check the num_error_logs value left by the Soft_errors plug-in. | 
 | 81 |         num_error_logs = int(restore_plug_in_value(0, "Soft_errors")) | 
 | 82 |         if num_error_logs > 0: | 
| Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 83 |             print_timen( | 
 | 84 |                 'The "Soft_errors" plug-in found soft_errors and the' | 
 | 85 |                 + " caller wishes to dump FFDC on soft errors." | 
 | 86 |             ) | 
| Michael Walsh | 642b355 | 2020-05-05 14:04:11 -0500 | [diff] [blame] | 87 |             exit(dump_ffdc_rc()) | 
 | 88 |  | 
 | 89 |     print_timen("The caller does not wish for any FFDC to be collected.") | 
 | 90 |  | 
 | 91 |  | 
 | 92 | main() |