Standardized Stop/cp_stop_check
Made changes to standardize Stop/cp_stop_check.
Change-Id: I56967d3c728a9170d59b8ed427cd7281e751c882
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/bin/plug_ins/Stop/cp_stop_check b/bin/plug_ins/Stop/cp_stop_check
index 40b8433..d736278 100755
--- a/bin/plug_ins/Stop/cp_stop_check
+++ b/bin/plug_ins/Stop/cp_stop_check
@@ -7,9 +7,6 @@
import sys
import subprocess
-save_path_0 = sys.path[0]
-del sys.path[0]
-
from gen_print import *
from gen_valid import *
from gen_arg import *
@@ -18,20 +15,17 @@
from gen_plug_in_utils import *
from gen_call_robot import *
-# Restore sys.path[0].
-sys.path.insert(0, save_path_0)
-
# Set exit_on_error for gen_valid functions.
set_exit_on_error(True)
-# Initialize.
-STOP_REST_FAIL = ''
+# Initialize default plug-in parms..
+STOP_REST_FAIL = 0
STOP_COMMAND = ''
stop_test_rc = 2
+STOP_VERIFY_HARDWARE_FAIL = 0
+
# Create parser object to process command line parameters and args.
-
-# Create parser object.
parser = argparse.ArgumentParser(
usage='%(prog)s [OPTIONS]',
description="If the \"Stop\" plug-in is selected by the user, %(prog)s" +
@@ -60,45 +54,22 @@
frame=None):
r"""
Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
- """
- dprint_executing()
- dprint_var(signal_number)
+ This function will be called by gen_exit_function().
+ """
process_robot_output_files()
- qprint_pgm_footer()
-
-
-def signal_handler(signal_number,
- frame):
- r"""
- Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
- with return code 143 and without calling our exit_function.
- """
-
- # Our convention is to set up exit_function with atexit.register() so there is no need to explicitly
- # call exit_function from here.
-
- dprint_executing()
-
- # Calling exit prevents us from returning to the code that was running when we received the signal.
- exit(0)
-
def validate_parms():
r"""
- Validate program parameters, etc. Return True or False (i.e. pass/fail) accordingly.
+ Validate program parameters, etc.
+
+ This function will be called by gen_setup().
"""
get_plug_vars()
- valid_value(AUTOBOOT_OPENBMC_HOST)
-
- gen_post_validation(exit_function, signal_handler)
-
- return True
-
def stop_check():
r"""
@@ -116,12 +87,12 @@
not, this function will stop the program by returning stop_test_rc.
"""
- if STOP_REST_FAIL != '1':
+ if not STOP_REST_FAIL:
return
print_timen("Checking to see whether REST commands are working.")
init_robot_out_parms(get_plug_in_package_name() + "." + pgm_name + ".")
- lib_file_path = init_robot_file_path("lib/state.py") + ":"\
+ lib_file_path = init_robot_file_path("lib/state.py") + ":" \
+ init_robot_file_path("lib/gen_robot_print.py")
set_mod_global(lib_file_path)
timeout = '0 seconds'
@@ -135,11 +106,9 @@
REST_USERNAME, REST_PASSWORD, keyword_string, lib_file_path, quiet,
test_mode, debug, outputdir, output, log, report, loglevel)
if not robot_cmd_fnc(cmd_buf):
- print_timen("The caller wishes to stop test execution if REST" +
- " commands are failing.")
+ print_timen("The caller wishes to stop test execution if REST commands are failing.")
stop_check()
- print_timen("REST commands are working so no reason as of yet to stop" +
- " the test.")
+ print_timen("REST commands are working so no reason as of yet to stop the test.")
def esel_stop_check():
@@ -151,27 +120,16 @@
if STOP_ESEL_STOP_FILE_PATH == "":
return
- cmd_buf = "esel_stop_check --esel_stop_file_path=" +\
- STOP_ESEL_STOP_FILE_PATH
- shell_rc, out_buf = cmd_fnc_u(cmd_buf, show_err=0)
+ cmd_buf = "esel_stop_check --esel_stop_file_path=" + STOP_ESEL_STOP_FILE_PATH
+ shell_rc, out_buf = shell_cmd(cmd_buf, show_err=0)
if shell_rc == stop_test_rc:
- print_timen("The caller wishes to stop test execution based on the" +
- " presence of certain esel entries.")
+ print_timen("The caller wishes to stop test execution based on the presence of certain esel entries.")
stop_check()
def main():
- if not gen_get_options(parser, stock_list):
- return False
-
- if not validate_parms():
- return False
-
- qprint_pgm_header()
-
- if not debug:
- qprint_vars(STOP_REST_FAIL, STOP_COMMAND, AUTOBOOT_BOOT_SUCCESS)
+ gen_setup()
print_plug_in_header()
@@ -183,7 +141,7 @@
print_timen("The caller wishes to stop after each boot test.")
stop_check()
elif len(STOP_COMMAND) > 0:
- shell_rc, out_buf = cmd_fnc_u(STOP_COMMAND, quiet=quiet, show_err=0)
+ shell_rc, out_buf = shell_cmd(STOP_COMMAND, quiet=quiet, show_err=0)
if shell_rc != 0:
print_timen("The caller wishes to stop test execution.")
stop_check()
@@ -192,11 +150,14 @@
esel_stop_check()
+ if STOP_VERIFY_HARDWARE_FAIL:
+ hardware_error_found = restore_plug_in_value(0, 'Verify_hardware')
+ if hardware_error_found:
+ print_timen("The caller wishes to stop test execution when the Verify_hardware plug-in detects a"
+ + " hardware error.")
+ stop_check()
+
qprint_timen("The caller does not wish to stop the test run.")
- return True
-# Main
-
-if not main():
- exit(1)
+main()