示例#1
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.ForceCmd    == SummaryDetail.ForceCmd   : my_msg += "ForceCommand, "
            if self.detail_flags & SummaryDetail.ForceResult == SummaryDetail.ForceResult: my_msg += "ForceResult, "
            if self.detail_flags & SummaryDetail.IssCmd      == SummaryDetail.IssCmd     : my_msg += "IssCommand, "
            if self.detail_flags & SummaryDetail.IssResult   == SummaryDetail.IssResult  : my_msg += "IssResult, "
            my_msg = my_msg[:-2]

        # Msg.user( my_msg )

        # Msg.info( "Originating Control File: %s"  % ( self.parent_fctrl ))
        # Msg.info( "Control File Item: %s"  % ( str(  self.fctrl_item )))
        # Msg.info( "F-Run Control File: %s" % ( self.frun_path ))
        Msg.dbg( "Force Ret Code: %s" % ( str( self.force_retcode )))
        Msg.info( "[%s], Generate Command: %s" % ( SysUtils.ifthen( SysUtils.success( self.force_retcode ), "SUCCESS", "FAILED" ), str( self.force_cmd )))
        Msg.info( "Instructions Generated - Default: %d, Secondary: %d, Total: %d" % ( self.default, self.secondary, self.total ))

        if self.iss_cmd is not None:
            if self.iss_success():
                Msg.info( "[SUCCESS], ISS Command: %s" % ( str( self.iss_cmd   )))
            else:
                Msg.info( "[FAILED], ISS Command: %s" % ( str( self.iss_cmd   )))
            #Msg.fout( self.iss_log, "user" )
        Msg.blank()
示例#2
0
    def commit(self):

        my_gen_cnt = 0
        my_gen_ret = 0
        my_sim_cnt = 0
        my_sim_ret = 0
        my_tgt_name = ""

        if self.has_generate():
            #Msg.user( "if self.has_generate(): True" )
            my_gen_cnt = 1
            my_gen_ret = self.commit_generate()

        if self.has_simulate():

            #Msg.user( "if self.has_simulate(): True" )
            my_sim_cnt = 1
            my_sim_ret = self.commit_simulate()
            my_tgt_name = "%s%s" % (self.task_path,
                                    SysUtils.ifthen(bool(my_sim_ret), "PASS",
                                                    "FAIL"))
        else:
            my_tgt_name = "%s%s" % (self.task_path,
                                    SysUtils.ifthen(bool(my_gen_ret), "PASS",
                                                    "FAIL"))

        my_src_name = "%s%s" % (self.task_path, "STARTED")
        PathUtils.move(my_src_name, my_tgt_name)

        return (my_gen_cnt, my_gen_ret, my_sim_cnt, my_sim_ret)
示例#3
0
    def exec_gen(self, arg_task_file):

        # Msg.dbg( "ExecuteController::exec_gen( %s )" % ( arg_task_file ) )

        # NOTE: Do not change force_cmd may need to reuse!!
        # my_task_file = self.ctrl_item.file_path()

        # my_cmd = self.force_cmd % ( my_testfile, arg_testname.replace( ".py", ".gen.log" ))
        my_log = "gen.log"  # arg_testname.replace( ".py", ".gen.log" )
        my_elog = "gen.err"  # arg_testname.replace( ".py", ".gen.log" )

        my_cmd = self.force_cmd % (arg_task_file)  # , my_log )
        # Msg.dbg( "Generate Command Line: %s" % ( my_cmd ))

        # if self.ctrl_item.mode == "mock":
        #     Msg.info( "Mock Generate: " +  my_cmd )
        # else:
        Msg.info(
            "ForceCommand = " + str({
                "force-command": my_cmd,
                "force-log": my_log,
                "force-elog": my_elog,
                "max-instr": self.ctrl_item.max_instr,
                "min-instr": self.ctrl_item.min_instr
            }), True)
        Msg.flush()
        #     if self.ctrl_item.summary is not None:
        #         # update the current test with the generate cmd and the generate log file.
        #         self.ctrl_item.summary.set_gen_info( arg_task_name, arg_ndx, my_cmd, my_log )
        my_result = SysUtils.exec_process(my_cmd, my_log, my_elog,
                                          self.ctrl_item.timeout, True)

        # Msg.user( str( my_result[0] ) + ", type: " + str( type( my_result[0] )))
        my_ret_code = int(my_result[0])
        my_std_out = str(my_result[1])
        my_std_err = str(my_result[2])
        my_start = str(my_result[3])
        my_end = str(my_result[4])

        my_time_elapsed = SysUtils.ifthen(my_result[3] is not None,
                                          float(my_result[3]), 0.0)

        Msg.info("ForceResult = " + str({
            "force-retcode": my_ret_code,
            "force-stdout": my_std_out,
            "force-stderr": my_std_err,
            "force-start": my_start,
            "force-end": my_end
        }))

        return SysUtils.success(my_result[0])
示例#4
0
    def commit_generate( self ):

        self.force_result = SysUtils.ifthen( SysUtils.success( self.force_retcode ), "PASS", "FAIL" )
        self.force_level = SummaryLevel.Any

        if SysUtils.failed( self.force_retcode ):
            self.force_level = SummaryLevel.Fail

        Msg.lout( self, "user" , "Performance Summary Item Commit Generate" )
        if SysUtils.success( self.force_retcode ):
            self.instruction_counts( )
            Msg.info( "Instructions: %d, Default: %d, Secondary: %d, Elapsed Time: %0.5f Seconds\n\n" % ( self.count, self.default, self.secondary, self.force_end - self.force_start ))
            return 1

        return 0
示例#5
0
    def populate(self, arg_dict):
        self.work_dir = arg_dict[CtrlItmKeys.fdir]
        #Msg.trace()
        Msg.user("self.work_dir: %s" % (self.work_dir),
                 "ParentData::populate()")
        self.test_root = arg_dict[CtrlItmKeys.test_root]
        self.mode = arg_dict[CtrlItmKeys.mode]
        self.force_path = arg_dict[CtrlItmKeys.force_path]
        self.action = arg_dict[CtrlItmKeys.action]
        self.process_queue = arg_dict[CtrlItmKeys.process_queue]
        self.force_cmd = arg_dict[CtrlItmKeys.force_cmd]
        self.process_max = arg_dict.get(CtrlItmKeys.process_max,
                                        CtrlItmDefs.process_max)
        self.iss_path = arg_dict.get(CtrlItmKeys.iss_path,
                                     CtrlItmDefs.iss_path)

        if not SysUtils.found(self.iss_path.find(self.test_root)):
            # Msg.user( "Test Root Not Found ..." )
            # if not then prepend the test root
            self.iss_path = PathUtils.include_trailing_path_delimiter(
                self.test_root) + PathUtils.exclude_leading_path_delimiter(
                    self.iss_path)
        Msg.user("Final Iss Path: %s" % (self.iss_path), "ISS_PATH")
        self.timeout = arg_dict.get(CtrlItmKeys.timeout, CtrlItmDefs.timeout)
        return self
示例#6
0
    def process_groups( self, arg_ofile ):

        my_total_count = 0
        my_total_elapsed = 0

        my_groups = self.groups.task_groups();


        # Msg.trace("PerformanceSummaryItem::process_groups")
        for my_group, my_items in my_groups.items():
            try:
                my_str = "\nBegin Group: %s\n" % ( my_group )
                arg_ofile.write( my_str )
                Msg.blank( "info" )
                Msg.info( my_str )

                my_grp_count, my_grp_elapsed = self.process_group_items( arg_ofile, my_items )

                my_total_count   += my_grp_count
                my_total_elapsed += my_grp_elapsed

                my_line =  "\nGroup Instructions: %3d\n" % ( my_grp_count )
                my_line += "Group Elapsed Time: %0.3f\n" % ( my_grp_elapsed )
                my_line += "Group Instructions per Second:  %0.3f\n"  % ( SysUtils.ifthen( bool( my_grp_elapsed ), my_grp_count / my_grp_elapsed, 0 ))
                my_line += "End Group: %s\n" % ( my_group )

                Msg.info( my_line )
                arg_ofile.write( my_line )

            except Exception as arg_ex:

                Msg.error_trace()
                Msg.err( "Unable to process, Group: %s, Reason: %s" % (  my_group, type( arg_ex )))

        return my_total_count, my_total_elapsed
示例#7
0
    def process_summary( self, sum_level = SummaryLevel.Fail ):

        my_file_name = "%sperformance_summary.log" % ( PathUtils().include_trailing_path_delimiter( self.summary_dir ))
        Msg.dbg( "Master Log File: %s" % ( my_file_name ))
        my_utcdt = DateTime.UTCNow()
        my_ofile = None
        try:
        # First try to open file
            with open( my_file_name, "w" ) as my_ofile:

                my_ofile.write( "Date: %s\n" % ( DateTime.DateAsStr( my_utcdt )))
                my_ofile.write( "Time: %s\n" % ( DateTime.TimeAsStr( my_utcdt )))

                self.process_errors( my_ofile )
                my_total_count, my_total_elapsed = self.process_groups( my_ofile )

                Msg.blank( "info" )
                my_line = "Total Instructions Generated: %3d\n" % ( my_total_count )
                my_line += "Total Elapsed Time:  %0.3f\n" % ( my_total_elapsed )
                my_line += "Overall Instructions per Second:  %0.3f\n" % ( SysUtils.ifthen( bool( my_total_elapsed ), my_total_count / my_total_elapsed, 0 ))

                Msg.info( my_line )
                my_ofile.write( my_line )

        except Exception as arg_ex:
            Msg.error_trace()
            Msg.err( "Error Processing Summary, " + str( arg_ex ) )

        finally:
            my_ofile.close()
示例#8
0
    def initialize_sim(self):

        # Msg.dbg( "ExecuteController::initialize_sim()")
        if not self.ctrl_item.no_sim:
            my_tmlog = "iss.railhouse"  #arg_testname.replace( ".py", ".log" )
            self.sim_log = "iss_sim.log"

            self.sim_cmd = "%s -T %s -C %s -i %d --exit_loop=%d" % (
                self.ctrl_item.parent_data.iss_path, my_tmlog,
                self.ctrl_item.num_cores, self.ctrl_item.max_instr,
                self.ctrl_item.exit_loop)

            if not self.ctrl_item.iss is None and type(
                    self.ctrl_item.iss) is dict:
                for my_key in self.ctrl_item.iss.keys():
                    if not my_key == CtrlItmKeys.iss_path:
                        Msg.user("sim_cmd: %s, key: %s " %
                                 (str(self.sim_cmd), str(my_key)))
                        self.sim_cmd += " %s %s" % (
                            str(my_key),
                            SysUtils.ifthen(
                                self.ctrl_item.iss[my_key] is None, "",
                                str(self.ctrl_item.iss[my_key])))

            self.sim_cmd += "%s%s"  #
示例#9
0
    def exec_iss(self, arg_task_name):

        # Msg.dbg( "ExecuteController::exec_iss( %s )" % ( arg_task_name ) )
        # build rest of command for iss
        my_elf = "%s.Default.ELF" % (arg_task_name)
        # Msg.dbg( "Looking For: %s" % ( my_elf ))
        my_elf = SysUtils.ifthen(PathUtils.check_file(my_elf), " %s" % my_elf,
                                 "")
        # Msg.dbg( "Using ELF: %s" % ( my_elf ))

        my_elfns = "%s.Secondary.ELF" % (arg_task_name)
        # Msg.dbg( "Looking For: %s" % ( my_elfns ))
        my_elfns = SysUtils.ifthen(PathUtils.check_file(my_elfns),
                                   " %s" % my_elfns, "")
        my_cmd = self.sim_cmd % (my_elf, my_elfns)

        try:
            # execute the simulation
            Msg.info("ISSCommand = " + str({"iss-command": my_cmd}))
            my_log = self.sim_log
            my_elog = self.sim_log

            #my_ret_code = int( SysUtils.exec_cmd( my_cmd ) )
            my_result = SysUtils.exec_process(my_cmd, my_log, my_elog,
                                              self.ctrl_item.timeout, True)

            my_ret_code = int(my_result[0])
            my_std_out = str(my_result[1])
            my_std_err = str(my_result[2])
            my_start = str(my_result[3])
            my_end = str(my_result[4])

            Msg.info("ISSResult = " + str({
                "iss-retcode": my_ret_code,
                "iss-log": self.sim_log,
                "iss-stdout": my_std_out,
                "iss-stderr": my_std_err,
                "iss-start": my_start,
                "iss-end": my_end
            }))

        except Exception as arg_ex:
            Msg.error_trace("ISS Execute Failure")
            Msg.err("ISS did not properly execute, Reason: %s" % (str(arg_ex)))
            return False

        return True
示例#10
0
    def load_force_elog( self ):
        self.force_msg = None
        my_elog = "%s%s" % ( PathUtils.include_trailing_path_delimiter( self.work_dir ), self.force_elog )
        # Msg.dbg( my_elog )

        if SysUtils.failed( self.force_retcode ):
            Msg.fout( my_elog, "dbg" )
            with open(  my_elog , "r" ) as my_flog:
                try:
                    for my_line in my_flog:

                        if SysUtils.found( my_line.find( "[fail]" )):
                            self.force_msg = my_line.replace( "[fail]", "" ).strip()
                            # Msg.dbg( "Message: %s" % ( str( self.force_msg  )))
                            break
                finally:
                    my_flog.close()
示例#11
0
    def initialize_gen(self):

        # Msg.dbg( "ExecuteController::initialize_gen()")

        my_cmd = self.ctrl_item.parent_data.force_cmd

        # Msg.user( "ControlItem.no-asm: %s" %  ( str( self.ctrl_item.no_asm )) )
        # Msg.dbg( "ControlItem.max_instr: %s" %  ( str( self.ctrl_item.max_instr )) )

        my_cmd += " -t %s" + SysUtils.ifthen(
            self.ctrl_item.no_asm == False, "",
            " --noasm") + " --max-instr %d" % self.ctrl_item.max_instr

        # Msg.dbg( "my_cmd: %s" %  ( str( my_cmd )) )

        if isinstance(self.ctrl_item.generator, dict):
            for my_key in self.ctrl_item.generator.keys():
                my_cmd += " %s %s " % (
                    str(my_key),
                    SysUtils.ifthen(self.ctrl_item.generator[my_key] is None,
                                    "", str(self.ctrl_item.generator[my_key])))

        self.force_cmd = my_cmd.strip()
示例#12
0
    def load(self, arg_ctrl_item ):
        super().load( arg_ctrl_item )
        # Msg.dbg( "FileController::load()" )
        self.parent_fctrl = self.ctrl_item.file_path()
        # Msg.dbg( "File Path: %s" % ( self.parent_fctrl ))

        #my_content = open( self.parent_fctrl ).read()
        # Msg.dbg( "\n" + my_content )

        try:
            my_content = open( self.parent_fctrl ).read()
        except Exception as arg_ex:
            Msg.err( "Message: %s, Control File Path: %s" % ( str( arg_ex ), self.parent_fctrl ))
            my_err_queue_item = SummaryErrorQueueItem( { "error"  : arg_ex
                                                       , "message": "Control File Not Found ..."
                                                       , "path"   : self.ctrl_item.file_path()
                                                       , "type"   : str( type( arg_ex ))
                                                       } )


            self.ctrl_item.summary().queue.enqueue( my_err_queue_item )
            return False
        finally:
            pass

        try:
            my_glb, my_loc = SysUtils.exec_content( my_content )

        except Exception as arg_ex:
            my_exc_type, my_exc_val, my_exc_tb = sys.exc_info()
            my_ex = arg_ex

            Msg.err( "Message: %s, Control File Path: %s" % ( str( arg_ex ), self.parent_fctrl))
            Msg.blank()

            my_err_queue_item = SummaryErrorQueueItem( { "error"  : arg_ex
                                                       , "message": "Control File not processed..."
                                                       , "path"   : self.ctrl_item.file_path()
                                                       , "type"   : str( my_exc_type )
                                                       } )

            self.ctrl_item.summary().queue.enqueue( my_err_queue_item )
            return False

        finally:
            pass

        self.fcontrol = my_loc["control_items"]
        return True
示例#13
0
    def load_gen_result(self, arg_dict):

        # Msg.lout( arg_dict, "dbg", "Generate Results Dictionary ... " )
        try:
            self.force_retcode = int(str(arg_dict["force-retcode"]).strip())
        except:
            self.force_retcode = -1
            Msg.err("Generate Return Code in unrecognizable format")

        self.force_stdout = arg_dict["force-stdout"]
        self.force_stderr = arg_dict["force-stderr"]

        if SysUtils.failed(self.force_retcode):
            self.force_level = SummaryLevel.Fail

        self.force_start = float(arg_dict.get("force-start", 0.00))
        self.force_end = float(arg_dict.get("force-end", 0.00))
    def run(self):
        # Record the starting and ending of the run for performance metrics
        start = DateTime.Time()

        my_cmd = self.process_queue.process_cmd % (self.queue_item.frun_path)
        # Msg.dbg( "Process Command: %s" % ( str( my_cmd )))
        my_log = "%s/forrest.log" % (self.queue_item.work_dir)
        # my_retcode = SysUtils.exec_process( my_cmd, my_log, my_log, self.my_queue_item.ctrl_item.timeout )

        # Msg.dbg( "Process Timeout: %s" % ( str( self.queue_item.ctrl_item.timeout )))  # self.queue_item.ctrl_item.timeout )))
        my_retcode = SysUtils.exec_process(my_cmd, my_log, my_log,
                                           self.queue_item.ctrl_item.timeout)

        end = DateTime.Time()

        self.extract_results(my_retcode, my_cmd, my_log, self.queue_item,
                             start, end)
        self.done_semaphore.release()
        self.thread_count.add(-1)
示例#15
0
    def load_process_line(self, arg_line):

        if SysUtils.found(arg_line.find("ForceCommand")):
            my_glb, my_loc = SysUtils.exec_content(arg_line)
            self.load_gen_info(my_loc["ForceCommand"])
            self.detail_flags |= SummaryDetail.ForceCmd

        elif SysUtils.found(arg_line.find("ForceResult")):
            my_glb, my_loc = SysUtils.exec_content(arg_line)
            self.load_gen_result(my_loc["ForceResult"])
            self.detail_flags |= SummaryDetail.ForceResult

        elif SysUtils.found(arg_line.find("ISSCommand")):
            my_glb, my_loc = SysUtils.exec_content(arg_line)
            self.load_iss_info(my_loc["ISSCommand"])
            self.detail_flags |= SummaryDetail.IssCmd

        elif SysUtils.found(arg_line.find("ISSResult")):
            my_glb, my_loc = SysUtils.exec_content(arg_line)
            self.load_iss_result(my_loc["ISSResult"])
            self.detail_flags |= SummaryDetail.IssResult
示例#16
0
    def check_ctrl_dir(self, arg_fctrl_dir):

        Msg.user(
            "Checking for control file at relative path[%s] from test root" %
            (arg_fctrl_dir), "RELATIVE PATH")
        my_tmp_dir = arg_fctrl_dir
        if not SysUtils.found(my_tmp_dir.find(self.parent_data.test_root)):
            # Prepend the test_root on the work directory
            Msg.user("Building Control Directory ...", "RELATIVE PATH")
            my_tmp_dir = PathUtils.append_path(self.parent_data.test_root,
                                               my_tmp_dir)

        if PathUtils.check_found(
                PathUtils.append_path(my_tmp_dir, self.fctrl_name)):
            self.fctrl_dir = my_tmp_dir
            Msg.user("Setting Control Directory: %s ..." % (self.fctrl_dir),
                     "RELATIVE PATH")
            return True
        return False
示例#17
0
    def load_item_values(self, arg_item_dict):

        my_options = arg_item_dict.get(CtrlItmKeys.options,
                                       CtrlItmDefs.options)
        my_parent_vals = arg_item_dict.get(CtrlItmKeys.parent_vals, {})
        Msg.lout(my_parent_vals, "dbg", "Parent Values from Control Item")
        Msg.lout(self.parent_data, "dbg", "Persistent Data")

        # Control File Location
        self.fctrl_dir = my_options.get(
            CtrlItmKeys.fdir,
            SysUtils.ifthen(self.parent_data.work_dir is None,
                            CtrlItmDefs.fctrl_dir, self.parent_data.work_dir))

        # Populated from control item options
        self.iterations = my_options.get(CtrlItmKeys.iterations,
                                         CtrlItmDefs.iterations)

        # Populated from control item options or parent
        self.exit_loop = my_options.get(
            CtrlItmKeys.exit_loop,
            my_parent_vals.get(CtrlItmKeys.exit_loop, CtrlItmDefs.exit_loop))
        self.group = my_options.get(
            CtrlItmKeys.group,
            my_parent_vals.get(CtrlItmKeys.group, CtrlItmDefs.group))
        self.min_instr = my_options.get(
            CtrlItmKeys.min_instr,
            my_parent_vals.get(CtrlItmKeys.min_instr, CtrlItmDefs.min_instr))
        self.max_instr = my_options.get(
            CtrlItmKeys.max_instr,
            my_parent_vals.get(CtrlItmKeys.max_instr, CtrlItmDefs.max_instr))
        self.num_cores = my_options.get(
            CtrlItmKeys.num_cores,
            my_parent_vals.get(CtrlItmKeys.num_cores, CtrlItmDefs.num_cores))
        self.no_asm = my_options.get(
            CtrlItmKeys.no_asm,
            my_parent_vals.get(CtrlItmKeys.no_asm, CtrlItmDefs.no_asm))
        self.no_sim = my_options.get(
            CtrlItmKeys.no_sim,
            my_parent_vals.get(CtrlItmKeys.no_sim, CtrlItmDefs.no_sim))
        self.timeout = my_options.get(
            CtrlItmKeys.timeout,
            my_parent_vals.get(CtrlItmKeys.timeout, CtrlItmDefs.timeout))
示例#18
0
    def commit_simulate( self ):

        self.instr_count, self.iss_message = self.extract_iss_info()
        Msg.user( "Instr Count: %d, Message: %s" % (self.instr_count, self.iss_message ))
        try:

            # check the return code for error
            if SysUtils.success( self.iss_retcode ):
                # Check to see for instruction overrun
                if int( self.instr_count ) < self.max_instr:
                    if int( self.instr_count ) >= self.min_instr:
                        self.iss_result = "PASS"
                        self.iss_level  = SummaryLevel.Any
                        return 1

            self.iss_result = "FAIL"
            self.iss_level  = SummaryLevel.Fail
            return 0
        finally:
            pass
示例#19
0
    def check_work_dir(self, arg_fctrl_dir):
        # check the work directory
        Msg.dbg(
            "Checking for control file using implict path[%s] of current control file"
            % (str(arg_fctrl_dir)))
        if not self.parent_data.work_dir is None:

            my_tmp_dir = PathUtils.append_path(self.parent_data.work_dir,
                                               arg_fctrl_dir)
            if not SysUtils.found(my_tmp_dir.find(self.parent_data.test_root)):
                # Prepend the test_root on the work directory
                my_tmp_dir = PathUtils.append_path(self.parent_data.test_root,
                                                   my_tmp_dir)

            if PathUtils.check_found(
                    PathUtils.append_path(my_tmp_dir, self.fctrl_name)):
                self.fctrl_dir = my_tmp_dir
                # Msg.dbg( "Using Control File Directory: %s" % ( self.fctrl_dir ))
                return True

        return False
示例#20
0
    def extract_iss_data(self, arg_item_dict):

        # first get the iss dictionary
        # Msg.lout( arg_item_dict, "user", "RAW Item Dictionary ..." )
        my_iss_data = arg_item_dict.get(CtrlItmKeys.iss, CtrlItmDefs.iss)
        my_iss_path = my_iss_data.get(CtrlItmKeys.iss_path, None)

        if my_iss_path is not None:
            # if the iss path was not specified then the iss path currently in the parent data instance is the correct one
            Msg.dbg("Iss Path: %s, Test Root: %s" %
                    (my_iss_path, self.parent_data.test_root))
            # check to see if path is absolute path
            if not SysUtils.found(my_iss_path.find(
                    self.parent_data.test_root)):
                Msg.dbg("Test Root Not Found ...")
                # if not then prepend the test root
                my_iss_path = PathUtils.include_trailing_path_delimiter(
                    self.parent_data.test_root
                ) + PathUtils.exclude_leading_path_delimiter(my_iss_path)

            self.parent_data.update_iss_path(my_iss_path)

        Msg.dbg("Final Iss Path: %s" % (self.parent_data.iss_path))
示例#21
0
    def load_force_log(self, arg_seed_only=False):

        self.default = None
        self.secondary = None
        self.total = None
        self.seed = None
        self.task_path = PathUtils.include_trailing_path_delimiter(
            self.work_dir)

        my_glog = "%s%s" % (self.task_path, self.force_log)

        Msg.dbg("Path: %s" % my_glog)
        # Msg.user( "Opening Generator Log File: %s" % ( my_glog ))
        with open(my_glog, "r") as my_flog:
            try:
                for my_line in my_flog:

                    if SysUtils.found(
                            my_line.find("Secondary Instructions Generated")):
                        # my_secondary = my_line.replace( "[notice]Secondary Instructions Generated:", "" ).strip()
                        # self.secondary = int( my_secondary )
                        my_lpos = my_line.find(':')
                        my_count = int(my_line[my_lpos + 2:].strip())
                        # Msg.user( "Secondary Instructions: %d" % ( my_count ))
                        self.secondary = my_count

                    elif SysUtils.found(
                            my_line.find("Default Instructions Generated")):
                        # my_pos = my_line.find( ":" ) + 2
                        # my_default = my_line[ my_pos: ].strip()
                        # get the count for this instruction type

                        my_lpos = my_line.find(':')
                        my_count = int(my_line[my_lpos + 2:].strip())
                        # Msg.user( "Default Instructions: %d" % ( my_count ))
                        self.default = my_count

                        # my_default = my_line.replace( "[notice]Default Instructions Generated:", "" ).strip()
                        # self.default = int( my_default )

                    if SysUtils.found(
                            my_line.find("Total Instructions Generated")):
                        self.total = int(
                            my_line.replace(
                                "[notice]Total Instructions Generated: ",
                                "").strip())

                        my_lpos = my_line.find(':')
                        my_count = int(my_line[my_lpos + 2:].strip())
                        # Msg.user( "Total Instructions: %d" % ( my_count ))
                        self.total = my_count

                    if SysUtils.found(my_line.find("Initial seed")):
                        self.seed = my_line.replace("[notice]", "").replace(
                            "Initial seed = ", "").strip()
                        # Msg.dbg( "Seed: %s" % ( self.seed ))

                        # for simulation only the seed is needed
                        if arg_seed_only:
                            break
                    if not (self.seed is None or self.total is None
                            or self.secondary is None or self.default is None):
                        break
            except Exception as arg_ex:
                # NOTE: Determine the possible errors and handle accordingly, for now just keep processing
                Msg.error_trace()
                Msg.err(str(arg_ex))

            finally:
                my_flog.close()
示例#22
0
    def resolve_file_location(self):

        my_fctrl_dir, self.fctrl_name = PathUtils.split_path(
            str(self.fctrl_name))

        Msg.user(
            "Extracted File Path: %s, Control File Path: %s, Extracted File Name: %s"
            % (str(my_fctrl_dir), str(self.fctrl_dir), str(self.fctrl_name)),
            "FCTRL-DIR")
        Msg.user(
            "1 - Control Directory: %s, Force Directory: %s, Test Root: %s, Work Dir: %s, Control File: %s, self.fctrl_dir: %s"
            % (my_fctrl_dir, self.parent_data.force_path,
               self.parent_data.test_root, self.parent_data.work_dir,
               self.fctrl_name, self.fctrl_dir), "FCTRL-DIR")
        # if the name does not contain a path use the contol directory
        if my_fctrl_dir is None:
            my_fctrl_dir = self.fctrl_dir

        Msg.user(
            "Control Directory: %s, Force Directory: %s, Test Root: %s, Work Dir: %s, Control File: %s"
            % (my_fctrl_dir, self.parent_data.force_path,
               self.parent_data.test_root, self.parent_data.work_dir,
               self.fctrl_name), "FCTRL-DIR")

        # because of the requirement of not knowing and needing to discover the directory
        # situation it is necessary to search for the control file
        my_tmp = None
        my_tmp_dir = None

        # if the a directory was specified in the control name or a specifies as part of the control item it is
        # necessary to check for either a absolute path or relative parent path
        # Msg.dbg( "Checking: [%s] for [%s]" % ( my_fctrl_dir, self.fctrl_name ))

        if my_fctrl_dir is None:
            raise Exception(
                "Control File Location was not specified, File[%s]" %
                (self.fctrl_name))

        if self.check_full_path(my_fctrl_dir):
            Msg.user("Using Real Path as Control Directory", "FILE_LOCATION")
            pass

        elif self.check_parent_dir(my_fctrl_dir):
            Msg.user("Using Parent Directory as Control Directory",
                     "FILE_LOCATION")
            pass

        elif self.check_work_dir(my_fctrl_dir):
            Msg.user(
                "Using Current Control File Location as Control Directory",
                "FILE_LOCATION")
            pass

        elif self.check_ctrl_dir(my_fctrl_dir):
            Msg.user("Using Specified Control Directory as Control Directory",
                     "FILE_LOCATION")
            pass

        else:

            if self.item_type() == ControlItemType.TaskItem:
                my_err_queue_item = SummaryErrorQueueItem({
                    "error":
                    "Template Not Found at Specified Location",
                    "message":
                    "Template File Not Found ...",
                    "path":
                    self.file_path(),
                    "type":
                    str("FileNotFoundError")
                })
                self.summary().queue.enqueue(my_err_queue_item)

            elif self.item_type() == ControlItemType.FileItem:
                my_err_queue_item = SummaryErrorQueueItem({
                    "error":
                    "FileNotFoundError",
                    "message":
                    "Control File Not Found at Specified Location",
                    "path":
                    self.file_path(),
                    "type":
                    str("FileNotFoundError")
                })
                self.summary().queue.enqueue(my_err_queue_item)

            raise Exception("File[%s] Not Found at Location Specified[%s]" %
                            (self.fctrl_name, my_fctrl_dir))

        # Msg.dbg( "Raw Control Directory: %s" % ( self.fctrl_dir ))
        # Msg.dbg( "Test Root: %s" % ( self.test_root ))
        # remove the test root if present
        if SysUtils.found(self.fctrl_dir.find(self.parent_data.test_root)):
            # Msg.dbg( "Test Root Found" )
            self.fctrl_dir = self.fctrl_dir.replace(self.parent_data.test_root,
                                                    "")

        # Msg.dbg( "Trimmed Control Directory: %s" % ( self.fctrl_dir ))

        # add the trailing path delimiter
        self.fctrl_dir = PathUtils.include_trailing_path_delimiter(
            self.fctrl_dir)
        Msg.user("Delimited Control Directory: %s" % (self.fctrl_dir),
                 "FILE_LOCATION")
        return True