python編寫一個壓測重啟的測試程式
阿新 • • 發佈:2021-03-31
文章目錄
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