Isolate the game-save and Bink test scratch directories #1952

Closed
lgr123 wants to merge 2 commits from upstream-pr/1952 into main
lgr123 commented 2026-11-25 16:34:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lgr123 on 2026-11-25T16:34:41Z.


Claimed as RT-ISOLATE-GAMESAVE-AND-BINK-SCRATCH in #1608, following the report's three residual sites.

Four concurrent game-save test processes sharing one temporary base exposed the race on Windows x64. Over three batches, public main failed 12 of 12 runs. This patch passed 12 of 12, with 76 checks per run and no leftover game-save scratch directories.

Two invocations using the same temporary base can delete or overwrite one another’s files. Game-save now uses the existing per-process RAII scratch directory, including on early returns. Bink audio and decode use per-process paths and clean them up on normal or handled-failure exit. Set LEONIDA_KEEP_BINK_OUTPUT=1 to retain diagnostics and print their folder. This patch stays scoped to the three remaining fixed names.

Reviewer check

Build the xgameruntime_gamesave_test CMake target, then start four copies at once with TEMP and TMP pointing to the same disposable folder. Let each process use an independent output log. Repeat on main and this branch. This test uses synthetic saves and needs no retail files.

Independent Windows verification passed 12 of 12 concurrent runs alongside #1579 after resolving the three overlapping lines. It also identified that Bink diagnostic folders would accumulate. The follow-up addresses retention with scoped cleanup and an explicit opt-in.

Tested

  • Windows x64, MSVC, public main 9e7720c. Built the actual synthetic game-save executable. Ran three batches of four simultaneously active processes sharing one disposable temporary base.
  • Public main failed 12 of 12 processes. The patched test passed 12 of 12, with 76 checks and zero failures in every process and no remaining scratch directories.
  • Both Bink test translation units compiled. Movie-dependent test paths were not run. Both Bink test files compiled again after the retention change. Synthetic cleanup and opt-in retention passed with default temp, an explicit LEONIDA_TEST_DIR, and cwd fallback with #1579's temp helper.
  • git diff --check and the source-only check passed. No game files were used.

GPUs tested: n/a.

AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5495209512 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1952). Originally posted by [lgr123](https://github.com/lgr123) on 2026-11-25T16:34:41Z. --- Claimed as `RT-ISOLATE-GAMESAVE-AND-BINK-SCRATCH` in [#1608](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7168028667), following the report's [three residual sites](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164348116). Four concurrent game-save test processes sharing one temporary base exposed the race on Windows x64. Over three batches, public main failed **12 of 12** runs. This patch passed **12 of 12**, with 76 checks per run and no leftover game-save scratch directories. Two invocations using the same temporary base can delete or overwrite one another’s files. Game-save now uses the existing per-process RAII scratch directory, including on early returns. Bink audio and decode use per-process paths and clean them up on normal or handled-failure exit. Set `LEONIDA_KEEP_BINK_OUTPUT=1` to retain diagnostics and print their folder. This patch stays scoped to the three remaining fixed names. ### Reviewer check Build the `xgameruntime_gamesave_test` CMake target, then start four copies at once with `TEMP` and `TMP` pointing to the same disposable folder. Let each process use an independent output log. Repeat on main and this branch. This test uses synthetic saves and needs no retail files. [Independent Windows verification](https://github.com/ubiquitarianism/leonida/pull/1952#issuecomment-7169998697) passed 12 of 12 concurrent runs alongside #1579 after resolving the three overlapping lines. It also identified that Bink diagnostic folders would accumulate. The follow-up addresses retention with scoped cleanup and an explicit opt-in. ### Tested - Windows x64, MSVC, public main `9e7720c`. Built the actual synthetic game-save executable. Ran three batches of four simultaneously active processes sharing one disposable temporary base. - Public main failed 12 of 12 processes. The patched test passed 12 of 12, with 76 checks and zero failures in every process and no remaining scratch directories. - Both Bink test translation units compiled. Movie-dependent test paths were not run. Both Bink test files compiled again after the retention change. Synthetic cleanup and opt-in retention passed with default temp, an explicit LEONIDA_TEST_DIR, and cwd fallback with #1579's temp helper. - `git diff --check` and the source-only check passed. No game files were used. GPUs tested: n/a. AI-assisted: yes.
MSedgeMC commented 2026-11-25 17:10:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MSedgeMC on 2026-11-25T17:10:47Z.

Review: APPROVED


Verified: runtime/test/test_temp_dir.h exists on main and defines process_temp_dir(name) as temp_directory_path()/(name_pid); it is already used by d3d12_subgroup_test.cpp. Replacing the fixed shared temp paths in the bink and gamesave tests with process_temp_dir prevents parallel test runs from clobbering each other's scratch files. Consistent with the existing helper, minimal, no game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6061816627 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1952#pullrequestreview-6061816627). Originally posted by [MSedgeMC](https://github.com/MSedgeMC) on 2026-11-25T17:10:47Z. **Review:** APPROVED --- Verified: runtime/test/test_temp_dir.h exists on main and defines process_temp_dir(name) as temp_directory_path()/(name_pid); it is already used by d3d12_subgroup_test.cpp. Replacing the fixed shared temp paths in the bink and gamesave tests with process_temp_dir prevents parallel test runs from clobbering each other's scratch files. Consistent with the existing helper, minimal, no game data.
Diegobecker07 commented 2026-11-25 17:47:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Diegobecker07 on 2026-11-25T17:47:15Z.


I tested this together with #1579, which changes the same three lines (to testfiles::writable_temp_dir() / "<fixed name>"). The two conflict in all three files, whichever lands second. Resolving each conflict with this PR's line works. #1579's process_temp_dir builds on writable_temp_dir(), so its fix for a stripped environment carries over.

Setup: main 863c1616a + #1579 + this PR, conflicts resolved that way, on Windows 11 Pro 26300 with MSVC 19.44.

  • xgameruntime_gamesave_test, normal runs: 3 of 3 pass with 76 checks and 0 failures.
  • Stripped environment: with TMP, TEMP, USERPROFILE and TMPDIR removed, 3 of 3 pass and nothing is left in the build folder.
  • Four copies at once, one shared TEMP/TMP folder, three batches: 0 of 12 fail and no folders are left. For comparison, on this machine two copies at once failed 10 of 10 on main and on #1579 alone (comment on #1579).
  • Bink tests: bink_audio_test and bink_decode_test build but were not run, because they need a movie.

One trade-off: each Bink test now writes to a new <name>_<pid> folder on every run, and nothing removes it. On main, each run overwrote one folder. bink_decode_test writes frames 0 and 1 (plus the LEONIDA_GOTO frame when set) as raw BGRA and PPM, about 7 bytes per pixel per frame. bink_audio_test writes a PCM and a WAV per track. The decoded output therefore builds up in %TEMP%, one folder per run. If the files are meant to stay for inspection, one option is ScratchDir by default, keeping the folder only when an environment variable asks for it.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7169998697 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1952#issuecomment-7169998697). Originally posted by [Diegobecker07](https://github.com/Diegobecker07) on 2026-11-25T17:47:15Z. --- I tested this together with #1579, which changes the same three lines (to `testfiles::writable_temp_dir() / "<fixed name>"`). The two conflict in all three files, whichever lands second. Resolving each conflict with this PR's line works. #1579's `process_temp_dir` builds on `writable_temp_dir()`, so its fix for a stripped environment carries over. Setup: main 863c1616a + #1579 + this PR, conflicts resolved that way, on Windows 11 Pro 26300 with MSVC 19.44. - **`xgameruntime_gamesave_test`, normal runs:** 3 of 3 pass with 76 checks and 0 failures. - **Stripped environment:** with TMP, TEMP, USERPROFILE and TMPDIR removed, 3 of 3 pass and nothing is left in the build folder. - **Four copies at once, one shared TEMP/TMP folder, three batches:** 0 of 12 fail and no folders are left. For comparison, on this machine two copies at once failed 10 of 10 on main and on #1579 alone ([comment on #1579](https://github.com/ubiquitarianism/leonida/pull/1579#issuecomment-7167400086)). - **Bink tests:** `bink_audio_test` and `bink_decode_test` build but were not run, because they need a movie. One trade-off: each Bink test now writes to a new `<name>_<pid>` folder on every run, and nothing removes it. On main, each run overwrote one folder. `bink_decode_test` writes frames 0 and 1 (plus the `LEONIDA_GOTO` frame when set) as raw BGRA and PPM, about 7 bytes per pixel per frame. `bink_audio_test` writes a PCM and a WAV per track. The decoded output therefore builds up in `%TEMP%`, one folder per run. If the files are meant to stay for inspection, one option is `ScratchDir` by default, keeping the folder only when an environment variable asks for it. AI-assisted.
OreoFR commented 2026-11-28 21:56:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:56:29Z.


Verified by OreoFR

  • Base: main c1ecf04ed + PR head 78249ac07; green run in a merge package of 15 PRs, no new ctest failure vs main
  • Test: ctest -R "^(bink_audio|bink_decode|xgameruntime_gamesave)$"
  • Red on main: xgameruntime_gamesave OK, bink_audio/bink_decode SKIP (no movie)
  • Green with the PR: same
  • Verdict: NO RED (test-only PR: isolated temp folders; the Bink tests need LEONIDA_MOVIE, not exercised)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246382906 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1952#issuecomment-7246382906). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:56:29Z. --- **Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `78249ac07`; green run in a merge package of 15 PRs, no new ctest failure vs main - Test: `ctest -R "^(bink_audio|bink_decode|xgameruntime_gamesave)$"` - Red on main: xgameruntime_gamesave OK, bink_audio/bink_decode SKIP (no movie) - Green with the PR: same - Verdict: NO RED (test-only PR: isolated temp folders; the Bink tests need LEONIDA_MOVIE, not exercised) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-29 02:42:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T02:42:24Z.


Windows 11 NTFS Verification (78249ac07b merged with main c8bf0e7b65) — PASS

  • Environment: Windows 11 (10.0.26200), NTFS, MSVC 19.44.35207 (/O2 /MD /EHsc /std:c++20 /W4 /permissive- /utf-8, /link /OPT:NOREF).
  • Merge, Docs & CTest Gates: Clean git merge-tree onto main (c8bf0e7b65) (0 conflicts); check_no_game_data.py, test_docs_env_vars.py (5/5), test_docs_table_rows.py (2/2), test_docs_encoding.py (1/1), test_ctest_registration.py (7/7), and test_ci_registration.py (18/18) all OK; 0 new /W4 warnings.
  • Red -> Green:
    • Red (main xgameruntime_gamesave_test.cpp under 4 concurrent staggered processes sharing %TEMP%): all 4/4 concurrent processes fail (rc = [1, 1, 1, 1]) when colliding on the un-isolated %TEMP%/leonida_gamesave_test folder.
    • Green (78249ac07b + main c8bf0e7b65):
      1. xgameruntime_gamesave_test.exe single run (96 checks, 0 failures, rc=0) and 4 concurrent staggered processes (rc = [0, 0, 0, 0], 0 leftover leonida_gamesave_test_<pid> directories in %TEMP%).
      2. bink_decode_test.exe and bink_audio_test.exe: compile cleanly (/W4) and exit 77 (CTest skip) when LEONIDA_GAME_DIR is unset.
      3. testfiles::ScratchDir::keep() unit probe: removes <name>_<pid> on scope exit by default and retains it when .keep() is called (rc=0).
  • Cross-PR note (#1579): Merging #1952 with open PR #1579 has a small 3-line overlap in bink_audio_test.cpp, bink_decode_test.cpp, and xgameruntime_gamesave_test.cpp (test_temp_dir.h auto-merges cleanly); keeping #1952's testfiles::ScratchDir lines automatically picks up #1579's writable_temp_dir() fallback through process_temp_dir(...).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249595805 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1952#issuecomment-7249595805). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T02:42:24Z. --- ### Windows 11 NTFS Verification (`78249ac07b` merged with `main` `c8bf0e7b65`) — PASS - **Environment**: Windows 11 (`10.0.26200`), NTFS, MSVC `19.44.35207` (`/O2 /MD /EHsc /std:c++20 /W4 /permissive- /utf-8`, `/link /OPT:NOREF`). - **Merge, Docs & CTest Gates**: Clean `git merge-tree` onto `main` (`c8bf0e7b65`) (`0` conflicts); `check_no_game_data.py`, `test_docs_env_vars.py` (`5/5`), `test_docs_table_rows.py` (`2/2`), `test_docs_encoding.py` (`1/1`), `test_ctest_registration.py` (`7/7`), and `test_ci_registration.py` (`18/18`) all `OK`; `0` new `/W4` warnings. - **Red -> Green**: - **Red (`main` `xgameruntime_gamesave_test.cpp` under 4 concurrent staggered processes sharing `%TEMP%`)**: all `4/4` concurrent processes fail (`rc = [1, 1, 1, 1]`) when colliding on the un-isolated `%TEMP%/leonida_gamesave_test` folder. - **Green (`78249ac07b` + `main` `c8bf0e7b65`)**: 1. `xgameruntime_gamesave_test.exe` single run (`96 checks, 0 failures`, `rc=0`) and **4 concurrent staggered processes** (`rc = [0, 0, 0, 0]`, `0` leftover `leonida_gamesave_test_<pid>` directories in `%TEMP%`). 2. `bink_decode_test.exe` and `bink_audio_test.exe`: compile cleanly (`/W4`) and exit `77` (`CTest` skip) when `LEONIDA_GAME_DIR` is unset. 3. `testfiles::ScratchDir::keep()` unit probe: removes `<name>_<pid>` on scope exit by default and retains it when `.keep()` is called (`rc=0`). - **Cross-PR note (`#1579`)**: Merging `#1952` with open PR `#1579` has a small 3-line overlap in `bink_audio_test.cpp`, `bink_decode_test.cpp`, and `xgameruntime_gamesave_test.cpp` (`test_temp_dir.h` auto-merges cleanly); keeping `#1952`'s `testfiles::ScratchDir` lines automatically picks up `#1579`'s `writable_temp_dir()` fallback through `process_temp_dir(...)`. AI-assisted.
aslan2142 commented 2026-12-01 17:24:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:24:37Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319253755 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1952#issuecomment-7319253755). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:24:37Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1952
No description provided.