예제 #1
0
    def initialize_output(self):

        self.mode = self.option_def(CmdLine.Switches[CmdLine.mode], None)
        self.output_root = PathUtils.exclude_trailing_path_delimiter(
            self.option_def(CmdLine.Switches[CmdLine.target_dir],
                            PathUtils.current_dir()))
        Msg.user("Output Root: %s" % (str(self.output_root)))

        # check launcher type here since we need to know if we are running
        # with LSF
        Msg.user("Before Launcher Type", "MASTERRUN")
        self.launcher_type = self.option_def(
            CmdLine.Switches[CmdLine.run_launcher], Defaults.run_launcher)
        Msg.user("Launcher Type: %s" % (str(self.launcher_type)), "MASTERRUN")

        # ok the root output directory has been established.
        # next check to see if there is an expiration if there is handle that
        # and exit the session
        my_expire = self.option_def(CmdLine.Switches[CmdLine.expire], None)

        my_session_type = (Formats.perf_output_dir if SysUtils.found(
            self.mode.find(Modes.perf)) else Formats.regress_output_dir)

        if my_expire is not None:
            self.handle_expire(my_expire, my_session_type)
            raise Exception(
                "Problem with handle_expire, should have terminated .....")

        # Continuing create the full output directory which if exists should
        # be archived or removed
        my_output_base = Formats.main_output_dir % self.output_root
        self.output_dir = "%s/%s/" % (
            PathUtils.exclude_trailing_path_delimiter(my_output_base),
            PathUtils.exclude_trailing_path_delimiter(my_session_type),
        )

        Msg.user("Target Output Dir: %s" % (str(self.output_dir)))

        mod_time = None
        # if there is no expire setting then
        if PathUtils.check_dir(self.output_dir):
            # check modification time of the directory, if it is created very
            # recently, delay a bit when running on LSF.
            # since client machines might hold a stale directory handler still.
            mod_time = PathUtils.time_modified(self.output_dir)
            if self.option_def(CmdLine.Switches[CmdLine.no_archive],
                               Defaults.no_archive):
                PathUtils.rmdir(self.output_dir,
                                True)  # remove output directory tree
            else:
                PathUtils.archive_dir(self.output_dir)

        PathUtils.mkdir(self.output_dir)

        if mod_time is not None:
            self.waitForLfs(mod_time)

        return True
예제 #2
0
def main():
    signal.signal(signal.SIGINT, sig_interrupt_handler)
    my_pwd = None

    print(
        "\n=======================================\n\tInitializing ....\n=======================================\n"
    )
    try:
        my_module = MasterRun()

        # save current working directory
        my_pwd = PathUtils.current_dir()

        Msg.dbg("Original Directory: " + my_pwd)
        Msg.dbg("Processing Command Line and Loading Control File")
        my_module.load()

        if not PathUtils.chdir(my_module.output_dir, True):
            Msg.dbg("Unable to change into: " + my_module.output_dir +
                    ", using the current directory for output")

        Msg.info("\nConcurrent Operations: %s" %
                 (str(my_module.m_app_info.mProcessMax)))
        my_module.run()

        Msg.info("Test Completed ....\n")

    except FileNotFoundError as arg_ex:
        # Msg.error_trace("[ERROR] -  " + str(arg_ex) )
        Msg.err(str(arg_ex))
        Msg.blank()

    except LoadError as arg_ex:
        # Msg.error_trace("[ERROR] -  " + str(arg_ex) )
        Msg.err(str(arg_ex))
        Msg.blank()

    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]))
        traceback.print_exc(file=sys.stdout)

    except:
        # traceback.print_exc( file=sys.stdout )
        # print( "An Unhandled Exception Occurred ..." )
        pass

    finally:
        # TODO
        # change back to original directory

        if my_pwd is not None:
            # Msg.dbg( "Restoring Original Directory: " + my_pwd )
            PathUtils.chdir(my_pwd)
예제 #3
0
    def outputRerunScript(self):
        #use current test directory as output location and write script that allows rerun of at least the RTL portion of the test.
        output_directory = PathUtils.current_dir()

        rerun_script_path = PathUtils.append_path(output_directory, RtlDefaults.RERUN_CMD_FILENAME)
        rerun_dump_script_path = PathUtils.append_path(output_directory, RtlDefaults.RERUN_DUMP_CMD_FILENAME)
        bsub_rerun_script_path = PathUtils.append_path(output_directory, RtlDefaults.BSUB_RERUN_CMD_FILENAME)
        bsub_rerun_dump_script_path = PathUtils.append_path(output_directory, RtlDefaults.BSUB_RERUN_DUMP_CMD_FILENAME)

        base_rerun_cmd = self.rtl_cmd.replace("UVM_NONE", "UVM_HIGH")
        base_rerun_dump_cmd = base_rerun_cmd.replace(self.rtl.get("exe"), self.rtl.get("debug_exe"))
        rerun_dump_cmd = base_rerun_dump_cmd + str(" +fsdbfile+./%s.fsdb -ucli -do ./%s_waves_fsdb.do" % (self.task_name, self.task_name))

        class LsfDefaults(object):
            Group = "trg"
            Queue = "normal"
            ThreadCount = 16
            CoreFileSize = 1
            lsf_log = "lsf.%J"

        bsub_prepend = "bsub -K -G %s -q %s -C %s -o " % (LsfDefaults.Group, LsfDefaults.Queue, LsfDefaults.CoreFileSize) + LsfDefaults.lsf_log 

        try:
            with open(str(rerun_script_path), "w+") as out_file:
                rerun_cmd_string = base_rerun_cmd 
                out_file.write(rerun_cmd_string)    
            PathUtils.chmod(rerun_script_path, 0o755) #The numeric argument here is an octal literal 

            with open(str(rerun_dump_script_path), "w+") as out_file:
                rerun_cmd_string = rerun_dump_cmd
                out_file.write(rerun_cmd_string)    
            PathUtils.chmod(rerun_dump_script_path, 0o755) #The numeric argument here is an octal literal 

            with open(str(bsub_rerun_script_path), "w+") as out_file:
                rerun_cmd_string = bsub_prepend + " \"" + base_rerun_cmd + "\""
                out_file.write(rerun_cmd_string)    
            PathUtils.chmod(bsub_rerun_script_path, 0o755) #The numeric argument here is an octal literal 

            with open(str(bsub_rerun_dump_script_path), "w+") as out_file:
                rerun_cmd_string = bsub_prepend + " \"" + rerun_dump_cmd + "\""
                out_file.write(rerun_cmd_string)    
            PathUtils.chmod(bsub_rerun_dump_script_path, 0o755) #The numeric argument here is an octal literal 

        except IOError as e:
            print("IO error({0}): {1}".format(e.errno, e.strerror))
            raise
        except:
            print("[RTL-SIM] Unhandled exception while attempting to write rerun command files")
            raise
예제 #4
0
    def convertRawResult(self, aMetaArgs, aFilter=False):
        current_dir = PathUtils.current_dir()
        PathUtils.chdir(self._mTopSimPath)
        result, is_valid = SysUtils.get_command_output(self._mMakeCommand + aMetaArgs)
        PathUtils.chdir(current_dir)

        if not is_valid:
            print("Converting meta args: %s to raw result failed." % aMetaArgs)
            sys.exit(1)

        if aFilter:
            args_list = result.split(" ")
            args_list = self.filterList(args_list)
            result = " ".join(args_list)

        return result
예제 #5
0
 def run(self):
     my_sum_qitem = None
     try:
         my_launcher = self.create_launcher()
         my_launcher.launch()
         my_sum_qitem = SummaryQueueItem(my_launcher.extract_results())
     except Exception as arg_ex:
         Msg.error_trace(str(arg_ex))
         Msg.err("Message: %s, Control File Path: %s" %
                 (str(arg_ex), PathUtils.current_dir()))
         my_sum_qitem = SummaryErrorQueueItem({
             "error":
             arg_ex,
             "message":
             "Error Processing Task ...",
             "path":
             self.ctrl_item.file_path(),
             "type":
             str(type(arg_ex)),
         })
     finally:
         return my_sum_qitem
예제 #6
0
    def _getTestDir(self):
        if self.summaryOnly() or self.reportOnly():
            if self._mRunParameters.report_dir is not None:
                return self._mRunParameters.report_dir

        if self._mRunParameters.test_dir is None:
            test_dir = PathUtils.current_dir() + "/"
        else:
            test_dir = self._mRunParameters.test_dir + "/"

        if self._mRunParameters.label is None:
            label_str = "general"
        else:
            label_str = self._mRunParameters.label

        if self._mRunParameters.tag is None:
            tag_str = self._getDateTimeStr()
        else:
            tag_str = self._mRunParameters.tag

        test_dir += "_" + label_str + "_" + tag_str + "_r%d" % self._getForceRev(
        )
        return test_dir
예제 #7
0
def main():
    # set up signal handlers,
    signal.signal(signal.SIGINT, handle_signal)
    signal.signal(signal.SIGTERM, handle_signal)

    # initialize variables
    my_hlog = None
    my_org_stdout = None

    # global the_output_path =

    # Step 1: Save the originating directory
    my_pwd = PathUtils.current_dir()

    # Step 3: Extract Pid Group
    os.setpgid(os.getpid(), os.getpid())

    my_module = ForrestRun()

    try:
        my_module.force_path = the_force_root

        my_logfile = my_module.m_app_info.mCmdLineOpts.option_def(
            CmdLine.Switches[CmdLine.logfile], None)

        if my_logfile is not None:
            # print( "Redirecting STDOUT to my_logfile" )
            my_org_stdout = sys.stdout
            my_hlog = open(my_logfile, "w")
            sys.stdout = my_hlog
            Msg.user("Log File: %s" % (str(my_logfile)), "STDLOG")

        Msg.dbg("\nForce Path: %s" % (str(the_force_root)))
        Msg.dbg("Original Directory: " + my_pwd)

        # save current working directory

        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(my_module.frun_dir, False):
            Msg.dbg(
                "Directory Unchanged, using the current directory for output")

        my_module.run()
        Msg.dbg("Test Completed ....\n")
        Msg.blank()
        # sys.exit( 0 )

    except Exception as ex:
        from force_init import force_usage

        Msg.err("An Unhandled Error has Occurred during run of " +
                str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)
        Msg.error_trace(str(ex))
        my_module.m_app_info.mCmdLineOpts.print_help()
        sys.exit(41)

    except BaseException:
        print("[ERROR] - An Unhandled Error has Occurred during run of " +
              str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)
        sys.exit(42)

    finally:
        if my_logfile is not None:
            my_hlog.close()
            sys.stdout = my_org_stdout
            with open(my_logfile, "r") as my_hlog:
                print(my_hlog.read())

        if my_pwd is not None:
            PathUtils.chdir(my_pwd)
            Msg.dbg("Returned To: %s" % (PathUtils.current_dir()))
예제 #8
0
        sys.exit(int(str(aSysExit)))
    except:
        print(
            "[ERROR] - An Unhandled Error has Occurred during applications setup of "
            + str(sys.argv[0]))
        traceback.print_exc(file=sys.stdout)
        sys.exit(44)

    print(
        "\n=======================================\n\tInitializing ....\n=======================================\n"
    )
    try:
        my_module = MasterRun(apps_info)

        # save current working directory
        my_pwd = PathUtils.current_dir()

        Msg.dbg("Original Directory: " + my_pwd)
        Msg.dbg("Processing Command Line and Loading Control File")
        my_module.load()

        if not PathUtils.chdir(my_module.output_dir, True):
            Msg.dbg("Unable to change into: " + my_module.output_dir +
                    ", using the current directory for output")

        Msg.info("\nConcurrent Operations: %s" %
                 (str(my_module._mAppsInfo.mProcessMax)))
        my_module.run()

        Msg.info("Test Completed ....\n")
예제 #9
0
 def copyWavesFsdbDoFile(self):
     dofile_path = self.rtl.get("fsdb_do")
     
     if isinstance(dofile_path, str):
         SysUtils.exec_cmd("cp %s %s/%s_waves_fsdb.do" % (dofile_path, PathUtils.current_dir(), self.task_name))