Skip to main content

Crate babble_bridge

Crate babble_bridge 

Source
Expand description

BabbleSim + Zephyr nRF RPC simulation bridge.

This crate provides three things:

§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§

TestProcesses
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_socat is called.

Functions§

spawn_zephyr_rpc_server_with_socat
tests_dir/<test_name>.sock.