Esempio 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
Esempio n. 2
0
    def process(self):

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

        # my_usr_lbl = Msg.set_label( "user", "EXEC-VALS" )
        # Msg.lout( self.ctrl_item.catalougs(), "user", "Control Item Cataloug" )
        my_task_file = PathUtils.include_trailing_path_delimiter(
            self.ctrl_item.parent_data.test_root)
        my_task_file += PathUtils.include_trailing_path_delimiter(
            self.ctrl_item.fctrl_dir)
        my_task_file += self.ctrl_item.fctrl_name

        my_tmp, my_task_ndx = PathUtils.split_path(self.ctrl_item.fctrl_dir)
        my_task_name = self.ctrl_item.fctrl_name.replace(".py", "")

        # Msg.user( "Task File: %s, Task Name: %s, Task Index: %s" % ( my_task_file, my_task_name, my_task_ndx )  )

        self.process_task_file(my_task_file, my_task_name, my_task_ndx)
Esempio n. 3
0
    def process_task(self, arg_task_file):

        try:
            # get the subdirectory index
            my_ndx = int(PathUtils.next_subdir())

            # update the user label and send iteration message to the screen if user is active
            # my_usr_lbl = Msg.set_label( "user", "TEST-ITERATION" )
            # Msg.user( "Executing Iteration #%d of Test File: %s" % ( my_ndx + 1, arg_task_file ))
            # Msg.set_label( "user", my_usr_lbl )

            # create subdirectory and change into it
            PathUtils.chdir("%05d" % my_ndx, True)

            # save the task template file name with path to the control item
            self.ctrl_item.fname = arg_task_file

            # write out the control file
            # if the write was successful then enqueue the new control file name with real path
            my_ctrl_file = "%s_def_frun.py" % (
                PathUtils.include_trailing_path_delimiter(
                    PathUtils.current_dir()))
            PathUtils.touch("%sSTARTED" %
                            PathUtils.include_trailing_path_delimiter(
                                PathUtils.current_dir()))
            my_content = self.prepare(arg_task_file)
            if self.write_control_file(my_ctrl_file, my_content):
                # my_queue_item = ProcessQueueItem( my_ctrl_file, self.ctrl_item.parent_fctrl, self.ctrl_item.fctrl_item, self.ctrl_item.group, my_content )
                my_queue_item = ProcessQueueItem(
                    my_ctrl_file, self.ctrl_item, my_content
                )  # self.parent_fctrl, self.ctrl_item.fctrl_item, self.ctrl_item.group)
                self.ctrl_item.parent_data.process_queue.enqueue(my_queue_item)

        except Exception as arg_ex:
            Msg.error_trace()
            Msg.err(str(arg_ex))
            # reraise to prevent adding to summary instance
            raise

        finally:
            PathUtils.chdir("..")
Esempio n. 4
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()
Esempio n. 5
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
Esempio n. 6
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))
Esempio n. 7
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
Esempio n. 8
0
 def file_path(self):
     return "%s%s%s" % (self.parent_data.test_root,
                        PathUtils.include_trailing_path_delimiter(
                            self.fctrl_dir), self.fctrl_name)
Esempio n. 9
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()