mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-05 14:10:34 -04:00
power: Improve GPU test reliability
This commit is contained in:
parent
32d31e9d27
commit
922ba006ae
2 changed files with 12 additions and 8 deletions
|
@ -260,6 +260,7 @@ impl SteamOSManager {
|
|||
mod test {
|
||||
use super::*;
|
||||
use crate::power::{self, get_gpu_performance_level};
|
||||
use crate::power::test::{format_clocks, read_clocks};
|
||||
use crate::testing;
|
||||
use tokio::fs::{create_dir_all, write};
|
||||
use zbus::{Connection, ConnectionBuilder};
|
||||
|
@ -354,10 +355,10 @@ mod test {
|
|||
|
||||
power::test::setup().await;
|
||||
proxy.set_manual_gpu_clock(200).await.expect("proxy_set");
|
||||
power::test::expect_clocks(200).await;
|
||||
assert_eq!(read_clocks().await.unwrap(), format_clocks(200));
|
||||
|
||||
assert!(proxy.set_manual_gpu_clock(100).await.is_err());
|
||||
power::test::expect_clocks(200).await;
|
||||
assert_eq!(read_clocks().await.unwrap(), format_clocks(200));
|
||||
}
|
||||
|
||||
#[zbus::proxy(
|
||||
|
|
15
src/power.rs
15
src/power.rs
|
@ -245,12 +245,14 @@ CCLK_RANGE in Core0:
|
|||
write(filename.as_path(), contents).await.expect("write");
|
||||
}
|
||||
|
||||
pub async fn expect_clocks(mhz: u32) {
|
||||
pub async fn read_clocks() -> Result<String, std::io::Error> {
|
||||
let base = find_hwmon().await.unwrap();
|
||||
let clocks = read_to_string(base.join(GPU_CLOCKS_SUFFIX))
|
||||
read_to_string(base.join(GPU_CLOCKS_SUFFIX))
|
||||
.await
|
||||
.expect("read");
|
||||
assert_eq!(clocks, format!("s 0 {mhz}\ns 1 {mhz}\nc\n"));
|
||||
}
|
||||
|
||||
pub fn format_clocks(mhz: u32) -> String {
|
||||
format!("s 0 {mhz}\ns 1 {mhz}\nc\n")
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -447,10 +449,11 @@ CCLK_RANGE in Core0:
|
|||
assert!(set_gpu_clocks(2000).await.is_err());
|
||||
|
||||
assert!(set_gpu_clocks(200).await.is_ok());
|
||||
expect_clocks(200).await;
|
||||
|
||||
assert_eq!(read_clocks().await.unwrap(), format_clocks(200));
|
||||
|
||||
assert!(set_gpu_clocks(1600).await.is_ok());
|
||||
expect_clocks(1600).await;
|
||||
assert_eq!(read_clocks().await.unwrap(), format_clocks(1600));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue