Fix SMT toggle always reenabling (fix #73)
This commit is contained in:
parent
b32c5c9d31
commit
0483ee1617
4 changed files with 45 additions and 2 deletions
|
@ -23,7 +23,7 @@ pub use traits::{OnResume, OnSet, SettingsRange, TGeneral, TGpu, TCpus, TBattery
|
|||
mod tests {
|
||||
#[test]
|
||||
fn system_defaults_test() {
|
||||
let settings = super::Settings::system_default("idc".into());
|
||||
let settings = super::Settings::system_default("idc".into(), "Cool name".into());
|
||||
println!("Loaded system settings: {:?}", settings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,6 +176,7 @@ impl TCpus for Cpus {
|
|||
}
|
||||
|
||||
fn smt(&mut self) -> &'_ mut bool {
|
||||
log::debug!("CPU driver thinks SMT is {}", self.smt);
|
||||
&mut self.smt
|
||||
}
|
||||
|
||||
|
|
|
@ -5,3 +5,45 @@ pub fn guess_smt(cpus: &Vec<crate::persist::CpuJson>) -> bool {
|
|||
}
|
||||
guess
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use crate::persist::CpuJson;
|
||||
|
||||
#[test]
|
||||
fn smt_guess_test() {
|
||||
let input = vec![
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(true),
|
||||
];
|
||||
assert_eq!(guess_smt(&input), true);
|
||||
|
||||
let input = vec![
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(false),
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(false),
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(false),
|
||||
cpu_with_online(true),
|
||||
cpu_with_online(false),
|
||||
];
|
||||
assert_eq!(guess_smt(&input), false);
|
||||
}
|
||||
|
||||
fn cpu_with_online(status: bool) -> CpuJson {
|
||||
CpuJson {
|
||||
online: status,
|
||||
clock_limits: None,
|
||||
governor: "schedutil".to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ export async function setCpuSmt(status: boolean): Promise<boolean[]> {
|
|||
}
|
||||
|
||||
export async function getCpuSmt(): Promise<boolean> {
|
||||
return await call_backend("CPU_get_smt", []);
|
||||
return (await call_backend("CPU_get_smt", []))[0];
|
||||
}
|
||||
|
||||
/*export async function getCpuCount(): Promise<number> {
|
||||
|
|
Loading…
Reference in a new issue