mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-05 14:10:34 -04:00
manager: Simplify test setup
This commit is contained in:
parent
6dc04e70d2
commit
2410334c0b
2 changed files with 31 additions and 52 deletions
|
@ -281,50 +281,33 @@ mod test {
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start(name: &str) -> TestHandle {
|
async fn start() -> Result<TestHandle> {
|
||||||
let handle = testing::start();
|
let handle = testing::start();
|
||||||
create_dir_all(crate::path("/sys/class/dmi/id"))
|
create_dir_all(crate::path("/sys/class/dmi/id")).await?;
|
||||||
.await
|
write(crate::path("/sys/class/dmi/id/board_vendor"), "Valve\n").await?;
|
||||||
.expect("create_dir_all");
|
write(crate::path("/sys/class/dmi/id/board_name"), "Jupiter\n").await?;
|
||||||
write(crate::path("/sys/class/dmi/id/board_vendor"), "Valve\n")
|
create_dir_all(crate::path("/etc/NetworkManager/conf.d")).await?;
|
||||||
.await
|
|
||||||
.expect("write");
|
|
||||||
write(crate::path("/sys/class/dmi/id/board_name"), "Jupiter\n")
|
|
||||||
.await
|
|
||||||
.expect("write");
|
|
||||||
create_dir_all(crate::path("/etc/NetworkManager/conf.d"))
|
|
||||||
.await
|
|
||||||
.expect("create_dir_all");
|
|
||||||
write(
|
write(
|
||||||
crate::path("/etc/NetworkManager/conf.d/wifi_backend.conf"),
|
crate::path("/etc/NetworkManager/conf.d/wifi_backend.conf"),
|
||||||
"wifi.backend=iwd\n",
|
"wifi.backend=iwd\n",
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.expect("write");
|
|
||||||
|
|
||||||
let connection = ConnectionBuilder::session()
|
let connection = ConnectionBuilder::session()?.build().await?;
|
||||||
.unwrap()
|
let manager = SteamOSManager::new(connection.clone()).await?;
|
||||||
.name(format!("com.steampowered.SteamOSManager1.Test.{name}"))
|
|
||||||
.unwrap()
|
|
||||||
.build()
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let manager = SteamOSManager::new(connection.clone()).await.unwrap();
|
|
||||||
connection
|
connection
|
||||||
.object_server()
|
.object_server()
|
||||||
.at("/com/steampowered/SteamOSManager1", manager)
|
.at("/com/steampowered/SteamOSManager1", manager)
|
||||||
.await
|
.await?;
|
||||||
.expect("object_server at");
|
|
||||||
|
|
||||||
TestHandle {
|
Ok(TestHandle {
|
||||||
_handle: handle,
|
_handle: handle,
|
||||||
connection,
|
connection,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus::proxy(
|
#[zbus::proxy(
|
||||||
interface = "com.steampowered.SteamOSManager1.RootManager",
|
interface = "com.steampowered.SteamOSManager1.RootManager",
|
||||||
default_service = "com.steampowered.SteamOSManager1.Test.GpuPerformanceLevel",
|
|
||||||
default_path = "/com/steampowered/SteamOSManager1"
|
default_path = "/com/steampowered/SteamOSManager1"
|
||||||
)]
|
)]
|
||||||
trait GpuPerformanceLevel {
|
trait GpuPerformanceLevel {
|
||||||
|
@ -333,10 +316,11 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn gpu_performance_level() {
|
async fn gpu_performance_level() {
|
||||||
let test = start("GpuPerformanceLevel").await;
|
let test = start().await.expect("start");
|
||||||
power::test::setup().await;
|
power::test::setup().await;
|
||||||
|
|
||||||
let proxy = GpuPerformanceLevelProxy::new(&test.connection)
|
let name = test.connection.unique_name().unwrap();
|
||||||
|
let proxy = GpuPerformanceLevelProxy::new(&test.connection, name.clone())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
proxy
|
proxy
|
||||||
|
@ -351,7 +335,6 @@ mod test {
|
||||||
|
|
||||||
#[zbus::proxy(
|
#[zbus::proxy(
|
||||||
interface = "com.steampowered.SteamOSManager1.RootManager",
|
interface = "com.steampowered.SteamOSManager1.RootManager",
|
||||||
default_service = "com.steampowered.SteamOSManager1.Test.ManualGpuClock",
|
|
||||||
default_path = "/com/steampowered/SteamOSManager1"
|
default_path = "/com/steampowered/SteamOSManager1"
|
||||||
)]
|
)]
|
||||||
trait ManualGpuClock {
|
trait ManualGpuClock {
|
||||||
|
@ -360,9 +343,12 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn manual_gpu_clock() {
|
async fn manual_gpu_clock() {
|
||||||
let test = start("ManualGpuClock").await;
|
let test = start().await.expect("start");
|
||||||
|
|
||||||
let proxy = ManualGpuClockProxy::new(&test.connection).await.unwrap();
|
let name = test.connection.unique_name().unwrap();
|
||||||
|
let proxy = ManualGpuClockProxy::new(&test.connection, name.clone())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
power::test::setup().await;
|
power::test::setup().await;
|
||||||
proxy.set_manual_gpu_clock(200).await.expect("proxy_set");
|
proxy.set_manual_gpu_clock(200).await.expect("proxy_set");
|
||||||
|
@ -374,7 +360,6 @@ mod test {
|
||||||
|
|
||||||
#[zbus::proxy(
|
#[zbus::proxy(
|
||||||
interface = "com.steampowered.SteamOSManager1.RootManager",
|
interface = "com.steampowered.SteamOSManager1.RootManager",
|
||||||
default_service = "com.steampowered.SteamOSManager1.Test.Version",
|
|
||||||
default_path = "/com/steampowered/SteamOSManager1"
|
default_path = "/com/steampowered/SteamOSManager1"
|
||||||
)]
|
)]
|
||||||
trait Version {
|
trait Version {
|
||||||
|
@ -384,8 +369,11 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn version() {
|
async fn version() {
|
||||||
let test = start("Version").await;
|
let test = start().await.expect("start");
|
||||||
let proxy = VersionProxy::new(&test.connection).await.unwrap();
|
let name = test.connection.unique_name().unwrap();
|
||||||
|
let proxy = VersionProxy::new(&test.connection, name.clone())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
assert_eq!(proxy.version().await, Ok(API_VERSION));
|
assert_eq!(proxy.version().await, Ok(API_VERSION));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,28 +325,19 @@ mod test {
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start(name: &str) -> TestHandle {
|
async fn start() -> Result<TestHandle> {
|
||||||
let handle = testing::start();
|
let handle = testing::start();
|
||||||
let connection = ConnectionBuilder::session()
|
let connection = ConnectionBuilder::session()?.build().await?;
|
||||||
.unwrap()
|
let manager = SteamOSManager::new(connection.clone(), &connection).await?;
|
||||||
.name(format!("com.steampowered.SteamOSManager1.UserTest.{name}"))
|
|
||||||
.unwrap()
|
|
||||||
.build()
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let manager = SteamOSManager::new(connection.clone(), &connection)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
connection
|
connection
|
||||||
.object_server()
|
.object_server()
|
||||||
.at("/com/steampowered/SteamOSManager1", manager)
|
.at("/com/steampowered/SteamOSManager1", manager)
|
||||||
.await
|
.await?;
|
||||||
.expect("object_server at");
|
|
||||||
|
|
||||||
TestHandle {
|
Ok(TestHandle {
|
||||||
_handle: handle,
|
_handle: handle,
|
||||||
connection,
|
connection,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_methods<'a>(methods: &'a [Method<'a>]) -> HashMap<String, &'a Method<'a>> {
|
fn collect_methods<'a>(methods: &'a [Method<'a>]) -> HashMap<String, &'a Method<'a>> {
|
||||||
|
@ -367,7 +358,7 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn interface_matches() {
|
async fn interface_matches() {
|
||||||
let test = start("Interface").await;
|
let test = start().await.expect("start");
|
||||||
|
|
||||||
let manager_ref = test
|
let manager_ref = test
|
||||||
.connection
|
.connection
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue