Beispiel #1
0
def init_robot_out_parms(extra_prefix=""):
    r"""
    Initialize robot output parms such as outputdir, output, etc.

    This function will set global values for the following robot output parms.

    outputdir, output, log, report, loglevel

    This function would typically be called prior to calling
    create_robot_cmd_string.

    Description of argument(s):
    extra_prefix                    An extra prefix to be appended to the
                                    default prefix for output file names.
    """

    gp.dprint_executing()
    AUTOBOOT_OPENBMC_NICKNAME = gm.get_mod_global("AUTOBOOT_OPENBMC_NICKNAME")

    # Set values for call to create_robot_cmd_string.
    # Environment variable TMP_ROBOT_DIR_PATH can be set by the user to
    # indicate that robot-generated output should initially be written to the
    # specified temporary directory and then moved to the normal output
    # location after completion.
    outputdir =\
        os.environ.get("TMP_ROBOT_DIR_PATH",
                       os.environ.get("STATUS_DIR_PATH",
                                      os.environ.get("HOME", ".")
                                      + "/autoipl/status"))
    outputdir = gm.add_trailing_slash(outputdir)
    seconds = time.time()
    loc_time = time.localtime(seconds)
    time_string = time.strftime("%y%m%d.%H%M%S", loc_time)
    file_prefix = AUTOBOOT_OPENBMC_NICKNAME + "." + extra_prefix +\
        time_string + "."
    # Environment variable SAVE_STATUS_POLICY governs when robot-generated
    # output files (e.g. the log.html) will be moved from TMP_ROBOT_DIR_PATH
    # to FFDC_DIR_PATH.  Valid values are "ALWAYS", "NEVER" and "FAIL".
    SAVE_STATUS_POLICY = os.environ.get("SAVE_STATUS_POLICY", "ALWAYS")
    if SAVE_STATUS_POLICY == "NEVER":
        output = "NONE"
        log = "NONE"
        report = "NONE"
    else:
        output = file_prefix + "output.xml"
        log = file_prefix + "log.html"
        report = file_prefix + "report.html"
    loglevel = "TRACE"

    # Make create_robot_cmd_string values global.
    gm.set_mod_global(outputdir)
    gm.set_mod_global(output)
    gm.set_mod_global(log)
    gm.set_mod_global(report)
    gm.set_mod_global(loglevel)
def init_robot_out_parms(extra_prefix=""):
    r"""
    Initialize robot output parms such as outputdir, output, etc.

    This function will set global values for the following robot output parms.

    outputdir, output, log, report, loglevel

    This function would typically be called prior to calling
    create_robot_cmd_string.
    """

    gp.dprint_executing()
    AUTOBOOT_OPENBMC_NICKNAME = gm.get_mod_global("AUTOBOOT_OPENBMC_NICKNAME")

    # Set values for call to create_robot_cmd_string.
    # Environment variable TMP_ROBOT_DIR_PATH can be set by the user to
    # indicate that robot-generated output should initially be written to the
    # specified temporary directory and then moved to the normal output
    # location after completion.
    outputdir =\
        os.environ.get("TMP_ROBOT_DIR_PATH",
                       os.environ.get("STATUS_DIR_PATH",
                                      os.environ.get("HOME", ".")
                                      + "/autoipl/status"))
    outputdir = gm.add_trailing_slash(outputdir)
    seconds = time.time()
    loc_time = time.localtime(seconds)
    time_string = time.strftime("%y%m%d.%H%M%S", loc_time)
    file_prefix = AUTOBOOT_OPENBMC_NICKNAME + "." + extra_prefix +\
        time_string + "."
    # Environment variable SAVE_STATUS_POLICY governs when robot-generated
    # output files (e.g. the log.html) will be moved from TMP_ROBOT_DIR_PATH
    # to FFDC_DIR_PATH.  Valid values are "ALWAYS", "NEVER" and "FAIL".
    SAVE_STATUS_POLICY = os.environ.get("SAVE_STATUS_POLICY", "ALWAYS")
    if SAVE_STATUS_POLICY == "NEVER":
        output = "NONE"
        log = "NONE"
        report = "NONE"
    else:
        output = file_prefix + "output.xml"
        log = file_prefix + "log.html"
        report = file_prefix + "report.html"
    loglevel = "TRACE"

    # Make create_robot_cmd_string values global.
    gm.set_mod_global(outputdir)
    gm.set_mod_global(output)
    gm.set_mod_global(log)
    gm.set_mod_global(report)
    gm.set_mod_global(loglevel)
def init_robot_out_parms(extra_prefix=""):
    r"""
    Initialize robot output parms such as outputdir, output, etc.

    This function will set global values for the following robot output parms.

    outputdir, output, log, report, loglevel

    This function would typically be called prior to calling
    create_robot_cmd_string.
    """

    AUTOBOOT_OPENBMC_NICKNAME = gm.get_mod_global("AUTOBOOT_OPENBMC_NICKNAME")

    FFDC_DIR_PATH_STYLE = os.environ.get('FFDC_DIR_PATH_STYLE', '0')
    if FFDC_DIR_PATH_STYLE == '1':
        default_ffdc_dir_path = "/tmp/"
    else:
        default_ffdc_dir_path = base_path
    # Set values for call to create_robot_cmd_string.
    outputdir = gm.add_trailing_slash(
        os.environ.get("FFDC_DIR_PATH", default_ffdc_dir_path))
    seconds = time.time()
    loc_time = time.localtime(seconds)
    time_string = time.strftime("%y%m%d.%H%M%S", loc_time)
    file_prefix = AUTOBOOT_OPENBMC_NICKNAME + "." + extra_prefix +\
        time_string + "."
    output = file_prefix + "output.xml"
    log = file_prefix + "log.html"
    report = file_prefix + "report.html"
    loglevel = "TRACE"

    # Make create_robot_cmd_string values global.
    gm.set_mod_global(outputdir)
    gm.set_mod_global(output)
    gm.set_mod_global(log)
    gm.set_mod_global(report)
    gm.set_mod_global(loglevel)
Beispiel #4
0
def init_robot_test_base_dir_path():
    r"""
    Initialize and validate the environment variable, ROBOT_TEST_BASE_DIR_PATH
    and set corresponding global variable ROBOT_TEST_RUNNING_FROM_SB.

    If ROBOT_TEST_BASE_DIR_PATH is already set, this function will merely
    validate it.  This function will also set environment variable
    ROBOT_TEST_RUNNING_FROM_SB when ROBOT_TEST_BASE_DIR_PATH is not pre-set.
    """

    # ROBOT_TEST_BASE_DIR_PATH will be set as follows:
    # This function will determine whether we are running in a user sandbox
    # or from a standard apolloxxx environment.
    # - User sandbox:
    # If there is a <developer's home dir>/git/openbmc-test-automation/,
    # ROBOT_TEST_BASE_DIR_PATH will be set to that path.  Otherwise, we set it
    # to <program dir path>/git/openbmc-test-automation/
    # - Not in user sandbox:
    # ROBOT_TEST_BASE_DIR_PATH will be set to <program dir
    # path>/git/openbmc-test-automation/

    ROBOT_TEST_BASE_DIR_PATH = os.environ.get('ROBOT_TEST_BASE_DIR_PATH', "")
    ROBOT_TEST_RUNNING_FROM_SB = \
        int(os.environ.get('ROBOT_TEST_RUNNING_FROM_SB', "0"))
    if ROBOT_TEST_BASE_DIR_PATH == "":
        # ROBOT_TEST_BASE_DIR_PATH was not set by user/caller.
        AUTOIPL_VERSION = os.environ.get('AUTOIPL_VERSION', '')
        if AUTOIPL_VERSION == "":
            ROBOT_TEST_BASE_DIR_PATH = base_path
        else:
            suffix = "git/openbmc-test-automation/"

            # Determine whether we're running out of a developer sandbox or
            # simply out of an apolloxxx/bin path.
            shell_rc, out_buf = gc.shell_cmd('dirname $(which gen_print.py)',
                                             quiet=(not debug), print_output=0)
            executable_base_dir_path = os.path.realpath(out_buf.rstrip()) + "/"
            apollo_dir_path = os.environ['AUTO_BASE_PATH'] + AUTOIPL_VERSION +\
                "/bin/"
            developer_home_dir_path = re.sub('/sandbox.*', '',
                                             executable_base_dir_path)
            developer_home_dir_path = \
                gm.add_trailing_slash(developer_home_dir_path)
            gp.dprint_vars(executable_base_dir_path, developer_home_dir_path,
                           apollo_dir_path)

            ROBOT_TEST_RUNNING_FROM_SB = 0
            if executable_base_dir_path != apollo_dir_path:
                ROBOT_TEST_RUNNING_FROM_SB = 1
                gp.dprint_vars(ROBOT_TEST_RUNNING_FROM_SB)
                ROBOT_TEST_BASE_DIR_PATH = developer_home_dir_path + suffix
                if not os.path.isdir(ROBOT_TEST_BASE_DIR_PATH):
                    gp.dprint_timen("NOTE: Sandbox directory "
                                    + ROBOT_TEST_BASE_DIR_PATH + " does not"
                                    + " exist.")
                    # Fall back to the apollo dir path.
                    ROBOT_TEST_BASE_DIR_PATH = apollo_dir_path + suffix
            else:
                # Use to the apollo dir path.
                ROBOT_TEST_BASE_DIR_PATH = apollo_dir_path + suffix

    if not gv.valid_value(ROBOT_TEST_BASE_DIR_PATH):
        return False
    gp.dprint_vars(ROBOT_TEST_RUNNING_FROM_SB, ROBOT_TEST_BASE_DIR_PATH)
    if not gv.valid_dir_path(ROBOT_TEST_BASE_DIR_PATH):
        return False

    ROBOT_TEST_BASE_DIR_PATH = gm.add_trailing_slash(ROBOT_TEST_BASE_DIR_PATH)
    gm.set_mod_global(ROBOT_TEST_BASE_DIR_PATH)
    os.environ['ROBOT_TEST_BASE_DIR_PATH'] = ROBOT_TEST_BASE_DIR_PATH

    gm.set_mod_global(ROBOT_TEST_RUNNING_FROM_SB)
    os.environ['ROBOT_TEST_RUNNING_FROM_SB'] = str(ROBOT_TEST_RUNNING_FROM_SB)