use luwen::api::chip::Chip;
#[allow(dead_code)]
pub fn hardware_available() -> bool {
match luwen::pci::detect_chips_fallible() {
Ok(chips) => {
if chips.is_empty() {
println!("Test SKIPPED: No devices found");
return false;
}
true
}
Err(e) => {
println!("Test SKIPPED: Error detecting chips: {e}");
false
}
}
}
#[allow(dead_code)]
pub fn has_chip_type<F>(chip_type_check: F) -> bool
where
F: Fn(&Chip) -> bool,
{
match luwen::pci::detect_chips_fallible() {
Ok(chips) => {
let has_type = chips.iter().any(|chip| {
if let Some(upgraded) = chip.try_upgrade() {
chip_type_check(upgraded)
} else {
false
}
});
if !has_type {
println!("Test SKIPPED: No matching chip type found");
return false;
}
true
}
Err(e) => {
println!("Test SKIPPED: Error detecting chips: {e}");
false
}
}
}