K1Guitar/tools/k1_harness/suites/ble_smoke.py

29 lines
986 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- 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)
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:]}")