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
def prepare(self): if self.root.startswith("$(") and self.root.endswith(")"): self.root = PathUtils.exclude_trailing_path_delimiter( SysUtils.envar(self.root[2:-1], None)) self.default_fsdb_do = PathUtils.append_path(self.root, self.default_fsdb_do) if self.regr.startswith("$(") and self.regr.endswith(")"): self.regr = PathUtils.exclude_trailing_path_delimiter( SysUtils.envar(self.regr[2:-1], "logs")) else: self.regr = "logs" if self.cfg.startswith("$(") and self.cfg.endswith(")"): self.cfg = PathUtils.exclude_trailing_path_delimiter( SysUtils.envar(self.cfg[2:-1], "target_config")) else: self.cfg = "config_name" if self.name.startswith("$(") and self.name.endswith(")"): self.name = PathUtils.exclude_trailing_path_delimiter( SysUtils.envar(self.name[2:-1], "uvm_simv_opt")) else: self.cfg = "uvm_simv_opt" self.path = PathUtils.exclude_trailing_path_delimiter(self.path) self.tgt = PathUtils.exclude_trailing_path_delimiter(self.tgt) self._debug_command = self.cmd % (self.root, self.path, self.regr, self.tgt, self.debug_cfg, self.debug_name)
def test_summary(aParameters): forrest_log = aParameters.forrest_log msg_level = aParameters.msg_lev if msg_level is not None: Msg.set_level(Msg.translate_levelstr(msg_level)) print("Forrest log file is: %s" % forrest_log) work_dir, my_tmp = PathUtils.split_path(forrest_log) frun_path = PathUtils.append_path( PathUtils.include_trailing_path_delimiter(work_dir), "_def_frun.py") # test - timeout summary_queue_args = { "frun-path": frun_path, "process-log": forrest_log, "process-result": ( 0, None, "Process Timeout Occurred", 1555792446.313606, 1555792446.313606, SysUtils.PROCESS_TIMEOUT, ), } summary_queue_item = SummaryQueueItem(summary_queue_args) summary_item = SummaryItem({}) summary_item.load(summary_queue_item)
def process_task(self, arg_task_file, aTaskDir): try: # get the subdirectory index my_ndx = self.mAppsInfo.getNextIndex(aTaskDir) # form sub task directory sub_task_dir = PathUtils.append_path( PathUtils.include_trailing_path_delimiter(aTaskDir), "%05d" % my_ndx) # save the task template file name with path to the control item self.ctrl_item.fname = arg_task_file # prepare control item content, TODO don't really need it. my_content = self.ctrl_item.prepare(self.mAppsInfo, arg_task_file) my_queue_item = ProcessQueueItem(sub_task_dir, self.ctrl_item, self.mAppsInfo, my_content) self.mProcessQueue.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: pass
def process_task_file(self, arg_task_file, aParentDir): try: # NOTE: a task file can be but is not limited to being an test template file # set base task directory and extract the task id and update directory my_task_name = PathUtils.base_name(arg_task_file) my_task_dir = my_task_name.replace(".py", "") # Msg.info("suffix: %s" % ( str( self.ctrl_item.suffix ))) if self.ctrl_item.suffix is not None: my_task_dir = my_task_dir.replace( "_force", "_%s_force" % (str(self.ctrl_item.suffix))) full_task_dir = PathUtils.append_path( PathUtils.include_trailing_path_delimiter(aParentDir), my_task_dir) # Msg.dbg( "Changed to Base Dir, my_task_name(%s), my_task_dir(%s)" % (my_task_name, my_task_dir)) # check for exiting sub-directories, and extract the task iteration count to prevent # unintended modifications to the original passed on the commafrom common.path_utils import PathUtilsnd line for this task or # acquired from a control file item self.process_task(arg_task_file, full_task_dir) finally: pass
def load(self, arg_ctrl_item): super().load(arg_ctrl_item) # Msg.dbg( "TaskController::load()") self.task_list = PathUtils.list_files( PathUtils.append_path(self.ctrl_item.fctrl_dir, self.ctrl_item.fctrl_name)) return True
def initialize_processor_cmd( self ): # the default task processor is "forrest_run.py" # the default directory is the same directory as the master_run # the processor can be replaced with a command line argument which may or may not contain a path # if it does not contain a path then the default path will be used # if a directory is passed on the command line in all cases that will be the location of the processor my_run_dir = None my_run_name = None my_tmp_name = None my_tmp_path = None my_run_path = self.option_def( CmdLine.Switches[CmdLine.run_name], None ) if my_run_path is not None: my_run_dir, my_run_name = PathUtils.split_path( my_run_path ) Msg.user( "Client Dir: %s, Client Name: %s (1)" % (str(my_run_dir), str(my_run_name)), "PROCESS_CMD" ) if my_run_dir is None: my_tmp_path = self.locate_directory( CmdLine.Switches[CmdLine.run_dir], EnVars.run_path, self.module_dir) # Msg.user( "Temp Path: [%s] (1)" % (str(my_tmp_path)), "PROCESS_CMD" ) if PathUtils.check_exe( my_tmp_path ): my_run_dir, my_tmp_name = PathUtils.split_path( my_tmp_path ) # Msg.user( "Client Dir: %s, Client Name: %s (2)" % (str(my_run_dir), str(my_tmp_name)), "PROCESS_CMD" ) else: my_run_dir = my_tmp_path # Msg.user( "Client Dir: %s, Client Name: %s (3)" % (str(my_run_dir), str(my_run_name)), "PROCESS_CMD" ) if my_run_name is None: my_run_name = my_tmp_name if my_tmp_name is not None else Defaults.run_name # Msg.user( "Client Dir: %s, Client Name: %s (4)" % (str(my_run_dir), str(my_run_name)), "PROCESS_CMD" ) my_process_cmd = PathUtils.real_path( PathUtils.append_path( PathUtils.include_trailing_path_delimiter( my_run_dir ), my_run_name )) Msg.user( "Process Cmd: %s (1)" % (str(my_process_cmd)), "PROCESS_CMD" ) my_msg_lev = self.option_def( CmdLine.Switches[CmdLine.client_lev], None) if my_msg_lev is not None : if my_msg_lev == True: my_process_cmd += Msg.get_level_as_str() # Msg.user( "Process Cmd: %s (2)" % (str(my_process_cmd)), "PROCESS_CMD" ) else : my_process_cmd += " -l " + my_msg_lev Msg.user( "Process Cmd: %s" % (str(my_process_cmd)), "PROCESS_CMD" ) if self._mAppsInfo.mConfigPath is not None: my_process_cmd += " -w %s" % self._mAppsInfo.mConfigPath my_process_cmd += " -f %s" self.processor_name = my_run_name.replace( ".py", "" ).replace( "_run", "" ) self.process_cmd = my_process_cmd Msg.dbg( "Process Cmd: %s" % (str(self.process_cmd)))
def __init__( self, aWorkDir, arg_ctrl_item, aAppsInfo, arg_content ): super().__init__() self.work_dir = aWorkDir self.frun_path = PathUtils.append_path(PathUtils.include_trailing_path_delimiter(self.work_dir), "_def_frun.py") self.ctrl_item = arg_ctrl_item self.mAppsInfo = aAppsInfo self.parent_fctrl = arg_ctrl_item.parent_fctrl self.fctrl_item = arg_ctrl_item.fctrl_item self.item_group = arg_ctrl_item.group self.content = arg_content
def initialize_task(self): # Msg.user( "ExecuteController::initialize_task(1)" ) my_task_file = PathUtils.append_path(self.ctrl_item.fctrl_dir, self.ctrl_item.fctrl_name) # Msg.user( "ExecuteController::initialize_task(2)" ) my_tmp, my_task_ndx = PathUtils.split_path(self.ctrl_item.fctrl_dir) # Msg.user( "ExecuteController::initialize_task(3)" ) my_task_name = self.ctrl_item.fctrl_name.replace(".py", "") # Msg.user( "ExecuteController::initialize_task(5)" ) Msg.user("Task File: %s, Task Name: %s, Task Index: %s" % (my_task_file, my_task_name, my_task_ndx)) return (my_task_file, my_task_name, my_task_ndx)
def load(self, arg_ctrl_item): super().load(arg_ctrl_item) # Msg.dbg( "TaskController::load()") self.task_list = PathUtils.list_files( PathUtils.append_path(self.ctrl_item.fctrl_dir, self.ctrl_item.fctrl_name)) # # Msg.user( "File Count: " + str( len( self.task_list )), "TASKCTRL" ) # my_usr_lbl = Msg.set_label( "user", "TASKCTRL" ) # Msg.lout(self.task_list, "user", "File List to Process with this Controller" ) # Msg.set_label( "user", my_usr_lbl ) # # import sys # sys.exit(-1) # return True
def checkNestedPath(aClass, aPathList): #validate the input if type(aPathList) != list: raise Exception( "Input to FileLocator.checkNestedPath must be a list") if len(aPathList) < 2: raise Exception( "Input to FileLocator.checkNesterPath needs to be a list more than 1 item long" ) joined_path = str(aPathList[0]) for path in aPathList[1:]: joined_path = PathUtils.real_path( PathUtils.append_path(joined_path, path)) #validate the joined path if not PathUtils.check_found(joined_path): return joined_path, False else: return joined_path, True
def __init__(self, aCmdLineOptions): """Iintialize the object :param CmdLineOptions aCmdLineOptions: """ super().__init__(RtlCmdLineOptions.cOptions, aCmdLineOptions) rtl_root = self.mAppParameters.parameter("root") if not PathUtils.check_dir(rtl_root): raise Exception(rtl_root + " is not a directory.") meta_conv_path = PathUtils.append_path(aCmdLineOptions.mProgramPath, "metaargs_to_plusargs.py") self.mAppParameters.setParameter("meta_converter", meta_conv_path) # determine svn revision information and store as a parameter version_data = VersionCtrlUtils.get_scm_revisions(rtl_root) version_output = VersionCtrlUtils.get_version_output(version_data) Msg.info("RTL Version Data:\n%s" % version_output) self.mAppParameters.setParameter("version", version_data) self.mAppParameters.setParameter("version_dir", rtl_root)
def file_path(self): return PathUtils.append_path(self.fctrl_dir, self.fctrl_name)