【Python】设备重启测试

#!/usr/bin/python
# -*- coding: UTF-8 -*-

'''
==============================================================================================
Usage:
    This script performs task that pressure test for automatic restart of equipment.

    python RebootTest.py 
    Examples:
    python RebootTest.py
==============================================================================================
'''

import os
import time



def find_device():
    # os.system('adb kill-server')
    # os.system('adb start-server')
    # os.system('adb root') 
    # os.system('adb remount') 
    print("adb devices")
    os.system('adb devices')

def reboot():
    os.system('adb reboot')

def screen_downup():
    os.system('adb shell input keyevent 26')

def power_downup():
    os.system('adb shell sendevent /dev/input/event0 1 116 1')
    os.system('adb shell sendevent /dev/input/event0 0 0 0')        
    os.system('adb shell sendevent /dev/input/event0 1 116 0')
    os.system('adb shell sendevent /dev/input/event0 0 0 0')

def get_log(name,count):
    os.system('adb logcat -t 50000 > '+name+count+'.log')


#重启
for i in range(1,5):
    find_device
    screen_downup()
    print("screen_down")
    time.sleep(5)
    screen_downup()
    print("screen_up")
    time.sleep(5)
    print("power_down")
    power_downup()
    time.sleep(5)
    print("power_up")
    power_downup()
    count=str(i)
    get_log(name="reboot",count=count)
    print("auto_reboot loop again")
    reboot()
    print("wait auto_reboot 60s")
    time.sleep(60)
print("auto_reboot finish\n")

猜你喜欢

转载自www.cnblogs.com/wucaiyun1/p/11018224.html