| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068 |
- #!/usr/bin/python
- # _*_ coding: utf-8 _*_
- try:
- from Tkinter import * # python2
- import ttk
- import tkMessageBox
- except Exception as e:
- from tkinter import * # python3
- from tkinter import ttk
- from tkinter import messagebox as tkMessageBox
- import time
- import os
- import threading
- import random
- from requests_offline import requests
- def ask_choice_with_timeout(title, message, timeout=5, default_choice=False):
- # 创建顶层弹窗窗口(Python 2 Tkinter语法)
- import Tkinter as tk
- top = tk.Toplevel()
- top.title(title)
- top.geometry("350x180") # 弹窗大小
- top.resizable(False, False) # 禁止调整大小
-
- # 设置模态窗口(阻塞主窗口操作)
- top.transient(top.master)
- top.grab_set()
-
- # 存储结果(用列表实现可变变量,Python 2中nonlocal仅在3.x支持)
- result = [default_choice]
-
- # 显示提示信息
- msg_label = tk.Label(top, text=message, padx=20, pady=20, font=("Arial", 10))
- msg_label.pack(fill=tk.X)
-
- # 显示倒计时提示
- timeout_text = "{}秒后自动{}...".format(timeout, "确认" if default_choice else "取消")
- timeout_label = tk.Label(top, text=timeout_text, fg="gray", font=("Arial", 9))
- timeout_label.pack()
-
- # 按钮回调函数
- def on_ok():
- result[0] = True
- top.destroy()
-
- def on_cancel():
- result[0] = False
- top.destroy()
-
- # 按钮布局
- btn_frame = tk.Frame(top)
- btn_frame.pack(pady=15)
-
- ok_btn = tk.Button(btn_frame, text="OK", command=on_ok, width=8)
- cancel_btn = tk.Button(btn_frame, text="Cancel", command=on_cancel, width=8)
-
- ok_btn.pack(side=tk.LEFT, padx=10)
- cancel_btn.pack(side=tk.LEFT, padx=10)
-
- # 倒计时线程(Python 2 threading语法)
- def countdown():
- current_timeout = timeout
- while current_timeout > 0:
- current_timeout -= 1
- # 更新倒计时文本
- new_text = "{}秒后自动{}...".format(current_timeout, "确认" if default_choice else "取消")
- print(new_text)
- timeout_label.config(text=new_text)
- top.update() # 刷新界面
- time.sleep(1) # 等待1秒
- top.destroy() # 超时关闭窗口
-
- # 启动守护线程(Python 2兼容)
- t = threading.Thread(target=countdown)
- t.setDaemon(True) # 守护线程,主程序退出时自动结束
- t.start()
-
- # 等待窗口关闭
- top.wait_window()
-
- return result[0]
- def step1_routine(context, *args):
- # bios_version
- context.print1("==SubTest: 检查BIOS版本号 - Titem_1")
- time.sleep(0.1)
- context.print1("-:) sh os-ver.sh bios")
- a = os.popen("sh os-ver.sh bios").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step2_routine(context):
- # bios release date # ec version
- context.print1("==SubTest: 检查EC版本号 - Titem_2")
- context.print1("-:) sh os-ver.sh ec")
- a = os.popen('sh os-ver.sh ec').read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step3_routine(context):
- # CPU type
- context.print1("==SubTest: 检查CPU type - Titem_4")
- context.print1("-:) cat /proc/cpuinfo | grep \"model name\" | awk '{print $5}' | head -1")
- a = os.popen("cat /proc/cpuinfo").read().strip()
- context.print1("output: {}".format(a))
- a = os.popen("cat /proc/cpuinfo | grep \"model name\" | awk '{print $5}' | head -1").read().replace('\n','').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step4_routine(context):
- # memory_version
- context.print1("==SubTest: 检查Memory内存版本号 - Titem_5")
- context.print1("-:) sh mem-ver.sh")
- a = os.popen("sh mem-ver.sh").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step5_routine(context):
- # hdd_version
- context.print1("==SubTest: 检查HDD硬盘版本号 - Titem_6")
- context.print1("-:) sh hdd-ver.sh")
- b = os.popen("sh hdd-ver.sh").read().strip()
- a = os.popen("cat /sys/block/nvme0n1/device/firmware_rev").read().replace('\n', '').replace('\r', '').strip()
- context.print1("output: {}".format(a))
- if len(a) == 0:
- return False, "Error! No Device found! " + a
- else:
- return True, 'PASS-{}'.format(a)
- def step6_routine(context):
- # os_version
- context.print1("==SubTest: 检查OS操作系统版本号 - Titem_7")
- context.print1("-:) lsb_release -rs")
- string = "os"
- a = os.popen("lsb_release -rs").read().strip()
- context.print1("output: {}".format(a))
- if a == "22.04":
- return True, 'PASS-{}'.format(a)
- else:
- return False, "Error! No Device found! " + a
- def step7_routine(context):
- context.print1("==SubTest: RTC电池 - Titem_8")
- context.print1("-:) sh os-ver.sh RTCBATTERY")
- a = os.popen("sh os-ver.sh RTCBATTERY").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if 2900 <= a_int <= 4000:
- return True, a_int
- else:
- return False, "FAIL " + a
- def step8_routine(context):
- # usb function
- context.print1("==SubTest: USB基本功能测试 - Titem_9")
- context.print1("-:) lsblk -d -o TRAN,NAME,SIZE")
- b = os.popen("lsblk -d -o TRAN,NAME,SIZE").read().replace('\n', '').replace('\r', '').strip()
- context.print1("output: {}".format(b))
- b = os.popen("lsusb").read().replace('\n', '').replace('\r', '').strip()
- context.print1("output: {}".format(b))
- context.print1("-:) lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l")
- a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 5:
- return True, a
- else:
- return False, "FAIL " + a
- def step9_routine(context):
- # network speed cli
- context.print1("==SubTest: 检查网络在线速度测试 - Titem_10")
- context.print1("-:) ip link show | grep -c 'BROADCAST,MULTICAST,UP,LOWER_UP'")
- c = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
- context.print1("output: {}".format(c))
- try:
- c_int = int(c)
- except ValueError:
- return False, "Invalid output c: {}".format(c)
- if c_int != 1:
- return False, "FAIL " + "Error! No Device found!"
- if(context.device_info['offline_test']):
- context.print1("-:) ping -c 10 www.baidu.com | grep -E 'packet loss' | awk -F'[,%]' '{print $2}' | tr -d ' ' | tr -d 'received'")
- b = os.popen("ping -c 10 www.baidu.com")
- context.print1("output: {}".format(b))
- b = os.popen("ping -c 10 www.baidu.com | grep -E 'packet loss' | awk -F'[,%]' '{print $2}' | tr -d ' ' | tr -d 'received'").read().replace('\n', '').replace('\r', '').strip()
-
- else:
- context.print1("-:) ping -c 10 10.60.64.87 | grep -E 'packet loss' | awk -F'[,%]' '{print $2}' | tr -d ' ' | tr -d 'received'")
- b = os.popen("ping -c 10 10.60.64.87")
- context.print1("output: {}".format(b))
- b = os.popen("ping -c 10 10.60.64.87 | grep -E 'packet loss' | awk -F'[,%]' '{print $2}' | tr -d ' ' | tr -d 'received'").read().replace('\n', '').replace('\r', '').strip()
- try:
- b_int = int(b)
- except ValueError:
- return False, "Invalid output b: {}".format(b)
- if b_int == 10:
- return True, b
- else:
- return False, "FAIL " + "Error! No Device found! {}".format(b)
- def step10_routine(context):
- return True, 'AAPASS'
- #serialA
-
- context.print1("==SubTest: UartA_Test - Titem_9")
- context.print1("-:) sh pcie.sh")
- a = os.popen("sh pcie.sh").read().strip()
- context.print1("{}".format(a))
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH0")
- time.sleep(1)
- ttyWCH0 = os.popen("sh serialport-test.sh /dev/ttyWCH0").read().strip()
- try:
- a_int = int(ttyWCH0)
- except ValueError:
- return False, "Invalid output ttyWCH0: {}".format(ttyWCH0)
- if a_int == 1:
- context.print1("output ttyWCH0: {}".format(ttyWCH0))
- context.print1("output A: {}".format("A1-2"))
- pass
- else:
- context.print1("output ttyWCH0: {}".format(ttyWCH0))
- context.print1("output A: {}".format("A1-2"))
- return False, "FAIL " + "Error! No Device found! A1-2"
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH1")
- ttyWCH1 = os.popen("sh serialport-test.sh /dev/ttyWCH1").read().strip()
- try:
- a_int = int(ttyWCH1)
- except ValueError:
- return False, "Invalid output ttyWCH1: {}".format(ttyWCH1)
- if a_int == 1:
- context.print1("output ttyWCH1: {}".format(ttyWCH1))
- context.print1("output A: {}".format("A1-6"))
- pass
- else:
- context.print1("output ttyWCH1: {}".format(ttyWCH1))
- context.print1("output A: {}".format("A1-6"))
- return False, "FAIL " + "Error! No Device found! A1-6"
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH2")
- ttyWCH2 = os.popen("sh serialport-test.sh /dev/ttyWCH2").read().strip()
- try:
- a_int = int(ttyWCH2)
- except ValueError:
- return False, "Invalid output ttyWCH2: {}".format(ttyWCH2)
- if a_int == 1:
- context.print1("output ttyWCH2: {}".format(ttyWCH2))
- context.print1("output A: {}".format("A1-1"))
- pass
- else:
- context.print1("output ttyWCH2: {}".format(ttyWCH2))
- context.print1("output A: {}".format("A1-1"))
- return False, "FAIL " + "Error! No Device found! A1-1"
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH3")
- ttyWCH3 = os.popen("sh serialport-test.sh /dev/ttyWCH3").read().strip()
- try:
- a_int = int(ttyWCH3)
- except ValueError:
- return False, "Invalid output ttyWCH3: {}".format(ttyWCH3)
- if a_int == 1:
- context.print1("output ttyWCH3: {}".format(ttyWCH3))
- context.print1("output A: {}".format("A1-5"))
- pass
- else:
- context.print1("output ttyWCH3: {}".format(ttyWCH3))
- context.print1("output A: {}".format("A1-5"))
- return False, "FAIL " + "Error! No Device found! A1-5"
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH4")
- ttyWCH4 = os.popen("sh serialport-test.sh /dev/ttyWCH4").read().strip()
- try:
- a_int = int(ttyWCH4)
- except ValueError:
- return False, "Invalid output ttyWCH4: {}".format(ttyWCH4)
- if a_int == 1:
- context.print1("output ttyWCH4: {}".format(ttyWCH4))
- context.print1("output A: {}".format("A1-4"))
- pass
- else:
- context.print1("output ttyWCH4: {}".format(ttyWCH4))
- context.print1("output A: {}".format("A1-4"))
- return False, "FAIL " + "Error! No Device found! A1-4"
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH5")
- ttyWCH5 = os.popen("sh serialport-test.sh /dev/ttyWCH5").read().strip()
- try:
- a_int = int(ttyWCH5)
- except ValueError:
- return False, "Invalid output ttyWCH5: {}".format(ttyWCH5)
- if a_int == 1:
- context.print1("output ttyWCH5: {}".format(ttyWCH5))
- context.print1("output A: {}".format("A1-8"))
- pass
- else:
- context.print1("output ttyWCH5: {}".format(ttyWCH5))
- context.print1("output A: {}".format("A1-8"))
- return False, "FAIL " + "Error! No Device found! A1-8"
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH6")
- ttyWCH6 = os.popen("sh serialport-test.sh /dev/ttyWCH6").read().strip()
- try:
- a_int = int(ttyWCH6)
- except ValueError:
- return False, "Invalid output ttyWCH6: {}".format(ttyWCH6)
- if a_int == 1:
- context.print1("output ttyWCH6: {}".format(ttyWCH6))
- context.print1("output A: {}".format("A1-3"))
- pass
- else:
- context.print1("output ttyWCH6: {}".format(ttyWCH6))
- context.print1("output A: {}".format("A1-3"))
- return False, "FAIL " + "Error! No Device found! A1-3"
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH7")
- ttyWCH7 = os.popen("sh serialport-test.sh /dev/ttyWCH7").read().strip()
- try:
- a_int = int(ttyWCH7)
- except ValueError:
- return False, "Invalid output ttyWCH7: {}".format(ttyWCH7)
- if a_int == 1:
- context.print1("output ttyWCH7: {}".format(ttyWCH7))
- context.print1("output A: {}".format("A1-7"))
- pass
- else:
- context.print1("output ttyWCH7: {}".format(ttyWCH7))
- context.print1("output A: {}".format("A1-7"))
- return False, "FAIL " + "Error! No Device found! A1-7"
- return True, "PASS"
- def step11_routine(context):
- return True, 'AAPASS'
- #serialB
- context.print1("==SubTest: UartB_Test - Titem_10")
- a = os.popen("sh pcie.sh").read().strip()
- time.sleep(1)
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH8")
- ttyWCH8 = os.popen("sh serialport-test.sh /dev/ttyWCH8").read().strip()
- try:
- a_int = int(ttyWCH8)
- except ValueError:
- return False, "Invalid output ttyWCH8: {}".format(ttyWCH8)
- if a_int == 1:
- context.print1("output ttyWCH8: {}".format(ttyWCH8))
- context.print1("output A: {}".format("A2-4"))
- pass
- else:
- context.print1("output ttyWCH8: {}".format(ttyWCH8))
- context.print1("output A: {}".format("A2-4"))
- return False, "FAIL " + "Error! No Device found! A2-4"
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH9")
- ttyWCH9 = os.popen("sh serialport-test.sh /dev/ttyWCH9").read().strip()
- try:
- a_int = int(ttyWCH9)
- except ValueError:
- return False, "Invalid output ttyWCH9: {}".format(ttyWCH9)
- if a_int == 1:
- context.print1("output ttyWCH9: {}".format(ttyWCH9))
- context.print1("output A: {}".format("A2-8"))
- pass
- else:
- context.print1("output ttyWCH9: {}".format(ttyWCH9))
- context.print1("output A: {}".format("A2-8"))
- return False, "FAIL " + "Error! No Device found! A2-8"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH10")
- ttyWCH10 = os.popen("sh serialport-test.sh /dev/ttyWCH10").read().strip()
- try:
- a_int = int(ttyWCH10)
- except ValueError:
- return False, "Invalid output ttyWCH10: {}".format(ttyWCH10)
- if a_int == 1:
- context.print1("output ttyWCH10: {}".format(ttyWCH10))
- context.print1("output A: {}".format("A2-3"))
- pass
- else:
- context.print1("output ttyWCH10: {}".format(ttyWCH10))
- context.print1("output A: {}".format("A2-3"))
- return False, "FAIL " + "Error! No Device found! A2-3"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH11")
- ttyWCH11 = os.popen("sh serialport-test.sh /dev/ttyWCH11").read().strip()
- try:
- a_int = int(ttyWCH11)
- except ValueError:
- return False, "Invalid output ttyWCH11: {}".format(ttyWCH11)
- if a_int == 1:
- context.print1("output ttyWCH11: {}".format(ttyWCH11))
- context.print1("output A: {}".format("A2-7"))
- pass
- else:
- context.print1("output ttyWCH11: {}".format(ttyWCH11))
- context.print1("output A: {}".format("A2-7"))
- return False, "FAIL " + "Error! No Device found! A2-7"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH12")
- ttyWCH12 = os.popen("sh serialport-test.sh /dev/ttyWCH12").read().strip()
- try:
- a_int = int(ttyWCH12)
- except ValueError:
- return False, "Invalid output ttyWCH12: {}".format(ttyWCH12)
- if a_int == 1:
- context.print1("output ttyWCH12: {}".format(ttyWCH12))
- context.print1("output A: {}".format("A2-2"))
- pass
- else:
- context.print1("output ttyWCH12: {}".format(ttyWCH12))
- context.print1("output A: {}".format("A2-2"))
- return False, "FAIL " + "Error! No Device found! A2-2"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH13")
- ttyWCH13 = os.popen("sh serialport-test.sh /dev/ttyWCH13").read().strip()
- try:
- a_int = int(ttyWCH13)
- except ValueError:
- return False, "Invalid output ttyWCH13: {}".format(ttyWCH13)
- if a_int == 1:
- context.print1("output ttyWCH13: {}".format(ttyWCH13))
- context.print1("output A: {}".format("A2-6"))
- pass
- else:
- context.print1("output ttyWCH13: {}".format(ttyWCH13))
- context.print1("output A: {}".format("A2-6"))
- return False, "FAIL " + "Error! No Device found! A2-6"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH14")
- ttyWCH14 = os.popen("sh serialport-test.sh /dev/ttyWCH14").read().strip()
- try:
- a_int = int(ttyWCH14)
- except ValueError:
- return False, "Invalid output ttyWCH14: {}".format(ttyWCH14)
- if a_int == 1:
- context.print1("output ttyWCH14: {}".format(ttyWCH14))
- context.print1("output A: {}".format("A2-1"))
- pass
- else:
- context.print1("output ttyWCH14: {}".format(ttyWCH14))
- context.print1("output A: {}".format("A2-1"))
- return False, "FAIL " + "Error! No Device found! A2-1"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyWCH15")
- ttyWCH15 = os.popen("sh serialport-test.sh /dev/ttyWCH15").read().strip()
- try:
- a_int = int(ttyWCH15)
- except ValueError:
- return False, "Invalid output ttyWCH15: {}".format(ttyWCH15)
- if a_int == 1:
- context.print1("output ttyWCH15: {}".format(ttyWCH15))
- context.print1("output A: {}".format("A2-5"))
- pass
- else:
- context.print1("output ttyWCH15: {}".format(ttyWCH15))
- context.print1("output A: {}".format("A2-5"))
- return False, "FAIL " + "Error! No Device found! A2-5"
-
- return True, "PASS"
- def step12_routine(context):
- #serialC
- context.print1("==SubTest: UartC_Test - Titem_11")
- context.print1("-:) sh serialport-test.sh /dev/ttyS0")
- ttyS0 = os.popen("sh serialport-test.sh /dev/ttyS0").read().strip()
- try:
- a_int = int(ttyS0)
- except ValueError:
- return False, "Invalid output ttyS0: {}".format(ttyS0)
- if a_int == 1:
- context.print1("output ttyS0: {}".format(ttyS0))
- context.print1("output COM: {}".format("COM2"))
- pass
- else:
- context.print1("output ttyS0: {}".format(ttyS0))
- context.print1("output COM: {}".format("COM2"))
- return False, "FAIL " + "Error! No Device found! COM2"
- context.print1("-:) sh serialport-test.sh /dev/ttyS1")
- ttyS1 = os.popen("sh serialport-test.sh /dev/ttyS1").read().strip()
- try:
- a_int = int(ttyS1)
- except ValueError:
- return False, "Invalid output ttyS1: {}".format(ttyS1)
- if a_int == 1:
- context.print1("output ttyS1: {}".format(ttyS1))
- context.print1("output COM: {}".format("COM5"))
- pass
- else:
- context.print1("output ttyS1: {}".format(ttyS1))
- context.print1("output COM: {}".format("COM5"))
- return False, "FAIL " + "Error! No Device found! COM5"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyS2")
- ttyS2 = os.popen("sh serialport-test.sh /dev/ttyS2").read().strip()
- try:
- a_int = int(ttyS2)
- except ValueError:
- return False, "Invalid output ttyS2: {}".format(ttyS2)
- if a_int == 1:
- context.print1("output ttyS2: {}".format(ttyS2))
- context.print1("output COM: {}".format("COM1"))
- pass
- else:
- context.print1("output ttyS2: {}".format(ttyS2))
- context.print1("output COM: {}".format("COM1"))
- return False, "FAIL " + "Error! No Device found! COM1"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyS3")
- ttyS3 = os.popen("sh serialport-test.sh /dev/ttyS3").read().strip()
- try:
- a_int = int(ttyS3)
- except ValueError:
- return False, "Invalid output ttyS3: {}".format(ttyS3)
- if a_int == 1:
- context.print1("output ttyS3: {}".format(ttyS3))
- context.print1("output COM: {}".format("COM4"))
- pass
- else:
- context.print1("output ttyS3: {}".format(ttyS3))
- context.print1("output COM: {}".format("COM4"))
- return False, "FAIL " + "Error! No Device found! COM4"
-
- # ttyS4 = os.popen("sh serialport-test.sh /dev/ttyS4").read().strip()
- # try:
- # a_int = int(ttyS4)
- # except ValueError:
- # return False, "Invalid output ttyS4: {}".format(ttyS4)
- # if a_int == 1:
- # pass
- # else:
- # return False, "FAIL " + "Error! No Device found! ttyS4"
-
- # ttyS5 = os.popen("sh serialport-test.sh /dev/ttyS5").read().strip()
- # try:
- # a_int = int(ttyS5)
- # except ValueError:
- # return False, "Invalid output ttyS5: {}".format(ttyS5)
- # if a_int == 1:
- # pass
- # else:
- # return False, "FAIL " + "Error! No Device found! ttyS5"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyS6")
- ttyS6 = os.popen("sh serialport-test.sh /dev/ttyS6").read().strip()
- try:
- a_int = int(ttyS6)
- except ValueError:
- return False, "Invalid output ttyS6: {}".format(ttyS6)
- if a_int == 1:
- context.print1("output ttyS6: {}".format(ttyS6))
- context.print1("output COM: {}".format("COM3"))
- pass
- else:
- context.print1("output ttyS6: {}".format(ttyS6))
- context.print1("output COM: {}".format("COM3"))
- return False, "FAIL " + "Error! No Device found! COM3"
-
- context.print1("-:) sh serialport-test.sh /dev/ttyS7")
- ttyS7 = os.popen("sh serialport-test.sh /dev/ttyS7").read().strip()
- try:
- a_int = int(ttyS7)
- except ValueError:
- return False, "Invalid output ttyS7: {}".format(ttyS7)
- if a_int == 1:
- context.print1("output ttyS7: {}".format(ttyS7))
- context.print1("output COM: {}".format("COM6"))
- pass
- else:
- context.print1("output ttyS7: {}".format(ttyS7))
- context.print1("output COM: {}".format("COM6"))
- return False, "FAIL " + "Error! No Device found! COM6"
-
- return True, "PASS"
- def step13_routine(context):
- #LCD Test
- context.print1("==SubTest: lcd测试 - Titem_14")
- context.print1("-:) ./lcd/lcd/lcd_app | grep -c 'LCD test completed'")
- a = os.popen('./lcd/lcd/lcd_app').read().replace('\n', '').replace('\r', '').strip()
- context.print1("output: {}".format(a))
- a = os.popen('./lcd/lcd/lcd_app | grep -c "LCD test completed"').read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output a: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step14_routine(context):
- #LED Test
- context.print1("==SubTest: led测试 - Titem_15")
- context.print1("-:) sh led-test.sh")
- a = os.popen("sh led-test.sh").read().replace('\n', '').replace('\r', '').strip()
- context.print1("output: {}".format(a))
- a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step15_routine(context):
- context.print1("==SubTest: 检查电池健康指示灯功能测试 - Titem_16")
- context.print1("-:) sh led-test.sh")
- a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step16_routine(context):
- context.print1("==SubTest: 检查拨码开关功能测试 - Titem_17")
- context.print1("-:) ls /dev/")
- return True, 'AAPASS'
- # a = os.popen("sh os-ver.sh USB394").read().replace('\n', '').replace('\r', '').strip()
- # if a == "0":
- # return False, "Error! No Device found!\n" + a
- # else:
- # return True, 'PASS-{}'.format(a)
- def step17_routine(context):
- context.print1("==SubTest: Console接口测试 - Titem_18")
- context.print1("-:) ls /dev/")
- return True, 'AAPASS'
- a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- elif a == "Download: Upload:":
- return False, "Error! no ethernet!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step18_routine(context):
- context.print1("==SubTest: Buzzer基本功能测试 - Titem_19")
- context.print1("-:) sh beep.sh")
- a = os.popen("sh beep.sh").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试蜂鸣器是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试蜂鸣器是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step19_routine(context):
- context.print1("==SubTest: SATA_SSD基本功能测试 - Titem_20")
- context.print1("-:) lsblk -o NAME,TYPE,MOUNTPOINT,MODEL")
- a = os.popen("lsblk -o NAME,TYPE,MOUNTPOINT,MODEL").read().strip()
- context.print1("output: {}".format(a))
- context.print1("-:) ls -l /dev/disk/by-id/ | grep ata-")
- b = os.popen("ls -l /dev/disk/by-id/ | grep -c ata-").read().strip()
- context.print1("output: {}".format(b))
- b = os.popen("ls -l /dev/disk/by-id/ | grep -c ata-").read().replace('\n', '').replace('\r', '').strip()
- if b == "1":
- return True, 'PASS-{}'.format(b)
- else:
- return False, "Error! No Device found! " + b
- def step20_routine(context):
- context.print1("==SubTest: HeadBest_Test - Titem_21")
- return True, 'AAPASS'
- def step21_routine(context):
- context.print1("==SubTest: 数码管测试 - Titem_22")
- context.print1("-:) sh seven_segment_display.sh")
- a = os.popen("sh seven_segment_display.sh").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试数码管是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step22_routine(context):
- return True, 'AAPASS'
- def step23_routine(context):
- return True, 'AAPASS'
- def step24_routine(context):
- return True, 'AAPASS'
- def step25_routine(context):
- return True, 'AAPASS'
- def step26_routine(context):
- return True, 'AAPASS'
- def step27_routine(context):
- context.print1("==SubTest: 检查gsensor基本功能测试 - Titem_23")
- context.print1("-:) bash ./gsensor-SC7A20H/C180_gsensor_function_script.sh")
- context.print1("10s内手动转动屏幕,才能测试PASS!")
- a = os.popen("bash ./gsensor-SC7A20H/C180_gsensor_function_script.sh | grep -c \"pass\"").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step28_routine(context):
- return True, 'AAPASS'
- def step29_routine(context):
- a = os.popen("sh display.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
- a = os.popen("find ./test_picture/ -name '*.jpg' | wc -l").read().strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step30_routine(context):
- a = os.popen("sh fio.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step31_routine(context):
- a = os.popen("sh os-ver.sh speaker | wc -l").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step32_routine(context):
- a = os.popen("sh record_play.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
- a = os.popen("echo 111111 | sudo -S find /tmp/ -name 'my_recording.wav' 2>&1 | wc -l").read().strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step33_routine(context):
- a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step34_routine(context):
- #a = os.popen("/usr/bin/guvcview &").read().replace('\n', '').replace('\r', '').strip()
- os.system("/usr/bin/guvcview &")
- time.sleep(15)
- os.system("sh os-ver.sh exit &")
- return True, 'PASS'
-
- def step35_routine(context):
- context.print1("==SubTest: 外置键盘测试 - Titem_24")
- context.print1("-:) sh ./keyboard.sh 111111")
- a = os.popen("sh ./keyboard.sh 111111").read().replace('\n', '').replace('\r', '').strip()
- context.print1("output: {}".format(a))
- try:
- if len(a) == 1:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- elif a == "":
- return False, "FAIL " + "Error! no cashDrawer!"
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if len(a) != 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step36_routine(context):
- # network speed cli
- c = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
- try:
- c_int = int(c)
- except ValueError:
- return False, "Invalid output c: {}".format(c)
- if c_int != 1:
- return False, "FAIL " + "Error! No Device found!"
- a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- elif a == "Download: Upload:":
- return False, "FAIL " + "Error! no ethernet!"
- else:
- b = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
- try:
- b_int = int(b)
- except ValueError:
- return False, "Invalid output b: {}".format(b)
- if b_int == 1:
- return True, a
- else:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- def step37_routine(context):
- a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 6:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step38_routine(context):
- time.sleep(1)
- os.system("sh os-ver.sh 1080p &")
- time.sleep(15)
- os.system("sh os-ver.sh exit &")
- return True, 'PASS'
- def step39_routine(context):
- context.print1("==SubTest: 钱箱基本功能测试 - Titem_27")
- context.print1("-:) sh ./cashDrawer_test.sh 111111 | tail -n 1")
- b = os.popen("sh ./cashDrawer_test.sh 111111").read().replace('\n', '').replace('\r', '').strip()
- context.print1("output: {}".format(b))
- a = os.popen("sh ./cashDrawer_test.sh 111111 | tail -n 1").read().replace('\n', '').replace('\r', '').strip()
- try:
- if len(a) == 0:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- elif a == "cashDrawer1: , cashDrawer2: ":
- return False, "FAIL " + "Error! no cashDrawer!"
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if len(a) > 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step40_routine(context):
- #serialC
- ttyS0 = os.popen("sh serialport-test.sh /dev/ttyS0").read().strip()
- try:
- a_int = int(ttyS0)
- except ValueError:
- return False, "Invalid output ttyS0: {}".format(ttyS0)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS0"
- ttyS1 = os.popen("sh serialport-test.sh /dev/ttyS1").read().strip()
- try:
- a_int = int(ttyS1)
- except ValueError:
- return False, "Invalid output ttyS1: {}".format(ttyS1)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS1"
-
- ttyS2 = os.popen("sh serialport-test.sh /dev/ttyS2").read().strip()
- try:
- a_int = int(ttyS2)
- except ValueError:
- return False, "Invalid output ttyS2: {}".format(ttyS2)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS2"
-
- ttyS3 = os.popen("sh serialport-test.sh /dev/ttyS3").read().strip()
- try:
- a_int = int(ttyS3)
- except ValueError:
- return False, "Invalid output ttyS3: {}".format(ttyS3)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS3"
-
- ttyS6 = os.popen("sh serialport-test.sh /dev/ttyS6").read().strip()
- try:
- a_int = int(ttyS6)
- except ValueError:
- return False, "Invalid output ttyS6: {}".format(ttyS6)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS6"
-
- ttyS7 = os.popen("sh serialport-test.sh /dev/ttyS7").read().strip()
- try:
- a_int = int(ttyS7)
- except ValueError:
- return False, "Invalid output ttyS7: {}".format(ttyS7)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS7"
-
- return True, "PASS"
- def step41_routine(context):
- a = os.popen("bash usb_test.sh 111111 | grep -s 'PASSED' | wc -l").read().replace('\n', '').replace('\r', '').strip()
- #b = os.popen("bash usb_test.sh 111111").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step42_routine(context):
- a = os.popen("sh readsn.sh").read().replace('\n', '').replace('\r', '').strip()
- try:
- if len(a) == 0:
- return False, "Error! Serial Number is empty!\n" + a
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if len(a) == 11:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step43_routine(context):
- context.print1("==SubTest: 相机基本功能测试 - Titem_20")
- context.print1("-:) /usr/bin/guvcview &")
- a = os.popen("/usr/bin/guvcview &").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试相机是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step44_routine(context):
- context.print1("==SubTest: 检查喇叭基本功能测试 - Titem_21")
- context.print1("-:) sh os-ver.sh speaker")
- a = os.popen("sh os-ver.sh speaker").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试喇叭是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step45_routine(context):
- context.print1("==SubTest: 检查Microphone_Test基本功能测试 - Titem_22")
- context.print1("-:) sh os-ver.sh arecord")
- a = os.popen("sh os-ver.sh arecord").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试Microphone_Test是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step46_routine(context):
- context.print1("==SubTest: 检查LEDBlinking基本功能测试 - Titem_26")
- context.print1("-:) sh lightRing.sh")
- a = os.popen("sh lightRing.sh").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试确定LEDBlinking是否正常?"):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step47_routine(context):
- context.print1("==SubTest: 触摸TP测试C180 - Titem_20")
- context.print1("-:) xinput --list | grep -c 'TouchScreen'")
- a = os.popen("xinput --list | grep -c 'TouchScreen'").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
|