blob: 8d512710d5f3e003b2998ef472fbcbe9a912d379 [file] [log] [blame]
George Keishinge7e91712021-09-03 11:28:44 -05001#!/usr/bin/env python3
Michael Walsh642b3552020-05-05 14:04:11 -05002
3from gen_print import *
4from gen_valid import *
George Keishinge635ddc2022-12-08 07:38:02 -06005from gen_arg import *
6from gen_misc import *
7from gen_cmd import *
8from gen_plug_in_utils import *
9from gen_call_robot import *
Michael Walsh642b3552020-05-05 14:04:11 -050010
11# Set exit_on_error for gen_valid functions.
12set_exit_on_error(True)
13
14parser = argparse.ArgumentParser(
George Keishinge635ddc2022-12-08 07:38:02 -060015 usage='%(prog)s [OPTIONS]',
16 description="%(prog)s will determine whether FFDC should be collected. If so, it will return "
17 + repr(dump_ffdc_rc()) + ".",
Michael Walsh642b3552020-05-05 14:04:11 -050018 formatter_class=argparse.ArgumentDefaultsHelpFormatter,
George Keishinge635ddc2022-12-08 07:38:02 -060019 prefix_chars='-+')
Michael Walsh642b3552020-05-05 14:04:11 -050020
21# The stock_list will be passed to gen_get_options. We populate it with the names of stock parm options we
22# want. These stock parms are pre-defined by gen_get_options.
George Keishinge635ddc2022-12-08 07:38:02 -060023stock_list = [("test_mode", get_plug_default("test_mode", 0)),
24 ("quiet", get_plug_default("quiet", 0)),
25 ("debug", get_plug_default("debug", 0))]
Michael Walsh642b3552020-05-05 14:04:11 -050026
27# For now we are hard-coding this value vs adding a soft_errors=boolean entry in the parm_def file.
28FFDC_SOFT_ERRORS = 1
29
30
George Keishinge635ddc2022-12-08 07:38:02 -060031def exit_function(signal_number=0,
32 frame=None):
Michael Walsh642b3552020-05-05 14:04:11 -050033 r"""
34 Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
35
36 This function will be called by gen_exit_function().
37 """
38
39 process_robot_output_files()
40
41
42def validate_parms():
43 r"""
44 Validate program parameters, etc.
45
46 This function will be called by gen_setup().
47 """
48
49 get_plug_vars()
50
51 valid_value(AUTOBOOT_OPENBMC_HOST)
52
53
54def main():
George Keishinge635ddc2022-12-08 07:38:02 -060055
Michael Walsh642b3552020-05-05 14:04:11 -050056 gen_setup()
57
58 print_plug_in_header()
59
60 if FFDC_COMMAND.upper() == "FAIL":
61 if AUTOBOOT_BOOT_SUCCESS == "0":
George Keishinge635ddc2022-12-08 07:38:02 -060062 print_timen("The caller wishes to dump FFDC after each boot failure.")
Michael Walsh642b3552020-05-05 14:04:11 -050063 exit(dump_ffdc_rc())
64 elif FFDC_COMMAND.upper() == "ALL":
65 print_timen("The caller wishes to dump FFDC after each boot test.")
66 exit(dump_ffdc_rc())
67 elif len(FFDC_COMMAND) > 0:
68 shell_rc, out_buf = shell_cmd(FFDC_COMMAND, quiet=quiet)
69 if shell_rc != 0:
70 print_timen("The caller wishes to dump FFDC.")
71 exit(dump_ffdc_rc())
72 if FFDC_SOFT_ERRORS:
73 # Check the num_error_logs value left by the Soft_errors plug-in.
74 num_error_logs = int(restore_plug_in_value(0, "Soft_errors"))
75 if num_error_logs > 0:
George Keishinge635ddc2022-12-08 07:38:02 -060076 print_timen("The \"Soft_errors\" plug-in found soft_errors and the"
77 + " caller wishes to dump FFDC on soft errors.")
Michael Walsh642b3552020-05-05 14:04:11 -050078 exit(dump_ffdc_rc())
79
80 print_timen("The caller does not wish for any FFDC to be collected.")
81
82
83main()