Files
Matthew Jackson 4031513574 audit: module-by-module code audit fixes and test coverage
Lands the code-audit branches for aacs, css, keys, labels, udf, ifo and
dvd, bdnav/mpls/clpi, disc/bluray, extract, io, scsi, the mkv, mp4,
network and mpg muxers, the audio and video codecs, and CI. Fixes
include MKB and FMTS validation, UDF bounds, IFO fallback to the BUP,
DTS Express framing, MPEG-2 field pairing and mpg re-basing; the rest
pins existing behaviour with tests.
2026-09-29 20:45:05 -07:00

32 lines
1.1 KiB
Rust

//! Drive-level timeout bound on a real device. The SgIoTransport fd-recovery
//! test lives beside the transport (its fields are private) in
//! `src/scsi/linux.rs`. Requires a real /dev/sg* device, hence #[ignore].
//! Linux-only at the crate level: elsewhere it would report a pass having run nothing.
#![cfg(target_os = "linux")]
use std::path::Path;
use std::time::Duration;
#[test]
#[ignore]
fn test_drive_read_per_cdb_timeout_bounds_call() {
let device = "/dev/sg2";
let device = std::env::var("FREEMKV_TEST_SG_DEVICE").unwrap_or(device.to_string());
let path = Path::new(&device);
let mut drive = libfreemkv::Drive::open(path).expect("open drive");
// Mirrors the crate-private scsi::READ_TIMEOUT_MS used by Drive::read.
let timeout_ms: u32 = 10_000;
let start = std::time::Instant::now();
let _ = drive.read(0, 1, &mut [0u8; 2048], false);
let elapsed = start.elapsed();
let overhead = Duration::from_millis(500);
assert!(
elapsed < Duration::from_millis(timeout_ms as u64) + overhead,
"Drive::read should return within timeout_ms + overhead, took {:?}",
elapsed
);
}