Expand description
BabbleSim + Zephyr nRF RPC simulation bridge.
This crate provides three things:
- Test harness (
spawn_zephyr_rpc_server_with_socat) — spawn a full BabbleSim simulation from Rust integration tests. - xtask CLI (
xtask::cli_main) — docker, zephyr-setup, and run-bsim commands that downstream crates can re-export. - Programmatic setup API (
xtask::fetch_prebuilt_binaries,xtask::zephyr_setup) — call from a downstreambuild.rsor any Rust code without shelling out.
§Test harness usage
use std::collections::HashSet;
use std::os::unix::net::UnixStream;
use std::path::Path;
use std::time::Duration;
use babble_bridge::LogOutput;
let tests_dir = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/sockets"));
let (mut processes, socket_path) =
babble_bridge::spawn_zephyr_rpc_server_with_socat(tests_dir, "my_test", LogOutput::Off);
// socat is spawned but may not be listening yet — retry until connectable.
let start = std::time::Instant::now();
let _socket = loop {
match UnixStream::connect(&socket_path) {
Ok(s) => break s,
Err(_) if start.elapsed() < Duration::from_secs(5) => {
std::thread::sleep(Duration::from_millis(50));
}
Err(e) => panic!("socket never became connectable: {e}"),
}
};
// … write/read via _socket …
processes.search_stdout_for_strings(HashSet::from([
"<inf> nrf_ps_server: Initializing RPC server",
]));Modules§
- xtask
- Xtask commands (docker, zephyr-setup, run-bsim) and programmatic API.
Structs§
- Test
Processes - Owns all child processes spawned for a single simulation run and accumulates their stdout output for later inspection.
Enums§
- LogOutput
- Controls where the simulation process output (stdout/stderr) is forwarded
when
spawn_zephyr_rpc_server_with_socatis called.
Functions§
- spawn_
zephyr_ rpc_ server_ with_ socat tests_dir/<test_name>.sock.