def playback(self, videoInfo=''): print('videoInfo', videoInfo) if not videoInfo: ... else: self.check.videoName = videoInfo['name'] self.videoTagDict = [ { videoInfo['url']: videoInfo['name'] }, ] print('videoTagDict', self.videoTagDict) for i in self.videoTagDict: for link, videoName in i.items(): self.check.videoPath = videoName self.check.videoType = self.playtype print('link', self.playerActivity.format(link)) adb.check_output(self.playerActivity.format(link)) time.sleep(15) print('检测播放状态') # Todo 检测播放状态 # playbackTime = 1 # while self.check.checkHWDecodePlayback() or self.check.checkSWDecodePlayback(): # time.sleep(1) # playbackTime += 1 # if playbackTime >= 10: # break # adb.check_output('input keyevent HOME') # writeResultTXT(self.check.getvideoName(), self.check.videoType, self.check.decodeType, self.check.error) adb.check_output('am force-stop ' + self.package)
def getMemInfo(self): ''' 获取meminfo相关信息 并写入/result/memInfo.txt :return: ''' while True: with open(self.eatMemInfo, 'a') as f: fcntl.flock(f.fileno(), fcntl.LOCK_EX) mem = adb.check_output(self.dump_meminfo_command).strip() if not mem: print('No mem') continue f.write('Dump meminfo:\n') f.write(mem) f.write('\n') f.write('Cat meminfo:\n') f.write(adb.check_output(self.cat_meminfo_command).strip()) f.write("\n") f.write('Cat pagetrace:\n') f.write(adb.check_output(self.cat_pagetrace_command)) f.write("\n") f.write('Cat slabinfo:\n') f.write(adb.check_output(self.cat_slab_command)) f.write("\n") sleep(3)
def reset_logcat(self): self.lock.acquire() adb.check_logcat('reconnect') self.lock.release() while not adb.check_devices(): sleep(1) adb.check_output('logcat -c')
def __init__(self): self.videoTagDict = [{'url': 'name'}] self.check = PlayStatusCheck() self.playerActivity = '' self.videoInfo = [] self.playtype = '' self.package = '' adb.check_output('input keyevent HOME')
def pull(self): print('正在pull截图 -> AATS_FW/result/screenCap/') capList = adb.check_output('ls -l /data/screenCap').split('\n')[:-1] for i in capList[1:]: pull = adb.check_logcat( 'pull /data/screenCap/{} {}/result/screenCap/'.format( i.split(' ')[-1], self.rootPath)) pull.communicate() adb.check_output("rm /data/screenCap/*")
def pushRecoverySh(self): ''' 检测待测产品中是否存在 recovery.sh :return: ''' result = adb.check_logcat('shell ls %s' % adb.addQuotes(self.testSh)) if 'No such file or directory' in ''.join(result.stderr.readlines()): print('不存在测试脚本,创建中') adb.root() adb.check_logcat('push ' + self.rootPath + '/scriptPython/sh/recovery.sh /data/') adb.check_output('chmod a+x /data/recovery.sh')
def openCheckSum(self): adb.check_output(adb.addQuotes("chmod 777 /data/local/tmp")) adb.check_output(adb.addQuotes("setenforce 0")) adb.check_output( adb.addQuotes("echo 0 1 > /sys/class/vdec/frame_check")) adb.check_output( adb.addQuotes( "echo 0x30 > /sys/module/decoder_common/parameters/fc_debug")) adb.check_output( adb.addQuotes( "echo 1 > /sys/module/decoder_common/parameters/checksum_enable" ))
def installEater(self): ''' 检测待测产品中是否存在 recovery.sh :return: ''' if 'com.amazon.stress' in adb.check_output('ls /data/app'): return adb.check_logcat('install ' + self.rootPath + '/scriptPython/apk/PFXStress.apk') while True: if 'com.amazon.stress' in adb.check_output('ls /data/app'): print('安装成功') break
def checkTextFile(self): ''' 检测待测产品中是否存在 测试文件 :return: ''' result = adb.check_logcat('shell ls %s' % adb.addQuotes(self.testFile)) if 'No such file or directory' in ''.join(result.stderr.readlines()): print('不存在测试文件,创建中') ser.write('su') adb.root() adb.check_output('touch %s' % adb.addQuotes(self.testFile)) return True else: return False
def playback(self, videoInfo='', random_seek='', yuvOpen=False, frameDrop=False): print('开始播放') # 检测是否有弹窗 if 'name' not in videoInfo: videoList = self.videoInfo else: self.check.videoName = videoInfo['name'] videoList = [ videoInfo['url'], ] adb.check_output('am force-stop %s' % self.playerActivity) time.sleep(2) adb.check_logcat('logcat -c') adb.check_output('setprop vendor.sys.videoplayer.debug true') if yuvOpen: print('打开checksum') self.yuv.active = True self.yuv.openCheckSum() if frameDrop: print('打开framedrop check') self.dropCheck.active = True self.dropCheck.openOMXLog() if random_seek: print('开启随机seek') adb.check_output('setprop vendor.sys.vprandomseek.enable true') for video in videoList: self.check.videoPath = video.strip() self.check.videoType = 'LocalPlayback' video = video.replace('(', '\(').replace(')', '\)').strip() print('Playing : %s' % video) info = adb.check_output( 'am start -n ' + self.playerActivity + ' -d ' + adb.addQuotes('file:/storage/' + self.uuid + self.uDiskVideoPath + video) + random_seek) print(info) # Todo 待加入更多的异常判断 if 'error' in info: print('异常!无法播放') self.check.error = 'Error' log.writeResultTXT(self.check.getvideoName(), self.check.videoType, self.check.decodeType, self.check.error) continue time.sleep(1) self.check.error = 'OK' self.check.getLogcat(self.yuv.active, self.dropCheck.active) log.cleanStatus() time.sleep(1) adb.check_output('am force-stop %s' % self.playerActivity)
def getRatioList(self): resList = adb.check_output(self.getRatioListCommand) for i in resList.split('\n'): if '*' in i: self.bestResultion = i.replace('*', '').strip() if i.replace( '*', '').strip() else '1080p60hz' return resList.replace('*', '').split('\n')[:-1]
def __init__(self): self.rootPath = os.path.abspath(os.path.dirname(__file__)) self.rootPath = self.rootPath[:self.rootPath.find('AATS_FW') + 7] print(self.rootPath) self.installEater() self.dump_meminfo_command = 'dumpsys -t 60 meminfo' self.cat_meminfo_command = 'cat /proc/meminfo ' self.cat_pagetrace_command = 'cat /proc/pagetrace' self.cat_slab_command = 'cat /proc/slabinfo' self.eatSh = '/data/eater.sh' adb.check_logcat('push ' + self.rootPath + '/scriptPython/sh/eater.sh /data/') adb.check_output('chmod a+x /data/eater.sh') self.eatMemInfo = self.rootPath + '/result/eatMemInfo.log' self.launcher, self.stress, self.count = '', '', 0 self.targetProcess = 'com.bestv.ott.baseservices'
def permission_check(self): print('正在检测访问权限') adb.check_output('am start -n ' + self.playerActivity) try: d(text='允许').click() except JsonRPCError as e: ... except OSError as e: ... try: d(text='Allow').click() except JsonRPCError as e: ... except OSError as e: ... adb.home() adb.check_output('am force-stop ' + self.playerActivity)
def switchRation(self): for i in self.radioList: print('Switch -> ', i) self.times += 1 for j in self.setRatioCommand: adb.run(adb.addQuotes(j.format(i))) sleep(4) current = adb.check_output(self.getRatioCommand) print("Current radio: ", adb.check_output(self.getRatioCommand)) screen.capture(i + str(self.times)) if i not in current: print('切换失败') self.errorCount += 1 self.result = 'Fail' adb.check_output( adb.addQuotes('echo {} > /sys/class/display/mode'.format( self.bestResultion)))
def check_display(self): result = adb.check_output(self.display_check) # print('result:', result) if result.strip() == '0': print('当前通道有显示') else: self.result = 'Fail' print('当前通道无信号')
def getVideoList(self): # 尝试获取目标测试目录 try: videoList = adb.check_output('ls /storage/' + self.uuid + self.uDiskVideoPath + ' |grep \\\\.') except CalledProcessError as e: print('!未找到U盘,请确认后重试!') if videoList: return videoList
def getCpuInfo(self): while True: with open(self.rootPath + '/result/cpuInfo.log', 'a') as f: fcntl.flock(f.fileno(), fcntl.LOCK_EX) self.all_count += 1 topInfo = adb.check_output(adb.addQuotes('top -n 1 -m 5')) if topInfo: f.write('Top info:\n') f.write(topInfo) f.write('\n') f.write('current_freq: ') f.write(adb.check_output(self.cur_freq).strip()) f.write('\n') f.write('max_freq: ') f.write(adb.check_output(self.max_freq).strip()) f.write('\n') f.write('min_freq: ') f.write(adb.check_output(self.min_freq).strip()) f.write('\n') f.write('cpu_online: ') f.write(adb.check_output(self.cpu_online).strip()) f.write('\n') f.write('cpu_temperature: ') f.write(adb.check_output(self.cpu_temperature).strip()) f.write('\n') f.write('-' * 20 + '\n') sleep(3) else: self.error_count += 1
def __switch_hdmi3(self): print('正在切换播放场景Hdmi3') switch = adb.check_output(self.hdmi3) if 'unable to resolve Intent' in switch: print('无该通道') self.result = 'Fail' return checkPoint = self.check_status('Hdmi3') if 'Hdmi3' == checkPoint: sleep(4) self.check_display() sleep(self.play_time) else: self.result = 'Fail'
def switch(self): print('正在切换播放场景AV') switch = adb.check_output(self.avin) if 'unable to resolve Intent' in switch: print('无该通道') self.result = 'Fail' return checkPoint = self.check_status('AV1') if 'AV1' == checkPoint: sleep(4) self.check_display() sleep(self.play_time) else: self.result = 'Fail'
def __init__(self): rootPath = os.path.abspath(os.path.dirname(__file__)) self.rootPath = rootPath[:rootPath.find('AATS_FW') + 7] self.cur_freq = 'cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq' self.max_freq = 'cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq' self.min_freq = 'cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq' self.cpu_online = 'cat /sys/devices/system/cpu/online' self.cpu_temperature = 'cat /sys/class/thermal/thermal_zone0/temp' self.temperature_control = adb.check_output( adb.addQuotes(self.cpu_temperature.replace('temp', 'mode'))) self.error_count = 0 self.all_count = 0 if os.path.exists(self.rootPath + '/result/cpuInfo.log'): os.remove(self.rootPath + '/result/cpuInfo.log')
def __init__(self, uDiskVideoPath='/Autotest/decoder_res/'): # 起播命令 self.playerActivity = 'com.droidlogic.videoplayer/.VideoPlayer' # 起播目录 self.uDiskVideoPath = uDiskVideoPath print(self.uDiskVideoPath) self.check = check # u盘名字 self.uuid = self.getUUIDInfo().strip() if not self.uuid: print('未找到u盘') exit() # 目录下的文件列表 list try: self.videoInfo = self.getVideoList().split('\n')[:-1] except AttributeError as e: print('未找到制定目录,请确认后重试') print(e) exit() adb.check_output('input keyevent HOME') # 创建YUV self.yuv = YUV() # 创建dropcheck self.dropCheck = FrameDropCheck()
def getUUIDInfo(self): # 获取u盘uuid adb.root() UUIDInfo = adb.check_output( "ls /storage/ |awk '{print $1}' |head -n 1") return UUIDInfo
def openOMXLog(self): adb.check_output(adb.addQuotes("setprop media.omx.log_levels 255")) adb.check_output(adb.addQuotes("setprop vendor.media.omx.log_levels 255"))
def catchFpsInfo(self): self.dropList = [] while True: info = adb.check_output(self.fps_info_for_IPTV_P_command) self.dropList.append(info) sleep(1)
def run_recovery(self): ''' 执行脚本 :return: ''' adb.check_output('sh %s' % adb.addQuotes(self.testSh))
def getYUVResult(self): resultInfo = adb.check_output(self.getCheckSumCommand) return resultInfo[:-2]