Пример #1
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):
            Msg.info(
                "Instructions: %d, Default: %d, Secondary: %d, "
                "Elapsed Time: %0.5f Seconds\n\n"
                % (
                    self.total,
                    self.default,
                    self.secondary,
                    self.force_end - self.force_start,
                )
            )
            return 1

        return 0
Пример #2
0
    def rename_elfs(self, arg_suffix):

        # before proceeding it is necessary to remove any existing renamed files to eliminate the possibility of causing
        # a chain and messing up the results
        for my_mask in ["*.ELF", "*.S", "*.img"]:
            my_match_files = PathUtils.list_files(my_mask)
            Msg.lout(my_match_files, "user", "Simulate File List")
            for my_src_file in my_match_files:
                Msg.user(
                    "Match File: %s, Suffix: %s" %
                    (str(my_src_file), str(arg_suffix)), "MATCH")
                if SysUtils.found(
                        my_src_file.find("_%s_force" % (str(arg_suffix)))):
                    PathUtils.remove(my_src_file)
                    continue

        # Now rename all the files that are found
        for my_mask in ["*.ELF", "*.S", "*.img"]:
            my_match_files = PathUtils.list_files(my_mask)
            for my_src_file in my_match_files:
                my_tgt_file = my_src_file.replace(
                    "_force", "_%s_force" % (str(arg_suffix)))
                PathUtils.rename(my_src_file, my_tgt_file)

        # raise Exception("Type %s test case for base test: %s not found." % (arg_extension, arg_test_name))
        return True
Пример #3
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
Пример #4
0
    def locate_test_case( self, arg_extension, arg_test_name ):

        Msg.user( "IssExecutor::locate_test_case( Extension: %s, Test Name: %s )" % ( str( arg_extension ), str( arg_test_name )))
        my_match_files = PathUtils.list_files( arg_extension )
        Msg.lout( my_match_files, "user", "Simulate File List" )
        if arg_test_name.endswith( "_force" ):
            arg_test_name = arg_test_name.replace( "_force", "" )

        for my_file in my_match_files:
            Msg.user( "Match File: %s, Test Name: %s" % ( str( my_file ), str( arg_test_name )))
            if ( my_file.find( arg_test_name ) != -1 ):
                return my_file

        raise Exception("Type %s test case for base test: %s not found." % (arg_extension, arg_test_name))

        return None
Пример #5
0
    def archive_dir(cls, arg_srcdir):

        try:
            # get the base name
            my_basename = "%s" % (str(DateTime.YMD()))
            Msg.dbg("Base Name: %s" % (my_basename))

            # set the directory mask
            my_srcdir = PathUtils.exclude_trailing_path_delimiter(arg_srcdir)
            my_srcmask = "%s_%s_???" % (my_srcdir, my_basename)
            Msg.dbg("Directory Mask: %s" % (my_srcmask))

            # list any previous copies
            my_dirlist = sorted(PathUtils.list_files(my_srcmask))

            Msg.lout(my_dirlist, "dbg")
            my_findex = 0

            # there are only two possiblities here
            # 1. there is only one match, in which case the mask does not
            #       include a number
            # 2. there are more than one match in which case the last match
            #       should contain a number

            if len(my_dirlist) > 0:
                # remove the wildcards
                my_srcmask = my_srcmask.replace("???", "")
                Msg.dbg("New File Mask: %s" % (my_srcmask))

                my_tmp = my_dirlist[-1]
                Msg.dbg("Last Filename: %s" % (my_tmp))

                my_tmp = my_tmp.replace(my_srcmask, "")
                Msg.dbg("My Index Last Filename: %s" % (my_tmp))

                my_findex = int(my_tmp) + 1
                Msg.dbg("My New Index Filename: %s" % (my_findex))

            # get the target name
            my_tgtdir = "%s_%s_%0.3d" % (my_srcdir, my_basename, my_findex)
            Msg.dbg("Target Directory: %s" % (my_tgtdir))
            return PathUtils.move(my_srcdir, my_tgtdir)

        except Exception as arg_ex:
            Msg.error_trace(str(arg_ex))
            Msg.err(str(arg_ex))
            return False
Пример #6
0
    def purge_dirs(arg_class, arg_basedir):
        try:
            my_dirlist = sorted(os.listdir(arg_basedir))
            Msg.lout(my_dirlist, "dbg")

            for my_dir in my_dirlist:
                #PathUtils.rmdir( my_dir, True )
                PathUtils.rmdir(
                    PathUtils.include_trailing_path_delimiter(arg_basedir) +
                    my_dir, True)
                # Msg.user( "Directory To Remove: %s" % ( my_dir ) )

        except OSError as arg_ex:
            Msg.error_trace()
            Msg.err(str(arg_ex))
            return False

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

        return True
Пример #7
0
 def next_dir(arg_class):
     # list any previous copies
     my_dirlist = sorted(PathUtils.list_files("."))
     Msg.lout(my_dirlist, "dbg")
     return len(my_dirlist)