def __init__(self, step_id, par_dict, dev_dict1, crt, caseFolderName, all_monitor_thread_dict, stepType, platform): self.step_id = step_id self.dict = par_dict self.dict1 = dev_dict1 self.crt = crt self.caseFolderName = caseFolderName self.stepType = stepType self.platform = platform print "Parameter List: " for key in self.dict: print key , ": " , self.dict[key] print "" self.rt_dict = {} crt_list = list(crt) print "Pass Criterion: " crt_exist = 0 for crt_no in crt_list: if cmp(crt_no.text,'Off'): print crt_no.tag, crt_no.text crt_exist = 1 if crt_exist == 0: print "None" print '' from tools.client import adbAccessor as accessor self.cli = accessor(self.dict1)
def check_file_size_in_dut(dev_dict, path): cli = accessor(dev_dict) cmd = 'du ' + path + ' -sh' stdout, stderr = cli.execute(cmd) file_size = stdout.split()[0] if str(file_size).strip() == '0': return 'fail' else: return 'pass'
def __init__(self, step_id, par_dict, dev_dict, crt, caseFolderName, all_monitor_thread_dict, stepType, platform): self.step_id = step_id self.dict = par_dict self.dict1 = dev_dict self.crt = crt self.caseFolderName = caseFolderName self.stepType = stepType self.platform = platform self.all_monitor_thread_dict = all_monitor_thread_dict print "Parameter List: " for key in self.dict: if key == "VideoCodec": self.videocodec = self.dict[key] elif key == "Resolution": self.resolution = self.dict[key] elif key == "Duration": self.duration = self.dict[key] elif key == "Bitrate": self.bitrate = self.dict[key] elif key == "FPS": self.fps = self.dict[key] print key, ": ", self.dict[key] print "" self.rt_dict = {} crt_list = list(crt) print "Pass Criterion: " crt_exist = 0 for crt_no in crt_list: if cmp(crt_no.text, 'Off'): print crt_no.tag, crt_no.text crt_exist = 1 if crt_exist == 0: print "None" print '' if not self.dict1.get('Connect', ''): raise TestException( "Error: no Connect element found in device's profile, while running" ) if not self.dict1.get('Connect', '') in ['ssh', 'adb']: raise TestException( "Error: the text of Connect element should be ssh or adb in device's profile " ) if not cmp(self.dict1['Connect'], 'ssh'): self.prefix = '' from tools.client import sshAccessor as accessor if not cmp(self.dict1['Connect'], 'adb'): self.prefix = '/system/bin/' from tools.client import adbAccessor as accessor self.cli = accessor(self.dict1) self.Clip_Path = get_clip_path()
def parse_device_profile(self): if self.args.get('device') is None: # if no -d, we'll use the default device profile. self.devcfg = conf.DEFAULT_DEVICE_PATH else: self.devcfg = self.args.get('device') check_device_profile(self.devcfg) xmlparser = XMLParser.XMLParser(self.devcfg) self.dev_dict = xmlparser.ClientParser() self.acc = accessor(self.dev_dict)
def __init__(self, step_id, par_dict, dev_dict, crt, caseFolderName, all_monitor_thread_dict, stepType, platform): self.step_id = step_id self.dict = par_dict self.dict1 = dev_dict self.crt = crt self.caseFolderName = caseFolderName self.stepType = stepType self.platform = platform self.all_monitor_thread_dict = all_monitor_thread_dict print "Parameter List: " for key in self.dict: if key == "VideoCodec": self.videocodec = self.dict[key] elif key == "Resolution": self.resolution = self.dict[key] elif key == "Duration": self.duration = self.dict[key] elif key == "Bitrate": self.bitrate = self.dict[key] elif key == "FPS": self.fps = self.dict[key] print key , ": " , self.dict[key] print "" self.rt_dict = {} crt_list = list(crt) print "Pass Criterion: " crt_exist = 0 for crt_no in crt_list: if cmp(crt_no.text,'Off'): print crt_no.tag, crt_no.text crt_exist = 1 if crt_exist == 0: print "None" print '' if not self.dict1.get('Connect', ''): raise TestException("Error: no Connect element found in device's profile, while running") if not self.dict1.get('Connect', '') in ['ssh', 'adb']: raise TestException("Error: the text of Connect element should be ssh or adb in device's profile ") if not cmp(self.dict1['Connect'], 'ssh'): self.prefix = '' from tools.client import sshAccessor as accessor if not cmp(self.dict1['Connect'], 'adb'): self.prefix = '/system/bin/' from tools.client import adbAccessor as accessor self.cli = accessor(self.dict1) self.Clip_Path = get_clip_path()
def connect_wifi(device_profile): # connect 9L02 xmlparser_2 = XMLParser.XMLParser(device_profile) dev_dict = xmlparser_2.ClientParser() acc = accessor(dev_dict) acc.upload('resource/settings/wpa_supplicant.conf', '/data/misc/wifi/') acc.execute('svc wifi disable') acc.execute('svc wifi enable') time.sleep(60) stdout, sterr = acc.execute('ping ' + IP_Of_Lab + ' -w 5') if stdout.find('bytes from ' + IP_Of_Lab.strip()) != - 1 and stdout.find('seq=0') != -1: return True else: return False
def __init__(self, step_id, par_dict, dev_dict, crt, caseFolderName, all_monitor_thread_dict, stepType, platform): self.step_id = step_id self.par_dict = par_dict self.dev_dict = dev_dict self.crt = crt self.caseFolderName = caseFolderName self.stepType = stepType self.platform = platform self.all_monitor_thread_dict = all_monitor_thread_dict print "Parameter List: " for key in self.par_dict: if key.strip() == 'InputFile': if self.par_dict[key].find('http:') != -1 or self.par_dict[key].find('rtp:') != -1: new_url = self.get_http_url(self.par_dict[key]) print key, ': ', new_url else: print key , ": " , self.par_dict[key] else: print key , ": " , self.par_dict[key] print "" self.rt_dict = {} crt_list = list(crt) print "Pass Criterion: " crt_exist = 0 for crt_no in crt_list: if cmp(crt_no.text,'Off'): print crt_no.tag, crt_no.text crt_exist = 1 if crt_exist == 0: print "None" print '' if not self.dev_dict.get('Connect', ''): raise TestException("Error: no Connect element found in device's profile, while running") if not self.dev_dict.get('Connect', '') in ['ssh', 'adb']: raise TestException("Error: the text of Connect element should be ssh or adb in device's profile ") if not cmp(self.dev_dict['Connect'], 'ssh'): self.prefix = '' from tools.client import sshAccessor as accessor if not cmp(self.dev_dict['Connect'], 'adb'): self.prefix = '/system/bin/' from tools.client import adbAccessor as accessor self.cli = accessor(self.dev_dict) self.Clip_Path = get_clip_path()
def push_busybox(device_profile): xmlparser_2 = XMLParser.XMLParser(device_profile) dev_dict = xmlparser_2.ClientParser() acc = accessor(dev_dict) cmd = "test -f /system/bin/busybox && echo 'File exists' || echo 'File not found'" stdout, stderr = acc.execute(cmd) if stdout.find('File not found') != -1: acc.execute_on_host('root') acc.execute_on_host('remount') acc.upload("./resource/busybox", '/system/') cmd = "test -f /system/bin/busybox && echo 'File exists' || echo 'File not found'" stdout, stderr = acc.execute(cmd) if stdout.find('File not found') != -1: return False else: return True else: return True
def __init__(self, step_id, par_dict, dev_dict, crt, caseFolderName, all_monitor_thread_dict, stepType, platform): self.step_id = step_id self.par_dict = par_dict self.dev_dict = dev_dict self.crt = crt self.caseFolderName = caseFolderName self.stepType = stepType self.all_monitor_thread_dict = all_monitor_thread_dict self.platform = platform print "Parameter List: " for key in self.par_dict: print key , ": " , self.par_dict[key] print "" self.rt_dict = {} crt_list = list(crt) print "Pass Criterion: " crt_exist = 0 for crt_no in crt_list: if cmp(crt_no.text.strip().lower(),'off'): print crt_no.tag, crt_no.text crt_exist = 1 if crt_exist == 0: print "None" print '' if not self.dev_dict.get('Connect', ''): raise TestException("Error: no Connect element found in device's profile, while running") if not self.dev_dict.get('Connect', '') in ['ssh', 'adb']: raise TestException("Error: the text of Connect element should be ssh or adb in device's profile ") if not cmp(self.dev_dict['Connect'], 'ssh'): self.prefix = '' from tools.client import sshAccessor as accessor elif not cmp(self.dev_dict['Connect'], 'adb'): self.prefix = '/system/bin/' from tools.client import adbAccessor as accessor self.cli = accessor(self.dev_dict) self.Clip_Path = get_clip_path()
def assertor(criteria_dict, actual_data_dict, operator_dict, addtional_dict, dev_dict, caseFolderName): if actual_data_dict == "noResult": return 'case not executed' result='pass' for key, actural_data in actual_data_dict.iteritems(): if criteria_dict.has_key(key): value = criteria_dict[key] # for key, value in criteria_dict.iteritems(): if len(key.split(CONCATENATION_STR)) == 2: tag_name = key.split(CONCATENATION_STR)[0] name_error = ' with name ' + key.split(CONCATENATION_STR)[1] + ' ' else: tag_name = key name_error = '' operator=operator_dict.get(key, 'no_value') if operator == 'no_value': raise TestException("Error: no operator value for tag " + str(tag_name) + name_error) # actural_data=actual_data_dict.get(key, 'no_value') # if actural_data == 'no_value': # raise TestException("Error: no actual value for tag " + str(tag_name) + name_error + ", maybe there is something wrong with case profile, or the program.") if actural_data == 'empty_value': raise TestException("Error: we didn't get value for tag " + str(tag_name) + name_error) if actural_data == '': actural_data = "NULL" print "Criteria: " + str(tag_name) + name_error + ": " + str(value) print 'failed on ' + str(tag_name) + name_error + ': ' + str(actural_data) result = 'fail' continue if operator != 'cmp': original_value = value original_actual_value = actural_data value = deal_with_pecentage_symbol(value, 'Error: the text of tag ' + tag_name + name_error + ' should be a number') actural_data = deal_with_pecentage_symbol(actural_data, 'Error: the value we got for tag '+ tag_name + name_error +' is not a number') if operator == '>=': print "Criteria: " + str(tag_name) + name_error + ": " + str(original_value) if actural_data < value: print 'failed on ' + str(tag_name) + name_error+ ':' + str(original_actual_value) + ' >= ' + str(original_value) result = 'fail' else: print "Actual: " + str(tag_name) + name_error+ ": " + str(original_actual_value) if operator =='lt': print "Criteria: " + str(tag_name) + name_error + ": " + str(original_value) if actural_data > value: print 'failed on ' + str(tag_name) + name_error + ':' + str(original_actual_value) + ' lt '+ str(original_value) result = 'fail' else: print "Actual: " + str(tag_name) + name_error + ": " + str(original_actual_value) if operator == '=': print "Criteria: " + str(tag_name) + name_error + ": " + str(original_value) if value != actural_data: print 'failed on ' + str(tag_name) + name_error + ':' + str(original_actual_value) + ' == ' + str(original_value) result = 'fail' else: print "Actual: " + str(tag_name) + name_error + ": " + str(original_actual_value) if operator == 'approx': print "Criteria: " + str(tag_name) + name_error + ": " + str(original_value) dvalue = addtional_dict.get(key, 'no_value') if dvalue == 'no_value': raise TestException("Error: no delta attribute of tag " + str(tag_name) + name_error + "found") dvalue = deal_with_pecentage_symbol(dvalue, 'the value of delta attribute of tag '+ tag_name + name_error + 'should be a number') tv = value - actural_data if abs(tv) > dvalue: print 'failed on ' + str(tag_name) + name_error + ':' + str(original_actual_value) + ' and ' + str(original_value) result = 'fail' else: print "Actual: " + str(tag_name) + name_error + ": " + str(original_actual_value) if operator == '>delta': print "Criteria: " + str(tag_name) + name_error + ": " + str(original_value) dvalue = addtional_dict.get(key, 'no_value') if dvalue == 'no_value': raise TestException("Error: no value attribute of tag " + str(tag_name) + name_error + " found") dvalue = deal_with_pecentage_symbol(dvalue, 'the value of value attribute of tag ' + tag_name + name_error + ' should be a number') tv = value - actural_data if tv > dvalue: print 'failed on ' + str(tag_name) + name_error + ':' + str(original_actual_value) + ' and ' + str(original_value) result = 'fail' else: print "Actual: " + str(tag_name) + name_error + ": " + str(original_actual_value) else: if str(actural_data).strip() == 'MPEG-4Visual' and str(value).strip() == 'MPEG-4': print "Criteria: " + str(tag_name) + name_error + ": " + str(value) print "Actual: " + str(tag_name) + name_error + ": " + str(actural_data) else: if cmp(str(value).strip().lower(), str(actural_data).strip().lower()): print "Criteria: " + str(tag_name) + name_error + ": " + str(value) print 'failed to match ' + str(tag_name).strip() + name_error + ':' + str(actural_data).strip() + " with the value in criteria:" + str(value).strip() result = 'fail' else: print "Criteria: " + str(tag_name) + name_error + ": " + str(value) print "Actual: " + str(tag_name) + name_error + ": " + str(actural_data) if tag_name == "AttribValue": if result == 'fail': from tools.client import adbAccessor as accessor cli = accessor(dev_dict) stdout, stderr = cli.execute("ls /data/1.*") flag1 = stdout.find("/data/") flag2 = flag1 + 15 logname = stdout[flag1:flag2] cli.download(logname, path.result_path + '/' + caseFolderName) return result
clips_eles = url_ele.findall('Clip') if len(clips_eles) == 0: return "No clip need to download" for each_ele in clips_eles: address = each_ele.text if address is None: print inred("Clip value is empty, download canceled.") continue # check if the clip exist, we should use the format in Parameter element, to keep consistent with test module format = root.find('Step').find('Parameter').find('Format').text inputFile = address.split('/')[-1] # check if the clip directory exist cli = accessor(dev_dict) stdout, stderr = cli.execute("test -d " + get_clip_path() + format + "/ && echo 'Directory exists' || echo 'Directory not found'") if str(stdout).strip() == 'Directory not found': cli.execute("mkdir -p " + get_clip_path() + format + '/') # check if clip exist stdout, stderr = cli.execute("test -f " + get_clip_path() + format + '/' + inputFile + " && echo 'File exists' || echo 'File not found'") if str(stdout).strip() == 'File exists': result = check_file_size_in_dut(dev_dict, get_clip_path() + format + '/' + inputFile) if result == 'pass': continue else: cli.execute("rm -rf " + get_clip_path() + format + '/' + inputFile) download_result = 'fail' download_count = 0 while download_result == 'fail':