use std::time::Duration;
use dvb_ci_runtime::{Driver, DriverBounds, MockCaDevice, StackBounds, TransportBounds};
#[global_allocator]
static A: test_alloc::ProcessCounting = test_alloc::ProcessCounting::new();
fn driver_bounds() -> DriverBounds {
DriverBounds {
stack: stack_bounds(),
max_pending_notifications: 1024,
slot_ready_grace: Duration::from_secs(12),
slot_retry: Duration::from_millis(250),
}
}
fn stack_bounds() -> StackBounds {
StackBounds {
transport: TransportBounds {
poll_interval: Duration::from_millis(100),
reply_timeout: Duration::from_secs(1),
max_setup_attempts: 5,
max_reassembly_len: 2 * 1024 * 1024,
max_outbound_queue: 64,
},
max_sessions: 32,
}
}
#[test]
fn pump_does_not_copy_the_received_frame() {
const FRAME: usize = 4096; let mock = MockCaDevice::new([vec![0u8; FRAME]]);
let mut driver = Driver::new(mock, driver_bounds());
A.reset_largest();
let _ = driver.pump(Duration::from_millis(1));
let largest = A.largest();
eprintln!("largest single allocation during pump: {largest} bytes");
assert!(
largest < FRAME / 2,
"largest single allocation was {largest} bytes: the frame was copied"
);
}