updated safety measurements and benchmarking behavior for 9380
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
use anyhow::Result;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use ember_tune_rs::sal::safety::{HardwareStateGuard, TdpLimitMicroWatts};
|
||||
use ember_tune_rs::sal::safety::{HardwareStateGuard, PowerLimitWatts};
|
||||
use crate::common::fakesys::FakeSysBuilder;
|
||||
use std::fs;
|
||||
|
||||
mod common;
|
||||
|
||||
@@ -34,23 +32,22 @@ fn test_hardware_state_guard_panic_restoration() {
|
||||
#[test]
|
||||
fn test_tdp_limit_bounds_checking() {
|
||||
// 1. Valid value
|
||||
assert!(TdpLimitMicroWatts::new(15_000_000).is_ok());
|
||||
assert!(PowerLimitWatts::try_new(15.0).is_ok());
|
||||
|
||||
// 2. Too low (Dangerous 0W or below 5W)
|
||||
let low_res = TdpLimitMicroWatts::new(1_000_000);
|
||||
// 2. Too low (Dangerous 0W or below 3W)
|
||||
let low_res = PowerLimitWatts::try_new(1.0);
|
||||
assert!(low_res.is_err());
|
||||
assert!(low_res.unwrap_err().to_string().contains("below safety floor"));
|
||||
assert!(low_res.unwrap_err().to_string().contains("outside safe bounds"));
|
||||
|
||||
// 3. Too high (> 80W)
|
||||
let high_res = TdpLimitMicroWatts::new(100_000_000);
|
||||
// 3. Too high (> 100W)
|
||||
let high_res = PowerLimitWatts::try_new(150.0);
|
||||
assert!(high_res.is_err());
|
||||
assert!(high_res.unwrap_err().to_string().contains("exceeds safety ceiling"));
|
||||
assert!(high_res.unwrap_err().to_string().contains("outside safe bounds"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_0w_tdp_regression_prevention() {
|
||||
// The prime directive is to never set 0W.
|
||||
// Ensure the new() constructor explicitly fails for 0.
|
||||
let zero_res = TdpLimitMicroWatts::new(0);
|
||||
let zero_res = PowerLimitWatts::try_new(0.0);
|
||||
assert!(zero_res.is_err());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user