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
This commit is contained in:
yu 2026-10-23 15:04:56 +08:00
parent 49f85db9f9
commit bae871c78c
3 changed files with 16 additions and 5 deletions

View File

@ -242,8 +242,10 @@ mod tests {
#[test] #[test]
fn coordinate_scaling_covers_full_range() { fn coordinate_scaling_covers_full_range() {
assert_eq!(scale(0, 1920), 0); assert_eq!(scale(0, 1920), 0);
// 归一化上界必须映射到 extent-1,否则指针永远到不了屏幕最右/最下
assert_eq!(scale(65535, 1920), 1919); assert_eq!(scale(65535, 1920), 1919);
assert_eq!(scale(32768, 1920), 960); // 中点:32768 × 1919 ÷ 65535 = 959.49…,整数除法向下取整 → 959
assert_eq!(scale(32768, 1920), 959);
assert_eq!(scale(12345, 0), 0); // 退化尺寸不 panic assert_eq!(scale(12345, 0), 0); // 退化尺寸不 panic
} }
} }

View File

@ -43,6 +43,9 @@ if [ "$ready" -ne 1 ]; then
fi fi
echo "[smoke] X server 就绪:$(xdpyinfo -display "$DISPLAY_NUM" | grep -E 'dimensions' | head -1)" 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 cargo test -p linux-agent --test smoke -- --nocapture --test-threads=1
echo "[smoke] 通过" echo "[smoke] 通过"

View File

@ -167,9 +167,15 @@ viewer.exe --addr <被控机IP> --port 47800 --code 123456
bash scripts/linux-smoke.sh bash scripts/linux-smoke.sh
``` ```
脚本自建 Xvfb 虚拟屏后跑端到端测试,覆盖:X11 采集 → openh264 编码 → QUIC 下行解帧、 脚本自建 Xvfb 虚拟屏后跑**单测 + 端到端**两层:
验证码认证(含**错误验证码被拒**)、Ping/Pong(含下行丢包统计字段)、静止桌面下的关键帧
恢复,以及**输入注入实证**——注入鼠标移动后,从另一条 X11 连接读回指针真实坐标。 - 单测(不需要 X server):键码映射、坐标换算等纯逻辑;
- 端到端:X11 采集 → openh264 编码 → QUIC 下行解帧、验证码认证(含**错误验证码被拒**)、
Ping/Pong(含下行丢包统计字段)、静止桌面下的关键帧恢复,以及**输入注入实证**——
注入鼠标移动后,从另一条 X11 连接读回指针真实坐标。
> 单测那层别省:坐标换算的取整边界就是靠它才发现的(集成测试有 ±2 像素容差,
> 期望值写错也照样绿)。
> 静止关键帧那条用例做过**变异测试**:把修复退回会失败、恢复后通过,确认断言不是摆设。 > 静止关键帧那条用例做过**变异测试**:把修复退回会失败、恢复后通过,确认断言不是摆设。
> 注意扰动量必须小(画 64x64 小方块)——整屏刷白会触发编码器场景切换自动 IDR, > 注意扰动量必须小(画 64x64 小方块)——整屏刷白会触发编码器场景切换自动 IDR,