Ejemplo n.º 1
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
Ejemplo n.º 2
0
    def check_parent_dir(self, arg_fctrl_dir):

        Msg.dbg("Checking for control file in parent directory")
        Msg.user(
            "Test Root[%s], Work Dir[%s]" %
            (str(self.parent_data.test_root), str(self.parent_data.work_dir)),
            "CHECK-PARENT-DIR")

        if arg_fctrl_dir.startswith(".."):

            my_search_dir = arg_fctrl_dir
            my_work_dir = PathUtils.append_path(self.parent_data.test_root,
                                                self.parent_data.work_dir)
            my_test_root = self.parent_data.test_root
            Msg.user(
                "Updated Test Root[%s], Full Work Dir[%s], Search Dir[%s]" %
                (my_test_root, my_work_dir, my_search_dir), "CHECK-PARENT-DIR")

            while my_search_dir.startswith(".."):

                # First get the parent directory
                # The search [updated] directory started with [..] split path for both the work directory and the search directory
                # this fact that the [updated] search directory still begins with a [..], means that the work directory
                my_test_root, my_dumy = PathUtils.split_dir(my_test_root)
                my_work_dir, my_dumy = PathUtils.split_dir(my_work_dir)
                my_search_dir = my_search_dir[3:]
                Msg.user(
                    "Updated Test Root[%s], Full Work Dir[%s], Search Dir[%s]"
                    % (my_test_root, my_work_dir, my_search_dir),
                    "CHECK-PARENT-DIR")

                my_filepath = str(
                    PathUtils.append_path(
                        my_work_dir,
                        PathUtils.append_path(my_search_dir, self.fctrl_name)))
                Msg.user("File Path[%s] ... " % (my_filepath),
                         "CHECK-PARENT-DIR")

                if PathUtils.check_found(my_filepath):
                    self.fctrl_dir = PathUtils.append_path(
                        my_work_dir, my_search_dir)
                    return True

                my_filepath = str(
                    PathUtils.append_path(
                        my_test_root,
                        PathUtils.append_path(my_search_dir, self.fctrl_name)))
                Msg.user("File Path[%s] ... " % (my_filepath),
                         "CHECK-PARENT-DIR")

                if PathUtils.check_found(my_filepath):
                    self.fctrl_dir = PathUtils.append_path(
                        my_test_root, my_search_dir)
                    return True

            raise Exception(
                "Control Item File[%s] Not Found in Parent Directory: [%s]" %
                (self.fctrl_name, arg_fctrl_dir))

        return False
Ejemplo n.º 3
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"  #
Ejemplo n.º 4
0
    def run(self):
        # Block on process queue while we have threads running and stuff to do

        # == Replaced ==>> while True:
        # == Replaced ==>>     # Pop off the top of the process queue (should block if the queue is empty)
        # == Replaced ==>>     try:
        # == Replaced ==>>         next_item = self.summary_queue.dequeue(0)
        # == Replaced ==>>     except TimeoutError:
        # == Replaced ==>>         if (workers_done_event.isSet()):
        # == Replaced ==>>             summary_done_event.Signal()
        # == Replaced ==>>             return
        # == Replaced ==>>         else:
        # == Replaced ==>>             self.HeartBeat()
        # == Replaced ==>>             continue
        # == Replaced ==>>     my_item = self.summary.create_summary_item()
        # == Replaced ==>>     my_item.load( next_item )
        # == Replaced ==>>     self.summary.commit_item( my_item )
        # == Replaced ==>>     next_item = None

        try:
            while True:  #not workers_done_event.isSet():
                # Pop off the top of the process queue (should block if the queue is empty)
                try:
                    # my_item = self.summary.create_summary_item()
                    # my_qitem = self.summary_queue.dequeue(0)
                    # my_item.load( my_qitem )
                    # self.summary.commit_item( my_item )
                    # my_qitem = None
                    # my_qitem = self.summary_queue.dequeue(0)

                    my_qitem = self.summary_queue.dequeue(0)
                    if isinstance(my_qitem, SummaryErrorQueueItem):
                        Msg.user(str(my_qitem.error_info), "SUMMARY_ERROR")
                        my_eitem = SummaryErrorItem()
                        my_eitem.load(my_qitem)
                        self.summary.commit_error_item(my_eitem)
                    else:
                        my_item = self.summary.create_summary_item()
                        my_item.load(my_qitem)
                        self.summary.commit_item(my_item)
                    my_qitem = None
                except TimeoutError as arg_ex:
                    # {{{TODO}}} Implement proper heartbeat
                    # Msg.dbg( str( arg_ex ) )
                    if (workers_done_event.isSet()):
                        break
                    else:
                        self.HeartBeat()
                        continue
                except Exception as arg_ex:
                    Msg.error_trace()
                    Msg.err(str(arg_ex))
                    raise
                except:
                    Msg.error_trace()
                    raise
        finally:
            summary_done_event.Signal()
Ejemplo n.º 5
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
Ejemplo n.º 6
0
    def instruction_counts( self ):
        my_lines = None
        my_glog = "%s%s" % ( PathUtils.include_trailing_path_delimiter( self.work_dir ), self.force_log )

        Msg.user("Path: %s" % my_glog)

        with open( my_glog, "r" ) as my_log:
            my_lines = my_log.readlines()
            Msg.dbg( "Line %d: %s" % ( len( my_lines ), my_lines[-1]))
            my_log.close()
        try:
            my_results = [ my_tmp for my_tmp in my_lines if re.search( ' Instructions Generated', my_tmp )]
            Msg.lout( my_results, "dbg" )
            if not my_results:
                raise Exception( "Instruction Count Not Found in \"gen.log\"" )

            # ok there are instruction counts located
            for my_line in my_results:
                my_line = my_line.strip()

                # find the instruction type (Total, Default, Secondary)
                my_lpos = my_line.find(']')
                my_rpos = my_line.find( "Instr" )
                my_type = PerformanceInstructionType.instruction_type(( my_line[my_lpos + 1 : my_rpos - 1 ]).strip())

                # get the count for this instruction type
                my_lpos = my_line.find( ':' )
                my_count = int( my_line[my_lpos+2:].strip())

                if my_type == PerformanceInstructionType.Total:
                    self.count = my_count
                elif my_type == PerformanceInstructionType.Secondary:
                    self.secondary = my_count
                elif my_type == PerformanceInstructionType.Default:
                    self.default = my_count

        except ValueError:
            Msg.error_trace()
            Msg.err( "Unable to extract instruction count from %s" % ( int( my_lines[-1] )))

        return 0
Ejemplo n.º 7
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
Ejemplo n.º 8
0
    def process(self):

        # Msg.dbg( "FileController::process()" )
        # Msg.dbg( "FileController Contents: \n\"" + str( self.fcontrol ) + "\n" )

        try:
            # Msg.lout( my_options["work-dir"], MsgLevel.dbg, "Work Director Stack" )
            # a control file may iterate through to completion according to the amount set in num_runs
            for my_ndx in range( self.ctrl_item.iterations ):

                # my_usr_lbl = Msg.set_label( "user", "FILE-ITERATION" )
                # Msg.user( "Executing %d of %d Iterations, Control File: %s" % ( my_ndx + 1, self.ctrl_item.iterations, self.ctrl_item.file_path() ))
                # Msg.set_label( "user", my_usr_lbl )

                try:
                    my_item_ndx = 0
                    # each item in the control set exists as a dictionary
                    for my_item_dict in self.fcontrol:
                        try:

                            my_item_ndx += 1
                            my_usr_lbl = Msg.set_label( "user", "CTRL-FILE"  )
                            Msg.blank( "user" )
                            Msg.user( "Processing Line: %s" % (str( my_item_dict )))

                            my_ctrl_item = ControlItem()
                            my_ctrl_item.parent_fctrl = self.parent_fctrl
                            my_ctrl_item.fctrl_item   = str( my_item_dict )

                            my_item_dict[CtrlItmKeys.parent_vals], my_parent_data = self.ctrl_item.values()

                            Msg.lout( my_parent_data, "user", "Result Parent Data" )
                            Msg.lout( my_item_dict  , "user", "Result Item Dictionary" )
                            Msg.set_label( "user", my_usr_lbl )

                            # Msg.user( "Processing Updated Line: %s" % (str( my_item_dict )), "CTRL-FILE" )
                            # Msg.user( str( my_parent_data.data() ), "CTRL-FILE" )
                            my_ctrl_item.load( my_item_dict, my_parent_data )

                            my_item_type = my_ctrl_item.item_type()
                            my_controller = None

                            if my_item_type == ControlItemType.TaskItem:
                                # Msg.dbg( "\nControl Item is a Control Task ..." )
                                my_controller = TaskController()

                            elif my_item_type == ControlItemType.FileItem:
                                # Msg.dbg( "\nControl Item is a Control File ..." )
                                my_controller = FileController()

                            else:
                                raise Exception( "\"" + my_fctrl_name + "\": Unknown Item Type ...\nUnable to Process ... " )

                            # Whew! everything is set up and ready to rock and roll, let the dogs out
                            # my_controller.load( my_ctrl_item )
                            # my_controller.process()

                            if my_controller.load( my_ctrl_item ):
                                my_controller.process()

                            # my_controller.load( my_ctrl_item )
                            # my_controller.process()

                            # Msg.dbg( "%s: Controller Creation Complete" % ( my_ctrl_item.fctrl_name ))

                        except TypeError as arg_ex:

                            Msg.err( str(  arg_ex  ))
                            my_err_queue_item = SummaryErrorQueueItem( { "error"  : "Item #%s Contains an Invalid Type" % ( str( my_item_ndx ))
                                                                       , "message": arg_ex
                                                                       , "path"   : self.ctrl_item.file_path()
                                                                       , "type"   : str( type( arg_ex ))
                                                                       } )

                            self.ctrl_item.summary().queue.enqueue( my_err_queue_item )
                            Msg.blank()

                        except FileNotFoundError as arg_ex:

                            Msg.err( str(  arg_ex  ))
                            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 )
                            Msg.blank()

                        except Exception as arg_ex:
                            Msg.error_trace( str(arg_ex) )
                            Msg.err( str(arg_ex))
                            Msg.blank()

                        finally:
                            my_controller = None
                            my_item_dict = None

                except Exception as arg_ex:
                    Msg.error_trace( "[ERROR] - " + str(arg_ex) )
                    Msg.err( str(arg_ex))
                finally:
                    pass

        finally:
            pass
            # Msg.dbg()

        return True
Ejemplo n.º 9
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