1. 程式人生 > 其它 >python編寫一個壓測重啟的測試程式

python編寫一個壓測重啟的測試程式

文章目錄

1、python指令碼

import time
import subprocess

def test_reboot(testcount):
    print("Start to test reboot.")
    count = 0

    while True:
        output = subprocess.getstatusoutput("adb wait-for-device")
        output = subprocess.getstatusoutput
("adb shell getprop") #sys.boot_completed if "[sys.boot_completed]: [1]" in str(output[1]): count = count + 1 if count > testcount: break output = subprocess.getstatusoutput("adb reboot") print(
"\tThe number of restart : %s, Total spend time : %ss" % (count,int(time.time() - a_time))) else: time.sleep(0.2) if __name__ == '__main__': a_time = time.time() test_reboot(100000)

2、製作成exe

使用pyinstaller工具製作exe,命令如下:

pyinstaller -F reboot_device_100000.py

3、雙擊exe,執行

在這裡插入圖片描述