コード例 #1
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()
コード例 #2
0
    def view(self, sum_level=SummaryLevel.Fail):
        # Instruction Over Flow Failure Count
        # print( "Regression::view() " )
        from datetime import date, time, datetime, timedelta, timezone, tzinfo
        my_utcdt = datetime.utcnow()
        my_file_name = PathUtils().include_trailing_path_delimiter( self.summary_dir ) \
                     + "regression_summary_"      \
                     + str( my_utcdt.year )       \
                     + str( my_utcdt.month )      \
                     + str( my_utcdt.day )        \
                     + "-"                        \
                     + str( my_utcdt.hour )       \
                     + str( my_utcdt.minute )     \
                     + str( my_utcdt.second )     \
                     + ".log"

        print(my_file_name)

        try:
            my_ofile = None
            myLines = []
            # First try to open file
            with open(my_file_name, "w") as my_ofile:
                my_ofile.write("Date: " + str(my_utcdt.date()) + "\n")
                my_ofile.write("Time: " + str(my_utcdt.time()) + "\n")

                print("\n\n")

                for my_key, my_val in self.results.items():

                    # print( str( my_val ))
                    my_line = my_val[
                        4] + " - Test Name: " + my_key + ", Return Code: " + str(
                            my_val[1]) + ", Log File: " + my_val[2]

                    if my_val[3]:
                        my_line += my_val[3]

                    my_ofile.write(my_line + "\n")

                    if sum_level > 2:
                        print(my_line)
                    elif sum_level == 1 and my_val[0] in [2]:
                        print(my_line)
                    elif sum_level == 2 and my_val[0] in [1, 2]:
                        print(my_line)

                my_ofile.write("Total Simulations: " + str(self.total_count) +
                               "\n")
                my_ofile.write("Total Fails:       " + str(self.failed_count) +
                               "\n")
                if self.total_count > 0:
                    my_ofile.write("Success Rate:      " +
                                   "{0:.2f}".format(100 * (self.total_count -
                                                           self.failed_count) /
                                                    self.total_count) + "%\n")
                else:
                    my_ofile.write("Success Rate:      0.00%\n")

                my_ofile.write("Test Suite Complete\n")

                print("Total Simulations: " + str(self.total_count) + "\n")
                print("Total Fails:       " + str(self.failed_count) + "\n")
                if self.total_count > 0:
                    print("Success Rate:      " +
                          "{0:.2f}".format(100 * (self.total_count -
                                                  self.failed_count) /
                                           self.total_count) + "%")
                else:
                    print("Success Rate:      0.00%")
                print("Test Suite Complete\n")

        except Exception as arg_ex:
            if Msg._debug():
                traceback.print_exception("Exception", arg_ex, None)
            print("Error Processing Summary, " + str(arg_ex))

        finally:
            pass