remote/scripts/linux-smoke.sh
yu bae871c78c fix(linux-agent): 修正坐标换算单测期望值 + 冒烟脚本纳入单测
- scale(32768,1920) 期望值应为 959(32768×1919÷65535=959.49 向下取整),
  原写成 960 —— 是**测试期望值错**,实现本身正确(0→0、65535→extents-1 均通过);
  集成测试因带 ±2 像素容差未能暴露,是跑单测才抓到的
- scripts/linux-smoke.sh 原先只跑 --test smoke,漏掉 --bins 单测;现两层都跑
- 手册 §8.4 说明补充单测这一层及其必要性

验证:bash scripts/linux-smoke.sh → 单测 4 passed + 端到端 2 passed
2026-10-23 15:04:56 +08:00

52 lines
1.5 KiB
Bash
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.

#!/usr/bin/env bash
# Linux 被控端冒烟测试一键脚本:自建 Xvfb 虚拟显示 → 跑端到端测试 → 收摊。
#
# 用法(容器内或任意有 Xvfb 的 Linux):
# bash scripts/linux-smoke.sh
# 可用环境变量覆盖:
# SMOKE_SCREEN=1920x1080 虚拟屏分辨率(默认 1280x720)
# SMOKE_DISPLAY=:99 X display 编号(默认 :99)
set -euo pipefail
SCREEN="${SMOKE_SCREEN:-1280x720}"
DISPLAY_NUM="${SMOKE_DISPLAY:-:99}"
export DISPLAY="$DISPLAY_NUM"
export SMOKE_SCREEN="$SCREEN"
XVFB_PID=""
cleanup() {
if [ -n "$XVFB_PID" ]; then
kill "$XVFB_PID" 2>/dev/null || true
wait "$XVFB_PID" 2>/dev/null || true
fi
}
trap cleanup EXIT
echo "[smoke] 启动 Xvfb $DISPLAY_NUM (${SCREEN}x24)"
Xvfb "$DISPLAY_NUM" -screen 0 "${SCREEN}x24" -nolisten tcp >/tmp/xvfb.log 2>&1 &
XVFB_PID=$!
ready=0
for _ in $(seq 1 50); do
if xdpyinfo -display "$DISPLAY_NUM" >/dev/null 2>&1; then
ready=1
break
fi
sleep 0.2
done
if [ "$ready" -ne 1 ]; then
echo "[smoke] Xvfb 启动失败,日志:"
cat /tmp/xvfb.log 2>/dev/null || true
exit 1
fi
echo "[smoke] X server 就绪:$(xdpyinfo -display "$DISPLAY_NUM" | grep -E 'dimensions' | head -1)"
# 先跑纯逻辑单测(键码映射 / 坐标换算),不需要 X server
cargo test -p linux-agent --bins
# 再跑端到端用例:两个用例共用同一块虚拟屏与指针,必须串行
cargo test -p linux-agent --test smoke -- --nocapture --test-threads=1
echo "[smoke] 通过"