test_function.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  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. def ask_choice_with_timeout(title, message, timeout=5, default_choice=False):
  16. # 创建顶层弹窗窗口(Python 2 Tkinter语法)
  17. import Tkinter as tk
  18. top = tk.Toplevel()
  19. top.title(title)
  20. top.geometry("350x180") # 弹窗大小
  21. top.resizable(False, False) # 禁止调整大小
  22. # 设置模态窗口(阻塞主窗口操作)
  23. top.transient(top.master)
  24. top.grab_set()
  25. # 存储结果(用列表实现可变变量,Python 2中nonlocal仅在3.x支持)
  26. result = [default_choice]
  27. # 显示提示信息
  28. msg_label = tk.Label(top, text=message, padx=20, pady=20, font=("Arial", 10))
  29. msg_label.pack(fill=tk.X)
  30. # 显示倒计时提示
  31. timeout_text = "{}秒后自动{}...".format(timeout, "确认" if default_choice else "取消")
  32. timeout_label = tk.Label(top, text=timeout_text, fg="gray", font=("Arial", 9))
  33. timeout_label.pack()
  34. # 按钮回调函数
  35. def on_ok():
  36. result[0] = True
  37. top.destroy()
  38. def on_cancel():
  39. result[0] = False
  40. top.destroy()
  41. # 按钮布局
  42. btn_frame = tk.Frame(top)
  43. btn_frame.pack(pady=15)
  44. ok_btn = tk.Button(btn_frame, text="OK", command=on_ok, width=8)
  45. cancel_btn = tk.Button(btn_frame, text="Cancel", command=on_cancel, width=8)
  46. ok_btn.pack(side=tk.LEFT, padx=10)
  47. cancel_btn.pack(side=tk.LEFT, padx=10)
  48. # 倒计时线程(Python 2 threading语法)
  49. def countdown():
  50. current_timeout = timeout
  51. while current_timeout > 0:
  52. current_timeout -= 1
  53. # 更新倒计时文本
  54. new_text = "{}秒后自动{}...".format(current_timeout, "确认" if default_choice else "取消")
  55. print(new_text)
  56. timeout_label.config(text=new_text)
  57. top.update() # 刷新界面
  58. time.sleep(1) # 等待1秒
  59. top.destroy() # 超时关闭窗口
  60. # 启动守护线程(Python 2兼容)
  61. t = threading.Thread(target=countdown)
  62. t.setDaemon(True) # 守护线程,主程序退出时自动结束
  63. t.start()
  64. # 等待窗口关闭
  65. top.wait_window()
  66. return result[0]
  67. def step1_routine(context, *args):
  68. # bios_version
  69. time.sleep(0.1)
  70. a = os.popen("sh os-ver.sh bios").read().replace('\n', '').replace('\r', '').strip()
  71. if len(a) == 0:
  72. return False, "Error! No Device found!\n" + a
  73. else:
  74. return True, 'PASS-{}'.format(a)
  75. def step2_routine(context):
  76. # bios release date
  77. a = os.popen('sh os-ver.sh ec').read().replace('\n', '').replace('\r', '').strip()
  78. if len(a) == 0:
  79. return False, "Error! No Device found!\n" + a
  80. else:
  81. return True, 'PASS-{}'.format(a)
  82. def step3_routine(context):
  83. # CPU type
  84. a = os.popen("cat /proc/cpuinfo | grep \"model name\" | awk '{print $5}' | head -1").read().replace('\n',
  85. '').replace(
  86. '\r', '').strip()
  87. if len(a) == 0:
  88. return False, "Error! No Device found!\n" + a
  89. else:
  90. return True, 'PASS-{}'.format(a)
  91. def step4_routine(context):
  92. # memory_version
  93. a = os.popen("sh mem-ver.sh").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 step5_routine(context):
  99. # hdd_version
  100. b = os.popen("sh hdd-ver.sh").read().strip()
  101. a = os.popen("cat /sys/block/nvme0n1/device/firmware_rev").read().replace('\n', '').replace('\r', '').strip()
  102. if len(a) == 0:
  103. return False, "Error! No Device found! " + a
  104. else:
  105. return True, 'PASS-{}'.format(a)
  106. def step6_routine(context):
  107. # os_version
  108. string = "os"
  109. a = os.popen("lsb_release -rs").read().strip()
  110. if a == "22.04":
  111. return True, 'PASS-{}'.format(a)
  112. else:
  113. return False, "Error! No Device found! " + a
  114. def step7_routine(context):
  115. a = os.popen("sh os-ver.sh RTCBATTERY").read().replace('\n', '').replace('\r', '').strip()
  116. try:
  117. a_int = int(a)
  118. except ValueError:
  119. return False, "Invalid output: {}".format(a)
  120. if 3000 <= a_int <= 4000:
  121. return True, a_int
  122. else:
  123. return False, "FAIL " + a
  124. def step8_routine(context):
  125. # usb function
  126. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read().replace('\n', '').replace('\r', '').strip()
  127. try:
  128. a_int = int(a)
  129. except ValueError:
  130. return False, "Invalid output: {}".format(a)
  131. if a_int == 5:
  132. return True, a
  133. else:
  134. return False, "FAIL " + a
  135. def step9_routine(context):
  136. # network speed cli
  137. c = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
  138. try:
  139. c_int = int(c)
  140. except ValueError:
  141. return False, "Invalid output c: {}".format(c)
  142. if c_int != 1:
  143. return False, "FAIL " + "Error! No Device found!"
  144. a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
  145. if len(a) == 0:
  146. return False, "FAIL " + "Error! No Device found! {}".format(a)
  147. elif a == "Download: Upload:":
  148. return False, "FAIL " + "Error! no ethernet!"
  149. else:
  150. b = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
  151. try:
  152. b_int = int(b)
  153. except ValueError:
  154. return False, "Invalid output b: {}".format(b)
  155. if b_int == 1:
  156. return True, a
  157. else:
  158. return False, "FAIL " + "Error! No Device found! {}".format(a)
  159. def step10_routine(context):
  160. return True, 'AAPASS'
  161. #serialA
  162. a = os.popen("sh pcie.sh").read().strip()
  163. time.sleep(1)
  164. ttyWCH0 = os.popen("sh serialport-test.sh /dev/ttyWCH0").read().strip()
  165. try:
  166. a_int = int(ttyWCH0)
  167. except ValueError:
  168. return False, "Invalid output ttyWCH0: {}".format(ttyWCH0)
  169. if a_int == 1:
  170. pass
  171. else:
  172. return False, "FAIL " + "Error! No Device found! ttyWCH0"
  173. ttyWCH1 = os.popen("sh serialport-test.sh /dev/ttyWCH1").read().strip()
  174. try:
  175. a_int = int(ttyWCH1)
  176. except ValueError:
  177. return False, "Invalid output ttyWCH1: {}".format(ttyWCH1)
  178. if a_int == 1:
  179. pass
  180. else:
  181. return False, "FAIL " + "Error! No Device found! ttyWCH1"
  182. ttyWCH2 = os.popen("sh serialport-test.sh /dev/ttyWCH2").read().strip()
  183. try:
  184. a_int = int(ttyWCH2)
  185. except ValueError:
  186. return False, "Invalid output ttyWCH2: {}".format(ttyWCH2)
  187. if a_int == 1:
  188. pass
  189. else:
  190. return False, "FAIL " + "Error! No Device found! ttyWCH2"
  191. ttyWCH3 = os.popen("sh serialport-test.sh /dev/ttyWCH3").read().strip()
  192. try:
  193. a_int = int(ttyWCH3)
  194. except ValueError:
  195. return False, "Invalid output ttyWCH3: {}".format(ttyWCH3)
  196. if a_int == 1:
  197. pass
  198. else:
  199. return False, "FAIL " + "Error! No Device found! ttyWCH3"
  200. ttyWCH4 = os.popen("sh serialport-test.sh /dev/ttyWCH4").read().strip()
  201. try:
  202. a_int = int(ttyWCH4)
  203. except ValueError:
  204. return False, "Invalid output ttyWCH4: {}".format(ttyWCH4)
  205. if a_int == 1:
  206. pass
  207. else:
  208. return False, "FAIL " + "Error! No Device found! ttyWCH4"
  209. ttyWCH5 = os.popen("sh serialport-test.sh /dev/ttyWCH5").read().strip()
  210. try:
  211. a_int = int(ttyWCH5)
  212. except ValueError:
  213. return False, "Invalid output ttyWCH5: {}".format(ttyWCH5)
  214. if a_int == 1:
  215. pass
  216. else:
  217. return False, "FAIL " + "Error! No Device found! ttyWCH5"
  218. ttyWCH6 = os.popen("sh serialport-test.sh /dev/ttyWCH6").read().strip()
  219. try:
  220. a_int = int(ttyWCH6)
  221. except ValueError:
  222. return False, "Invalid output ttyWCH6: {}".format(ttyWCH6)
  223. if a_int == 1:
  224. pass
  225. else:
  226. return False, "FAIL " + "Error! No Device found! ttyWCH6"
  227. ttyWCH7 = os.popen("sh serialport-test.sh /dev/ttyWCH7").read().strip()
  228. try:
  229. a_int = int(ttyWCH7)
  230. except ValueError:
  231. return False, "Invalid output ttyWCH7: {}".format(ttyWCH7)
  232. if a_int == 1:
  233. pass
  234. else:
  235. return False, "FAIL " + "Error! No Device found! ttyWCH7"
  236. return True, "PASS"
  237. def step11_routine(context):
  238. return True, 'AAPASS'
  239. #serialB
  240. a = os.popen("sh pcie.sh").read().strip()
  241. time.sleep(1)
  242. ttyWCH8 = os.popen("sh serialport-test.sh /dev/ttyWCH8").read().strip()
  243. try:
  244. a_int = int(ttyWCH8)
  245. except ValueError:
  246. return False, "Invalid output ttyWCH8: {}".format(ttyWCH8)
  247. if a_int == 1:
  248. pass
  249. else:
  250. return False, "FAIL " + "Error! No Device found! ttyWCH8"
  251. ttyWCH9 = os.popen("sh serialport-test.sh /dev/ttyWCH9").read().strip()
  252. try:
  253. a_int = int(ttyWCH9)
  254. except ValueError:
  255. return False, "Invalid output ttyWCH9: {}".format(ttyWCH9)
  256. if a_int == 1:
  257. pass
  258. else:
  259. return False, "FAIL " + "Error! No Device found! ttyWCH9"
  260. ttyWCH10 = os.popen("sh serialport-test.sh /dev/ttyWCH10").read().strip()
  261. try:
  262. a_int = int(ttyWCH10)
  263. except ValueError:
  264. return False, "Invalid output ttyWCH10: {}".format(ttyWCH10)
  265. if a_int == 1:
  266. pass
  267. else:
  268. return False, "FAIL " + "Error! No Device found! ttyWCH10"
  269. ttyWCH11 = os.popen("sh serialport-test.sh /dev/ttyWCH11").read().strip()
  270. try:
  271. a_int = int(ttyWCH11)
  272. except ValueError:
  273. return False, "Invalid output ttyWCH11: {}".format(ttyWCH11)
  274. if a_int == 1:
  275. pass
  276. else:
  277. return False, "FAIL " + "Error! No Device found! ttyWCH11"
  278. ttyWCH12 = os.popen("sh serialport-test.sh /dev/ttyWCH12").read().strip()
  279. try:
  280. a_int = int(ttyWCH12)
  281. except ValueError:
  282. return False, "Invalid output ttyWCH12: {}".format(ttyWCH12)
  283. if a_int == 1:
  284. pass
  285. else:
  286. return False, "FAIL " + "Error! No Device found! ttyWCH12"
  287. ttyWCH13 = os.popen("sh serialport-test.sh /dev/ttyWCH13").read().strip()
  288. try:
  289. a_int = int(ttyWCH13)
  290. except ValueError:
  291. return False, "Invalid output ttyWCH13: {}".format(ttyWCH13)
  292. if a_int == 1:
  293. pass
  294. else:
  295. return False, "FAIL " + "Error! No Device found! ttyWCH13"
  296. ttyWCH14 = os.popen("sh serialport-test.sh /dev/ttyWCH14").read().strip()
  297. try:
  298. a_int = int(ttyWCH14)
  299. except ValueError:
  300. return False, "Invalid output ttyWCH14: {}".format(ttyWCH14)
  301. if a_int == 1:
  302. pass
  303. else:
  304. return False, "FAIL " + "Error! No Device found! ttyWCH14"
  305. ttyWCH15 = os.popen("sh serialport-test.sh /dev/ttyWCH15").read().strip()
  306. try:
  307. a_int = int(ttyWCH15)
  308. except ValueError:
  309. return False, "Invalid output ttyWCH15: {}".format(ttyWCH15)
  310. if a_int == 1:
  311. pass
  312. else:
  313. return False, "FAIL " + "Error! No Device found! ttyWCH15"
  314. return True, "PASS"
  315. def step12_routine(context):
  316. #serialC
  317. ttyS0 = os.popen("sh serialport-test.sh /dev/ttyS0").read().strip()
  318. try:
  319. a_int = int(ttyS0)
  320. except ValueError:
  321. return False, "Invalid output ttyS0: {}".format(ttyS0)
  322. if a_int == 1:
  323. pass
  324. else:
  325. return False, "FAIL " + "Error! No Device found! ttyS0"
  326. ttyS1 = os.popen("sh serialport-test.sh /dev/ttyS1").read().strip()
  327. try:
  328. a_int = int(ttyS1)
  329. except ValueError:
  330. return False, "Invalid output ttyS1: {}".format(ttyS1)
  331. if a_int == 1:
  332. pass
  333. else:
  334. return False, "FAIL " + "Error! No Device found! ttyS1"
  335. ttyS2 = os.popen("sh serialport-test.sh /dev/ttyS2").read().strip()
  336. try:
  337. a_int = int(ttyS2)
  338. except ValueError:
  339. return False, "Invalid output ttyS2: {}".format(ttyS2)
  340. if a_int == 1:
  341. pass
  342. else:
  343. return False, "FAIL " + "Error! No Device found! ttyS2"
  344. ttyS3 = os.popen("sh serialport-test.sh /dev/ttyS3").read().strip()
  345. try:
  346. a_int = int(ttyS3)
  347. except ValueError:
  348. return False, "Invalid output ttyS3: {}".format(ttyS3)
  349. if a_int == 1:
  350. pass
  351. else:
  352. return False, "FAIL " + "Error! No Device found! ttyS3"
  353. # ttyS4 = os.popen("sh serialport-test.sh /dev/ttyS4").read().strip()
  354. # try:
  355. # a_int = int(ttyS4)
  356. # except ValueError:
  357. # return False, "Invalid output ttyS4: {}".format(ttyS4)
  358. # if a_int == 1:
  359. # pass
  360. # else:
  361. # return False, "FAIL " + "Error! No Device found! ttyS4"
  362. # ttyS5 = os.popen("sh serialport-test.sh /dev/ttyS5").read().strip()
  363. # try:
  364. # a_int = int(ttyS5)
  365. # except ValueError:
  366. # return False, "Invalid output ttyS5: {}".format(ttyS5)
  367. # if a_int == 1:
  368. # pass
  369. # else:
  370. # return False, "FAIL " + "Error! No Device found! ttyS5"
  371. ttyS6 = os.popen("sh serialport-test.sh /dev/ttyS6").read().strip()
  372. try:
  373. a_int = int(ttyS6)
  374. except ValueError:
  375. return False, "Invalid output ttyS6: {}".format(ttyS6)
  376. if a_int == 1:
  377. pass
  378. else:
  379. return False, "FAIL " + "Error! No Device found! ttyS6"
  380. ttyS7 = os.popen("sh serialport-test.sh /dev/ttyS7").read().strip()
  381. try:
  382. a_int = int(ttyS7)
  383. except ValueError:
  384. return False, "Invalid output ttyS7: {}".format(ttyS7)
  385. if a_int == 1:
  386. pass
  387. else:
  388. return False, "FAIL " + "Error! No Device found! ttyS7"
  389. return True, "PASS"
  390. def step13_routine(context):
  391. #LCD Test
  392. a = os.popen('./lcd/lcd/lcd_app | grep -c "LCD test completed"').read().replace('\n', '').replace('\r', '').strip()
  393. a = os.popen("sh serialport-test.sh /dev/a").read().strip()
  394. try:
  395. a_int = int(a)
  396. except ValueError:
  397. return False, "Invalid output a: {}".format(a)
  398. if a_int == 1:
  399. return True, 'PASS-{}'.format(a)
  400. else:
  401. return False, "FAIL " + "Error! No Device found!"
  402. def step14_routine(context):
  403. #LED Test
  404. a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
  405. try:
  406. a_int = int(a)
  407. except ValueError:
  408. return False, "Invalid output: {}".format(a)
  409. if a_int == 1:
  410. return True, 'PASS-{}'.format(a)
  411. else:
  412. return False, "FAIL " + "Error! No Device found!"
  413. def step15_routine(context):
  414. a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
  415. try:
  416. a_int = int(a)
  417. except ValueError:
  418. return False, "Invalid output: {}".format(a)
  419. if a_int == 1:
  420. return True, 'PASS-{}'.format(a)
  421. else:
  422. return False, "FAIL " + "Error! No Device found!"
  423. def step16_routine(context):
  424. return True, 'AAPASS'
  425. # a = os.popen("sh os-ver.sh USB394").read().replace('\n', '').replace('\r', '').strip()
  426. # if a == "0":
  427. # return False, "Error! No Device found!\n" + a
  428. # else:
  429. # return True, 'PASS-{}'.format(a)
  430. def step17_routine(context):
  431. # network speed cli
  432. return True, 'AAPASS'
  433. a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
  434. if len(a) == 0:
  435. return False, "Error! No Device found!\n" + a
  436. elif a == "Download: Upload:":
  437. return False, "Error! no ethernet!\n" + a
  438. else:
  439. return True, 'PASS-{}'.format(a)
  440. def step18_routine(context):
  441. a = os.popen("sh beep.sh").read().replace('\n', '').replace('\r', '').strip()
  442. if tkMessageBox.askokcancel("PASS?", "测试蜂鸣器是否正常."):
  443. # if ask_choice_with_timeout("PASS?", "测试蜂鸣器是否正常.",30):
  444. return True, 'PASS'
  445. else:
  446. return False, "FAIL"
  447. def step19_routine(context):
  448. return True, 'AAPASS'
  449. def step20_routine(context):
  450. return True, 'AAPASS'
  451. def step21_routine(context):
  452. a = os.popen("sh seven_segment_display.sh").read().replace('\n', '').replace('\r', '').strip()
  453. if tkMessageBox.askokcancel("PASS?", "测试数码管是否正常."):
  454. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  455. return True, 'PASS'
  456. else:
  457. return False, "FAIL"
  458. def step22_routine(context):
  459. return True, 'AAPASS'
  460. def step23_routine(context):
  461. return True, 'AAPASS'
  462. def step24_routine(context):
  463. return True, 'AAPASS'
  464. def step25_routine(context):
  465. return True, 'AAPASS'
  466. def step26_routine(context):
  467. return True, 'AAPASS'
  468. def step27_routine(context):
  469. a = os.popen("bash ./gsensor-SC7A20H/C180_gsensor_function_script.sh | grep -c \"pass\"").read().replace('\n', '').replace('\r', '').strip()
  470. try:
  471. a_int = int(a)
  472. except ValueError:
  473. return False, "Invalid output: {}".format(a)
  474. if a_int == 1:
  475. return True, 'PASS-{}'.format(a)
  476. else:
  477. return False, "FAIL " + "Error! No Device found!"
  478. def step28_routine(context):
  479. return True, 'AAPASS'
  480. def step29_routine(context):
  481. a = os.popen("sh display.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
  482. a = os.popen("find ./test_picture/ -name '*.jpg' | wc -l").read().strip()
  483. try:
  484. a_int = int(a)
  485. except ValueError:
  486. return False, "Invalid output: {}".format(a)
  487. if a_int >= 0:
  488. return True, 'PASS-{}'.format(a)
  489. else:
  490. return False, "FAIL " + "Error! No Device found!"
  491. def step30_routine(context):
  492. a = os.popen("sh fio.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
  493. try:
  494. a_int = int(a)
  495. except ValueError:
  496. return False, "Invalid output: {}".format(a)
  497. if a_int >= 0:
  498. return True, 'PASS-{}'.format(a)
  499. else:
  500. return False, "FAIL " + "Error! No Device found!"
  501. def step31_routine(context):
  502. a = os.popen("sh os-ver.sh speaker | wc -l").read().replace('\n', '').replace('\r', '').strip()
  503. try:
  504. a_int = int(a)
  505. except ValueError:
  506. return False, "Invalid output: {}".format(a)
  507. if a_int >= 0:
  508. return True, 'PASS-{}'.format(a)
  509. else:
  510. return False, "FAIL " + "Error! No Device found!"
  511. def step32_routine(context):
  512. a = os.popen("sh record_play.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
  513. a = os.popen("echo 111111 | sudo -S find /tmp/ -name 'my_recording.wav' 2>&1 | wc -l").read().strip()
  514. try:
  515. a_int = int(a)
  516. except ValueError:
  517. return False, "Invalid output: {}".format(a)
  518. if a_int >= 0:
  519. return True, 'PASS-{}'.format(a)
  520. else:
  521. return False, "FAIL " + "Error! No Device found!"
  522. def step33_routine(context):
  523. a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
  524. try:
  525. a_int = int(a)
  526. except ValueError:
  527. return False, "Invalid output: {}".format(a)
  528. if a_int == 1:
  529. return True, 'PASS-{}'.format(a)
  530. else:
  531. return False, "FAIL " + "Error! No Device found!"
  532. def step34_routine(context):
  533. #a = os.popen("/usr/bin/guvcview &").read().replace('\n', '').replace('\r', '').strip()
  534. os.system("/usr/bin/guvcview &")
  535. time.sleep(15)
  536. os.system("sh os-ver.sh exit &")
  537. return True, 'PASS'
  538. def step35_routine(context):
  539. #return True, 'AAPASS'
  540. a = os.popen("sh ./keyboard.sh 111111").read().replace('\n', '').replace('\r', '').strip()
  541. try:
  542. if len(a) == 1:
  543. return False, "FAIL " + "Error! No Device found! {}".format(a)
  544. elif a == "cashDrawer1: , cashDrawer2: ":
  545. return False, "FAIL " + "Error! no cashDrawer!"
  546. except ValueError:
  547. return False, "Invalid output: {}".format(a)
  548. if len(a) == 0:
  549. return True, 'PASS-{}'.format(a)
  550. else:
  551. return False, "FAIL " + "Error! No Device found!"
  552. def step36_routine(context):
  553. # network speed cli
  554. c = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
  555. try:
  556. c_int = int(c)
  557. except ValueError:
  558. return False, "Invalid output c: {}".format(c)
  559. if c_int != 1:
  560. return False, "FAIL " + "Error! No Device found!"
  561. a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
  562. if len(a) == 0:
  563. return False, "FAIL " + "Error! No Device found! {}".format(a)
  564. elif a == "Download: Upload:":
  565. return False, "FAIL " + "Error! no ethernet!"
  566. else:
  567. b = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
  568. try:
  569. b_int = int(b)
  570. except ValueError:
  571. return False, "Invalid output b: {}".format(b)
  572. if b_int == 1:
  573. return True, a
  574. else:
  575. return False, "FAIL " + "Error! No Device found! {}".format(a)
  576. def step37_routine(context):
  577. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read().replace('\n', '').replace('\r', '').strip()
  578. try:
  579. a_int = int(a)
  580. except ValueError:
  581. return False, "Invalid output: {}".format(a)
  582. if a_int >= 6:
  583. return True, 'PASS-{}'.format(a)
  584. else:
  585. return False, "FAIL " + "Error! No Device found!"
  586. def step38_routine(context):
  587. time.sleep(1)
  588. os.system("sh os-ver.sh 1080p &")
  589. time.sleep(15)
  590. os.system("sh os-ver.sh exit &")
  591. return True, 'PASS'
  592. def step39_routine(context):
  593. a = os.popen("sh ./cashDrawer_test.sh 111111 | tail -n 1").read().replace('\n', '').replace('\r', '').strip()
  594. try:
  595. if len(a) == 0:
  596. return False, "FAIL " + "Error! No Device found! {}".format(a)
  597. elif a == "cashDrawer1: , cashDrawer2: ":
  598. return False, "FAIL " + "Error! no cashDrawer!"
  599. except ValueError:
  600. return False, "Invalid output: {}".format(a)
  601. if len(a) > 0:
  602. return True, 'PASS-{}'.format(a)
  603. else:
  604. return False, "FAIL " + "Error! No Device found!"
  605. def step40_routine(context):
  606. #serialC
  607. ttyS0 = os.popen("sh serialport-test.sh /dev/ttyS0").read().strip()
  608. try:
  609. a_int = int(ttyS0)
  610. except ValueError:
  611. return False, "Invalid output ttyS0: {}".format(ttyS0)
  612. if a_int == 1:
  613. pass
  614. else:
  615. return False, "FAIL " + "Error! No Device found! ttyS0"
  616. ttyS1 = os.popen("sh serialport-test.sh /dev/ttyS1").read().strip()
  617. try:
  618. a_int = int(ttyS1)
  619. except ValueError:
  620. return False, "Invalid output ttyS1: {}".format(ttyS1)
  621. if a_int == 1:
  622. pass
  623. else:
  624. return False, "FAIL " + "Error! No Device found! ttyS1"
  625. ttyS2 = os.popen("sh serialport-test.sh /dev/ttyS2").read().strip()
  626. try:
  627. a_int = int(ttyS2)
  628. except ValueError:
  629. return False, "Invalid output ttyS2: {}".format(ttyS2)
  630. if a_int == 1:
  631. pass
  632. else:
  633. return False, "FAIL " + "Error! No Device found! ttyS2"
  634. ttyS3 = os.popen("sh serialport-test.sh /dev/ttyS3").read().strip()
  635. try:
  636. a_int = int(ttyS3)
  637. except ValueError:
  638. return False, "Invalid output ttyS3: {}".format(ttyS3)
  639. if a_int == 1:
  640. pass
  641. else:
  642. return False, "FAIL " + "Error! No Device found! ttyS3"
  643. ttyS6 = os.popen("sh serialport-test.sh /dev/ttyS6").read().strip()
  644. try:
  645. a_int = int(ttyS6)
  646. except ValueError:
  647. return False, "Invalid output ttyS6: {}".format(ttyS6)
  648. if a_int == 1:
  649. pass
  650. else:
  651. return False, "FAIL " + "Error! No Device found! ttyS6"
  652. ttyS7 = os.popen("sh serialport-test.sh /dev/ttyS7").read().strip()
  653. try:
  654. a_int = int(ttyS7)
  655. except ValueError:
  656. return False, "Invalid output ttyS7: {}".format(ttyS7)
  657. if a_int == 1:
  658. pass
  659. else:
  660. return False, "FAIL " + "Error! No Device found! ttyS7"
  661. return True, "PASS"
  662. def step41_routine(context):
  663. a = os.popen("bash usb_test.sh 111111 | grep -s 'PASSED' | wc -l").read().replace('\n', '').replace('\r', '').strip()
  664. #b = os.popen("bash usb_test.sh 111111").read().replace('\n', '').replace('\r', '').strip()
  665. try:
  666. a_int = int(a)
  667. except ValueError:
  668. return False, "Invalid output: {}".format(a)
  669. if a_int >= 1:
  670. return True, 'PASS-{}'.format(a)
  671. else:
  672. return False, "FAIL " + "Error! No Device found!"
  673. def step42_routine(context):
  674. a = os.popen("sh readsn.sh").read().replace('\n', '').replace('\r', '').strip()
  675. try:
  676. if len(a) == 0:
  677. return False, "Error! Serial Number is empty!\n" + a
  678. except ValueError:
  679. return False, "Invalid output: {}".format(a)
  680. if len(a) == 11:
  681. return True, 'PASS-{}'.format(a)
  682. else:
  683. return False, "FAIL " + "Error! No Device found!"
  684. def step43_routine(context):
  685. a = os.popen("/usr/bin/guvcview &").read().replace('\n', '').replace('\r', '').strip()
  686. if tkMessageBox.askokcancel("PASS?", "测试数码管是否正常."):
  687. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  688. return True, 'PASS'
  689. else:
  690. return False, "FAIL"
  691. def step44_routine(context):
  692. a = os.popen("sh os-ver.sh speaker").read().replace('\n', '').replace('\r', '').strip()
  693. if tkMessageBox.askokcancel("PASS?", "测试喇叭是否正常."):
  694. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  695. return True, 'PASS'
  696. else:
  697. return False, "FAIL"
  698. def step45_routine(context):
  699. a = os.popen("sh os-ver.sh arecord").read().replace('\n', '').replace('\r', '').strip()
  700. if tkMessageBox.askokcancel("PASS?", "测试Microphone_Test是否正常."):
  701. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  702. return True, 'PASS'
  703. else:
  704. return False, "FAIL"
  705. def step46_routine(context):
  706. a = os.popen("sh lightRing.sh").read().replace('\n', '').replace('\r', '').strip()
  707. if tkMessageBox.askokcancel("PASS?", "测试确定LEDBlinking是否正常?"):
  708. # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
  709. return True, 'PASS'
  710. else:
  711. return False, "FAIL"
  712. def step47_routine(context):
  713. a = os.popen("xinput --list | grep -c 'TouchScreen'").read().replace('\n', '').replace('\r', '').strip()
  714. try:
  715. a_int = int(a)
  716. except ValueError:
  717. return False, "Invalid output: {}".format(a)
  718. if a_int >= 1:
  719. return True, 'PASS-{}'.format(a)
  720. else:
  721. return False, "FAIL " + "Error! No Device found!"