46 lines
1.6 KiB
Rust
46 lines
1.6 KiB
Rust
use ember_tune_rs::sal::heuristic::discovery::discover_facts;
|
|
use ember_tune_rs::sal::heuristic::schema::{Discovery, SensorDiscovery, ActuatorDiscovery, Benchmarking};
|
|
use crate::common::fakesys::FakeSysBuilder;
|
|
|
|
mod common;
|
|
|
|
#[test]
|
|
fn test_heuristic_discovery_with_fakesys() {
|
|
let fake = FakeSysBuilder::new();
|
|
fake.add_dmi("Dell Inc.", "XPS 13 9380")
|
|
.add_hwmon("dell_smm", "Package id 0", "45000")
|
|
.add_rapl("intel-rapl:0", "123456", "15000000")
|
|
.add_proc_cmdline("quiet msr.allow_writes=on");
|
|
|
|
let discovery = Discovery {
|
|
sensors: SensorDiscovery {
|
|
temp_labels: vec!["Package id 0".to_string()],
|
|
fan_labels: vec![],
|
|
hwmon_priority: vec!["dell_smm".to_string()],
|
|
},
|
|
actuators: ActuatorDiscovery {
|
|
rapl_paths: vec!["intel-rapl:0".to_string()],
|
|
amd_energy_paths: vec![],
|
|
governor_files: vec![],
|
|
},
|
|
configs: std::collections::HashMap::new(),
|
|
tools: std::collections::HashMap::new(),
|
|
};
|
|
|
|
let benchmarking = Benchmarking {
|
|
idle_duration_s: 1,
|
|
stress_duration_min_s: 1,
|
|
stress_duration_max_s: 2,
|
|
cool_down_s: 1,
|
|
power_steps_watts: vec![10.0, 15.0],
|
|
};
|
|
|
|
let facts = discover_facts(&fake.base_path(), &discovery, &[], benchmarking);
|
|
|
|
assert_eq!(facts.vendor, "Dell Inc.");
|
|
assert_eq!(facts.model, "XPS 13 9380");
|
|
assert!(facts.temp_path.is_some());
|
|
assert!(facts.temp_path.unwrap().to_string_lossy().contains("hwmon0/temp1_input"));
|
|
assert_eq!(facts.rapl_paths.len(), 1);
|
|
}
|