test: clearer BLE scan FAIL; RTT reset; longer UI ACK timeouts
Report missing Smart Guitar MIDI as an explicit FAIL instead of parse noise, reset target when opening RTT sessions, and give ui boot/charge more ACK time for LCD draws. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4c6e2122ed
commit
cae4eb84a1
|
|
@ -17,7 +17,7 @@ from ..paths import TOOLS_DIR
|
|||
ROW_RE = re.compile(r"^\[(PASS|FAIL|SKIP|SENT)\s*\]\s*(.+?)(?:\s*\|\s*(.*))?$")
|
||||
|
||||
|
||||
def _absorb_output(report, suite: str, text: str) -> None:
|
||||
def _absorb_output(report, suite: str, text: str, stderr: str = "") -> None:
|
||||
n = 0
|
||||
for line in text.splitlines():
|
||||
m = ROW_RE.match(line.strip())
|
||||
|
|
@ -25,7 +25,16 @@ def _absorb_output(report, suite: str, text: str) -> None:
|
|||
report.add(suite, m.group(2), m.group(1), m.group(3) or "")
|
||||
n += 1
|
||||
if n == 0:
|
||||
tail = "\\n".join(text.splitlines()[-5:])
|
||||
blob = (text or "") + "\n" + (stderr or "")
|
||||
if "未找到设备" in blob or "扫描 BLE" in blob:
|
||||
report.add(
|
||||
suite,
|
||||
"BLE 扫描连接",
|
||||
"FAIL",
|
||||
"未发现 Smart Guitar MIDI(确认已开机且蓝牙开;勿在软关机态跑 BLE)",
|
||||
)
|
||||
return
|
||||
tail = "\\n".join((text or "").splitlines()[-5:])
|
||||
report.add(suite, "子进程输出解析", "FAIL", f"未找到结果行;tail: {tail}")
|
||||
|
||||
|
||||
|
|
@ -56,6 +65,6 @@ def run(report, ctx) -> None:
|
|||
if ctx.allow_poweroff:
|
||||
cmd.append("--allow-poweroff")
|
||||
proc = subprocess.run(cmd, capture_output=True, text=True, timeout=600)
|
||||
_absorb_output(report, suite, proc.stdout)
|
||||
_absorb_output(report, suite, proc.stdout, proc.stderr or "")
|
||||
if proc.returncode != 0 and not any(c.suite == suite and c.status == "FAIL" for c in report.cases):
|
||||
report.add(suite, "BLE 协议子进程", "FAIL", f"exit={proc.returncode} {proc.stderr[-300:]}")
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ def run(report, ctx) -> None:
|
|||
report.add(suite, "BLE smoke", "FAIL", "timeout 180s(设备未广播/未配对?)")
|
||||
return
|
||||
before = len(report.cases)
|
||||
_absorb_output(report, suite, proc.stdout)
|
||||
_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:]}")
|
||||
|
|
|
|||
|
|
@ -68,9 +68,11 @@ def run(report, ctx) -> None:
|
|||
else:
|
||||
report.add(SUITE, "TAP 后页面状态", "FAIL", "TAP 后 log status 无响应")
|
||||
|
||||
for cmd, ack, name in (("ui boot", "UI_BOOT_OK", "开机画面绘制"),
|
||||
("ui charge", "UI_CHARGE_", "充电画面绘制")):
|
||||
ok = sess.cmd_ack(cmd, ack, timeout_s=3.0, retries=3)
|
||||
for cmd, ack, name, to in (
|
||||
("ui boot", "UI_BOOT_OK", "开机画面绘制", 5.0),
|
||||
("ui charge", "UI_CHARGE_", "充电画面绘制", 15.0),
|
||||
):
|
||||
ok = sess.cmd_ack(cmd, ack, timeout_s=to, retries=3)
|
||||
report.add(SUITE, name, "PASS" if ok else "FAIL", "" if ok else f"无 {ack}*")
|
||||
|
||||
if tap_ack:
|
||||
|
|
|
|||
|
|
@ -18,11 +18,22 @@ CheckResult = _rtt.CheckResult
|
|||
|
||||
|
||||
@contextmanager
|
||||
def open_session(device: str = "AT32F403AC"):
|
||||
"""连接 J-Link + 启动 RTT,yield RttSession;退出时清理."""
|
||||
def open_session(device: str = "AT32F403AC", *, reset: bool = True):
|
||||
"""连接 J-Link + 启动 RTT,yield RttSession;退出时清理.
|
||||
|
||||
reset=True:先硬件复位并等待开机,避免前序 LCD/烧写把主循环卡死导致无 ACK。
|
||||
"""
|
||||
import time
|
||||
|
||||
_rtt.import_deps()
|
||||
jlink = connect_jlink(device)
|
||||
try:
|
||||
if reset:
|
||||
try:
|
||||
jlink.reset(halt=False)
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(5.0)
|
||||
cb = find_rtt_control_block(jlink)
|
||||
if cb is None:
|
||||
raise SystemExit("SEGGER RTT control block 未找到(固件未运行?)")
|
||||
|
|
|
|||
|
|
@ -424,12 +424,19 @@ def main():
|
|||
sys.exit("缺少 bleak: pip install bleak")
|
||||
|
||||
print(f"选项: unpair={args.unpair} transport={args.transport}")
|
||||
try:
|
||||
sim = BleMidiSim(
|
||||
name=args.ble_name,
|
||||
address=args.ble_address,
|
||||
transport=args.transport,
|
||||
unpair=args.unpair,
|
||||
)
|
||||
except Exception as exc:
|
||||
R = Results()
|
||||
R.add("BLE 扫描连接", "FAIL", str(exc))
|
||||
R.summary()
|
||||
print(f"[FAIL] BLE 扫描连接 | {exc}")
|
||||
sys.exit(1)
|
||||
print(
|
||||
f"=== BLE 测试: {sim.info.get('name')} ({sim.info.get('address')}) "
|
||||
f"transport={sim.info.get('transport')} payload={sim.info.get('max_payload')} ==="
|
||||
|
|
|
|||
Loading…
Reference in New Issue