Keep live TUI output raw under retransmit pressure
ci / test (push) Has been cancelled
ci / fuzz-smoke (push) Has been cancelled
ci / windows-client (push) Has been cancelled
ci / package-release (linux-x86_64, ubuntu-latest) (push) Has been cancelled
ci / package-release (macos-aarch64, macos-14) (push) Has been cancelled
ci / package-release (macos-x86_64, macos-13) (push) Has been cancelled
ci / package-release (windows-x86_64, windows-latest) (push) Has been cancelled
ci / remote-bench (push) Has been cancelled
ci / test (push) Has been cancelled
ci / fuzz-smoke (push) Has been cancelled
ci / windows-client (push) Has been cancelled
ci / package-release (linux-x86_64, ubuntu-latest) (push) Has been cancelled
ci / package-release (macos-aarch64, macos-14) (push) Has been cancelled
ci / package-release (macos-x86_64, macos-13) (push) Has been cancelled
ci / package-release (windows-x86_64, windows-latest) (push) Has been cancelled
ci / remote-bench (push) Has been cancelled
This commit is contained in:
@@ -112,6 +112,21 @@ fn write_server_config_with_output_interval(
|
||||
config
|
||||
}
|
||||
|
||||
fn write_server_config_with_retransmit_window(
|
||||
dir: &tempfile::TempDir,
|
||||
port: u16,
|
||||
retransmit_window: u64,
|
||||
) -> std::path::PathBuf {
|
||||
let config = write_server_config(dir, port);
|
||||
let mut raw = fs::read_to_string(&config).unwrap();
|
||||
raw = raw.replace(
|
||||
"retransmit_window = 256\n",
|
||||
&format!("retransmit_window = {retransmit_window}\n"),
|
||||
);
|
||||
fs::write(&config, raw).unwrap();
|
||||
config
|
||||
}
|
||||
|
||||
fn start_server(dir: &tempfile::TempDir, config: &std::path::Path) -> Child {
|
||||
let server = env!("CARGO_BIN_EXE_dosh-server");
|
||||
let child = Command::new(server)
|
||||
@@ -1694,6 +1709,69 @@ fn tui_graph_glyphs_survive_fast_repaints_without_snapshot_substitution() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn btop_style_graph_output_stays_raw_when_retransmit_history_overflows() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let port = free_udp_port();
|
||||
let config = write_server_config_with_retransmit_window(&dir, port, 3);
|
||||
let mut server = start_server(&dir, &config);
|
||||
let (socket, bootstrap, ok) = direct_attach(&config, port, "read-write");
|
||||
|
||||
let graph = "DOSH_BTOP_NET ⠀⠁⠃⠇⡇⣇⣧⣷⣿";
|
||||
let input = Input {
|
||||
bytes: format!(
|
||||
"stty -echo; \
|
||||
printf '\\033[?1049h\\033[?2026h\\033[?25l'; \
|
||||
for i in 1 2 3 4 5 6 7 8 9 10; do \
|
||||
printf '\\033[6;4H\\033[38;2;80;220;140m{} %s\\033[0m' \"$i\"; \
|
||||
done; \
|
||||
printf '\\033[?25h\\033[?2026l\\033[?1049l'\n",
|
||||
graph
|
||||
)
|
||||
.into_bytes(),
|
||||
};
|
||||
send_encrypted(
|
||||
&socket,
|
||||
port,
|
||||
PacketKind::Input,
|
||||
ok.client_id,
|
||||
2,
|
||||
0,
|
||||
&bootstrap.session_key,
|
||||
&protocol::to_body(&input).unwrap(),
|
||||
);
|
||||
|
||||
let mut text = String::new();
|
||||
let mut snapshots = 0usize;
|
||||
let deadline = std::time::Instant::now() + Duration::from_secs(3);
|
||||
while std::time::Instant::now() < deadline
|
||||
&& !(text.matches("DOSH_BTOP_NET").count() >= 10 && text.contains("\x1b[?2026l"))
|
||||
{
|
||||
if let Some((_header, frame)) = recv_frame(&socket, &bootstrap.session_key) {
|
||||
if frame.snapshot {
|
||||
snapshots += 1;
|
||||
}
|
||||
text.push_str(&String::from_utf8_lossy(&frame.bytes));
|
||||
}
|
||||
}
|
||||
|
||||
let _ = server.kill();
|
||||
let _ = server.wait();
|
||||
|
||||
assert_eq!(
|
||||
snapshots, 0,
|
||||
"live btop-style graph output must not be replaced by snapshots; got {snapshots}"
|
||||
);
|
||||
assert!(
|
||||
text.matches("DOSH_BTOP_NET").count() >= 10
|
||||
&& text.contains("⣿")
|
||||
&& text.contains("\x1b[38;2;80;220;140m")
|
||||
&& text.contains("\x1b[?2026h")
|
||||
&& text.contains("\x1b[?2026l"),
|
||||
"expected raw btop-style graph output to survive under retransmit pressure, got {text:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn large_tui_paint_is_delivered_in_mtu_safe_frames() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user