def main(): try: matrix_file, metrics_file = parse_args() metric_result_dict, metric_target_dict = get_metrics_list(metrics_file) metric_result_dict = get_value_for_metrics_list(matrix_file, metric_result_dict) fill_metrics_file(metrics_file, metric_result_dict, metric_target_dict) except TestException, e: print inred(e.value)
def parse_args(): usage = "usage: python %prog [options]" parser = OptionParser(usage=usage) parser.add_option('-m', '--matrix', dest='matrix', help="matrix output log", default=False) parser.add_option('-l', '--metrics', dest='metrics', help="metrics list", default=False) options, args = parser.parse_args() if (not options.matrix) or (not options.metrics): print inred('Error: you should input -m and -l parameter, the usage is as bellow:') parser.print_help() sys.exit(2) else: return (options.matrix, options.metrics)
def audioDecode(self): for item in self.dict: if self.dict[item] == None: raise TestException("Error: No text in element '" + item + "', please check the case profile.") try: if not cmp(self.dict['Codec'], 'mp3'): pass elif not cmp(self.dict['Codec'], 'acc'): pass else: raise TestException("Error: Invalid text in Codec element in case configuration file.") except KeyError: raise TestException("Error: no Codec element found in Parameter element.") try: input = self.Clip_Path + self.dict['Codec'] + '/' + self.dict['InputFile'] except KeyError: raise TestException("Error: no InputFile element found in Parameter element ") try: output = self.Clip_Path + self.dict['Codec'] + '/' + self.dict['OutputFile'] except KeyError: raise TestException("Error: no OutputFile element found in Parameter element ") try: format = self.dict['Format'] except KeyError: raise TestException("Error: no Format element found in Parameter element ") cmd = "omx_mp3_dec_test " + input + ' ' + output + ' ' + format print "Command:" print cmd print "" self.rt_dict.setdefault('cmd', cmd) #execute in remote device print "Execute Output: " stdout,stderr = self.cli.execute(cmd) if stdout == '': raise TestException("Error: No content in log. You may use a wrong test tool or wrong platform ") outfile = open('log' + str(self.step_id), 'w+') outfile.writelines(stderr) outfile.writelines(stdout) outfile.close() #download output file self.cli.download(self.Clip_Path + self.dict['Codec'] + '/' + self.dict['OutputFile'], path.result_path + '/' + self.casename + '/') #count md5 value res = os.system("./resource/md5sum " + path.result_path + '/' + self.casename + '/' + self.dict['OutputFile'] + " >> md5info") if res == 256: print inred("No wav file generated.") try: md5file = open('md5info') except IOError, e: md5 = ''
def execute(self): #get cam if self.cam == False: print inred("Maybe you forgot to input --cam ") raise TestException("Error: invalid camera component type!") caseRoute_1 = self.cam for item in self.dict: if self.dict[item] == None: raise TestException("Error: No text in element '" + item + "', please check the case profile.") #get type try: if self.dict.get('type') is None: raise TestException( "Error: no text in element 'cam' in case profile.") if not cmp(self.dict['type'], 'Integration'): caseRoute_2 = 'Integration' elif not cmp(self.dict['type'], 'Std_ioctl'): caseRoute_2 = 'Std_ioctl' else: raise TestException( "Error: invalid text in element 'cam' in case profile. The content of 'type' element must be one of 'Integration' and 'Std_ioctl'. " ) except KeyError: raise TestException( "Error: no type element found in Parameter element! ") #get cmdname try: if self.dict.get('cmdname') is None: raise TestException( "Error: no text in element 'cmdname' in case profile.") cmdname = self.dict['cmdname'] except KeyError, e: raise TestException( "Error: no cmdname element found in Parameter element")
def audioDecode(self): for item in self.dict: if self.dict[item] == None: raise TestException("Error: No text in element '" + item + "', please check the case profile.") try: if not cmp(self.dict['Codec'], 'mp3'): pass elif not cmp(self.dict['Codec'], 'acc'): pass else: raise TestException( "Error: Invalid text in Codec element in case configuration file." ) except KeyError: raise TestException( "Error: no Codec element found in Parameter element.") try: input = self.Clip_Path + self.dict['Codec'] + '/' + self.dict[ 'InputFile'] except KeyError: raise TestException( "Error: no InputFile element found in Parameter element ") try: output = self.Clip_Path + self.dict['Codec'] + '/' + self.dict[ 'OutputFile'] except KeyError: raise TestException( "Error: no OutputFile element found in Parameter element ") try: format = self.dict['Format'] except KeyError: raise TestException( "Error: no Format element found in Parameter element ") cmd = "omx_mp3_dec_test " + input + ' ' + output + ' ' + format print "Command:" print cmd print "" self.rt_dict.setdefault('cmd', cmd) #execute in remote device print "Execute Output: " stdout, stderr = self.cli.execute(cmd) if stdout == '': raise TestException( "Error: No content in log. You may use a wrong test tool or wrong platform " ) outfile = open('log' + str(self.step_id), 'w+') outfile.writelines(stderr) outfile.writelines(stdout) outfile.close() #download output file self.cli.download( self.Clip_Path + self.dict['Codec'] + '/' + self.dict['OutputFile'], path.result_path + '/' + self.casename + '/') #count md5 value res = os.system("./resource/md5sum " + path.result_path + '/' + self.casename + '/' + self.dict['OutputFile'] + " >> md5info") if res == 256: print inred("No wav file generated.") try: md5file = open('md5info') except IOError, e: md5 = ''
def execute_on_host(self, cmd): try: mycmd = 'adb -s ' + self.num + cmd except TypeError, e: print inred("Error: Invalid serialNumber in device profile!") sys.exit(2)
def execute(self, cmd): try: mycmd = 'adb -s ' + self.num + ' shell ' + '"' + cmd + '"' except TypeError, e: print inred("Error: Invalid serialNumber in device profile!") sys.exit(2)
"Error: the text of serialNumber element can't be empty in device profile " ) def execute(self, cmd): try: mycmd = 'adb -s ' + self.num + ' shell ' + '"' + cmd + '"' except TypeError, e: print inred("Error: Invalid serialNumber in device profile!") sys.exit(2) print mycmd p = subprocess.Popen(mycmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if p.wait() != 0: print inred('Failed:' + mycmd) sys.exit(2) else: stdout, stderr = p.communicate() return stdout, stderr def execute_on_host(self, cmd): try: mycmd = 'adb -s ' + self.num + cmd except TypeError, e: print inred("Error: Invalid serialNumber in device profile!") sys.exit(2) print mycmd p = subprocess.Popen(mycmd, shell=True, stdout=subprocess.PIPE,