monitor_test_results.sh 820 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/busybox sh
  2. # 串口文件路径
  3. SERIAL_FILE="serial_opt.txt"
  4. # qemu进程PID
  5. QEMU_PID=${QEMU_PID}
  6. # 清空串口输出日志文件
  7. > "$SERIAL_FILE"
  8. # 资源清理函数
  9. clean_up() {
  10. kill -9 $QEMU_PID
  11. stty sane 2>/dev/null
  12. }
  13. # 每隔10s查看qemu串口输出日志文件serial_opt.txt后100行是否包含“测试完成”
  14. while true; do
  15. sleep 10
  16. tail -n 100 "$SERIAL_FILE" | grep -a "测试完成" && break
  17. done
  18. # 提取成功率
  19. success_rate=$(grep -a "成功率" "$SERIAL_FILE" | awk -F'[:%]' '{gsub(/ /,""); print $2}')
  20. # 比较是否等于100
  21. if [ "$success_rate" = "100.00" ]; then
  22. echo "syscall测试通过, 成功率为 ${success_rate}%"
  23. clean_up
  24. stty sane 2>/dev/null
  25. exit 0
  26. else
  27. echo "syscall测试失败, 成功率为 ${success_rate}%"
  28. clean_up
  29. exit 1
  30. fi