use super::*;
#[test]
fn test_get_allowed_cpus_not_empty() {
let allowed = get_allowed_cpus();
assert!(
!allowed.is_empty(),
"The list of allowed CPUs must not be empty."
);
}
#[test]
fn test_select_optimal_cpu_returns_something() {
let cpu = select_optimal_cpu();
assert!(cpu.is_some(), "Should be able to select an optimal core.");
if let Some(cpu_idx) = cpu {
let allowed = get_allowed_cpus();
assert!(
allowed.contains(&cpu_idx),
"The selected core must be in the list of allowed CPUs."
);
}
}
#[test]
fn test_parse_interrupts_basic() {
let allowed = get_allowed_cpus();
let irqs = parse_interrupts_per_cpu(allowed.len() + 1);
assert_eq!(irqs.len(), allowed.len() + 1);
}
#[test]
fn test_rdtsc_nanos_monotonic() {
let t1 = rdtsc_nanos();
std::thread::sleep(std::time::Duration::from_millis(1));
let t2 = rdtsc_nanos();
assert!(t2 > t1, "Time did not advance: {} -> {}", t1, t2);
}
#[test]
fn test_rdtsc_nanos_significant() {
std::thread::sleep(std::time::Duration::from_millis(5));
let t = rdtsc_nanos();
assert!(t > 1_000_000, "Reported time is too low: {} ns", t);
}
#[test]
fn test_configure_realtime_thread_invalid_cpu() {
let rt_status = std::sync::Arc::new(crate::common::spsc::RtStatusFlags::new());
configure_realtime_thread(2048, rt_status);
}