manager: Add get/set_gpu_performance_level tests

This commit is contained in:
Vicki Pfau 2024-04-02 19:02:19 -07:00
parent 9ddbc9997d
commit 3c62c57d52
2 changed files with 54 additions and 11 deletions

View file

@ -197,6 +197,14 @@ pub async fn set_tdp_limit(limit: u32) -> Result<()> {
Ok(())
}
#[cfg(test)]
pub async fn setup_test() {
let filename = path(GPU_PERFORMANCE_LEVEL_PATH);
fs::create_dir_all(filename.parent().unwrap())
.await
.expect("create_dir_all");
}
#[cfg(test)]
mod test {
use super::*;
@ -209,9 +217,7 @@ mod test {
let h = testing::start();
let filename = path(GPU_PERFORMANCE_LEVEL_PATH);
create_dir_all(filename.parent().unwrap())
.await
.expect("create_dir_all");
setup_test().await;
assert!(get_gpu_performance_level().await.is_err());
write(filename.as_path(), "auto\n").await.expect("write");
@ -255,9 +261,7 @@ mod test {
let h = testing::start();
let filename = path(GPU_PERFORMANCE_LEVEL_PATH);
create_dir_all(filename.parent().unwrap())
.await
.expect("create_dir_all");
setup_test().await;
set_gpu_performance_level(GPUPerformanceLevel::Auto)
.await