Пример #1
0
 def sanity_check(self):
     # get src_design and dst_design
     if self.top_dir:
         if not self.design:
             xTools.say_it("-Error. No design name specified")
             return 1
         self.top_dir = os.path.abspath(self.top_dir)
     else:
         if self.design:
             if os.path.isabs(self.design):
                 xTools.say_it("-Warning. <--design=[single design_name or relative design path for top_dir]> is nicer")
             self.top_dir = os.getcwd()
         else:
             self.top_dir, self.design = os.path.split(os.getcwd())
     self.src_design = xTools.get_abs_path(self.design, self.top_dir)
     if xTools.not_exists(self.top_dir, "Top Source path"):
         return 1
     if xTools.not_exists(self.src_design, "Source Design"):
         return 1
     if self.job_dir:
         self.job_dir = os.path.abspath(self.job_dir)
     else:
         self.job_dir = self.top_dir
     self.dst_design = os.path.join(self.job_dir, self.design, self.tag)
     if xTools.wrap_md(self.dst_design, "Job Working Design Path"):
         return 1
     self.scripts_options["src_design"] = self.src_design
     self.scripts_options["dst_design"] = self.dst_design
     for conf_f in os.listdir(self.scripts_options["src_design"]):
         if conf_f.endswith(".conf"):
             try:
                 shutil.copy(os.path.join(self.src_design,conf_f),os.path.join(self.job_dir, self.design))
             except:
                 pass
Пример #2
0
 def sanity_check(self):
     if xTools.not_exists(self.top_dir, "top result path"):
         return 1
     # get designs
     self.designs = list()
     if self.design:
         self.designs.append(self.design)
     else:
         for foo in os.listdir(self.top_dir):
             check_folder = os.path.join(self.top_dir, foo, "_scratch")
             if os.path.isdir(check_folder):
                 self.designs.append(foo)
         if not self.designs:
             xTools.say_it("Error. Not found any designs in %s" %
                           self.top_dir)
             return 1
     self.makejdv = _is_a_file(self.makejdv, self.xlib, "MAKEJDV EXE FILE")
     self.package = _is_a_file(self.package, self.xlib, "PACKAGE FILE")
     if not self.makejdv:
         return 1
     if not self.package:
         return 1
     if xTools.wrap_md(self.target_dir, "Target Path"):
         return 1
     self.target_dir = os.path.abspath(self.target_dir)
Пример #3
0
    def __create_ports(self):
        """
        1. sorted all ports get like: A[4],A[3],...,A[0],CLK,DATA[31],DATA[30],...DATA[0],RST
        2. get input and output port list
        """
        def _new_key(raw_key):
            pieces = self.p_port_digital.split(raw_key)
            pieces[1::2] = map(int, pieces[1::2])
            return pieces

        sorted_ports = sorted(self.pad_dict.keys(), key=_new_key, reverse=True)
        for pn in sorted_ports:
            port_content = self.pad_dict.get(pn)
            buffer_type = port_content.get("Buffer Type")
            if buffer_type.endswith("_IN"):
                self.ports_in.append(pn)
            elif buffer_type.endswith("_OUT"):
                self.ports_out.append(pn)
            elif buffer_type.endswith("_BIDI"):
                if self.bidi_as == "in":
                    self.ports_in.append(pn)
                elif self.bidi_as == "out":
                    self.ports_out.append(pn)
                else:
                    xTools.say_it("Warning. Found BIDI port name: %s" % pn)
                    return 1
            else:
                xTools.say_it("Error. Not support Buffer Type: %s" %
                              buffer_type)
                return 1
Пример #4
0
def _is_a_file(file_string, default_path, comments):
    if not file_string:
        xTools.say_it("Error. no value for %s" % comments)
        return
    if os.path.isfile(file_string):
        return os.path.abspath(file_string)
    else:
        file_string = xTools.get_abs_path(file_string, default_path)
        if xTools.not_exists(file_string, comments):
            return
        return file_string
Пример #5
0
 def copy_suite_files(self):
     ldf_dir = os.path.dirname(self.ldf_file)
     self.new_suite = os.path.join(ldf_dir,
                                   os.path.basename(self.base_suite))
     if xTools.remove_dir_without_error(self.new_suite):
         return 1
     try:
         shutil.copytree(self.base_suite, self.new_suite)
     except Exception, e:
         xTools.say_it(e)
         return 1
Пример #6
0
 def get_other_files(self):
     impl_pattern = os.path.join(self.top_dir, self.dsn, "_scratch", "*",
                                 "*.dir")
     impl_folder = glob.glob(impl_pattern)
     if not impl_folder:
         xTools.say_it("Error. Not found implementation folder like %s" %
                       impl_pattern)
         return 1
     self.basic_impl = os.path.splitext(impl_folder[0])[0]
     xTools.say_it("Basic Implementation string: %s" % self.basic_impl, "",
                   self.debug)
     self.pad_file = self.basic_impl + ".pad"
     if xTools.not_exists(self.pad_file, "pad file"):
         return 1
Пример #7
0
def get_svn_dirs_files(svn_path):
    svn_dirs, svn_files = list(), list()
    svn_ls_cmd = "svn ls %s" % svn_path
    sts, text = get_status_output(svn_ls_cmd)
    if sts:
        say_it("- Error. Failed to run %s" % svn_ls_cmd)
        return svn_dirs, svn_files
    p_dir = re.compile("\W$")
    for item in text:
        if p_dir.search(item):
            svn_dirs.append(p_dir.sub("", item))
        else:
            svn_files.append(item)
    return svn_dirs, svn_files
Пример #8
0
def get_bin_data(zipped_ports, raw_lst, is_bin, is_input):
    print locals()
    bin_data = list()
    for (port_name, width) in zipped_ports:
        raw_data = raw_lst.get(port_name)
        if not raw_data:
            xTools.say_it("Error. Please check Port Name: %s" % port_name)
            return 1, bin_data
        raw_bin_data = hex2bin_string(raw_data, is_bin)
        if not is_input:
            print port_name, width, raw_bin_data
            raw_bin_data = re.sub("1", "H", raw_bin_data)
            raw_bin_data = re.sub("[^H]", "L", raw_bin_data)
        bin_data.append(raw_bin_data[-width:])
    return 0, bin_data
Пример #9
0
    def run_check_flow(self):
        # // run check flow always!
        report_path = os.getcwd();
        report = "check_flow.csv"
        check_py = os.path.join(os.path.dirname(__file__),'..','tools','check', "check.py")
        check_py = os.path.abspath(check_py)
        if xTools.not_exists(check_py, "source script file"):
            return 1
        cmd_kwargs = dict()
        cmd_kwargs["top_dir"] = "--top-dir=%s" % self.job_dir
        cmd_kwargs["design"] = "--design=%s" % self.design

        _check_conf = self.scripts_options.get("check_conf")
        if _check_conf:
            cmd_kwargs["conf_file"] = "--conf-file=%s" % _check_conf
        else:
            ### the conf file will be used as as family_device_package.conf
            [self.family2,self.device2,self.package2] = ["","",""]
            if not self.family:
                try:
                    [self.family2,self.device2,self.package2] = self.scripts_options.get("devkit","").split(",")
                except:
                    pass
            if self.family2.strip():
                self.family = self.family2
            if self.device2.strip():
                self.device = self.device2
            if self.package2.strip():
                self.package = self.package2
            _check_conf = self.family.strip()+"_"+self.device.strip()+"_"+self.package.strip()+".conf"
            if(os.path.isfile(os.path.join(self.src_design,_check_conf))):
                cmd_kwargs["conf_file"] ="--conf-file="+ _check_conf.replace(".conf","")
            else:
                #cmd_kwargs["conf_file"] = ""
                pass
        cmd_kwargs["report_path"] = "--report-path=%s" % report_path
        cmd_kwargs["tag"] = "--tag=%s" % self.tag
        cmd_kwargs["report"] = "--report=%s" % report
        cmd_line = r"%s %s " % (sys.executable, check_py)
        for key, value in cmd_kwargs.items():
            cmd_line += " %s " % value
        cmd_line = xTools.win2unix(cmd_line, 0)
        xTools.say_it(" Launching %s" % cmd_line)
        sts, text = xTools.get_status_output(cmd_line)
        xTools.say_it(text)
        return sts
Пример #10
0
 def merge_local_options(self):
     '''
     Get the info/project options from the case directory
     :return:
     '''
     if self.info_file_name:
         t = os.path.join(self.src_design, self.info_file_name)
         if xTools.not_exists(t, "user specified info file"):
             return 1
         info_file = [t]
         len_info_file = 1
     else:
         info_file = glob.glob(os.path.join(self.src_design, "*.info"))
         len_info_file = len(info_file)
         if len_info_file > 1:
             xTools.say_it("-Error. Found %d info file under %s" % (len_info_file, self.src_design))
             return 1
     if not len_info_file:  # read the project file directly
         ice_prj_files = glob.glob(os.path.join(self.src_design, "par", "*.project"))
         if not ice_prj_files:
             ice_prj_files = glob.glob(os.path.join(self.src_design, "synthesis", "*", "*.project"))
         if not ice_prj_files:
             ice_prj_files = glob.glob(os.path.join(self.src_design, "project", "*", "*", "*.project"))
         if xTools.check_file_number(ice_prj_files, "iCEcube2 project file"):
             return 1
         local_options = self.get_ice_project_options(ice_prj_files[0])
         self._merge_options(local_options)
         self.scripts_options["same_ldf_dir"] = os.path.dirname(ice_prj_files[0])
         self.scripts_options["use_ice_prj"] = 1
     else:
         sts, info_dict = xTools.get_conf_options(info_file)
         if sts:
             return 1
         qa_info_dict = info_dict.get("qa")
         if qa_info_dict:
             project_file = qa_info_dict.get("project_file")
         else:
             project_file = ""
         if project_file:
             local_options = self.get_ice_project_options(project_file)
             self.scripts_options["same_ldf_dir"] = os.path.dirname(project_file)
             self.scripts_options["use_ice_prj"] = 1
             self._merge_options(local_options)
         else:
             self.scripts_options["same_ldf_dir"] = os.path.dirname(info_file[0])
             self._merge_options(info_dict)
Пример #11
0
 def run_pre_post_process(self,pre=0):
     '''
     This function will run pre/post process for the cases. the scripts should be passed
     through the command.
     The run path is case result path(job_dir/design)!
     '''
     if pre == 1:
         cmd = self.scripts_options.get("pre_process")
     else:
         cmd = self.scripts_options.get("post_process")
     if cmd.find(".py")!= -1:
         if cmd.find("python") == -1:
             cmd = "%s %s" % (sys.executable, cmd)
         else:
             pass
     xTools.say_it("Launching %s" % cmd)
     sts, text = xTools.get_status_output(cmd)
     xTools.say_it(text)
     return sts
Пример #12
0
 def get_lst_file(self):
     sim_dir = os.path.join(self.top_dir, self.dsn, "_scratch",
                            self.lst_from)
     if xTools.not_exists(sim_dir, "simulation result path"):
         return 1
     self.is_riviera = 0
     self.lst_file = ""
     for foo in os.listdir(sim_dir):
         abs_foo = os.path.join(sim_dir, foo)
         if not self.is_riviera:
             if self.p_sim_log.search(foo):
                 self.is_riviera = xTools.simple_parser(
                     abs_foo, [
                         self.p_riviera,
                     ])
                 if self.is_riviera:
                     self.is_riviera = 1
         if foo.lower().endswith(".lst"):
             self.lst_file = abs_foo
     if not self.lst_file:
         xTools.say_it("Error. Not found lst file in %s" % sim_dir)
         return 1
     xTools.say_it("LST File: %s" % self.lst_file, "", self.debug)
Пример #13
0
 def parse_pad_file(self):
     pad_parser = ParseFilePAD(self.pad_file, self.bidi_as)
     if pad_parser.sts:
         return 1
     self.ports_in, self.ports_out = pad_parser.ports_in, pad_parser.ports_out
     self.pad_dict = pad_parser.pad_dict
     xTools.say_it(self.pad_dict, "PAD dictionary:", self.debug)
     xTools.say_it(self.ports_in, "INPUT ports:", self.debug)
     xTools.say_it(self.ports_out, "OUTPUT ports:", self.debug)
Пример #14
0
 def merge_conf_options(self):
     '''
     get the conf file setting, and merge them with command options
     '''
     _conf = self.scripts_options.get("conf")
     if not _conf:
         _conf = os.path.join(os.path.dirname(sys.argv[0]), "..", "conf")
     if os.path.isdir(_conf):
         pass
     else:
         if xTools.not_exists(_conf, "Default Configuration Path"):
             return 1
     _conf = os.path.abspath(_conf)
     self.scripts_options["conf"] = _conf
     conf_files = glob.glob(os.path.join(_conf, "*.ini"))
     if not conf_files:
         xTools.say_it("-Error. Not found any ini file under %s" % _conf)
         return 1
     sts, conf_options = xTools.get_conf_options(conf_files)
     if sts:
         return 1
     #if conf_options.get("ice",""):
     #    conf_options["icecube_path"] = conf_options.get("ice","")
     self._merge_options(conf_options)
Пример #15
0
    def process(self):
        xTools.say_it("--Start Generating Download files...")
        self.run_option_parser()
        if self.sanity_check():
            return 1

        for i, design in enumerate(self.designs):
            xTools.say_it("  <%03d> Design:%s" % (i, design))
            self.dsn = design
            self.run_a_design()
        xTools.say_it("--Successfully generating the download files.")
Пример #16
0
    def run_batch_file(self):
        testrun_path = os.path.join(self.design, "_scratch_cmd")
        if xTools.wrap_md(testrun_path, "TestRun Path"):
            return 1
        _recov = xTools.ChangeDir(testrun_path)
        squish_map_files, squish_conf_files = get_squish_file(
            os.path.join(self.design, "testdata"))
        if len(squish_map_files) != 1:
            xTools.say_it("Error. Found map files: %s" % squish_map_files)
            return 1
        if len(squish_conf_files) != 1:
            xTools.say_it("Error. Found conf files: %s" % squish_conf_files)
            return 1

        batch_kwargs = {
            "squishserver":
            self.squish_server,
            "squishrunner":
            self.squish_runner,
            "path_to_aut":
            os.path.join(self.diamond, "bin", self.nt_lin),
            "testcase":
            self.design,
            "reportgen":
            os.path.abspath("report_%s.xml" % time.strftime("%m%d%H%M")),
            "objectmap":
            squish_map_files[0],
            "language":
            get_focus(squish_conf_files[0], re.compile("LANGUAGE=(\w+)",
                                                       re.I)),
            "wrapper":
            get_focus(squish_conf_files[0], re.compile("WRAPPERS=(\w+)",
                                                       re.I)),
            # ------------
        }

        if self.on_win:
            batch_kwargs["set_path"] = r'set PATH=%%PATH%%;%s;%s\bin' % (
                os.path.join(self.diamond, "bin", self.nt_lin), self.squish)
            batch_kwargs[
                "run_server"] = r'start "Squishserver Window" /B "%s" --verbose' % self.squish_server
            batch_kwargs["sleep"] = "%s 5" % os.path.join(
                self.xlib, "sleep.exe")
            batch_kwargs["name_of_aut"] = "pnmain.exe"
        else:
            batch_kwargs["set_path"] = r'set PATH=$PATH:%s:%s/bin' % (
                os.path.join(self.diamond, "bin", self.nt_lin), self.squish)
            batch_kwargs["run_server"] = "%s &" % self.squish_server
            batch_kwargs["sleep"] = "sleep 5"
            batch_kwargs["name_of_aut"] = "diamond"

        batch_file = "run_squish.bat"
        xTools.write_file("run_squish.bat", RUN_SQUISH % batch_kwargs)
        if self.on_win:
            sts, txt = xTools.get_status_output(batch_file)
        else:
            sts, txt = xTools.get_status_output("sh %s" % batch_file)
        xTools.say_it("Status: %s" % sts)
        xTools.say_it(txt, "Detail:")
        xTools.write_file("runtime_console.log", txt)
        check_sts = get_final_status(txt)
        _recov.comeback()
        return check_sts
Пример #17
0
def export_file_from_svn(svn_url):
    export_cmd = "svn export %s" % svn_url
    sts, text = get_status_output(export_cmd)
    if sts:
        say_it(text)
        return 1
Пример #18
0
    def run_option_parser(self):
        _cwd = os.getcwd()
        _makejdv = "makejdv.exe"
        _lst_list = ("sim_rtl", "sim_map_vlg", "sim_par_vlg", "sim_map_vhd",
                     "sim_par_vhd")
        _bidi_as_list = ("in", "out")
        parser = optparse.OptionParser()
        parser.add_option("--debug",
                          action="store_true",
                          help="print debug message")
        parser.add_option("--top-dir",
                          default=_cwd,
                          help="specify top results path, default is %s" %
                          _cwd)
        parser.add_option(
            "--design",
            help=
            "specify design name, if not specified, all folders under $top_dir "
            "will be treated as a design name")
        parser.add_option("--makejdv",
                          default=_makejdv,
                          help="specify makejdv.exe file, "
                          "default is %s, default dirname is %s" %
                          (_makejdv, self.xlib))
        parser.add_option("--package",
                          help="specify package file, default dirname is %s" %
                          self.xlib)
        parser.add_option(
            "--target-dir",
            default=_cwd,
            help="specify target path for download test, default is %s" % _cwd)
        parser.add_option("--verbose",
                          action="store_true",
                          help="copy more files to target path")
        parser.add_option("--step",
                          type="int",
                          help="specify lst line window width")
        parser.add_option("--lineno",
                          type="int",
                          help="specify the maximum data number in jdv file")
        parser.add_option("--lst-from",
                          type="choice",
                          default=_lst_list[0],
                          choices=_lst_list,
                          help="specify lst file type. default is %s" %
                          _lst_list[0])
        parser.add_option("--bidi-as",
                          type="choice",
                          choices=_bidi_as_list,
                          help="treat bidi port as %s" %
                          "/".join(_bidi_as_list))
        opts, args = parser.parse_args()

        self.debug = opts.debug
        self.top_dir = opts.top_dir
        self.design = opts.design
        self.makejdv = opts.makejdv
        self.package = opts.package
        self.target_dir = opts.target_dir
        self.verbose = opts.verbose
        self.step = opts.step
        self.lineno = opts.lineno
        self.lst_from = opts.lst_from
        self.bidi_as = opts.bidi_as
        xTools.say_it(eval(str(opts)), "Raw Options:", self.debug)
Пример #19
0
 def process(self):
     xTools.say_it("---- Start running Squish test case ...")
     sts = self._process()
     xTools.say_it("---- End of running Squish test case ...")
     return sts