Initial import: ICE-NET research docs and Rust workspace (v0.4)
Some checks failed
rust-ci / checks (push) Has been cancelled
Some checks failed
rust-ci / checks (push) Has been cancelled
- Rust workspace: 7 library crates, icenetd CLI, icenet-city (Slint GUI) - Sim: fix false Delivered after a route cut, derive traffic class from payload size, per-link airtime slots (link capacity, queueing) - Docs: single docs/STATUS.md for all figures, remove v0.2/egui leftovers, drop unimplemented seed claims, uncheck store-and-forward - License: LGPL-3.0-or-later (LICENSE, LICENSES/GPL-3.0.txt)
This commit is contained in:
commit
2e61688eb3
141 changed files with 13993 additions and 0 deletions
75
workspace/apps/icenetd/tests/udp_cli.rs
Normal file
75
workspace/apps/icenetd/tests/udp_cli.rs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
//! Process-to-process UDP tests for `icenetd send-udp` and `icenetd serve`.
|
||||
mod common;
|
||||
|
||||
use std::io::{BufRead, BufReader, Read};
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
use common::{run, stderr, stdout};
|
||||
|
||||
#[test]
|
||||
fn serve_and_send_udp_exchange_a_frame() {
|
||||
let mut server = Command::new(env!("CARGO_BIN_EXE_icenetd"))
|
||||
.args([
|
||||
"serve",
|
||||
"--bind",
|
||||
"127.0.0.1:0",
|
||||
"--count",
|
||||
"1",
|
||||
"--timeout",
|
||||
"5000",
|
||||
])
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.expect("serve starts");
|
||||
|
||||
let stdout_pipe = server.stdout.take().expect("server stdout");
|
||||
let mut reader = BufReader::new(stdout_pipe);
|
||||
let mut first_line = String::new();
|
||||
reader.read_line(&mut first_line).expect("listening line");
|
||||
let address = first_line
|
||||
.trim()
|
||||
.strip_prefix("listening: ")
|
||||
.expect("listening address")
|
||||
.to_owned();
|
||||
|
||||
let sent = run(&[
|
||||
"send-udp",
|
||||
"--to",
|
||||
&address,
|
||||
"--service",
|
||||
"77777",
|
||||
"--class",
|
||||
"text",
|
||||
"--text",
|
||||
"hello-udp",
|
||||
]);
|
||||
assert!(sent.status.success(), "stderr: {}", stderr(&sent));
|
||||
assert!(stdout(&sent).contains("sent:"));
|
||||
|
||||
let mut received = String::new();
|
||||
reader.read_to_string(&mut received).expect("server output");
|
||||
let status = server.wait().expect("server exits");
|
||||
assert!(status.success(), "server stderr: {received}");
|
||||
assert!(
|
||||
received.contains("service=77777 class=Text bytes=9 payload=hello-udp"),
|
||||
"received: {received}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serve_times_out_when_no_frames_arrive() {
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_icenetd"))
|
||||
.args(["serve", "--bind", "127.0.0.1:0", "--timeout", "200"])
|
||||
.output()
|
||||
.expect("serve starts");
|
||||
assert_eq!(output.status.code(), Some(1));
|
||||
assert!(stderr(&output).contains("timeout after"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_udp_rejects_invalid_addresses() {
|
||||
let output = run(&["send-udp", "--to", "not-an-address", "--text", "hello"]);
|
||||
assert_eq!(output.status.code(), Some(2));
|
||||
assert!(stderr(&output).contains("invalid socket address"));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue