mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2026-11-03 20:56:39 -06:00
feat: make mock usable not just from tests
This commit is contained in:
1 parent
8ef367b46a
commit
ce5f5dcf19
2 files changed
+5
-1
No files matched your search
@@ -2,6 +2,7 @@ use super::{DrmProvider, VramInfo};
|
||||
use crate::server::handler::SnapshotDeviceInfo;
|
||||
use lact_schema::IntelDrmInfo;
|
||||
use std::path::Path;
|
||||
use tracing::info;
|
||||
|
||||
pub struct MockDrmProvider {
|
||||
snapshot: SnapshotDeviceInfo,
|
||||
@@ -10,9 +11,11 @@ pub struct MockDrmProvider {
|
||||
impl MockDrmProvider {
|
||||
pub fn new(sysfs: &Path) -> Option<Self> {
|
||||
let info_path = sysfs.parent()?.parent()?.join("info.json");
|
||||
let raw_snapshot = std::fs::read_to_string(info_path).ok()?;
|
||||
let raw_snapshot = std::fs::read_to_string(&info_path).ok()?;
|
||||
let snapshot = serde_json::from_str(&raw_snapshot).expect("could not parse snapshot");
|
||||
|
||||
info!("using mock device info from {}", info_path.display());
|
||||
|
||||
Some(Self { snapshot })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ edition.workspace = true
|
||||
default = ["lact-gui", "nvidia", "display-info"]
|
||||
nvidia = ["lact-daemon/nvidia"]
|
||||
display-info = ["lact-daemon/display-info"]
|
||||
mock = ["lact-daemon/mock"]
|
||||
|
||||
[dependencies]
|
||||
lact-daemon = { path = "../lact-daemon", default-features = false }
|
||||
|
||||
Reference in new issue
Block a user