Added support for ffdc_report plug-in call point.

Also changed wait interval from 3 to 10 seconds in run_boot function.

Change-Id: Ic528c68f1950adf95a17e7ba2020d8532218140a
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/obmc_boot_test.py b/lib/obmc_boot_test.py
index 660424d..d5b1081 100755
--- a/lib/obmc_boot_test.py
+++ b/lib/obmc_boot_test.py
@@ -148,6 +148,7 @@
     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'))
@@ -171,6 +172,9 @@
     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"
+
 ###############################################################################
 
 
@@ -194,6 +198,8 @@
                                   ffdc_list_file_path)
     BuiltIn().set_global_variable("${FFDC_REPORT_LIST_PATH}",
                                   ffdc_report_list_path)
+    BuiltIn().set_global_variable("${FFDC_SUMMARY_LIST_PATH}",
+                                  ffdc_summary_list_path)
 
     BuiltIn().set_global_variable("${FFDC_DIR_PATH_STYLE}",
                                   ffdc_dir_path_style)
@@ -205,7 +211,8 @@
     # element in additional_values.
     additional_values = ["program_pid", "master_pid", "ffdc_dir_path",
                          "status_dir_path", "base_tool_dir_path",
-                         "ffdc_list_file_path", "ffdc_report_list_path"]
+                         "ffdc_list_file_path", "ffdc_report_list_path",
+                         "ffdc_summary_list_path"]
 
     plug_in_vars = parm_list + additional_values
 
@@ -298,6 +305,12 @@
     except OSError:
         pass
 
+    # Clear the ffdc_summary_list_path file.  Plug-ins may now write to it.
+    try:
+        os.remove(ffdc_summary_list_path)
+    except OSError:
+        pass
+
 ###############################################################################
 
 
@@ -567,6 +580,11 @@
     Print a defect report.
     """
 
+    # Making deliberate choice to NOT run plug_in_setup().  We don't want
+    # ffdc_prefix updated.
+    rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
+        call_point='ffdc_report', stop_on_plug_in_failure=0)
+
     # At some point I'd like to have the 'Call FFDC Methods' return a list
     # of files it has collected.  In that case, the following "ls" command
     # would no longer be needed.  For now, however, glob shows the files
@@ -581,6 +599,14 @@
     shell_rc, more_header_info = gc.cmd_fnc_u(cmd_buf, print_output=0,
                                               show_err=0)
 
+    # Get additional header data which may have been created by ffdc plug-ins.
+    # Also, delete the individual header files to cleanup.
+    cmd_buf = "file_list=$(cat " + ffdc_summary_list_path + " 2>/dev/null)" +\
+              " ; [ ! -z \"${file_list}\" ] && cat ${file_list}" +\
+              " 2>/dev/null ; rm -rf ${file_list} 2>/dev/null || :"
+    shell_rc, ffdc_summary_info = gc.cmd_fnc_u(cmd_buf, print_output=0,
+                                               show_err=0)
+
     LOG_PREFIX = BuiltIn().get_variable_value("${LOG_PREFIX}")
 
     output = '\n'.join(sorted(glob.glob(LOG_PREFIX + '*')))
@@ -623,6 +649,9 @@
     # gp.qprintn(ffdc_list)
     gp.qprintn()
 
+    if len(ffdc_summary_info) > 0:
+        gp.printn(ffdc_summary_info)
+
     gp.qprint_dashes(0, 90, 1, "=")
 
     ffdc_list_file.write(output + "\n")
@@ -642,7 +671,7 @@
 
     plug_in_setup()
     rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
-        call_point='ffdc', stop_on_plug_in_failure=1)
+        call_point='ffdc', stop_on_plug_in_failure=0)
 
     AUTOBOOT_FFDC_PREFIX = os.environ['AUTOBOOT_FFDC_PREFIX']
     status, ret_values = grk.run_key_u("FFDC  ffdc_prefix=" +
@@ -734,7 +763,7 @@
             del match_state['epoch_seconds']
             # Wait for the state to change in any way.
             st.wait_state(match_state, wait_time=state_change_timeout,
-                          interval="3 seconds", invert=1)
+                          interval="10 seconds", invert=1)
 
         gp.qprintn()
         if boot_table[boot]['end']['chassis'] == "Off":
@@ -742,7 +771,7 @@
         else:
             boot_timeout = power_on_timeout
         st.wait_state(boot_table[boot]['end'], wait_time=boot_timeout,
-                      interval="3 seconds")
+                      interval="10 seconds")
 
     plug_in_setup()
     rc, shell_rc, failed_plug_in_name = \
@@ -800,7 +829,7 @@
     # NOTE: A post_test_case call point failure is NOT counted as a boot
     # failure.
     rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
-        call_point='post_test_case', stop_on_plug_in_failure=1)
+        call_point='post_test_case', stop_on_plug_in_failure=0)
 
     plug_in_setup()
     rc, shell_rc, failed_plug_in_name = grpi.rprocess_plug_in_packages(
@@ -843,13 +872,14 @@
     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=1)
+            call_point='cleanup', stop_on_plug_in_failure=0)
 
-    # 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)
+    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)
 
 ###############################################################################