2026-09-14 15:05:17 +08:00
|
|
|
|
# -*- 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)
|
2026-09-14 21:49:37 +08:00
|
|
|
|
_absorb_output(report, suite, proc.stdout, proc.stderr or "")
|
2026-09-14 15:05:17 +08:00
|
|
|
|
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:]}")
|