• 【Python】设备重启测试


    ①添加读取键盘输入功能,方便测试者选择压测次数!
    Python提供了 input() 内置函数从标准输入读入一行文本,默认的标准输入是键盘。
    input 可以接收一个Python表达式作为输入,并将运算结果返回。
    例:

    #!/usr/bin/python3
    str = input("请输入:");
    print ("你输入的内容是: ", str)
    

    这会产生如下对应的结果:

    请输入:ABCD
    你输入的内容是:  ABCD
    
    #!/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
    
    rebootCount = int(input("请输入重启次数:"));
    print ("你输入的次数是: ", rebootCount)
    
    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(0,rebootCount):
    	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
    ")
    
  • 相关阅读:
    DRF中的序列化器
    Django REST framework的分页
    DRF的解析器和渲染器
    DRF 权限 频率
    Django ContentType组件
    CORS跨域请求
    RESTful API介绍
    module.exports 和 exports(转)
    vue全选反选demo
    wangEditor大图片上传问题
  • 原文地址:https://www.cnblogs.com/wucaiyun1/p/11018224.html
Copyright © 2020-2023  润新知