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 get_crash_data(self): ''' get anr info and tombstones info :return: ''' adb.check_logcat('pull /data/anr/ {}/result/anr/'.format(self.rootPath)) adb.check_logcat('pull /data/tombstones/ {}/result/tombstones/'.format(self.rootPath))
def __init__(self): self.lock = threading.Lock() self.play_time = 10 self.status_check = "logcat -s DroidLogicTvInputService " self.display_check = "cat /sys/class/video/disable_video" self.result = 'Pass' adb.home() adb.check_logcat("logcat -c")
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 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 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 __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 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 check_status(self, channel): # 从logcat 获取当前通道信息 server = 'register Input:com.droidlogic.tvinput/.services.' logcat = adb.check_logcat(self.status_check) with logcat: for line in logcat.stdout: # print(line) if server + channel in line: print('当前在{}通道'.format(channel)) logcat.terminate() sleep(2) self.reset_logcat() return channel
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 catchLogcat(self): logcat = adb.check_logcat( "logcat -s {} |grep -v 'drm: codec_get_freed_handle' > {}/result/omxLogcat.log".format(self.TAG, self.rootPath)) return logcat