K1Guitar/tools/k1_harness/suites/ble_smoke.py

29 lines
1005 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""ble 套件BLE 链路 smoke连接 + BLE-MIDI framing + 少量协议往返)."""
from __future__ import annotations
import os
import subprocess
import sys
from ..paths import TOOLS_DIR
from .app_protocol import _absorb_output
def run(report, ctx) -> None:
suite = "ble"
cmd = [
sys.executable, os.path.join(TOOLS_DIR, "test_protocol_ble.py"),
"--transport", "midi", "--smoke", "--no-unpair",
]
try:
proc = subprocess.run(cmd, capture_output=True, text=True, timeout=180)
except subprocess.TimeoutExpired:
report.add(suite, "BLE smoke", "FAIL", "timeout 180s设备未广播/未配对?)")
return
before = len(report.cases)
_absorb_output(report, suite, proc.stdout, proc.stderr or "")
new = report.cases[before:]
if not any(c.status == "FAIL" for c in new) and proc.returncode != 0:
report.add(suite, "BLE smoke 退出码", "FAIL", f"exit={proc.returncode} {proc.stderr[-300:]}")