diff --git a/app/Cargo.toml b/app/Cargo.toml index 01a9d37..738e18a 100644 --- a/app/Cargo.toml +++ b/app/Cargo.toml @@ -45,7 +45,7 @@ codegen-units = 4 strip = "symbols" [target.'cfg(windows)'.dependencies] -windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Globalization", "Win32_Security_Cryptography", "Win32_System_SystemInformation", "Win32_Devices_DeviceAndDriverInstallation", "Win32_Graphics_Gdi", "Win32_UI_WindowsAndMessaging", "Win32_System_Registry", "Win32_UI_Shell", "Win32_System_Threading", "Win32_System_Performance"] } +windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Globalization", "Win32_Security_Cryptography", "Win32_System_SystemInformation", "Win32_Devices_DeviceAndDriverInstallation", "Win32_Graphics_Gdi", "Win32_UI_WindowsAndMessaging", "Win32_System_Registry", "Win32_UI_Shell", "Win32_System_Threading", "Win32_System_Performance", "Win32_System_Diagnostics_ToolHelp"] } [target.'cfg(unix)'.dependencies] libc = "0.2" diff --git a/app/src/admin.spec.md b/app/src/admin.spec.md index 239903d..c8d9cc4 100644 --- a/app/src/admin.spec.md +++ b/app/src/admin.spec.md @@ -368,11 +368,14 @@ between the normal placement and the game placement as games come and go (not wi 2 GiB, else 0 GiB, else pause), measured once at that context like the normal one. Other programs' memory is what the card holds after the LLM stopped, less the STT worker's model while it is loaded (1300 MiB), read afresh at every placement. A normal placement made with no game - running keeps its reading. The game stage counts other programs as that kept reading and leaves + running keeps its reading; one made while a game runs (the way back from a failed game stage) + keeps the earlier one. The game stage counts other programs as that kept reading and leaves a reserve of at least what has grown since (the game and any program opened after that reading), so nothing is counted twice and nothing that grew is missed. When a game already ran - as the services started (game detection looks once before the LLM starts), there is no such - reading: the game stage then counts what the card holds now, the game included, and leaves only + as the services started, there is no such reading: game detection looks once before the LLM + starts, at the window in front and at every running program (one in a launcher's game folder or + the person's games list counts, also behind other windows; how a window looks is not known + there). Then the game stage counts what the card holds now, the game included, and leaves only the room for other programs. The dashboard shows the stage that runs, also on a fallback placement without experts. - Pause: the LLM stops (`llm` off, "게임 중 일시정지"); the brain answers nothing until the stage @@ -613,7 +616,9 @@ Strata and card): a game moves the LLM to the game placement (measured once at 1 2 GiB on the game PC's numbers, half the 16 engine threads) and back after the wait, pause stops it, a card with no room for a game pauses, the normal stage counts a program opened since, the game stage does not count the game twice and counts what grew since the normal reading, a game running -as the services start does not pause the LLM, a fallback game placement still shows as the game +as the services start does not pause the LLM, the way back to normal from a failed game stage while +the game runs keeps the reading from before the game, a game program behind other windows is found +at the start (win-ci VM: a minimised program in a Steam game folder), a fallback game placement still shows as the game stage, and the stage loop tells the brain switching (with the notice), waits, restarts and tells it ready, also on the way back; a game stage that cannot start goes back to normal each time and is tried three times; after that a new game tries again, and the next try waits from when the diff --git a/app/src/game.rs b/app/src/game.rs index dd6b66f..2a103b4 100644 --- a/app/src/game.rs +++ b/app/src/game.rs @@ -150,6 +150,16 @@ pub fn classify(fg: &Foreground, d3d_fullscreen: bool, s: &GameSettings, install (fg.covers_monitor && fg.no_frame && fg.gpu_3d >= MIN_GPU_3D).then_some(Reason::Borderless) } +/// Whether one of these programs (full paths) is a game by what it is: the person's list or a +/// launcher's game folder. Used once as the services start, for games behind other windows (how a +/// window looks is not known there, so those rules do not apply). +pub fn game_running_among(paths: &[String], s: &GameSettings, installed: &[InstalledGame]) -> bool { + paths.iter().any(|p| { + let fg = Foreground { pid: 0, path: p.clone(), covers_monitor: false, no_frame: false, gpu_3d: 0.0 }; + classify(&fg, false, s, installed).is_some() + }) +} + /// A game's name for the dashboard: its name from the launcher (the folder under a launcher's game /// folder, or an installed game's name), else the program's name without ".exe". pub fn game_name(path: &str, installed: &[InstalledGame]) -> String { @@ -200,6 +210,8 @@ impl GameState { /// sees one). pub struct GameWatch { state: Arc>, + /// A game process ran (in front or behind other windows) when the watch started. + background: bool, stop: Arc, thread: Mutex>>, } @@ -209,9 +221,11 @@ impl GameWatch { /// known at once (`on`). pub fn start(settings: GameSettings) -> Self { let (state, stop) = (Arc::new(Mutex::new(GameState::default())), Arc::new(AtomicBool::new(false))); + let mut background = false; if cfg!(windows) && settings.detect { let snap = probe::Probe::new().snapshot(); state.lock().unwrap().update(&snap, &settings, probe::alive); + background = game_running_among(&probe::process_paths(), &settings, &snap.installed); } let thread = (cfg!(windows) && settings.detect).then(|| { let (state, stop) = (state.clone(), stop.clone()); @@ -239,7 +253,13 @@ impl GameWatch { } }) }); - Self { state, stop, thread: Mutex::new(thread) } + Self { state, background, stop, thread: Mutex::new(thread) } + } + + /// Whether a game process ran when the watch started, also one behind other windows (found by + /// what the program is: the person's list or a launcher's game folder). + pub fn in_background_at_start(&self) -> bool { + self.background } /// Whether game mode is on. @@ -286,6 +306,10 @@ mod probe { pub fn alive(_pid: u32) -> bool { false } + + pub fn process_paths() -> Vec { + vec![] + } } #[cfg(windows)] @@ -453,18 +477,7 @@ mod probe { } let mut pid = 0; GetWindowThreadProcessId(hwnd, &mut pid); - let h = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid); - if h.is_null() { - return None; - } - let mut buf = [0u16; 1024]; - let mut len = buf.len() as u32; - let ok = QueryFullProcessImageNameW(h, PROCESS_NAME_WIN32, buf.as_mut_ptr(), &mut len) != 0; - CloseHandle(h); - if !ok { - return None; - } - let path = String::from_utf16_lossy(&buf[..len as usize]); + let path = image_path(pid)?; let mut r: RECT = std::mem::zeroed(); GetWindowRect(hwnd, &mut r); let mut mi = MONITORINFO { cbSize: std::mem::size_of::() as u32, ..Default::default() }; @@ -477,6 +490,48 @@ mod probe { } } + /// Process `pid`'s program path. + fn image_path(pid: u32) -> Option { + // SAFETY: a query-only handle, closed at once; the buffer is sized as passed. + unsafe { + let h = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid); + if h.is_null() { + return None; + } + let mut buf = [0u16; 1024]; + let mut len = buf.len() as u32; + let ok = QueryFullProcessImageNameW(h, PROCESS_NAME_WIN32, buf.as_mut_ptr(), &mut len) != 0; + CloseHandle(h); + ok.then(|| String::from_utf16_lossy(&buf[..len as usize])) + } + } + + /// Every running program's path this user may read. + pub fn process_paths() -> Vec { + use windows_sys::Win32::System::Diagnostics::ToolHelp::{ + CreateToolhelp32Snapshot, Process32FirstW, Process32NextW, PROCESSENTRY32W, TH32CS_SNAPPROCESS, + }; + let mut out = vec![]; + // SAFETY: a process snapshot walked with a sized entry, then closed. + unsafe { + let snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if snap == windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE { + return out; + } + let mut e: PROCESSENTRY32W = std::mem::zeroed(); + e.dwSize = std::mem::size_of::() as u32; + let mut more = Process32FirstW(snap, &mut e) != 0; + while more { + if let Some(p) = image_path(e.th32ProcessID) { + out.push(p); + } + more = Process32NextW(snap, &mut e) != 0; + } + CloseHandle(snap); + } + out + } + /// Whether process `pid` still runs. pub fn alive(pid: u32) -> bool { // SAFETY: a handle only to wait on, closed at once. @@ -562,6 +617,22 @@ mod tests { assert_eq!(entry("World of Warcraft", "Blizzard Entertainment", "x", ""), None, "no folder, nothing to match"); } + #[test] + fn a_game_running_in_the_background_is_found_by_its_program() { + let s = settings(); + let wow = InstalledGame { dir: r"D:\Games\World of Warcraft".into(), name: "World of Warcraft".into(), launcher: "Battle.net" }; + // Behind other windows: only what the program is (where it lives, or the person's list). + assert!(game_running_among(&[r"C:\Windows\explorer.exe".into(), r"C:\Riot Games\VALORANT\live\VALORANT.exe".into()], &s, &[])); + assert!(game_running_among(&[r"D:\Games\World of Warcraft\_retail_\Wow.exe".into()], &s, &[wow])); + assert!(!game_running_among(&[r"C:\Windows\explorer.exe".into(), r"C:\Riot Games\Riot Client\RiotClientServices.exe".into(), + r"C:\Program Files\Google\Chrome\Application\chrome.exe".into()], &s, &[]), "launchers and browsers are not games"); + let mut mine = settings(); + mine.games = vec!["mygame".into()]; + assert!(game_running_among(&[r"D:\x\MyGame.exe".into()], &mine, &[])); + mine.not_games = vec!["VALORANT.exe".into()]; + assert!(!game_running_among(&[r"C:\Riot Games\VALORANT\live\VALORANT.exe".into()], &mine, &[])); + } + #[test] fn the_persons_lists_come_first() { let mut s = settings(); diff --git a/app/src/services.rs b/app/src/services.rs index bc756d6..6303973 100644 --- a/app/src/services.rs +++ b/app/src/services.rs @@ -121,7 +121,7 @@ pub async fn start_services(data_dir: &Path, llm: Arc) -> Result, brain: Ar if !brain.wait_llm_idle(id, std::time::Duration::from_secs(120)).await { crate::warn_log!("perf", "Warning: the brain did not finish its answers in 2 minutes; switching anyway"); } - let ended = match llm.switch(&settings, want, brain.stt_on_card()).await { + let ended = match llm.switch(&settings, want, brain.stt_on_card(), game()).await { Ok(ended) => { retry.succeeded(); actual = want; @@ -291,7 +291,7 @@ async fn perf_loop(settings: crate::settings::Settings, llm: Arc, brain: Ar } Err(e) => { crate::error_log!("perf", "the LLM did not start in the {want:?} stage: {e}; going back to {actual:?}"); - let back = match llm.switch(&settings, actual, brain.stt_on_card()).await { + let back = match llm.switch(&settings, actual, brain.stt_on_card(), game()).await { Ok(ended) => ended, Err(e) => { crate::error_log!("perf", "the LLM did not come back in the {actual:?} stage either: {e}"); @@ -456,6 +456,47 @@ mod perf_tests { assert!(gap >= Duration::from_secs(1), "the next try came {gap:?} after the normal stage was back"); } + #[cfg(unix)] + #[tokio::test] + async fn going_back_to_normal_while_the_game_runs_keeps_the_reading_from_before_the_game() { + // 24 GB card; other programs 1460 MiB at the start. A game (2500 MiB) starts; the first + // game start fails and the normal stage comes back while the game still runs; the second + // try works. It must count other programs from the reading before the game, not one that + // has the game in it. + let l = layout("perf-loop-keep-reading"); + let port = server_after_launch(&l, "list").await; + let log = l.strata_home().join("x.engine.log"); + let failed_once = l.data.join("failed-once"); + let exe = crate::strata::tests::fake_strata(&l, &format!( + "case \"$*\" in *'--context 16384'*'expert-vram=0'*) ;; *'--context 16384'*) if [ ! -e '{fo}' ]; then touch '{fo}'; exit 4; fi;; esac; rm -f '{g}'; echo 'strata-q36: (1.10 GiB staging) on 16 CPU threads' >> '{log}'; echo 'Strata is serving.'", + fo = failed_once.display(), g = l.data.join("gone").display(), log = log.display())); + let others = Arc::new(std::sync::atomic::AtomicI64::new(1460)); + let calls = l.data.join("calls"); + let o2 = others.clone(); + let llm = Arc::new(Llm::with_exe(l.clone(), exe).with_gpu(Arc::new(move || { + let c = std::fs::read_to_string(&calls).unwrap_or_default(); + let running = c.lines().last().is_some_and(|x| x.starts_with("launch --family")); + Some(crate::strata::Gpu { id: "GPU-test".into(), used_mib: o2.load(Ordering::SeqCst) + if running { 9874 } else { 0 }, total_mib: 24576 }) + }))); + let s = crate::settings::parse_settings(&serde_json::json!({"llm": {"port": port}})).unwrap(); + llm.start(&s).await.unwrap(); + others.store(1460 + 2500, Ordering::SeqCst); + let brain = Arc::new(FakeBrain::default()); + let task = tokio::spawn(perf_loop(s, llm.clone(), brain.clone(), Arc::new(|| true), Duration::from_millis(300))); + for _ in 0..100 { + if llm.stage_view()["stage"] == serde_json::json!("gaming") { break; } + tokio::time::sleep(Duration::from_millis(100)).await; + } + task.abort(); + assert!(failed_once.exists(), "the first game start failed"); + assert_eq!(llm.stage_view()["stage"], serde_json::json!("gaming")); + let probe16 = crate::placement::Probe { context: 16384, parallel: 1, gpu: "GPU-test".into(), model_mib: 9874, staging_gib: 1.1 }; + let right = crate::placement::game(24576, 1460, &probe16, 8192).expert_gib; + let wrong = crate::placement::game(24576, 1460 + 2500, &probe16, 8192).expert_gib; + assert_ne!(right, wrong); + assert!(launches(&l).last().unwrap().contains(&format!("--set expert-vram={right} ")), "{:?}", launches(&l)); + } + #[derive(Default)] struct TimedBrain(Mutex>); diff --git a/app/src/strata.rs b/app/src/strata.rs index a2ae83e..b1f06a2 100644 --- a/app/src/strata.rs +++ b/app/src/strata.rs @@ -256,8 +256,9 @@ pub struct Llm { /// game stage counts other programs from it (the card then also holds the game, which its /// reserve is for). None when the services started with a game running. baseline: Mutex>, - /// A game ran when the services started (set before `start`). - game_at_start: AtomicBool, + /// A game runs (or may run) as the LLM is placed: set before `start` and at every `switch`. + /// Only a normal placement made while none runs keeps its reading. + game_running: AtomicBool, /// The STT worker's model is on the card (true at switches while the worker runs), so it is not /// taken for another program's memory. stt_on_card: AtomicBool, @@ -286,14 +287,14 @@ impl Llm { pub fn with_exe(layout: Layout, exe: std::path::PathBuf) -> Self { Self { layout, exe, status: Mutex::new(LlmStatus { state: LlmState::Off, managed: false, percent: None, note: None }), active: Mutex::new(None), cancel: Arc::new(AtomicBool::new(false)), port: Mutex::new(0), - stop_timeout: Duration::from_secs(120), gpu: None, baseline: Mutex::new(None), game_at_start: AtomicBool::new(false), stt_on_card: AtomicBool::new(false), room: Mutex::new(None), threads: Mutex::new(None), + stop_timeout: Duration::from_secs(120), gpu: None, baseline: Mutex::new(None), game_running: AtomicBool::new(false), stt_on_card: AtomicBool::new(false), room: Mutex::new(None), threads: Mutex::new(None), stage: Mutex::new((Stage::Normal, None)) } } - /// Whether a game runs as the services start: the start's reading of the card then includes it - /// and is not kept as other programs' memory. + /// Whether a game runs (also in the background) as the services start: the start's reading of + /// the card then includes it and is not kept as other programs' memory. pub fn game_at_start(&self, on: bool) { - self.game_at_start.store(on, Ordering::SeqCst); + self.game_running.store(on, Ordering::SeqCst); } /// `{stage, gameRoomMib}` for the dashboard. @@ -351,9 +352,9 @@ impl Llm { // from the latest normal placement, as the card then also holds the game. let stt_model = if self.stt_on_card.load(Ordering::SeqCst) { crate::placement::STT_MODEL_MIB } else { 0 }; let now_others = (card.used_mib - stt_model).max(0); - // A normal placement keeps its reading, unless a game ran at the start (its memory would be - // taken for other programs'; a later normal placement comes only after the game ended). - if stage != Stage::Gaming && !self.game_at_start.swap(false, Ordering::SeqCst) { + // Only a normal placement made while no game runs keeps its reading (a game's memory would be + // taken for other programs'; also on the way back from a failed game stage). + if stage != Stage::Gaming && !self.game_running.load(Ordering::SeqCst) { *self.baseline.lock().unwrap() = Some(now_others); } let baseline = *self.baseline.lock().unwrap(); @@ -456,12 +457,13 @@ impl Llm { /// Move the running LLM to `stage` (`perf.rs`): a restart with that stage's placement, or a stop /// when it pauses (also a game stage with no room for the game). Returns the stage it ended in. /// With `llm.url` nothing moves. - /// `stt_on_card`: the STT worker's model is loaded on the card. - pub async fn switch(&self, settings: &Settings, stage: Stage, stt_on_card: bool) -> Result { + /// `stt_on_card`: the STT worker's model is loaded on the card; `game_running`: a game runs now. + pub async fn switch(&self, settings: &Settings, stage: Stage, stt_on_card: bool, game_running: bool) -> Result { if settings.llm.url.is_some() { return Ok(Stage::Normal); } self.stt_on_card.store(stt_on_card, Ordering::SeqCst); + self.game_running.store(game_running, Ordering::SeqCst); if stage != Stage::Paused && self.start_stage(settings, stage).await?.is_some() { return Ok(stage); } @@ -987,7 +989,7 @@ pub(crate) mod tests { llm.start(&s).await.unwrap(); assert_eq!(llm.stage_view(), json!({"stage": "normal", "gameRoomMib": null})); std::fs::remove_file(l.data.join("calls")).unwrap(); - assert_eq!(tokio::time::timeout(Duration::from_secs(30), llm.switch(&s, Stage::Gaming, false)).await.unwrap().unwrap(), Stage::Gaming); + assert_eq!(tokio::time::timeout(Duration::from_secs(30), llm.switch(&s, Stage::Gaming, false, true)).await.unwrap().unwrap(), Stage::Gaming); let g = launches(&l); // Measured once at the game's context and one request, then the 2 GiB minimum (8 GB does not // fit on 16 GB) with half the engine's 16 CPU threads. @@ -999,13 +1001,13 @@ pub(crate) mod tests { assert_eq!(llm.status().state, LlmState::Ready); // Back to normal: the run's first reading of other programs, the normal placement again. std::fs::remove_file(l.data.join("calls")).unwrap(); - assert_eq!(llm.switch(&s, Stage::Normal, false).await.unwrap(), Stage::Normal); + assert_eq!(llm.switch(&s, Stage::Normal, false, false).await.unwrap(), Stage::Normal); let n = launches(&l); assert_eq!(n.len(), 1, "{n:?}"); assert!(n[0].contains("--context 32768") && n[0].ends_with("--set expert-vram=1.5 --set prefill=2048"), "{}", n[0]); assert_eq!(llm.stage_view(), json!({"stage": "normal", "gameRoomMib": null})); // Pause: the LLM stops. - assert_eq!(llm.switch(&s, Stage::Paused, false).await.unwrap(), Stage::Paused); + assert_eq!(llm.switch(&s, Stage::Paused, false, true).await.unwrap(), Stage::Paused); assert_eq!(llm.status().state, LlmState::Off); assert_eq!(llm.stage_view()["stage"], json!("paused")); } @@ -1036,11 +1038,11 @@ pub(crate) mod tests { let llm = llm.with_gpu(live_card(&l, others.clone(), true)); // A game starts and holds 2500 MiB: the game stage counts other programs as before the game. others.store(1460 + 2500, Ordering::SeqCst); - llm.switch(&s, Stage::Gaming, true).await.unwrap(); + llm.switch(&s, Stage::Gaming, true, true).await.unwrap(); assert!(launches(&l).last().unwrap().contains("--set expert-vram=2 "), "{:?}", launches(&l)); // The game ends but a video player now holds 1000 MiB more: the normal stage reads that. others.store(1460 + 1000, Ordering::SeqCst); - llm.switch(&s, Stage::Normal, true).await.unwrap(); + llm.switch(&s, Stage::Normal, true, false).await.unwrap(); let expected = crate::placement::normal(16303, 1460 + 1000, &crate::placement::Probe { context: 32768, parallel: 1, gpu: "GPU-test".into(), model_mib: 9874, staging_gib: 1.1 }, 1024); assert!(expected < 1.5); @@ -1069,7 +1071,7 @@ pub(crate) mod tests { llm.game_at_start(true); let s = parse_settings(&json!({"llm": {"port": port}})).unwrap(); llm.start(&s).await.unwrap(); - assert_eq!(llm.switch(&s, Stage::Gaming, false).await.unwrap(), Stage::Gaming, "not paused"); + assert_eq!(llm.switch(&s, Stage::Gaming, false, true).await.unwrap(), Stage::Gaming, "not paused"); let probe16 = crate::placement::Probe { context: 16384, parallel: 1, gpu: "GPU-test".into(), model_mib: 9874, staging_gib: 1.1 }; let expected = crate::placement::normal(16303, 1460 + 2500, &probe16, 1024); assert!(launches(&l).last().unwrap().contains(&format!("--set expert-vram={expected} ")), "{:?}", launches(&l)); @@ -1087,7 +1089,7 @@ pub(crate) mod tests { let s = parse_settings(&json!({"llm": {"port": port}})).unwrap(); llm.start(&s).await.unwrap(); others.store(1460 + 4000 + 4500, Ordering::SeqCst); - llm.switch(&s, Stage::Gaming, false).await.unwrap(); + llm.switch(&s, Stage::Gaming, false, true).await.unwrap(); let probe16 = crate::placement::Probe { context: 16384, parallel: 1, gpu: "GPU-test".into(), model_mib: 9874, staging_gib: 1.1 }; let expected = crate::placement::game(24576, 1460, &probe16, 8500).expert_gib; assert_ne!(expected, crate::placement::game(24576, 1460, &probe16, 8192).expert_gib, "the test tells them apart"); @@ -1109,7 +1111,7 @@ pub(crate) mod tests { let llm = llm.with_gpu(Arc::new(move || { (r2.fetch_add(1, Ordering::SeqCst) == 0).then(|| Gpu { id: "GPU-test".into(), used_mib: 1460, total_mib: 16303 }) })); - assert_eq!(llm.switch(&s, Stage::Gaming, false).await.unwrap(), Stage::Gaming); + assert_eq!(llm.switch(&s, Stage::Gaming, false, true).await.unwrap(), Stage::Gaming); assert!(launches(&l).last().unwrap().contains("--set expert-vram=0 "), "{:?}", launches(&l)); assert_eq!(llm.stage_view(), json!({"stage": "gaming", "gameRoomMib": null})); } @@ -1128,7 +1130,7 @@ pub(crate) mod tests { })); let s = parse_settings(&json!({"llm": {"port": port}})).unwrap(); llm.start(&s).await.unwrap(); - assert_eq!(llm.switch(&s, Stage::Gaming, false).await.unwrap(), Stage::Paused); + assert_eq!(llm.switch(&s, Stage::Gaming, false, true).await.unwrap(), Stage::Paused); assert_eq!(llm.status().state, LlmState::Off); assert_eq!(llm.stage_view(), json!({"stage": "paused", "gameRoomMib": null})); let c = std::fs::read_to_string(l.data.join("calls")).unwrap(); diff --git a/app/tests/game_watch.rs b/app/tests/game_watch.rs index 8da7370..3e72944 100644 --- a/app/tests/game_watch.rs +++ b/app/tests/game_watch.rs @@ -44,3 +44,18 @@ fn a_launcher_game_turns_game_mode_on_until_it_ends() { assert_eq!(off, serde_json::Value::Null, "game mode ends with the game"); w.stop(); } + +/// A game program running behind other windows when the watch starts is found by what it is. +/// Runs only with `JARVIS_TEST_BACKGROUND_GAME=1` (a launcher-folder program runs) or `=0` (none). +#[test] +fn a_game_running_behind_other_windows_is_found_at_the_start() { + let Ok(want) = std::env::var("JARVIS_TEST_BACKGROUND_GAME") else { + eprintln!("skipped: set JARVIS_TEST_BACKGROUND_GAME"); + return; + }; + let w = GameWatch::start(GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0, + reserve_gb: 8.0, revert_seconds: 30, pause_in_game: false }); + eprintln!("in front: {}, at the start: {}", w.on(), w.in_background_at_start()); + assert_eq!(w.in_background_at_start(), want == "1"); + w.stop(); +}