test_function.py 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. #!/usr/bin/python
  2. # _*_ coding: utf-8 _*_
  3. try:
  4. from Tkinter import * # python2
  5. import ttk
  6. import tkMessageBox
  7. except Exception as e:
  8. from tkinter import * # python3
  9. from tkinter import ttk
  10. from tkinter import messagebox as tkMessageBox
  11. import time
  12. import os
  13. import threading
  14. import random
  15. from requests_offline import requests
  16. def ask_choice_with_timeout(title, message, timeout=5, default_choice=False):
  17. # 创建顶层弹窗窗口(Python 2 Tkinter语法)
  18. import Tkinter as tk
  19. top = tk.Toplevel()
  20. top.title(title)
  21. top.geometry("350x180") # 弹窗大小
  22. top.resizable(False, False) # 禁止调整大小
  23. # 设置模态窗口(阻塞主窗口操作)
  24. top.transient(top.master)
  25. top.grab_set()
  26. # 存储结果(用列表实现可变变量,Python 2中nonlocal仅在3.x支持)
  27. result = [default_choice]
  28. # 显示提示信息
  29. msg_label = tk.Label(top, text=message, padx=20, pady=20, font=("Arial", 10))
  30. msg_label.pack(fill=tk.X)
  31. # 显示倒计时提示
  32. timeout_text = "{}秒后自动{}...".format(timeout, "确认" if default_choice else "取消")
  33. timeout_label = tk.Label(top, text=timeout_text, fg="gray", font=("Arial", 9))
  34. timeout_label.pack()
  35. # 按钮回调函数
  36. def on_ok():
  37. result[0] = True
  38. top.destroy()
  39. def on_cancel():
  40. result[0] = False
  41. top.destroy()
  42. # 按钮布局
  43. btn_frame = tk.Frame(top)
  44. btn_frame.pack(pady=15)
  45. ok_btn = tk.Button(btn_frame, text="OK", command=on_ok, width=8)
  46. cancel_btn = tk.Button(btn_frame, text="Cancel", command=on_cancel, width=8)
  47. ok_btn.pack(side=tk.LEFT, padx=10)
  48. cancel_btn.pack(side=tk.LEFT, padx=10)
  49. # 倒计时线程(Python 2 threading语法)
  50. def countdown():
  51. current_timeout = timeout
  52. while current_timeout > 0:
  53. current_timeout -= 1
  54. # 更新倒计时文本
  55. new_text = "{}秒后自动{}...".format(current_timeout, "确认" if default_choice else "取消")
  56. print(new_text)
  57. timeout_label.config(text=new_text)
  58. top.update() # 刷新界面
  59. time.sleep(1) # 等待1秒
  60. top.destroy() # 超时关闭窗口
  61. # 启动守护线程(Python 2兼容)
  62. t = threading.Thread(target=countdown)
  63. t.setDaemon(True) # 守护线程,主程序退出时自动结束
  64. t.start()
  65. # 等待窗口关闭
  66. top.wait_window()
  67. return result[0]
  68. def step1_routine(context, *args):
  69. # bios_version
  70. context.print1("==SubTest: 检查BIOS版本号 - Titem_1")
  71. time.sleep(0.1)
  72. context.print1("-:) sh os-ver.sh bios")
  73. a = os.popen("sh os-ver.sh bios").read().replace('\n', '').replace('\r', '').strip()
  74. if len(a) == 0:
  75. return False, "Error! No Device found!\n" + a
  76. else:
  77. return True, 'PASS-{}'.format(a)
  78. def step2_routine(context):
  79. # bios release date # ec version
  80. context.print1("==SubTest: 检查EC版本号 - Titem_2")
  81. context.print1("-:) sh os-ver.sh ec")
  82. a = os.popen('sh os-ver.sh ec').read().replace('\n', '').replace('\r', '').strip()
  83. if len(a) == 0:
  84. return False, "Error! No Device found!\n" + a
  85. else:
  86. return True, 'PASS-{}'.format(a)
  87. def step3_routine(context):
  88. # CPU type
  89. context.print1("==SubTest: 检查CPU type - Titem_4")
  90. context.print1("-:) cat /proc/cpuinfo | grep \"model name\" | awk '{print $5}' | head -1")
  91. a = os.popen("cat /proc/cpuinfo").read().strip()
  92. context.print1("output: {}".format(a))
  93. a = os.popen("cat /proc/cpuinfo | grep \"model name\" | awk '{print $5}' | head -1").read().replace('\n','').replace('\r', '').strip()
  94. if len(a) == 0:
  95. return False, "Error! No Device found!\n" + a
  96. else:
  97. return True, 'PASS-{}'.format(a)
  98. def step4_routine(context):
  99. # memory_version
  100. context.print1("==SubTest: 检查Memory内存版本号 - Titem_5")
  101. context.print1("-:) sh mem-ver.sh")
  102. a = os.popen("sh mem-ver.sh").read().replace('\n', '').replace('\r', '').strip()
  103. if len(a) == 0:
  104. return False, "Error! No Device found!\n" + a
  105. else:
  106. return True, 'PASS-{}'.format(a)
  107. def step5_routine(context):
  108. # hdd_version
  109. context.print1("==SubTest: 检查SSD硬盘版本号 - Titem_6")
  110. context.print1("-:) sh hdd-ver.sh")
  111. b = os.popen("sh hdd-ver.sh").read().strip()
  112. a = os.popen("cat /sys/block/nvme0n1/device/firmware_rev").read().replace('\n', '').replace('\r', '').strip()
  113. context.print1("output: {}".format(a))
  114. if len(a) == 0:
  115. return False, "Error! No Device found! " + a
  116. else:
  117. return True, 'PASS-{}'.format(a)
  118. def step6_routine(context):
  119. # os_version
  120. context.print1("==SubTest: 检查OS操作系统版本号 - Titem_7")
  121. context.print1("-:) lsb_release -rs")
  122. string = "os"
  123. a = os.popen("lsb_release -rs").read().strip()
  124. context.print1("output: {}".format(a))
  125. if a == "22.04":
  126. return True, 'PASS-{}'.format(a)
  127. else:
  128. return False, "Error! No Device found! " + a
  129. def step7_routine(context):
  130. context.print1("==SubTest: RTC电池 - Titem_8")
  131. context.print1("-:) sh os-ver.sh RTCBATTERY")
  132. a = os.popen("sh os-ver.sh RTCBATTERY").read().replace('\n', '').replace('\r', '').strip()
  133. try:
  134. a_int = int(a)
  135. except ValueError:
  136. return False, "Invalid output: {}".format(a)
  137. if 2950 <= a_int <= 4000:
  138. return True, a_int
  139. else:
  140. return False, "FAIL " + a
  141. def step8_routine(context):
  142. # usb function
  143. context.print1("==SubTest: USB基本功能测试 - Titem_9")
  144. context.print1("-:) lsblk -d -o TRAN,NAME,SIZE")
  145. b = os.popen("lsblk -d -o TRAN,NAME,SIZE").read().replace('\n', '').replace('\r', '').strip()
  146. context.print1("output: {}".format(b))
  147. b = os.popen("lsusb").read().replace('\n', '').replace('\r', '').strip()
  148. context.print1("output: {}".format(b))
  149. context.print1("-:) lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l")
  150. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read().replace('\n', '').replace('\r', '').strip()
  151. try:
  152. a_int = int(a)
  153. except ValueError:
  154. return False, "Invalid output: {}".format(a)
  155. if a_int == 5:
  156. return True, a
  157. else:
  158. return False, "FAIL " + a
  159. def step9_routine(context):
  160. # network speed cli
  161. context.print1("==SubTest: 检查网络在线速度测试 - Titem_10")
  162. context.print1("-:) ip link show | grep -c 'BROADCAST,MULTICAST,UP,LOWER_UP'")
  163. c = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
  164. context.print1("output: {}".format(c))
  165. try:
  166. c_int = int(c)
  167. except ValueError:
  168. return False, "Invalid output c: {}".format(c)
  169. if c_int != 1:
  170. return False, "FAIL " + "Error! No Device found!"
  171. if(context.device_info['offline_test']):
  172. context.print1("-:) ping -c 10 www.baidu.com | grep -E 'packet loss' | awk -F'[,%]' '{print $2}' | tr -d ' ' | tr -d 'received'")
  173. b = os.popen("ping -c 10 www.baidu.com")
  174. context.print1("output: {}".format(b))
  175. 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()
  176. else:
  177. context.print1("-:) ping -c 10 10.60.64.87 | grep -E 'packet loss' | awk -F'[,%]' '{print $2}' | tr -d ' ' | tr -d 'received'")
  178. b = os.popen("ping -c 10 10.60.64.87")
  179. context.print1("output: {}".format(b))
  180. 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()
  181. try:
  182. b_int = int(b)
  183. except ValueError:
  184. return False, "Invalid output b: {}".format(b)
  185. if b_int == 10:
  186. return True, b
  187. else:
  188. return False, "FAIL " + "Error! No Device found! {}".format(b)
  189. def step10_routine(context):
  190. return True, 'AAPASS'
  191. #serialA
  192. context.print1("==SubTest: UartA_Test - Titem_9")
  193. context.print1("-:) sh pcie.sh")
  194. a = os.popen("sh pcie.sh").read().strip()
  195. context.print1("{}".format(a))
  196. context.print1("-:) sh serialport-test.sh /dev/ttyWCH0")
  197. time.sleep(1)
  198. ttyWCH0 = os.popen("sh serialport-test.sh /dev/ttyWCH0").read().strip()
  199. try:
  200. a_int = int(ttyWCH0)
  201. except ValueError:
  202. return False, "Invalid output ttyWCH0: {}".format(ttyWCH0)
  203. if a_int == 1:
  204. context.print1("output ttyWCH0: {}".format(ttyWCH0))
  205. context.print1("output A: {}".format("A1-2"))
  206. pass
  207. else:
  208. context.print1("output ttyWCH0: {}".format(ttyWCH0))
  209. context.print1("output A: {}".format("A1-2"))
  210. return False, "FAIL " + "Error! No Device found! A1-2"
  211. context.print1("-:) sh serialport-test.sh /dev/ttyWCH1")
  212. ttyWCH1 = os.popen("sh serialport-test.sh /dev/ttyWCH1").read().strip()
  213. try:
  214. a_int = int(ttyWCH1)
  215. except ValueError:
  216. return False, "Invalid output ttyWCH1: {}".format(ttyWCH1)
  217. if a_int == 1:
  218. context.print1("output ttyWCH1: {}".format(ttyWCH1))
  219. context.print1("output A: {}".format("A1-6"))
  220. pass
  221. else:
  222. context.print1("output ttyWCH1: {}".format(ttyWCH1))
  223. context.print1("output A: {}".format("A1-6"))
  224. return False, "FAIL " + "Error! No Device found! A1-6"
  225. context.print1("-:) sh serialport-test.sh /dev/ttyWCH2")
  226. ttyWCH2 = os.popen("sh serialport-test.sh /dev/ttyWCH2").read().strip()
  227. try:
  228. a_int = int(ttyWCH2)
  229. except ValueError:
  230. return False, "Invalid output ttyWCH2: {}".format(ttyWCH2)
  231. if a_int == 1:
  232. context.print1("output ttyWCH2: {}".format(ttyWCH2))
  233. context.print1("output A: {}".format("A1-1"))
  234. pass
  235. else:
  236. context.print1("output ttyWCH2: {}".format(ttyWCH2))
  237. context.print1("output A: {}".format("A1-1"))
  238. return False, "FAIL " + "Error! No Device found! A1-1"
  239. context.print1("-:) sh serialport-test.sh /dev/ttyWCH3")
  240. ttyWCH3 = os.popen("sh serialport-test.sh /dev/ttyWCH3").read().strip()
  241. try:
  242. a_int = int(ttyWCH3)
  243. except ValueError:
  244. return False, "Invalid output ttyWCH3: {}".format(ttyWCH3)
  245. if a_int == 1:
  246. context.print1("output ttyWCH3: {}".format(ttyWCH3))
  247. context.print1("output A: {}".format("A1-5"))
  248. pass
  249. else:
  250. context.print1("output ttyWCH3: {}".format(ttyWCH3))
  251. context.print1("output A: {}".format("A1-5"))
  252. return False, "FAIL " + "Error! No Device found! A1-5"
  253. context.print1("-:) sh serialport-test.sh /dev/ttyWCH4")
  254. ttyWCH4 = os.popen("sh serialport-test.sh /dev/ttyWCH4").read().strip()
  255. try:
  256. a_int = int(ttyWCH4)
  257. except ValueError:
  258. return False, "Invalid output ttyWCH4: {}".format(ttyWCH4)
  259. if a_int == 1:
  260. context.print1("output ttyWCH4: {}".format(ttyWCH4))
  261. context.print1("output A: {}".format("A1-4"))
  262. pass
  263. else:
  264. context.print1("output ttyWCH4: {}".format(ttyWCH4))
  265. context.print1("output A: {}".format("A1-4"))
  266. return False, "FAIL " + "Error! No Device found! A1-4"
  267. context.print1("-:) sh serialport-test.sh /dev/ttyWCH5")
  268. ttyWCH5 = os.popen("sh serialport-test.sh /dev/ttyWCH5").read().strip()
  269. try:
  270. a_int = int(ttyWCH5)
  271. except ValueError:
  272. return False, "Invalid output ttyWCH5: {}".format(ttyWCH5)
  273. if a_int == 1:
  274. context.print1("output ttyWCH5: {}".format(ttyWCH5))
  275. context.print1("output A: {}".format("A1-8"))
  276. pass
  277. else:
  278. context.print1("output ttyWCH5: {}".format(ttyWCH5))
  279. context.print1("output A: {}".format("A1-8"))
  280. return False, "FAIL " + "Error! No Device found! A1-8"
  281. context.print1("-:) sh serialport-test.sh /dev/ttyWCH6")
  282. ttyWCH6 = os.popen("sh serialport-test.sh /dev/ttyWCH6").read().strip()
  283. try:
  284. a_int = int(ttyWCH6)
  285. except ValueError:
  286. return False, "Invalid output ttyWCH6: {}".format(ttyWCH6)
  287. if a_int == 1:
  288. context.print1("output ttyWCH6: {}".format(ttyWCH6))
  289. context.print1("output A: {}".format("A1-3"))
  290. pass
  291. else:
  292. context.print1("output ttyWCH6: {}".format(ttyWCH6))
  293. context.print1("output A: {}".format("A1-3"))
  294. return False, "FAIL " + "Error! No Device found! A1-3"
  295. context.print1("-:) sh serialport-test.sh /dev/ttyWCH7")
  296. ttyWCH7 = os.popen("sh serialport-test.sh /dev/ttyWCH7").read().strip()
  297. try:
  298. a_int = int(ttyWCH7)
  299. except ValueError:
  300. return False, "Invalid output ttyWCH7: {}".format(ttyWCH7)
  301. if a_int == 1:
  302. context.print1("output ttyWCH7: {}".format(ttyWCH7))
  303. context.print1("output A: {}".format("A1-7"))
  304. pass
  305. else:
  306. context.print1("output ttyWCH7: {}".format(ttyWCH7))
  307. context.print1("output A: {}".format("A1-7"))
  308. return False, "FAIL " + "Error! No Device found! A1-7"
  309. return True, "PASS"
  310. def step11_routine(context):
  311. return True, 'AAPASS'
  312. #serialB
  313. context.print1("==SubTest: UartB_Test - Titem_10")
  314. a = os.popen("sh pcie.sh").read().strip()
  315. time.sleep(1)
  316. context.print1("-:) sh serialport-test.sh /dev/ttyWCH8")
  317. ttyWCH8 = os.popen("sh serialport-test.sh /dev/ttyWCH8").read().strip()
  318. try:
  319. a_int = int(ttyWCH8)
  320. except ValueError:
  321. return False, "Invalid output ttyWCH8: {}".format(ttyWCH8)
  322. if a_int == 1:
  323. context.print1("output ttyWCH8: {}".format(ttyWCH8))
  324. context.print1("output A: {}".format("A2-4"))
  325. pass
  326. else:
  327. context.print1("output ttyWCH8: {}".format(ttyWCH8))
  328. context.print1("output A: {}".format("A2-4"))
  329. return False, "FAIL " + "Error! No Device found! A2-4"
  330. context.print1("-:) sh serialport-test.sh /dev/ttyWCH9")
  331. ttyWCH9 = os.popen("sh serialport-test.sh /dev/ttyWCH9").read().strip()
  332. try:
  333. a_int = int(ttyWCH9)
  334. except ValueError:
  335. return False, "Invalid output ttyWCH9: {}".format(ttyWCH9)
  336. if a_int == 1:
  337. context.print1("output ttyWCH9: {}".format(ttyWCH9))
  338. context.print1("output A: {}".format("A2-8"))
  339. pass
  340. else:
  341. context.print1("output ttyWCH9: {}".format(ttyWCH9))
  342. context.print1("output A: {}".format("A2-8"))
  343. return False, "FAIL " + "Error! No Device found! A2-8"
  344. context.print1("-:) sh serialport-test.sh /dev/ttyWCH10")
  345. ttyWCH10 = os.popen("sh serialport-test.sh /dev/ttyWCH10").read().strip()
  346. try:
  347. a_int = int(ttyWCH10)
  348. except ValueError:
  349. return False, "Invalid output ttyWCH10: {}".format(ttyWCH10)
  350. if a_int == 1:
  351. context.print1("output ttyWCH10: {}".format(ttyWCH10))
  352. context.print1("output A: {}".format("A2-3"))
  353. pass
  354. else:
  355. context.print1("output ttyWCH10: {}".format(ttyWCH10))
  356. context.print1("output A: {}".format("A2-3"))
  357. return False, "FAIL " + "Error! No Device found! A2-3"
  358. context.print1("-:) sh serialport-test.sh /dev/ttyWCH11")
  359. ttyWCH11 = os.popen("sh serialport-test.sh /dev/ttyWCH11").read().strip()
  360. try:
  361. a_int = int(ttyWCH11)
  362. except ValueError:
  363. return False, "Invalid output ttyWCH11: {}".format(ttyWCH11)
  364. if a_int == 1:
  365. context.print1("output ttyWCH11: {}".format(ttyWCH11))
  366. context.print1("output A: {}".format("A2-7"))
  367. pass
  368. else:
  369. context.print1("output ttyWCH11: {}".format(ttyWCH11))
  370. context.print1("output A: {}".format("A2-7"))
  371. return False, "FAIL " + "Error! No Device found! A2-7"
  372. context.print1("-:) sh serialport-test.sh /dev/ttyWCH12")
  373. ttyWCH12 = os.popen("sh serialport-test.sh /dev/ttyWCH12").read().strip()
  374. try:
  375. a_int = int(ttyWCH12)
  376. except ValueError:
  377. return False, "Invalid output ttyWCH12: {}".format(ttyWCH12)
  378. if a_int == 1:
  379. context.print1("output ttyWCH12: {}".format(ttyWCH12))
  380. context.print1("output A: {}".format("A2-2"))
  381. pass
  382. else:
  383. context.print1("output ttyWCH12: {}".format(ttyWCH12))
  384. context.print1("output A: {}".format("A2-2"))
  385. return False, "FAIL " + "Error! No Device found! A2-2"
  386. context.print1("-:) sh serialport-test.sh /dev/ttyWCH13")
  387. ttyWCH13 = os.popen("sh serialport-test.sh /dev/ttyWCH13").read().strip()
  388. try:
  389. a_int = int(ttyWCH13)
  390. except ValueError:
  391. return False, "Invalid output ttyWCH13: {}".format(ttyWCH13)
  392. if a_int == 1:
  393. context.print1("output ttyWCH13: {}".format(ttyWCH13))
  394. context.print1("output A: {}".format("A2-6"))
  395. pass
  396. else:
  397. context.print1("output ttyWCH13: {}".format(ttyWCH13))
  398. context.print1("output A: {}".format("A2-6"))
  399. return False, "FAIL " + "Error! No Device found! A2-6"
  400. context.print1("-:) sh serialport-test.sh /dev/ttyWCH14")
  401. ttyWCH14 = os.popen("sh serialport-test.sh /dev/ttyWCH14").read().strip()
  402. try:
  403. a_int = int(ttyWCH14)
  404. except ValueError:
  405. return False, "Invalid output ttyWCH14: {}".format(ttyWCH14)
  406. if a_int == 1:
  407. context.print1("output ttyWCH14: {}".format(ttyWCH14))
  408. context.print1("output A: {}".format("A2-1"))
  409. pass
  410. else:
  411. context.print1("output ttyWCH14: {}".format(ttyWCH14))
  412. context.print1("output A: {}".format("A2-1"))
  413. return False, "FAIL " + "Error! No Device found! A2-1"
  414. context.print1("-:) sh serialport-test.sh /dev/ttyWCH15")
  415. ttyWCH15 = os.popen("sh serialport-test.sh /dev/ttyWCH15").read().strip()
  416. try:
  417. a_int = int(ttyWCH15)
  418. except ValueError:
  419. return False, "Invalid output ttyWCH15: {}".format(ttyWCH15)
  420. if a_int == 1:
  421. context.print1("output ttyWCH15: {}".format(ttyWCH15))
  422. context.print1("output A: {}".format("A2-5"))
  423. pass
  424. else:
  425. context.print1("output ttyWCH15: {}".format(ttyWCH15))
  426. context.print1("output A: {}".format("A2-5"))
  427. return False, "FAIL " + "Error! No Device found! A2-5"
  428. return True, "PASS"
  429. def step12_routine(context):
  430. #serialC
  431. context.print1("==SubTest: UartC_Test - Titem_11")
  432. context.print1("-:) sh serialport-test.sh /dev/ttyS0")
  433. ttyS0 = os.popen("sh serialport-test.sh /dev/ttyS0").read().strip()
  434. try:
  435. a_int = int(ttyS0)
  436. except ValueError:
  437. return False, "Invalid output ttyS0: {}".format(ttyS0)
  438. if a_int == 1:
  439. context.print1("output ttyS0: {}".format(ttyS0))
  440. context.print1("output COM: {}".format("COM2"))
  441. pass
  442. else:
  443. context.print1("output ttyS0: {}".format(ttyS0))
  444. context.print1("output COM: {}".format("COM2"))
  445. return False, "FAIL " + "Error! No Device found! COM2"
  446. context.print1("-:) sh serialport-test.sh /dev/ttyS1")
  447. ttyS1 = os.popen("sh serialport-test.sh /dev/ttyS1").read().strip()
  448. try:
  449. a_int = int(ttyS1)
  450. except ValueError:
  451. return False, "Invalid output ttyS1: {}".format(ttyS1)
  452. if a_int == 1:
  453. context.print1("output ttyS1: {}".format(ttyS1))
  454. context.print1("output COM: {}".format("COM5"))
  455. pass
  456. else:
  457. context.print1("output ttyS1: {}".format(ttyS1))
  458. context.print1("output COM: {}".format("COM5"))
  459. return False, "FAIL " + "Error! No Device found! COM5"
  460. context.print1("-:) sh serialport-test.sh /dev/ttyS2")
  461. ttyS2 = os.popen("sh serialport-test.sh /dev/ttyS2").read().strip()
  462. try:
  463. a_int = int(ttyS2)
  464. except ValueError:
  465. return False, "Invalid output ttyS2: {}".format(ttyS2)
  466. if a_int == 1:
  467. context.print1("output ttyS2: {}".format(ttyS2))
  468. context.print1("output COM: {}".format("COM1"))
  469. pass
  470. else:
  471. context.print1("output ttyS2: {}".format(ttyS2))
  472. context.print1("output COM: {}".format("COM1"))
  473. return False, "FAIL " + "Error! No Device found! COM1"
  474. context.print1("-:) sh serialport-test.sh /dev/ttyS3")
  475. ttyS3 = os.popen("sh serialport-test.sh /dev/ttyS3").read().strip()
  476. try:
  477. a_int = int(ttyS3)
  478. except ValueError:
  479. return False, "Invalid output ttyS3: {}".format(ttyS3)
  480. if a_int == 1:
  481. context.print1("output ttyS3: {}".format(ttyS3))
  482. context.print1("output COM: {}".format("COM4"))
  483. pass
  484. else:
  485. context.print1("output ttyS3: {}".format(ttyS3))
  486. context.print1("output COM: {}".format("COM4"))
  487. return False, "FAIL " + "Error! No Device found! COM4"
  488. # ttyS4 = os.popen("sh serialport-test.sh /dev/ttyS4").read().strip()
  489. # try:
  490. # a_int = int(ttyS4)
  491. # except ValueError:
  492. # return False, "Invalid output ttyS4: {}".format(ttyS4)
  493. # if a_int == 1:
  494. # pass
  495. # else:
  496. # return False, "FAIL " + "Error! No Device found! ttyS4"
  497. # ttyS5 = os.popen("sh serialport-test.sh /dev/ttyS5").read().strip()
  498. # try:
  499. # a_int = int(ttyS5)
  500. # except ValueError:
  501. # return False, "Invalid output ttyS5: {}".format(ttyS5)
  502. # if a_int == 1:
  503. # pass
  504. # else:
  505. # return False, "FAIL " + "Error! No Device found! ttyS5"
  506. context.print1("-:) sh serialport-test.sh /dev/ttyS6")
  507. ttyS6 = os.popen("sh serialport-test.sh /dev/ttyS6").read().strip()
  508. try:
  509. a_int = int(ttyS6)
  510. except ValueError:
  511. return False, "Invalid output ttyS6: {}".format(ttyS6)
  512. if a_int == 1:
  513. context.print1("output ttyS6: {}".format(ttyS6))
  514. context.print1("output COM: {}".format("COM3"))
  515. pass
  516. else:
  517. context.print1("output ttyS6: {}".format(ttyS6))
  518. context.print1("output COM: {}".format("COM3"))
  519. return False, "FAIL " + "Error! No Device found! COM3"
  520. context.print1("-:) sh serialport-test.sh /dev/ttyS7")
  521. ttyS7 = os.popen("sh serialport-test.sh /dev/ttyS7").read().strip()
  522. try:
  523. a_int = int(ttyS7)
  524. except ValueError:
  525. return False, "Invalid output ttyS7: {}".format(ttyS7)
  526. if a_int == 1:
  527. context.print1("output ttyS7: {}".format(ttyS7))
  528. context.print1("output COM: {}".format("COM6"))
  529. pass
  530. else:
  531. context.print1("output ttyS7: {}".format(ttyS7))
  532. context.print1("output COM: {}".format("COM6"))
  533. return False, "FAIL " + "Error! No Device found! COM6"
  534. return True, "PASS"
  535. def step13_routine(context):
  536. #LCD Test
  537. context.print1("==SubTest: lcd测试 - Titem_14")
  538. context.print1("-:) ./lcd/lcd/lcd_app | grep -c 'LCD test completed'")
  539. a = os.popen('./lcd/lcd/lcd_app').read().replace('\n', '').replace('\r', '').strip()
  540. context.print1("output: {}".format(a))
  541. a = os.popen('./lcd/lcd/lcd_app | grep -c "LCD test completed"').read().replace('\n', '').replace('\r', '').strip()
  542. try:
  543. a_int = int(a)
  544. except ValueError:
  545. return False, "Invalid output a: {}".format(a)
  546. if a_int == 1:
  547. return True, 'PASS-{}'.format(a)
  548. else:
  549. return False, "FAIL " + "Error! No Device found!"
  550. def step14_routine(context):
  551. #LED Test
  552. context.print1("==SubTest: led测试 - Titem_15")
  553. context.print1("-:) sh led-test.sh")
  554. a = os.popen("sh led-test.sh").read().replace('\n', '').replace('\r', '').strip()
  555. context.print1("output: {}".format(a))
  556. a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
  557. try:
  558. a_int = int(a)
  559. except ValueError:
  560. return False, "Invalid output: {}".format(a)
  561. if a_int == 1:
  562. return True, 'PASS-{}'.format(a)
  563. else:
  564. return False, "FAIL " + "Error! No Device found!"
  565. def step15_routine(context):
  566. context.print1("==SubTest: 检查电池健康指示灯功能测试 - Titem_16")
  567. context.print1("-:) sh batled-test.sh")
  568. a = os.popen("sh batled-test.sh").read().replace('\n', '').replace('\r', '').strip()
  569. context.print1("output: {}".format(a))
  570. a = os.popen("sh batled-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
  571. try:
  572. a_int = int(a)
  573. except ValueError:
  574. return False, "Invalid output: {}".format(a)
  575. if a_int == 1:
  576. return True, 'PASS-{}'.format(a)
  577. else:
  578. return False, "FAIL " + "Error! No Device found!"
  579. def step16_routine(context):
  580. context.print1("==SubTest: 检查拨码开关功能测试 - Titem_17")
  581. context.print1("-:) ls /dev/")
  582. return True, 'AAPASS'
  583. # a = os.popen("sh os-ver.sh USB394").read().replace('\n', '').replace('\r', '').strip()
  584. # if a == "0":
  585. # return False, "Error! No Device found!\n" + a
  586. # else:
  587. # return True, 'PASS-{}'.format(a)
  588. def step17_routine(context):
  589. context.print1("==SubTest: Console接口测试 - Titem_18")
  590. context.print1("-:) ls /dev/")
  591. return True, 'AAPASS'
  592. a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
  593. if len(a) == 0:
  594. return False, "Error! No Device found!\n" + a
  595. elif a == "Download: Upload:":
  596. return False, "Error! no ethernet!\n" + a
  597. else:
  598. return True, 'PASS-{}'.format(a)
  599. def step18_routine(context):
  600. context.print1("==SubTest: Buzzer基本功能测试 - Titem_19")
  601. context.print1("-:) sh beep.sh")
  602. a = os.popen("sh beep.sh").read().replace('\n', '').replace('\r', '').strip()
  603. if tkMessageBox.askokcancel("PASS?", "测试蜂鸣器是否正常."):
  604. # if ask_choice_with_timeout("PASS?", "测试蜂鸣器是否正常.",30):
  605. return True, 'PASS'
  606. else:
  607. return False, "FAIL"
  608. def step19_routine(context):
  609. context.print1("==SubTest: SATA_SSD基本功能测试 - Titem_20")
  610. context.print1("-:) lsblk -o NAME,TYPE,MOUNTPOINT,MODEL")
  611. a = os.popen("lsblk -o NAME,TYPE,MOUNTPOINT,MODEL").read().strip()
  612. context.print1("output: {}".format(a))
  613. context.print1("-:) ls -l /dev/disk/by-id/ | grep ata-")
  614. b = os.popen("ls -l /dev/disk/by-id/ | grep -c ata-").read().strip()
  615. context.print1("output: {}".format(b))
  616. b = os.popen("ls -l /dev/disk/by-id/ | grep -c ata-").read().replace('\n', '').replace('\r', '').strip()
  617. if b == "1":
  618. return True, 'PASS-{}'.format(b)
  619. else:
  620. return False, "Error! No Device found! " + b
  621. def step20_routine(context):
  622. context.print1("==SubTest: HeadBest_Test - Titem_21")
  623. return True, 'AAPASS'
  624. def step21_routine(context):
  625. context.print1("==SubTest: 数码管测试 - Titem_22")
  626. context.print1("-:) sh seven_segment_display.sh")
  627. a = os.popen("sh seven_segment_display.sh").read().replace('\n', '').replace('\r', '').strip()
  628. if tkMessageBox.askokcancel("PASS?", "测试数码管是否正常."):
  629. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  630. return True, 'PASS'
  631. else:
  632. return False, "FAIL"
  633. def step22_routine(context):
  634. return True, 'AAPASS'
  635. def step23_routine(context):
  636. return True, 'AAPASS'
  637. def step24_routine(context):
  638. return True, 'AAPASS'
  639. def step25_routine(context):
  640. return True, 'AAPASS'
  641. def step26_routine(context):
  642. return True, 'AAPASS'
  643. def step27_routine(context):
  644. context.print1("==SubTest: 检查gsensor基本功能测试 - Titem_23")
  645. context.print1("-:) bash ./gsensor-SC7A20H/C180_gsensor_function_script.sh")
  646. context.print1("10s内手动转动屏幕,才能测试PASS!")
  647. tkMessageBox.showinfo("Prompt", "请人工向右转动屏幕检查横竖屏,判断重力传感器是否正常?")
  648. a = os.popen("bash ./gsensor-SC7A20H/C180_gsensor_function_script.sh | grep -c \"pass\"").read().replace('\n', '').replace('\r', '').strip()
  649. try:
  650. a_int = int(a)
  651. except ValueError:
  652. return False, "Invalid output: {}".format(a)
  653. if a_int == 1:
  654. return True, 'PASS-{}'.format(a)
  655. else:
  656. return False, "FAIL " + "Error! No Device found!"
  657. def step28_routine(context):
  658. return True, 'AAPASS'
  659. def step29_routine(context):
  660. a = os.popen("sh display.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
  661. a = os.popen("find ./test_picture/ -name '*.jpg' | wc -l").read().strip()
  662. try:
  663. a_int = int(a)
  664. except ValueError:
  665. return False, "Invalid output: {}".format(a)
  666. if a_int >= 0:
  667. return True, 'PASS-{}'.format(a)
  668. else:
  669. return False, "FAIL " + "Error! No Device found!"
  670. def step30_routine(context):
  671. a = os.popen("sh fio.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
  672. try:
  673. a_int = int(a)
  674. except ValueError:
  675. return False, "Invalid output: {}".format(a)
  676. if a_int >= 0:
  677. return True, 'PASS-{}'.format(a)
  678. else:
  679. return False, "FAIL " + "Error! No Device found!"
  680. def step31_routine(context):
  681. a = os.popen("sh os-ver.sh speaker | wc -l").read().replace('\n', '').replace('\r', '').strip()
  682. try:
  683. a_int = int(a)
  684. except ValueError:
  685. return False, "Invalid output: {}".format(a)
  686. if a_int >= 0:
  687. return True, 'PASS-{}'.format(a)
  688. else:
  689. return False, "FAIL " + "Error! No Device found!"
  690. def step32_routine(context):
  691. a = os.popen("sh record_play.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
  692. a = os.popen("echo 111111 | sudo -S find /tmp/ -name 'my_recording.wav' 2>&1 | wc -l").read().strip()
  693. try:
  694. a_int = int(a)
  695. except ValueError:
  696. return False, "Invalid output: {}".format(a)
  697. if a_int >= 0:
  698. return True, 'PASS-{}'.format(a)
  699. else:
  700. return False, "FAIL " + "Error! No Device found!"
  701. def step33_routine(context):
  702. a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
  703. try:
  704. a_int = int(a)
  705. except ValueError:
  706. return False, "Invalid output: {}".format(a)
  707. if a_int == 1:
  708. return True, 'PASS-{}'.format(a)
  709. else:
  710. return False, "FAIL " + "Error! No Device found!"
  711. def step34_routine(context):
  712. #a = os.popen("/usr/bin/guvcview &").read().replace('\n', '').replace('\r', '').strip()
  713. os.system("/usr/bin/guvcview &")
  714. time.sleep(15)
  715. os.system("sh os-ver.sh exit &")
  716. return True, 'PASS'
  717. def step35_routine(context):
  718. context.print1("==SubTest: 外置键盘测试 - Titem_24")
  719. context.print1("-:) sh ./keyboard.sh 111111")
  720. a = os.popen("sh ./keyboard.sh 111111").read().replace('\n', '').replace('\r', '').strip()
  721. context.print1("output: {}".format(a))
  722. try:
  723. if len(a) == 1:
  724. return False, "FAIL " + "Error! No Device found! {}".format(a)
  725. elif a == "":
  726. return False, "FAIL " + "Error! no cashDrawer!"
  727. except ValueError:
  728. return False, "Invalid output: {}".format(a)
  729. if len(a) != 0:
  730. return True, 'PASS-{}'.format(a)
  731. else:
  732. return False, "FAIL " + "Error! No Device found!"
  733. def step36_routine(context):
  734. # network speed cli
  735. c = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
  736. try:
  737. c_int = int(c)
  738. except ValueError:
  739. return False, "Invalid output c: {}".format(c)
  740. if c_int != 1:
  741. return False, "FAIL " + "Error! No Device found!"
  742. a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
  743. if len(a) == 0:
  744. return False, "FAIL " + "Error! No Device found! {}".format(a)
  745. elif a == "Download: Upload:":
  746. return False, "FAIL " + "Error! no ethernet!"
  747. else:
  748. b = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
  749. try:
  750. b_int = int(b)
  751. except ValueError:
  752. return False, "Invalid output b: {}".format(b)
  753. if b_int == 1:
  754. return True, a
  755. else:
  756. return False, "FAIL " + "Error! No Device found! {}".format(a)
  757. def step37_routine(context):
  758. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read().replace('\n', '').replace('\r', '').strip()
  759. try:
  760. a_int = int(a)
  761. except ValueError:
  762. return False, "Invalid output: {}".format(a)
  763. if a_int >= 6:
  764. return True, 'PASS-{}'.format(a)
  765. else:
  766. return False, "FAIL " + "Error! No Device found!"
  767. def step38_routine(context):
  768. time.sleep(1)
  769. os.system("sh os-ver.sh 1080p &")
  770. time.sleep(15)
  771. os.system("sh os-ver.sh exit &")
  772. return True, 'PASS'
  773. def step39_routine(context):
  774. context.print1("==SubTest: 钱箱基本功能测试 - Titem_27")
  775. context.print1("-:) sh ./cashDrawer_test.sh 111111 | tail -n 1")
  776. b = os.popen("sh ./cashDrawer_test.sh 111111").read().replace('\n', '').replace('\r', '').strip()
  777. context.print1("output: {}".format(b))
  778. a = os.popen("sh ./cashDrawer_test.sh 111111 | tail -n 1").read().replace('\n', '').replace('\r', '').strip()
  779. try:
  780. if len(a) == 0:
  781. return False, "FAIL " + "Error! No Device found! {}".format(a)
  782. elif a == "cashDrawer1: , cashDrawer2: ":
  783. return False, "FAIL " + "Error! no cashDrawer!"
  784. elif a == "cashDrawer1: 0, cashDrawer2: 0":
  785. return False, "FAIL " + "Error! no cashDrawer!"
  786. elif a == "cashDrawer1: 1, cashDrawer2: 0":
  787. return False, "FAIL " + "Error! no cashDrawer2!"
  788. elif a == "cashDrawer1: 0, cashDrawer2: 1":
  789. return False, "FAIL " + "Error! no cashDrawer1"
  790. except ValueError:
  791. return False, "Invalid output: {}".format(a)
  792. if len(a) > 0:
  793. return True, 'PASS-{}'.format(a)
  794. else:
  795. return False, "FAIL " + "Error! No Device found!"
  796. def step40_routine(context):
  797. #serialC
  798. ttyS0 = os.popen("sh serialport-test.sh /dev/ttyS0").read().strip()
  799. try:
  800. a_int = int(ttyS0)
  801. except ValueError:
  802. return False, "Invalid output ttyS0: {}".format(ttyS0)
  803. if a_int == 1:
  804. pass
  805. else:
  806. return False, "FAIL " + "Error! No Device found! ttyS0"
  807. ttyS1 = os.popen("sh serialport-test.sh /dev/ttyS1").read().strip()
  808. try:
  809. a_int = int(ttyS1)
  810. except ValueError:
  811. return False, "Invalid output ttyS1: {}".format(ttyS1)
  812. if a_int == 1:
  813. pass
  814. else:
  815. return False, "FAIL " + "Error! No Device found! ttyS1"
  816. ttyS2 = os.popen("sh serialport-test.sh /dev/ttyS2").read().strip()
  817. try:
  818. a_int = int(ttyS2)
  819. except ValueError:
  820. return False, "Invalid output ttyS2: {}".format(ttyS2)
  821. if a_int == 1:
  822. pass
  823. else:
  824. return False, "FAIL " + "Error! No Device found! ttyS2"
  825. ttyS3 = os.popen("sh serialport-test.sh /dev/ttyS3").read().strip()
  826. try:
  827. a_int = int(ttyS3)
  828. except ValueError:
  829. return False, "Invalid output ttyS3: {}".format(ttyS3)
  830. if a_int == 1:
  831. pass
  832. else:
  833. return False, "FAIL " + "Error! No Device found! ttyS3"
  834. ttyS6 = os.popen("sh serialport-test.sh /dev/ttyS6").read().strip()
  835. try:
  836. a_int = int(ttyS6)
  837. except ValueError:
  838. return False, "Invalid output ttyS6: {}".format(ttyS6)
  839. if a_int == 1:
  840. pass
  841. else:
  842. return False, "FAIL " + "Error! No Device found! ttyS6"
  843. ttyS7 = os.popen("sh serialport-test.sh /dev/ttyS7").read().strip()
  844. try:
  845. a_int = int(ttyS7)
  846. except ValueError:
  847. return False, "Invalid output ttyS7: {}".format(ttyS7)
  848. if a_int == 1:
  849. pass
  850. else:
  851. return False, "FAIL " + "Error! No Device found! ttyS7"
  852. return True, "PASS"
  853. def step41_routine(context):
  854. a = os.popen("bash usb_test.sh 111111 | grep -s 'PASSED' | wc -l").read().replace('\n', '').replace('\r', '').strip()
  855. #b = os.popen("bash usb_test.sh 111111").read().replace('\n', '').replace('\r', '').strip()
  856. try:
  857. a_int = int(a)
  858. except ValueError:
  859. return False, "Invalid output: {}".format(a)
  860. if a_int >= 1:
  861. return True, 'PASS-{}'.format(a)
  862. else:
  863. return False, "FAIL " + "Error! No Device found!"
  864. def step42_routine(context):
  865. a = os.popen("sh readsn.sh").read().replace('\n', '').replace('\r', '').strip()
  866. try:
  867. if len(a) == 0:
  868. return False, "Error! Serial Number is empty!\n" + a
  869. except ValueError:
  870. return False, "Invalid output: {}".format(a)
  871. if len(a) == 11:
  872. return True, 'PASS-{}'.format(a)
  873. else:
  874. return False, "FAIL " + "Error! No Device found!"
  875. def step43_routine(context):
  876. context.print1("==SubTest: 相机基本功能测试 - Titem_20")
  877. context.print1("-:) /usr/bin/guvcview &")
  878. a = os.popen("/usr/bin/guvcview &").read().replace('\n', '').replace('\r', '').strip()
  879. if tkMessageBox.askokcancel("PASS?", "测试相机是否正常."):
  880. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  881. return True, 'PASS'
  882. else:
  883. return False, "FAIL"
  884. def step44_routine(context):
  885. context.print1("==SubTest: 检查喇叭基本功能测试 - Titem_21")
  886. context.print1("-:) sh os-ver.sh speaker")
  887. a = os.popen("sh os-ver.sh speaker").read().replace('\n', '').replace('\r', '').strip()
  888. if tkMessageBox.askokcancel("PASS?", "测试喇叭是否正常."):
  889. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  890. return True, 'PASS'
  891. else:
  892. return False, "FAIL"
  893. def step45_routine(context):
  894. context.print1("==SubTest: 检查Microphone_Test基本功能测试 - Titem_22")
  895. context.print1("-:) sh os-ver.sh arecord")
  896. a = os.popen("sh os-ver.sh arecord").read().replace('\n', '').replace('\r', '').strip()
  897. if tkMessageBox.askokcancel("PASS?", "测试Microphone_Test是否正常."):
  898. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  899. return True, 'PASS'
  900. else:
  901. return False, "FAIL"
  902. def step46_routine(context):
  903. context.print1("==SubTest: 检查LEDBlinking基本功能测试 - Titem_26")
  904. context.print1("-:) sh lightRing.sh")
  905. a = os.popen("sh lightRing.sh").read().replace('\n', '').replace('\r', '').strip()
  906. if tkMessageBox.askokcancel("PASS?", "测试确定LEDBlinking是否正常?"):
  907. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  908. return True, 'PASS'
  909. else:
  910. return False, "FAIL"
  911. def step47_routine(context):
  912. context.print1("==SubTest: 触摸TP测试C180 - Titem_20")
  913. context.print1("-:) xinput --list | grep -c 'TouchScreen'")
  914. a = os.popen("xinput --list | grep -c 'TouchScreen'").read().replace('\n', '').replace('\r', '').strip()
  915. try:
  916. a_int = int(a)
  917. except ValueError:
  918. return False, "Invalid output: {}".format(a)
  919. if a_int >= 1:
  920. return True, 'PASS-{}'.format(a)
  921. else:
  922. return False, "FAIL " + "Error! No Device found!"
  923. def step48_routine(context):
  924. context.print1("==SubTest: 检查耳机基本功能测试 - Titem_22")
  925. context.print1("-:) Prompt, 请插上耳机继续测试")
  926. tkMessageBox.showinfo("Prompt", "请插上耳机继续测试")
  927. context.print1("-:) sh os-ver.sh speaker")
  928. a = os.popen("sh os-ver.sh speaker").read().replace('\n', '').replace('\r', '').strip()
  929. tkMessageBox.showinfo("Prompt", "请拔出耳机继续测试")
  930. if tkMessageBox.askokcancel("PASS?", "测试耳机是否正常并拔出耳机."):
  931. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  932. return True, 'PASS'
  933. else:
  934. return False, "FAIL"