Пример #1
0
    def add_result(self, arg_ret_code):

        my_tup = None
        self.total_count += 1

        Msg.dbg('Adding Simulation results, "%s"' % (str(self.sim_cmd)))
        if arg_ret_code != 0:
            # only need to create a tuple with the return code
            Msg.dbg("Simulation Failed, return code: " + str(arg_ret_code))
            self.failed_count += 1
            my_tup = (1, arg_ret_code, self.curr_test_log, None, "FAIL")

        else:
            my_lines = None
            try:
                Msg.dbg("Attempting to Open: " + self.curr_test_log)
                with open(self.curr_test_log, "r") as my_log:
                    Msg.dbg("File Open: " + self.curr_test_log)
                    my_lines = my_log.readlines()
                    Msg.dbg("Line %d: %s" % (len(my_lines), my_lines[-1]))
                    my_lastline = my_lines[-1]

                my_segs = my_lastline.split()
                my_num_instr = int(my_segs[0])
                if my_num_instr < self.num_instr:
                    Msg.dbg(
                        "Simulation Success, return code = 0 and the "
                        "instruction limit was not reached"
                    )
                    my_tup = (
                        0,
                        arg_ret_code,
                        self.curr_test_log,
                        None,
                        "PASS",
                    )
                else:
                    #
                    Msg.dbg("Simulation Failed, Instruction Limit Reached ")
                    self.failed_count += 1
                    my_tup = (
                        2,
                        arg_ret_code,
                        self.curr_test_log,
                        "Instruction Limit Reached: Failed at "
                        + str(self.num_instr)
                        + " Instructions ",
                        "FAIL",
                    )
            except BaseException:
                if Msg._debug():
                    traceback.print_exc(file=sys.stdout)
                my_tup = (
                    arg_ret_code,
                    "Unsupported",
                    "Unable to Extract Test Failure Information",
                    "FAIL",
                    " ",
                )
            finally:
                my_log.close()

        self.results[self.curr_test_id] = my_tup
        Msg.dbg("Results Tuple: " + str(my_tup))

        self.curr_test_id = None
        self.curr_test_log = None
Пример #2
0
 def load( self, arg_ctrl_item ):
     Msg.dbg( "Controller::load( ... )" )
     self.ctrl_item = arg_ctrl_item
Пример #3
0
    def exec_process(cls,
                     arg_cmd,
                     arg_fout=None,
                     arg_ferr=None,
                     arg_timeout=None,
                     arg_kill=False,
                     arg_set_process=None):
        #def exec_process( cls, arg_cmd, arg_fout = None, arg_ferr = None, arg_timeout = None, arg_kill_all = True ):

        my_process_cmd = arg_cmd
        Msg.dbg(my_process_cmd)
        my_fout, my_ferr = SysUtils.open_output(arg_fout, arg_ferr)
        my_result = None
        my_stdout = None
        my_stderr = None

        Msg.user(
            "SysUtils.exec_process( ... , arg_set_process: %s" %
            (str(bool(arg_set_process is not None))), "SYS-UTILS")
        Msg.flush()

        try:
            from common.datetime_utils import DateTime
            my_process = subprocess.Popen(my_process_cmd,
                                          stdout=my_fout,
                                          stderr=my_ferr,
                                          shell=True)
            my_start_time = DateTime.Time()
            my_pid = my_process.pid
            if arg_timeout is None or not SysUtils.is_numeric(arg_timeout):
                Msg.user("Exec PID[NONE]: %s" % (str(my_pid)))
                my_result = my_process.communicate()
                Msg.user("Done PID[NONE]: %s" % (str(my_pid)))
            else:
                Msg.user("Timeout: %s" % (str(arg_timeout)))
                try:
                    my_pgid = os.getpgid(my_pid)
                    my_parent_pgid = os.getpgid(0)

                    # use callback to save an instance of the process to allow
                    if arg_set_process is not None:
                        arg_set_process(my_process)

                    # Msg.dbg( "Exec Cmd: %s" % ( str( arg_cmd )))
                    # Msg.dbg( "PID: %s, PGID: %s, P-PGID: %s, Timeout: %s" % ( str( my_pid ), str( my_pgid ), str( my_parent_pgid ), str(arg_timeout)))
                    # Msg.flush()
                    my_result = my_process.communicate(timeout=arg_timeout)
                    #my_pgid = os.getpgid(my_pid)
                    # Msg.user( "Done PID: %s, PGID: %s, Timeout: %s" % ( str( my_pid ), str( my_pgid ), str(arg_timeout)))

                except TimeoutExpired:
                    try:
                        Msg.err(
                            'Timeout after %d seconds, terminating process: %s'
                            % (arg_timeout, my_process_cmd))
                        my_parent_pgid = os.getpgid(0)
                        my_pgid = os.getpgid(my_pid)
                        # os.setpgid( os.getpid(), os.getpid())

                        # on timeout kill the spawned process and all related sub-processes
                        if arg_kill:
                            # Msg.dbg( "Killing Everything ..." )
                            # os.killpg( os.getpgid( my_pid ), signal.SIGTERM )
                            os.killpg(os.getpgid(my_pid), signal.SIGKILL)

                        # Trigger Shutdown of spawned processes
                        else:
                            Msg.error_trace()
                            # my_process.kill()
                            os.kill(my_pid, signal.SIGTERM)

                    except OSError as arg_ex:
                        # Msg.dbg( "Spawned Killing encountered OS Error ... " )
                        Msg.error(str(arg_ex))
                    finally:
                        # Msg.dbg( "Timeout Occurred ... " )
                        my_result = my_process.communicate()
                        Msg.flush()
                        return (my_process.returncode, None,
                                "Process Timeout Occurred", my_start_time,
                                my_start_time, SysUtils.PROCESS_TIMEOUT)

                except Exception as arg_ex:

                    Msg.err(str(arg_ex))
                    Msg.error_trace()

                except:
                    Msg.error_trace()

                finally:
                    Msg.user("[1] SysUtils::exec_process")
                    # Msg.user( "SysUtils.exec_process[10]", "test" )
                    pass

            my_end_time = DateTime.Time()
            # Msg.dbg( "SysUtils.exec_process, my_result: %s" % ( str( my_result )))
            # Msg.dbg( "Return Code:    %d" % ( my_process.returncode ))

            if my_result[0] is not None:
                my_stdout = my_result[0].decode("utf-8")

            if my_result[1] is not None:
                my_stderr = my_result[1].decode("utf-8")

            return (my_process.returncode, my_stdout, my_stderr, my_start_time,
                    my_end_time, SysUtils.NORMAL)

        finally:

            if not (my_fout == PIPE or my_fout.closed): my_fout.close()
            if not (my_ferr == PIPE or my_ferr.closed): my_ferr.close()

        return (0, None, "Unable to Spawn Process ....", 0, None, None,
                SysUtils.PROCESS_UNABLE_TO_SPAWN)
Пример #4
0
    def archive_dir(cls, arg_srcdir):

        try:
            # get the base name
            my_basename = "%s" % (str(DateTime.YMD()))
            Msg.dbg("Base Name: %s" % (my_basename))

            # set the directory mask
            my_srcdir = PathUtils.exclude_trailing_path_delimiter(arg_srcdir)
            my_srcmask = "%s_%s_???" % (my_srcdir, my_basename)
            Msg.dbg("Directory Mask: %s" % (my_srcmask))

            # list any previous copies
            my_dirlist = sorted(PathUtils.list_files(my_srcmask))

            Msg.lout(my_dirlist, "dbg")
            my_findex = 0

            # there are only two possiblities here
            # 1. there is only one match, in which case the mask does not include a number
            # 2. there are more than one match in which case the last match should contain a number

            if len(my_dirlist) > 0:
                # remove the wildcards
                my_srcmask = my_srcmask.replace("???", "")
                Msg.dbg("New File Mask: %s" % (my_srcmask))

                my_tmp = my_dirlist[-1]
                Msg.dbg("Last Filename: %s" % (my_tmp))

                my_tmp = my_tmp.replace(my_srcmask, "")
                Msg.dbg("My Index Last Filename: %s" % (my_tmp))

                my_findex = int(my_tmp) + 1
                Msg.dbg("My New Index Filename: %s" % (my_findex))

            # get the target name
            my_tgtdir = ("%s_%s_%0.3d" % (my_srcdir, my_basename, my_findex))
            Msg.dbg("Target Directory: %s" % (my_tgtdir))
            return PathUtils.move(my_srcdir, my_tgtdir)

        except Exception as arg_ex:
            Msg.error_trace(str(arg_ex))
            Msg.err(str(arg_ex))
            return False
Пример #5
0
 def chmod(aClass, aFPath, aOctalPermissions):
     try:
         os.chmod(aFPath, aOctalPermissions)
     except OSError:
         Msg.dbg("Failed to modify permissions of file: " + str(aFPath))
         raise
Пример #6
0
 def run(self):
     Msg.dbg("ThreadTestRun::run()")
     UnitTest_HiThread().run()
     UnitTest_HiEvent().run()
     UnitTest_HiMutex().run()
Пример #7
0
    def report(self, a_apps_info, a_my_tag):

        if not self.setup_report(a_apps_info):
            return

        time_stamp = datetime.utcnow()
        time_string = "_%0.4d%0.2d%0.2d_%0.2d%0.2d" % (
            time_stamp.year,
            time_stamp.month,
            time_stamp.day,
            time_stamp.hour,
            time_stamp.minute,
        )

        version = ""
        revision_stamp = ""

        for item in self.m_force_scm_version:
            if item.get("status", False):
                version = item["version"]
                # prefer git data, otherwise keep looking for
                # valid version
                if item["scm_type"] == "git":
                    break
        if version:
            revision_stamp = "_r" + str(version)

        rtl_report_name = self.rtl_report_name + time_string + revision_stamp

        rtl_control_data = {}
        self.rtl_config.processControlData(rtl_control_data)
        report_script_path = rtl_control_data.get("report_script_path", None)
        report_script_path = PathUtils.real_path(a_apps_info.mMainAppPath +
                                                 "/" + report_script_path)
        report_directory = PathUtils.real_path(
            self.m_regression_output_directory + "/../../")

        # What about the report path?  We get that from the
        # master_run output_dir
        report_command = (report_script_path + " --report-dir " +
                          report_directory + " --name " + rtl_report_name)
        if self.m_report_dump_xml:
            report_command += " --dump-xml"

        Msg.dbg("Main app path: " + str(a_apps_info.mMainAppPath))
        Msg.dbg("Report script path: " + str(report_script_path))
        Msg.dbg("Report directory: " + str(report_directory))
        Msg.dbg("Reporting command: " + str(report_command))

        # actually execute the report script
        report.call_from_python(report_command)

        # create or append metrics file
        rtl_metrics_path = rtl_control_data.get("rtl_metrics_path", None)
        home = os.path.expanduser("~")
        rtl_metrics_path = rtl_metrics_path.replace("~", home)

        if not os.path.isfile(rtl_metrics_path):
            with open(rtl_metrics_path, "w+") as outfile:
                outfile.write("||------------------------------------------"
                              "---|--------------------|-------------------"
                              "-||\n")
                outfile.write("||                                   "
                              "Regression|        Total Cycles|  Total "
                              "Instructions||\n")
                outfile.write("||-------------------------------------------"
                              "--|--------------------|-------------------"
                              "-||\n")

        with open(rtl_metrics_path, "a") as outfile:
            outfile.write("||")
            for _ in range(45 - len(rtl_report_name)):
                outfile.write(" ")
            outfile.write(rtl_report_name + "|")
            for _ in range(20 - len(str(self.m_total_cycle_count))):
                outfile.write(" ")
            outfile.write(str(self.m_total_cycle_count) + "|")
            for _ in range(20 - len(str(self.m_total_instruction_count))):
                outfile.write(" ")
            outfile.write(str(self.m_total_instruction_count) + "||\n")
Пример #8
0
    def report(self):

        if self.default is None:
            self.default = 0
        if self.secondary is None:
            self.secondary = 0
        if self.total is None:
            self.total = 0

        Msg.info("Task Id: %s, Task Index: %d" %
                 (self.task_id, self.task_index))

        my_msg = "Process Log Contains "
        if (self.detail_flags
                & SummaryDetail.AnyDetail == SummaryDetail.Nothing):
            my_msg = "Process No Found or is Empty"
        else:
            if (self.detail_flags
                    & SummaryDetail.GenCmd == SummaryDetail.GenCmd):
                my_msg += "GenCmd, "
            if (self.detail_flags
                    & SummaryDetail.GenResult == SummaryDetail.GenResult):
                my_msg += "GenResult, "
            if (self.detail_flags
                    & SummaryDetail.IssCmd == SummaryDetail.IssCmd):
                my_msg += "IssCommand, "
            if (self.detail_flags
                    & SummaryDetail.IssResult == SummaryDetail.IssResult):
                my_msg += "IssResult, "
            if (self.detail_flags
                    & SummaryDetail.TraceCmpCmd == SummaryDetail.TraceCmpCmd):
                my_msg += "TraceCmpCommand, "
            if (self.detail_flags & SummaryDetail.TraceCmpResult ==
                    SummaryDetail.TraceCmpResult):
                my_msg += "TraceCmpResult, "

            # remove the trailing comma
            my_msg = my_msg[:-2]

        Msg.user(my_msg, "SUM-RPT")
        Msg.user("Force Return Code: %s" % (str(self.force_retcode)),
                 "SUM-RPT")
        # Msg.trace()

        # Msg.info( "Originating Control File: %s"  % ( self.parent_fctrl ))
        # Msg.info( "Control File Item: %s"  % ( str(  self.fctrl_item )))  2
        # Msg.info( "F-Run Control File: %s" % ( self.frun_path ))
        Msg.dbg("Force Ret Code: %s" % (str(self.force_retcode)))

        if SysUtils.success(self.force_retcode):
            Msg.info("[SUCCESS] Generate Command: %s" % (str(self.force_cmd)))
            Msg.info("Instructions Generated - "
                     "Default: %d, Secondary: %d, Total: %d" %
                     (self.default, self.secondary, self.total))
        elif self.signal_id is not None:
            Msg.info("[INCOMPLETE] Generate Command: %s" %
                     (str(self.force_cmd)))
            Msg.info("No Instructions Generated")
        else:
            Msg.info("[FAILED] Generate Command: %s" % (str(self.force_cmd)))
            Msg.info("No Instructions Generated")

        if self.iss_cmd is not None:
            if self.iss_success():
                Msg.info("[SUCCESS] ISS Command: %s" % (str(self.iss_cmd)))
            elif self.signal_id is not None:
                Msg.info("[INCOMPLETE] ISS Command: %s" % (str(self.iss_cmd)))
            else:
                Msg.info("[FAILED] ISS Command: %s" % (str(self.iss_cmd)))
            # Msg.fout( self.iss_log, "user" )

        if self.rtl_cmd is not None:
            if SysUtils.success(self.rtl_retcode):
                Msg.info("[SUCCESS] RTL Command: %s" % (str(self.rtl_cmd)))
                Msg.info("Cycle count : %d" % (self.cycle_count))
            elif self.signal_id is not None:
                Msg.info("[INCOMPLETE] RTL Command: %s" % (str(self.rtl_cmd)))
            else:
                Msg.info("[FAILED] RTL Command: %s" % (str(self.rtl_cmd)))

        if (self.detail_flags
                & SummaryDetail.TraceCmpCmd == SummaryDetail.TraceCmpCmd):
            Msg.info("Comparing Simulation output .... ")
            if SysUtils.success(self.trace_cmp_retcode):
                Msg.info("[SUCCESS] Trace Compare Command: %s" %
                         (str(self.trace_cmp_cmd)))
            elif self.signal_id is not None:
                Msg.info("[INCOMPLETE] Trace Compare Command: %s" %
                         (str(self.trace_cmp_cmd)))
            else:
                Msg.info("[FAILED] Trace Compare Command: %s" %
                         (str(self.trace_cmp_cmd)))

        Msg.blank()
Пример #9
0
    def initialize_processor_cmd(self):

        # the default task processor is "forrest_run.py"
        # the default directory is the same directory as the master_run
        # the processor can be replaced with a command line argument which may
        # or may not contain a path
        # if it does not contain a path then the default path will be used
        # if a directory is passed on the command line in all cases that will
        # be the location of the processor
        my_run_dir = None
        my_run_name = None
        my_tmp_name = None
        my_tmp_path = None

        my_run_path = self.option_def(CmdLine.Switches[CmdLine.run_name], None)

        if my_run_path is not None:
            my_run_dir, my_run_name = PathUtils.split_path(my_run_path)
            Msg.user(
                "Client Dir: %s, Client Name: %s (1)" %
                (str(my_run_dir), str(my_run_name)),
                "PROCESS_CMD",
            )

        if my_run_dir is None:
            my_tmp_path = self.locate_directory(
                CmdLine.Switches[CmdLine.run_dir],
                EnVars.run_path,
                self.module_dir,
            )

            if PathUtils.check_exe(my_tmp_path):
                my_run_dir, my_tmp_name = PathUtils.split_path(my_tmp_path)
            else:
                my_run_dir = my_tmp_path

        if my_run_name is None:
            my_run_name = (my_tmp_name
                           if my_tmp_name is not None else Defaults.run_name)

        my_process_cmd = PathUtils.real_path(
            PathUtils.append_path(
                PathUtils.include_trailing_path_delimiter(my_run_dir),
                my_run_name,
            ))
        Msg.user("Process Cmd: %s (1)" % (str(my_process_cmd)), "PROCESS_CMD")

        my_msg_lev = self.option_def(CmdLine.Switches[CmdLine.client_lev],
                                     None)

        if my_msg_lev is not None:
            if my_msg_lev:
                my_process_cmd += Msg.get_level_as_str()

            else:
                my_process_cmd += " -l " + my_msg_lev
                Msg.user("Process Cmd: %s" % (str(my_process_cmd)),
                         "PROCESS_CMD")

        if self.m_app_info.mConfigPath is not None:
            my_process_cmd += " -w %s" % self.m_app_info.mConfigPath
        my_process_cmd += " -f %s"

        self.processor_name = my_run_name.replace(".py",
                                                  "").replace("_run", "")
        self.process_cmd = my_process_cmd

        Msg.dbg("Process Cmd: %s" % (str(self.process_cmd)))
Пример #10
0
    def report(self, aAppsInfo, aMyTag):

        mr_info = aAppsInfo.mTagToReportInfo.get("master_run", None)
        if mr_info:
            self.mTotalCycleCount = mr_info.get("total_cycle_count", None)
            self.mTotalInstructionCount = mr_info.get(
                "total_instruction_count", None)
            self.mReportBaseName = mr_info.get("initial_control_file", None)
            self.mRegressionOutputDirectory = mr_info.get("output_dir", None)

        force_info = aAppsInfo.mTagToReportInfo.get("generator", None)
        if force_info:  # force info was in the report info dictionary
            self.mForceScmVersion = force_info.get("version", None)
        else:  # force info was obtainable from the config object
            force_info = aAppsInfo.mTagToApp.get('generator')
            self.mForceScmVersion = force_info.parameter('version')

        rtl_config = aAppsInfo.mTagToApp.get('rtl', None)
        if rtl_config:
            self.mRtlWasEnabled = rtl_config.parameter('rtl')

            # If the rtl app was active, check if the user disabled reporting
            if self.mRtlWasEnabled:
                self.mReportingWasSkipped = rtl_config.parameter(
                    'rtl.report.skip')

                # If reporting was enabled, continue to resolve information
                if not self.mReportingWasSkipped:
                    self.mReportDumpXml = rtl_config.parameter(
                        'rtl.report.xml')
                    rtl_report_name = rtl_config.parameter('rtl.report.name')

                    if rtl_report_name == "master_run" and self.mReportBaseName:
                        rtl_report_name = self.mReportBaseName.strip(".py")

                    time_stamp = datetime.utcnow()
                    time_string = "_%0.4d%0.2d%0.2d_%0.2d%0.2d" % \
                                  (time_stamp.year,
                                   time_stamp.month,
                                   time_stamp.day,
                                   time_stamp.hour,
                                   time_stamp.minute)

                    version = ''
                    revision_stamp = ""

                    for item in self.mForceScmVersion:
                        if item.get('status', False):
                            version = item['version']
                            # prefer git data, otherwise keep looking for valid version
                            if item['scm_type'] == 'git':
                                break
                    if version:
                        revision_stamp = "_r" + str(version)

                    rtl_report_name = rtl_report_name + time_string + revision_stamp

                    rtl_control_data = {}
                    rtl_config.processControlData(rtl_control_data)
                    report_script_path = rtl_control_data.get(
                        'report_script_path', None)
                    report_script_path = PathUtils.real_path(
                        aAppsInfo.mMainAppPath + "/" + report_script_path)
                    report_directory = PathUtils.real_path(
                        self.mRegressionOutputDirectory + "/../../")

                    # What about the report path?  We get that from the master_run output_dir
                    report_command = report_script_path + " --report-dir " + report_directory + " --name " + rtl_report_name
                    if self.mReportDumpXml:
                        report_command += " --dump-xml"

                    Msg.dbg("Main app path: " + str(aAppsInfo.mMainAppPath))
                    Msg.dbg("Report script path: " + str(report_script_path))
                    Msg.dbg("Report directory: " + str(report_directory))
                    Msg.dbg("Reporting command: " + str(report_command))

                    # actually execute the report script
                    report.callFromPython(report_command)

                    # create or append metrics file
                    rtl_metrics_path = rtl_control_data.get(
                        'rtl_metrics_path', None)
                    home = os.path.expanduser('~')
                    rtl_metrics_path = rtl_metrics_path.replace('~', home)

                    if not os.path.isfile(rtl_metrics_path):
                        with open(rtl_metrics_path, 'w+') as outfile:
                            outfile.write(
                                "||---------------------------------------------|--------------------|--------------------||\n"
                            )
                            outfile.write(
                                "||                                   Regression|        Total Cycles|  Total Instructions||\n"
                            )
                            outfile.write(
                                "||---------------------------------------------|--------------------|--------------------||\n"
                            )

                    with open(rtl_metrics_path, 'a') as outfile:
                        outfile.write("||")
                        for space in range(45 - len(rtl_report_name)):
                            outfile.write(" ")
                        outfile.write(rtl_report_name + "|")
                        for space in range(20 -
                                           len(str(self.mTotalCycleCount))):
                            outfile.write(" ")
                        outfile.write(str(self.mTotalCycleCount) + "|")
                        for space in range(
                                20 - len(str(self.mTotalInstructionCount))):
                            outfile.write(" ")
                        outfile.write(
                            str(self.mTotalInstructionCount) + "||\n")
Пример #11
0
 def run(self):
     Msg.dbg("ForrestRun::run()")
     self.fctrl.process()
Пример #12
0
    def load(self, arg_ctrl_item):
        super().load(arg_ctrl_item)

        Msg.dbg("ExecuteController::initialize_sim()")
        if not self.ctrl_item.no_sim:
            self.sim_log = "fpix_sim.log"
Пример #13
0
def main():
    # set up signal handlers,
    signal.signal(signal.SIGINT, handle_signal)
    signal.signal(signal.SIGTERM, handle_signal)

    # initialize variables
    my_hlog = None
    my_org_stdout = None

    # global the_output_path =

    # Step 1: Save the originating directory
    my_pwd = PathUtils.current_dir()

    # Step 3: Extract Pid Group
    os.setpgid(os.getpid(), os.getpid())

    my_module = ForrestRun()

    try:
        my_module.force_path = the_force_root

        my_logfile = my_module.m_app_info.mCmdLineOpts.option_def(
            CmdLine.Switches[CmdLine.logfile], None)

        if my_logfile is not None:
            # print( "Redirecting STDOUT to my_logfile" )
            my_org_stdout = sys.stdout
            my_hlog = open(my_logfile, "w")
            sys.stdout = my_hlog
            Msg.user("Log File: %s" % (str(my_logfile)), "STDLOG")

        Msg.dbg("\nForce Path: %s" % (str(the_force_root)))
        Msg.dbg("Original Directory: " + my_pwd)

        # save current working directory

        Msg.dbg("Processing Command Line and Loading Control File")
        my_module.load()

        Msg.dbg("Directory set to %s" % (PathUtils.current_dir()))
        if not PathUtils.chdir(my_module.frun_dir, False):
            Msg.dbg(
                "Directory Unchanged, using the current directory for output")

        my_module.run()
        Msg.dbg("Test Completed ....\n")
        Msg.blank()
        # sys.exit( 0 )

    except Exception as ex:
        from force_init import force_usage

        Msg.err("An Unhandled Error has Occurred during run of " +
                str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)
        Msg.error_trace(str(ex))
        my_module.m_app_info.mCmdLineOpts.print_help()
        sys.exit(41)

    except BaseException:
        print("[ERROR] - An Unhandled Error has Occurred during run of " +
              str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)
        sys.exit(42)

    finally:
        if my_logfile is not None:
            my_hlog.close()
            sys.stdout = my_org_stdout
            with open(my_logfile, "r") as my_hlog:
                print(my_hlog.read())

        if my_pwd is not None:
            PathUtils.chdir(my_pwd)
            Msg.dbg("Returned To: %s" % (PathUtils.current_dir()))
Пример #14
0
    def run_loop(self):

        Msg.info("Entering HIThread[%s] Loop Processing...." % (self.name))
        while not self.terminated():
            # initialize iteration for work performed in execute
            Msg.dbg("HiThread[%s]::run_loop(1)" % (self.name))
            if self.on_execute is not None:
                Msg.dbg("HiThread[%s]::run_loop(2)" % (self.name))
                self.on_execute()
            # perform the iteration work
            Msg.dbg("HiThread[%s]::run_loop(3)" % (self.name))
            self.execute()
            # finish work prior the next iteratation
            Msg.dbg("HiThread[%s]::run_loop(4)" % (self.name))
            if self.on_done is not None:
                Msg.dbg("HiThread[%s]::run_loop(5)" % (self.name))
                self.on_done()
            Msg.dbg("HiThread[%s]::run_loop(6)" % (self.name))

        Msg.info("Leaving HIThread[%s] Loop Processing...." % (self.name))
Пример #15
0
            force_usage(UsageStr)


if __name__ == "__main__":

    # save current working directory
    my_pwd = PathUtils.current_dir()

    try:
        my_module = UnitTestRun(the_force_root)

        Msg.info("\nForce Path: %s" % (str(the_force_root)))
        Msg.info("Original Directory: " + my_pwd)

        Msg.dbg("Processing Command Line and Loading  Control File")
        my_module.load()

        Msg.dbg("Directory set to %s" % (PathUtils.current_dir()))
        if not PathUtils.chdir(the_force_root, False):
            Msg.dbg(
                "Directory Unchanged, using the current directory for output")

        my_module.run()
        Msg.dbg("Test Completed ....\n")
        Msg.blank()
        sys.exit(40)

    except getopt.GetoptError as arg_ex:

        from force_init import force_usage
Пример #16
0
 def list_files(cls, arg_path):
     Msg.dbg(arg_path)
     return glob.glob(arg_path)
Пример #17
0
 def load(self):
     Msg.dbg("ForrestRun::load()")
     self.check_usage()
     self.process_cmdline()
Пример #18
0
    def chdir(cls, arg_dir, arg_force=False):

        Msg.dbg("PathUtils::chdir( %s, %s )" % (arg_dir, str(arg_force)))
        if not PathUtils.check_dir(
                PathUtils.exclude_trailing_path_delimiter(arg_dir)):
            if arg_force:
                Msg.dbg(
                    "Directory Does Not Exist, Attempting to Create Directory: %s"
                    % (arg_dir))
                if not PathUtils.mkdir(arg_dir):
                    Msg.dbg("Failed Create: %s" % (arg_dir))
                    return False
                Msg.dbg("Success Created: %s " % (arg_dir))
            else:
                Msg.dbg("Failed Change Directory: %s" % (arg_dir))
                return False
        try:
            real_path = PathUtils.real_path(arg_dir)
            os.chdir(arg_dir)
            Msg.dbg("Success Changed Directory: %s (real path: %s)" %
                    (arg_dir, real_path))
        except:
            return False

        return True
Пример #19
0
    if my_logfile is not None:
        # print( "Redirecting STDOUT to my_logfile" )
        my_org_stdout = sys.stdout
        my_hlog = open(my_logfile, "w")
        sys.stdout = my_hlog
        Msg.user("Log File: %s" % (str(my_logfile)), "STDLOG")

    # Step 3: Extract Pid Group
    os.setpgid(os.getpid(), os.getpid())

    try:
        my_module = ForrestRun(apps_info)
        my_module.force_path = the_force_root  # TODO remove this very soon

        Msg.dbg("\nForce Path: %s" % (str(the_force_root)))
        Msg.dbg("Original Directory: " + my_pwd)

        # save current working directory

        Msg.dbg("Processing Command Line and Loading Control File")
        my_module.load()

        Msg.dbg("Directory set to %s" % (PathUtils.current_dir()))
        if not PathUtils.chdir(my_module.frun_dir, False):
            Msg.dbg(
                "Directory Unchanged, using the current directory for output")

        my_module.run()
        Msg.dbg("Test Completed ....\n")
        Msg.blank()
Пример #20
0
        print(
            "[ERROR] - An Unhandled Error has Occurred during applications setup of "
            + str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)
        sys.exit(44)

    print(
        "\n=======================================\n\tInitializing ....\n=======================================\n"
    )
    try:
        my_module = MasterRun(apps_info)

        # save current working directory
        my_pwd = PathUtils.current_dir()

        Msg.dbg("Original Directory: " + my_pwd)
        Msg.dbg("Processing Command Line and Loading Control File")
        my_module.load()

        if not PathUtils.chdir(my_module.output_dir, True):
            Msg.dbg("Unable to change into: " + my_module.output_dir +
                    ", using the current directory for output")

        Msg.info("\nConcurrent Operations: %s" %
                 (str(my_module._mAppsInfo.mProcessMax)))
        my_module.run()

        Msg.info("Test Completed ....\n")

    #    print( "[ERROR] Parsing Command Line: %s\n" % ( str( arg_ex )))