示例#1
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
示例#2
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()
示例#3
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()
示例#4
0
    def process_errors(self, arg_ofile):

        if len(self.errors) > 0:
            arg_ofile.write("\n")
            Msg.blank()
            for my_eitem in self.errors:
                my_err_line = str(my_eitem.get_err_line())
                Msg.info(my_err_line)
                arg_ofile.write("%s\n" % (my_err_line))
示例#5
0
 def process_task_list(self):
     for my_task_file in self.task_list:
         # Msg.dbg( "Process Task File: %s" % ( my_task_file ))
         my_curdir = PathUtils.current_dir()
         try:
             # self.process_task_file( my_task_file )
             self.process_task_file(my_task_file)
         except Exception as arg_ex:
             Msg.error_trace()
             Msg.err(str(arg_ex))
             Msg.blank()
         finally:
             PathUtils.chdir(my_curdir)
示例#6
0
 def process(self):
     # Msg.dbg( "TaskController::process()")
     for my_ndx in range(0, self.ctrl_item.iterations):
         try:
             # my_usr_lbl = Msg.set_label( "user", "TASK-ITERATION" )
             # Msg.user( "Executing Iteration #%d of %d Task: %s " % ( my_ndx + 1, self.ctrl_item.iterations, self.ctrl_item.fctrl_name ))
             self.process_task_list()
         except Exception as arg_ex:
             # pass
             Msg.error_trace()
             Msg.err(str(arg_ex))
             Msg.blank()
         finally:
             pass
示例#7
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
示例#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
示例#9
0
        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
        Msg.error_trace("[ERROR] - " + str(arg_ex))
        force_usage(UsageStr)
        sys.exit(41)

    except Exception as arg_ex:

        from force_init import force_usage

        Msg.err("[ERROR] - An Unhandled Error has Occurred during run of " +
                str(sys.argv[0]))
示例#10
0
 def thread_done(self):
     Msg.info("UnitTest_LoopThread << Execute Done .... ")
     Msg.blank()
示例#11
0
 def __exit__(self, type, value, traceback):
     self.process_result()
     Msg.blank()