Update deps

This commit is contained in:
Luke D. Jones
2024-11-28 16:28:20 +13:00
parent 71fcb382ea
commit e7c4619ee9
21 changed files with 1258 additions and 891 deletions

View File

@@ -244,25 +244,26 @@ mod tests {
use super::*;
#[test]
#[ignore = "Can't check in docker env"]
fn find_attributes() {
let attrs = FirmwareAttributes::new();
for attr in attrs.attributes() {
dbg!(attr.name());
match attr.name() {
"nv_dynamic_boost" => {
"dgpu_disable" => {
assert!(!attr.help().is_empty());
assert!(matches!(
attr.current_value().unwrap(),
AttrValue::Integer(_)
));
if let AttrValue::Integer(val) = attr.current_value().unwrap() {
assert_eq!(val, 5);
assert_eq!(val, 0);
}
if let AttrValue::Integer(val) = attr.default_value {
assert_eq!(val, 25);
}
assert_eq!(attr.min_value, AttrValue::Integer(0));
assert_eq!(attr.max_value, AttrValue::Integer(25));
assert_eq!(attr.min_value, AttrValue::None);
assert_eq!(attr.max_value, AttrValue::None);
}
"boot_sound" => {
assert!(!attr.help().is_empty());
@@ -278,6 +279,7 @@ mod tests {
}
#[test]
#[ignore = "Can't check in docker env"]
fn test_boot_sound() {
let attrs = FirmwareAttributes::new();
let attr = attrs
@@ -302,7 +304,7 @@ mod tests {
}
#[test]
#[ignore = "Requires root to set the value"]
#[ignore = "Can't check in docker env"]
fn test_set_boot_sound() {
let attrs = FirmwareAttributes::new();
let attr = attrs

View File

@@ -14,6 +14,7 @@ pub mod usb_raw;
use std::path::Path;
use error::{PlatformError, Result};
use log::warn;
use udev::Device;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -44,9 +45,13 @@ pub fn read_attr_bool(device: &Device, attr_name: &str) -> Result<bool> {
}
pub fn write_attr_bool(device: &mut Device, attr: &str, value: bool) -> Result<()> {
let value = if value { 1 } else { 0 };
device
.set_attribute_value(attr, value.to_string())
.map_err(|e| PlatformError::IoPath(attr.into(), e))
.map_err(|e| {
warn!("attr write error: {e:?}");
PlatformError::IoPath(attr.into(), e)
})
}
pub fn read_attr_u8(device: &Device, attr_name: &str) -> Result<u8> {