Esempio n. 1
0
	def append_workdir(self):
		if self.is_exists():
			index = 1
			workdir = '%s_%s'% (self.work_path, index)
			while os.path.exists(workdir):
				index += 1
				workdir = '%s_%s'% (self.work_path, index)
			delete = True
		else:
			workdir = self.work_path
			delete = False
		SHELL.call("md %s" % workdir)
		return (workdir, delete)
Esempio n. 2
0
	def run(self):
		self._info("===start test: %s" % self)
		
		SHELL.call("md %s" % self.result_path)
		if not self.coveraged_case():
			with open(os.path.join(self.result_path, self.key+'.txt'), 'w') as f:
				f.write("Status: NotSupport. Time: 0")
				self._info("Skip: not support.")
				return 0
				
		with self.tester._mutex:
			(workdir, delete) = self.append_workdir()
		self.install_case(workdir)
		self.prepare_test()
		
		log_file = os.path.join(workdir, self.key+'.txt')
		with open(log_file, 'w') as f:
			with self.tester._mutex:
				os.chdir(workdir)
				try:
					self._info("Start to run at %s" % os.getcwd())
					start = datetime.now()	
					child = SHELL.Popen(self.cmdline, stdout=f)
				except:
					import traceback
					self._error("Failed to start: %s" % self.cmdline)
					traceback.print_exc()
					f.write("\nStatus: Cases error. Time: 0")
					SHELL.call('xcopy /y /q %s %s\\' % (log_file, self.result_path))
					return -1
			status = 'Finish'	
			try:	
				ret = child.wait(self._timeout)
			except subprocess.TimeoutExpired:
				status = 'Timeout'
				child.terminate()
				self._error("Timeout (%s)", self._timeout)
			end = datetime.now()
			if ret != 0:
				status = 'Crash'
			f.write("\nStatus: %s. Time: %s" % (status, (end-start).seconds))
		self.end_work(workdir, log_file)
		SHELL.call('xcopy /y /q %s %s\\' % (log_file, self.result_path))
		if delete:
			os.chdir(os.path.dirname(workdir))
			shutil.rmtree(workdir, True)
		self._info("Finish: Status: %s. Time: %s" % (status, (end-start).seconds))
Esempio n. 3
0
	def init_test(self):
		SHELL.call("md %s" % self._local_driver)
		SHELL.call("md %s" % self._savedir)
		UT.xcopy(self._driver, self._local_driver)
		SHELL.call("xcopy /y/q %s\\*.ini %s" % (self._driver, self._savedir))
		os.environ['path'] = "%s;%s" % (self._local_driver, os.environ['path'])#往环境变量path里添加本地driver的路径
		tmp = self._chip.split('_')
		os.environ['HW_CONFIG'] = tmp[-1].replace('pid', '')
		os.environ['VIV_VX_ENABLE_PRINT_TARGET'] = str(1)#str(1)将数字1转换成字符串1
		
		with open("\\\\192.168.33.105\\data\\test_envs\\hw_configs\\latest.txt", 'r') as f:
			latest = f.readline().strip()
		env_file = os.path.join("\\\\192.168.33.105\\data\\test_envs\\hw_configs", latest, tmp[-1].replace('pid', '')+'.sh')
		if os.path.exists(env_file):#根据env_file设置环境变量
			with open(env_file, 'r') as f:
				lines = f.readlines()
			for line in lines:
				tmp = line.strip().split()
				keys = tmp[1].split('=')
				os.environ[keys[0]] = keys[1]
Esempio n. 4
0
    def __init__(self, path, name, **kargs):
        super(NN_FULL_RLT, self).__init__(path, name)
        self.info['total'] = None
        self.info['total_same'] = None
        self.info['total_acceptable_diff'] = None
        self.info['total_veto_diff'] = None
        self.info['same_ratio'] = None

        log_file = os.path.join(path, name + '.txt')
        if not os.path.exists(log_file):
            return
        (status, self.info['Time']) = self.get_status(log_file)
        if status != 'Finish':
            self.info['Status'] = status
            return

        chip = kargs.get('chip', 'unified')
        if not os.path.exists(path):
            return
        script = os.path.join(path, 'check_result.py')
        if not os.path.exists(script):
            return
        rlog = os.path.join(path, 'nn_result_dump_0.txt')
        if not os.path.exists(rlog):
            tmp = glob.glob(os.path.join(path, 'output*.txt'))
            if tmp:
                rlog = tmp[0]
        print(rlog)
        if not os.path.exists(rlog):
            return
        sqa = os.path.join(path, 'sqa.ini')
        if not os.path.join(sqa):
            return
        golden = os.path.join(path, 'golden', chip)
        if not os.path.exists(golden):
            golden = os.path.join(path, 'golden', 'cmodel')
        if not os.path.exists(golden):
            golden = os.path.join(path, 'golden', 'unified')
        glog = os.path.join(golden, 'nn_result_dump.txt')
        if not os.path.exists(glog):
            tmp = glob.glob(os.path.join(golden, 'output*'))
            if tmp:
                glog = tmp[0]
        if not os.path.exists(glog):
            self.info['Status'] = 'Golden Miss'
            return

        print('check full result: %s' % name)
        try:
            if path.find('full_network_coverage_1.0') != -1:
                SHELL.call(
                    'python %s %s %s --sqa-ini %s --%s --save-dir %s' %
                    (script, rlog, glog, sqa, name_to_dtype(name), path))
            else:
                SHELL.call('python %s %s %s --sqa-ini %s --save-dir %s' %
                           (script, rlog, glog, sqa, path))
        except:
            self.info['Status'] = 'Result check fail'
            return

        rlt_file = os.path.join(path, 'compared_result.txt')
        if not os.path.exists(rlt_file):
            self.info['Status'] = 'Result check fail'
            return

        f = open(rlt_file, 'r')
        lines = f.readlines()
        f.close()

        for line in lines:
            keys = line.split(':')
            if len(keys) == 2:
                if keys[0].strip() == 'result':
                    self.info['Status'] = keys[1].strip()
                    continue
                self.info[keys[0].strip()] = keys[1].strip()
Esempio n. 5
0
	def is_exists(self):
		try:
			SHELL.check_call("tasklist /fo csv | find /i \"%s.exe\"" % self.bin)
		except:
			return False	
		return True
Esempio n. 6
0
	def prepare_test(self):
		SHELL.call("xcopy /y/q %s\\*.ini %s\\" % (self.tester._local_driver, self.result_path))
		SHELL.call("xcopy /y/q %s\\case_info.ini %s\\" % (self.case_path, self.result_path))
		self.record_case_info()
		self.record_environment()
Esempio n. 7
0
	def install_case(self, dst):
		SHELL.call("xcopy /y/q %s\\%s.exe %s\\" % (self.case_path, self._bin, dst))
		SHELL.call("xcopy /y/q/s %s\\* %s\\" % (self.tester._local_driver, dst))
		self._info("Finish install cases")
Esempio n. 8
0
	def prepare_test(self):
		with self.tester._cfg_mutex:
			if not os.path.exists(os.path.join(self.result_path, "cfg.ini")):
				SHELL.call("xcopy /y/q %s\\*.ini %s\\" % (self.tester._local_driver, self.result_path))
				SHELL.call("xcopy /y/q %s\\case_info.ini %s" % (os.path.join(CASE_HOME, self._category, self._name), self.result_path))
				self.record_environment()
Esempio n. 9
0
	def end_work(self, workdir, log_file):
		SHELL.call('xcopy /y /q %s\\nn_result_dump_0.txt %s\\' % (workdir, self.result_path))
		SHELL.call('xcopy /y /q %s\\output*.txt %s\\' % (workdir, self.result_path))
Esempio n. 10
0
	def copy_cfg_files(self):
		SHELL.call('xcopy /y %s\\*.ini %s\\' % (self.tester._local_driver, self.result_path))
		SHELL.call('xcopy /y %s\\golden.txt %s\\' % (self.case_path, self.result_path))
		SHELL.call('xcopy /y %s\\*.ini %s\\' % (self.case_path, self.result_path))
		SHELL.call('xcopy /y %s\\check_result.py %s\\' % (self.case_path, self.result_path))
		SHELL.call('xcopy /s/y/i %s\\golden\\* %s\\golden\\' % (self.case_path, self.result_path))
Esempio n. 11
0
	def install_case(self, dst):
		UT.incr_copy(self.case_path, dst)
		SHELL.call('xcopy /y %s\\cl_viv_vx_ext.h %s\\'%(self.tester._local_driver, dst))
		self._info("Finish install cases")