tests: resolve a writable temp dir instead of crashing on C:\Windows #1579

Closed
whoalin1 wants to merge 1 commit from upstream-pr/1579 into main
whoalin1 commented 2026-11-25 04:57:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T04:57:22Z.


Claimed in the coordination issue: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7152024965

What

With TMP/TEMP/USERPROFILE unset, GetTempPathW returns C:\Windows, which is not writable. Dozens of test binaries then die with 0xc0000409 (uncaught std::filesystem exception) instead of running or skipping — reproduced on main as ctest -R d3d12_mesh → exit 0xc0000409.

runtime/test/test_temp_dir.h gains a writable-dir probe chain (LEONIDA_TEST_DIR → temp_directory_path → current_path, each proven by an actual create/write/delete) and ensure_temp_env(), a pre-main initializer that repairs TMP/TEMP/TMPDIR when the effective temp dir is not writable — which also fixes the loader's own GetTempPathW clone dir, unreachable from test code. scratch_dir()/process_temp_dir() now resolve through it, covering every ScratchDir user (~17 suites), and the ~15 sites that threw directly (create_directories, copy_file, ofstream, _sopen_s capture) get empty → SKIP(77)/loud-failure guards. d3d12_queue_handover_test's stderr capture no longer reads an empty file as "layer was silent".

runtime/shims/d3d12_vulkan_device.cpp default_shader_cache_dir() probes the temp-based dir and falls back to cwd/leonida_shader_cache — without it d3d12_shader_cache reached its disk section and returned E_FAIL under a stripped env. Writable-temp behavior is byte-identical to before.

runtime/CMakeLists.txt: the 14 ctest entries that execute gta6rt/loader guests which the test exes' header cannot reach get ENVIRONMENT "TMP=${CMAKE_CURRENT_BINARY_DIR};TEMP=${CMAKE_CURRENT_BINARY_DIR}" — verified failing before (run_tiny_* "home clone of gta6rt_tls_host.dll cannot be loaded", run_startup_cmdline TLS index) and passing after, with the env stripped. The other gta6rt entries were run under the same stripped env and pass untouched (their guests never touch temp).

Verification (native Windows 11, env stripped of TMP/TEMP/USERPROFILE/ TMPDIR — the failure environment itself)

  • 23/23 GPU d3d12 tests pass (mesh, geometry, state_sweep, shader_cache, queue_handover ×3, conservative ×3+reference+inner_coverage ×2, depth24, depth_resolve, execute_indirect_validation, f16_halves, indirect_dispatch_count, multi_viewport, bindless_churn ×2, stores_atomics, bundle ×2, compute, draw) — zero 0xc0000409.
  • 14/14 run_tiny_* + run_startup_cmdline ctest entries pass (were all failing).
  • 11/11 non-GPU temp users pass (file_system, pipeline_cache_file, shader_fixture_path, xdxr_build_output, module_names ×2, pe_loader_bounds, pe_loader_fuzz, startup_trace, unimplemented_policy, large_module_gate); loader/pe_loader/loader_tls families and 10 GetTempPathW-user + 13 variant tests pass.
  • Spot-check under a normal env: 7/7 pass — no behavior change when temp is writable.
  • GPU runs on the default ICD (NVIDIA RTX 4070 SUPER); LEONIDA_VK_VALIDATION not needed (test-harness-only change plus a fallback path).

Independent review: APPROVE after one fix round (the gta6rt ctest gap above was the reviewer's catch; verified and fixed).

AI-assisted (Devin).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5485443756 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1579). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T04:57:22Z. --- Claimed in the coordination issue: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7152024965 ## What With `TMP`/`TEMP`/`USERPROFILE` unset, `GetTempPathW` returns `C:\Windows`, which is not writable. Dozens of test binaries then die with `0xc0000409` (uncaught `std::filesystem` exception) instead of running or skipping — reproduced on `main` as `ctest -R d3d12_mesh` → exit `0xc0000409`. `runtime/test/test_temp_dir.h` gains a writable-dir probe chain (`LEONIDA_TEST_DIR` → `temp_directory_path` → `current_path`, each proven by an actual create/write/delete) and `ensure_temp_env()`, a pre-`main` initializer that repairs `TMP`/`TEMP`/`TMPDIR` when the effective temp dir is not writable — which also fixes the loader's own `GetTempPathW` clone dir, unreachable from test code. `scratch_dir()`/`process_temp_dir()` now resolve through it, covering every `ScratchDir` user (~17 suites), and the ~15 sites that threw directly (`create_directories`, `copy_file`, `ofstream`, `_sopen_s` capture) get `empty → SKIP(77)`/loud-failure guards. `d3d12_queue_handover_test`'s stderr capture no longer reads an empty file as "layer was silent". `runtime/shims/d3d12_vulkan_device.cpp` `default_shader_cache_dir()` probes the temp-based dir and falls back to `cwd/leonida_shader_cache` — without it `d3d12_shader_cache` reached its disk section and returned `E_FAIL` under a stripped env. Writable-temp behavior is byte-identical to before. `runtime/CMakeLists.txt`: the 14 ctest entries that execute `gta6rt`/loader guests which the test exes' header cannot reach get `ENVIRONMENT "TMP=${CMAKE_CURRENT_BINARY_DIR};TEMP=${CMAKE_CURRENT_BINARY_DIR}"` — verified failing before (`run_tiny_*` "home clone of gta6rt_tls_host.dll cannot be loaded", `run_startup_cmdline` TLS index) and passing after, with the env stripped. The other gta6rt entries were run under the same stripped env and pass untouched (their guests never touch temp). ## Verification (native Windows 11, env stripped of TMP/TEMP/USERPROFILE/ TMPDIR — the failure environment itself) - 23/23 GPU d3d12 tests pass (mesh, geometry, state_sweep, shader_cache, queue_handover ×3, conservative ×3+reference+inner_coverage ×2, depth24, depth_resolve, execute_indirect_validation, f16_halves, indirect_dispatch_count, multi_viewport, bindless_churn ×2, stores_atomics, bundle ×2, compute, draw) — zero `0xc0000409`. - 14/14 `run_tiny_*` + `run_startup_cmdline` ctest entries pass (were all failing). - 11/11 non-GPU temp users pass (file_system, pipeline_cache_file, shader_fixture_path, xdxr_build_output, module_names ×2, pe_loader_bounds, pe_loader_fuzz, startup_trace, unimplemented_policy, large_module_gate); loader/pe_loader/loader_tls families and 10 GetTempPathW-user + 13 variant tests pass. - Spot-check under a normal env: 7/7 pass — no behavior change when temp is writable. - GPU runs on the default ICD (NVIDIA RTX 4070 SUPER); `LEONIDA_VK_VALIDATION` not needed (test-harness-only change plus a fallback path). Independent review: APPROVE after one fix round (the gta6rt ctest gap above was the reviewer's catch; verified and fixed). AI-assisted (Devin).
Diegobecker07 commented 2026-11-25 15:53:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Diegobecker07 on 2026-11-25T15:53:13Z.


Reviewed 805acd181, merged with main b0f3d3998, on Windows 11 Pro 26300 with an RTX 5070 Ti (NVIDIA 621.24) and MSVC 19.44. The full ctest passes, 449 of 449.

What it fixes, confirmed. I ran the nine scratch-folder tests (d3d12_depth24_draw, d3d12_depth_resolve, d3d12_f16_halves, d3d12_geometry, d3d12_mesh, d3d12_shader_cache, d3d12_state_sweep, d3d12_stores_atomics, xgameruntime_gamesave) with TMP, TEMP, USERPROFILE and TMPDIR removed:

  • main's binaries crash with 0xc0000409 in all nine. They were built at 0d80bc5df, and none of these files has changed on main since.
  • With this PR all nine pass.

The per-process folders also fix running two copies at once. I started two copies of d3d12_shader_cache together, five rounds: 3 of 10 copies fail on main and 0 of 10 with this PR.

1. Four of the new per-process folders are never removed. scratch_dir() creates <temp>/<name>_<pid>, and in four tests nothing deletes it: d3d12_depth_resolve_test, d3d12_f16_halves_test, d3d12_state_sweep_test and d3d12_stores_atomics_test. The other four remove theirs. On main these four used one fixed folder that each run overwrote; with this PR each run leaves its own folder behind. One run of the nine tests left four new folders in %TEMP%, holding 2–4 files each (the copied SPIR-V and index.json). With the environment stripped, the folders land in the working directory, which is the build folder under ctest. testfiles::ScratchDir, already in test_temp_dir.h, creates the folder and removes it on exit, so switching these four to it fixes both cases.

2. Three sites keep a fixed name (writable_temp_dir() / "<name>"): bink_audio_test.cpp:426, bink_decode_test.cpp:248 and xgameruntime_gamesave_test.cpp:126. When two copies of xgameruntime_gamesave_test start together, all 10 of 10 copies fail, both on main and with this PR; each copy fails 6 of 76 checks, starting with "seed blobs a and b". One copy on its own passes. This is outside the PR's stated scope (the stripped environment), so it can be a follow-up; the three sites are listed in #1608 (comment 7164348116).

3. Minor, in the runtime. default_shader_cache_dir() now creates the folder whenever the path is requested. clear_all() requests it, so a ClearAll now creates an empty %TEMP%\leonida_shader_cache when there was none. When no temp folder is writable, it falls back to the working directory, which for gta6rt is the directory it was started from rather than the overlay. Neither of these changes a test result.

Overlap: #1600 (TEST-TEMPDIR-STRIPPED-ENV, open, needs rebase) changes the same ~47 files to fix the same stripped-environment crash, so the two can't both land as they are.

Recommendation: merge after fixing 1 (switching four tests to ScratchDir); 2 can be a follow-up.

AI-assisted review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7167400086 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1579#issuecomment-7167400086). Originally posted by [Diegobecker07](https://github.com/Diegobecker07) on 2026-11-25T15:53:13Z. --- Reviewed 805acd181, merged with main b0f3d3998, on Windows 11 Pro 26300 with an RTX 5070 Ti (NVIDIA 621.24) and MSVC 19.44. The full ctest passes, 449 of 449. **What it fixes, confirmed.** I ran the nine scratch-folder tests (`d3d12_depth24_draw`, `d3d12_depth_resolve`, `d3d12_f16_halves`, `d3d12_geometry`, `d3d12_mesh`, `d3d12_shader_cache`, `d3d12_state_sweep`, `d3d12_stores_atomics`, `xgameruntime_gamesave`) with TMP, TEMP, USERPROFILE and TMPDIR removed: - main's binaries crash with `0xc0000409` in all nine. They were built at 0d80bc5df, and none of these files has changed on main since. - With this PR all nine pass. The per-process folders also fix running two copies at once. I started two copies of `d3d12_shader_cache` together, five rounds: 3 of 10 copies fail on main and 0 of 10 with this PR. **1. Four of the new per-process folders are never removed.** `scratch_dir()` creates `<temp>/<name>_<pid>`, and in four tests nothing deletes it: `d3d12_depth_resolve_test`, `d3d12_f16_halves_test`, `d3d12_state_sweep_test` and `d3d12_stores_atomics_test`. The other four remove theirs. On main these four used one fixed folder that each run overwrote; with this PR each run leaves its own folder behind. One run of the nine tests left four new folders in `%TEMP%`, holding 2–4 files each (the copied SPIR-V and `index.json`). With the environment stripped, the folders land in the working directory, which is the build folder under ctest. `testfiles::ScratchDir`, already in `test_temp_dir.h`, creates the folder and removes it on exit, so switching these four to it fixes both cases. **2. Three sites keep a fixed name** (`writable_temp_dir() / "<name>"`): `bink_audio_test.cpp:426`, `bink_decode_test.cpp:248` and `xgameruntime_gamesave_test.cpp:126`. When two copies of `xgameruntime_gamesave_test` start together, all 10 of 10 copies fail, both on main and with this PR; each copy fails 6 of 76 checks, starting with "seed blobs a and b". One copy on its own passes. This is outside the PR's stated scope (the stripped environment), so it can be a follow-up; the three sites are listed in #1608 (comment 7164348116). **3. Minor, in the runtime.** `default_shader_cache_dir()` now creates the folder whenever the path is requested. `clear_all()` requests it, so a `ClearAll` now creates an empty `%TEMP%\leonida_shader_cache` when there was none. When no temp folder is writable, it falls back to the working directory, which for gta6rt is the directory it was started from rather than the overlay. Neither of these changes a test result. **Overlap:** #1600 (TEST-TEMPDIR-STRIPPED-ENV, open, needs rebase) changes the same ~47 files to fix the same stripped-environment crash, so the two can't both land as they are. **Recommendation:** merge after fixing 1 (switching four tests to `ScratchDir`); 2 can be a follow-up. AI-assisted review.
Diegobecker07 commented 2026-11-25 17:47:13 +00:00 (Migrated from github.com)

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


Checked edd15f364, merged with main 863c1616a, on the same machine as before (Windows 11 Pro 26300, RTX 5070 Ti, NVIDIA 621.24, MSVC 19.44). Point 1 is fixed. I built the four tests and ran each one three times normally and three times with TMP, TEMP, USERPROFILE and TMPDIR removed. All 24 runs exit 0, and none leaves a <name>_<pid> folder in %TEMP% or in the build folder.

Heads-up: #1952 changes the same lines in bink_audio_test.cpp, bink_decode_test.cpp and xgameruntime_gamesave_test.cpp, so whichever of the two lands second will conflict. The details are on #1952.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7169998173 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1579#issuecomment-7169998173). Originally posted by [Diegobecker07](https://github.com/Diegobecker07) on 2026-11-25T17:47:13Z. --- Checked edd15f364, merged with main 863c1616a, on the same machine as before (Windows 11 Pro 26300, RTX 5070 Ti, NVIDIA 621.24, MSVC 19.44). Point 1 is fixed. I built the four tests and ran each one three times normally and three times with TMP, TEMP, USERPROFILE and TMPDIR removed. All 24 runs exit 0, and none leaves a `<name>_<pid>` folder in `%TEMP%` or in the build folder. Heads-up: #1952 changes the same lines in `bink_audio_test.cpp`, `bink_decode_test.cpp` and `xgameruntime_gamesave_test.cpp`, so whichever of the two lands second will conflict. The details are on #1952. AI-assisted.
whoalin1 commented 2026-11-25 18:31:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T18:31:03Z.


Thanks for the thorough review, @Diegobecker07 — especially the concurrent-copy experiment. Pushed edd15f364 addressing point 1: all four tests (d3d12_depth_resolve_test, d3d12_f16_halves_test, d3d12_state_sweep_test, d3d12_stores_atomics_test) now use testfiles::ScratchDir, which removes the per-process folder on every way out of main — the same pattern the other scratch-library tests use. The no-writable-dir case still SKIPs with 77 (checked via is_directory after construction, since ScratchDir always falls back to a path). Syntax-checked each translation unit with MSVC cl /Zs (NOMINMAX + the test-shader defines); a full ctest run on both GPUs follows once the shared GPU lock cycles free, and I'll post the result here.

On point 2 (the three fixed-name sites in bink_audio_test.cpp:426, bink_decode_test.cpp:248, xgameruntime_gamesave_test.cpp:126): agreed, follow-up material — they're outside the stripped-environment scope and already tracked in #1608. On point 3: noted; clear_all() creating an empty cache dir is harmless in practice, but I'll look at it if it ever surfaces in a test. On the #1600 overlap: agreed they can't both land as-is; this branch is the superset (stripped-env + per-process isolation + cleanup), happy to rebase whichever way the maintainer prefers.

AI-assisted (Devin).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7171014814 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1579#issuecomment-7171014814). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T18:31:03Z. --- Thanks for the thorough review, @Diegobecker07 — especially the concurrent-copy experiment. Pushed `edd15f364` addressing point 1: all four tests (`d3d12_depth_resolve_test`, `d3d12_f16_halves_test`, `d3d12_state_sweep_test`, `d3d12_stores_atomics_test`) now use `testfiles::ScratchDir`, which removes the per-process folder on every way out of main — the same pattern the other scratch-library tests use. The no-writable-dir case still SKIPs with 77 (checked via `is_directory` after construction, since `ScratchDir` always falls back to a path). Syntax-checked each translation unit with MSVC `cl /Zs` (`NOMINMAX` + the test-shader defines); a full ctest run on both GPUs follows once the shared GPU lock cycles free, and I'll post the result here. On point 2 (the three fixed-name sites in `bink_audio_test.cpp:426`, `bink_decode_test.cpp:248`, `xgameruntime_gamesave_test.cpp:126`): agreed, follow-up material — they're outside the stripped-environment scope and already tracked in #1608. On point 3: noted; `clear_all()` creating an empty cache dir is harmless in practice, but I'll look at it if it ever surfaces in a test. On the #1600 overlap: agreed they can't both land as-is; this branch is the superset (stripped-env + per-process isolation + cleanup), happy to rebase whichever way the maintainer prefers. AI-assisted (Devin).
whoalin1 commented 2026-11-25 20:02:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T20:02:15Z.


Rebased onto current main (db1a22d29) as f4a906884 and squashed the four ScratchDir commits into one for a single conflict-resolution pass. The only textual conflict was run_tiny_first_run_ui in runtime/CMakeLists.txt; resolution unions main's LEONIDA_KEYBOARD_PAD reset with this PR's TMP/TEMP redirect. The overlapping bink/gamesave hunks auto-merged and retain the current-main code with only the temp-root substitution. git diff --check is clean; a fresh MSVC runtime build is running locally as a sanity check, and CI will provide the full matrix. AI-assisted with Devin.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7173098896 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1579#issuecomment-7173098896). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T20:02:15Z. --- Rebased onto current main (`db1a22d29`) as `f4a906884` and squashed the four ScratchDir commits into one for a single conflict-resolution pass. The only textual conflict was `run_tiny_first_run_ui` in `runtime/CMakeLists.txt`; resolution unions main's `LEONIDA_KEYBOARD_PAD` reset with this PR's TMP/TEMP redirect. The overlapping bink/gamesave hunks auto-merged and retain the current-main code with only the temp-root substitution. `git diff --check` is clean; a fresh MSVC runtime build is running locally as a sanity check, and CI will provide the full matrix. AI-assisted with Devin.
TheGeogeo commented 2026-11-28 22:16:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T22:16:43Z.


Duplicate check (diff reading only, no build): #1579 and #1600 fix the same finding (GetTempPath gives C:\Windows with TMP, TEMP and USERPROFILE unset). They conflict in many test files (git merge-tree), so only one can land as is.

Suggest keeping #1600. It is based on a recent main (149 commits behind, against 3314 here) and moves all the tests to testfiles::temp_dir().

Two parts of this PR are not in #1600 and could come back as a follow-up:

  • the shader cache folder fallback in runtime/shims/d3d12_vulkan_device.cpp;
  • setting TMP and TEMP through CMake for the tests that run gta6rt, where #1600 changes pe_loader.cpp instead.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246622582 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1579#issuecomment-7246622582). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T22:16:43Z. --- Duplicate check (diff reading only, no build): #1579 and #1600 fix the same finding (`GetTempPath` gives `C:\Windows` with TMP, TEMP and USERPROFILE unset). They conflict in many test files (`git merge-tree`), so only one can land as is. Suggest keeping #1600. It is based on a recent `main` (149 commits behind, against 3314 here) and moves all the tests to `testfiles::temp_dir()`. Two parts of this PR are not in #1600 and could come back as a follow-up: - the shader cache folder fallback in `runtime/shims/d3d12_vulkan_device.cpp`; - setting TMP and TEMP through CMake for the tests that run `gta6rt`, where #1600 changes `pe_loader.cpp` instead. AI-assisted (Claude Code).
zmasi commented 2026-11-29 00:36:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T00:36:31Z.


Windows 11 + MSVC 19.44 + RTX 3090 Verification — PASS (f4a9068844)

Verified f4a9068844 merged onto origin/main (829530dbd0 and 48bae6cade, 0 conflicts, plus a 5-way combined merge alongside #1918, #1628, #2198, and #900) on native Windows 11 (10.0.26200.9974) with MSVC 19.44.35228, NVIDIA GeForce RTX 3090, and VK_LAYER_KHRONOS_validation 1.4.363.1.

Checks Run

  • detail::kTempEnvEnsured pre-main dynamic initializer under /O2 /Gw /Gy /OPT:REF:
    • Compiled a minimal harness that only #include "test_temp_dir.h" without referencing any testfiles:: symbol in main(), linked with /OPT:REF, and verified Win32 GetTempPathW() inside main():
      • With TMP and TEMP set to a non-creatable path (...\drivers\etc\hosts\unwritable_temp) and USERPROFILE unset -> GetTempPathW() resolved to the writable working directory (rc=0).
      • With TMP, TEMP, and USERPROFILE all stripped from the process environment (where Windows defaults GetTempPathW() to C:\Windows\) -> writable_probe rejected C:\Windows\ and updated TMP/TEMP before main() so GetTempPathW() resolved to the writable working directory (rc=0).
  • Red -> Green C++ & GPU test execution under unwritable TMP/TEMP:
    • shader_fixture_path_test.exe: Red crash 0xc0000409 (__fastfail on uncaught std::filesystem::filesystem_error before try) on origin/main -> Green rc=0 on #1579 + origin/main.
    • pipeline_cache_file_test.exe: Red crash 0xc0000409 on origin/main -> Green rc=0 on #1579 + origin/main.
    • d3d12_shader_cache_test.exe on NVIDIA GeForce RTX 3090 with unwritable TMP/TEMP, LEONIDA_VK_VALIDATION=1, and VK_VALIDATE_SYNC=1 (exercising both testfiles::scratch_dir and default_shader_cache_dir() in runtime/shims/d3d12_vulkan_device.cpp): rc=0, 0 VUID- / validation errors.
  • Registration gates: tests/test_ctest_registration.py and tests/test_ci_registration.py passed (rc=0).

Non-Blocking Notes

  1. Newer gta6rt CTest entries added on main since #1579's base: Four newer gta6rt tests on current main (run_tiny_async, run_tiny_gdk_load, run_tiny_bundled_load, and run_tiny_atexit in runtime/CMakeLists.txt, where tiny_atexit exercises thread_local TLS host clones) sit just above #1579's foreach(test_name ...) ENVIRONMENT "TMP=...;TEMP=..." block and could be added to that foreach list in a follow-up for stripped-environment CTest runs.
  2. Pre-existing read-only directory edge case in default_shader_cache_dir() (runtime/shims/d3d12_vulkan_device.cpp): std::filesystem::create_directories(dir, ec) succeeds with !ec if <tmp>\leonida_shader_cache already exists on disk even when the directory is not writable by the current user (whereas testfiles::detail::writable_probe also probes file creation).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248230183 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1579#issuecomment-7248230183). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T00:36:31Z. --- ## Windows 11 + MSVC `19.44` + RTX 3090 Verification — PASS (`f4a9068844`) Verified `f4a9068844` merged onto `origin/main` (`829530dbd0` and `48bae6cade`, `0` conflicts, plus a 5-way combined merge alongside `#1918`, `#1628`, `#2198`, and `#900`) on native Windows 11 (`10.0.26200.9974`) with MSVC `19.44.35228`, NVIDIA GeForce RTX 3090, and `VK_LAYER_KHRONOS_validation` `1.4.363.1`. ### Checks Run - **`detail::kTempEnvEnsured` pre-`main` dynamic initializer under `/O2 /Gw /Gy /OPT:REF`**: - Compiled a minimal harness that only `#include "test_temp_dir.h"` without referencing any `testfiles::` symbol in `main()`, linked with `/OPT:REF`, and verified Win32 `GetTempPathW()` inside `main()`: - With `TMP` and `TEMP` set to a non-creatable path (`...\drivers\etc\hosts\unwritable_temp`) and `USERPROFILE` unset -> `GetTempPathW()` resolved to the writable working directory (`rc=0`). - With `TMP`, `TEMP`, and `USERPROFILE` all stripped from the process environment (where Windows defaults `GetTempPathW()` to `C:\Windows\`) -> `writable_probe` rejected `C:\Windows\` and updated `TMP`/`TEMP` before `main()` so `GetTempPathW()` resolved to the writable working directory (`rc=0`). - **Red -> Green C++ & GPU test execution under unwritable `TMP`/`TEMP`**: - `shader_fixture_path_test.exe`: **Red** crash `0xc0000409` (`__fastfail` on uncaught `std::filesystem::filesystem_error` before `try`) on `origin/main` -> **Green** `rc=0` on `#1579 + origin/main`. - `pipeline_cache_file_test.exe`: **Red** crash `0xc0000409` on `origin/main` -> **Green** `rc=0` on `#1579 + origin/main`. - `d3d12_shader_cache_test.exe` on **NVIDIA GeForce RTX 3090** with unwritable `TMP`/`TEMP`, `LEONIDA_VK_VALIDATION=1`, and `VK_VALIDATE_SYNC=1` (exercising both `testfiles::scratch_dir` and `default_shader_cache_dir()` in `runtime/shims/d3d12_vulkan_device.cpp`): **`rc=0`**, **`0` `VUID-` / validation errors**. - **Registration gates**: `tests/test_ctest_registration.py` and `tests/test_ci_registration.py` passed (`rc=0`). ### Non-Blocking Notes 1. **Newer `gta6rt` CTest entries added on `main` since `#1579`'s base**: Four newer `gta6rt` tests on current `main` (`run_tiny_async`, `run_tiny_gdk_load`, `run_tiny_bundled_load`, and `run_tiny_atexit` in `runtime/CMakeLists.txt`, where `tiny_atexit` exercises `thread_local` TLS host clones) sit just above `#1579`'s `foreach(test_name ...)` `ENVIRONMENT "TMP=...;TEMP=..."` block and could be added to that `foreach` list in a follow-up for stripped-environment CTest runs. 2. **Pre-existing read-only directory edge case in `default_shader_cache_dir()` (`runtime/shims/d3d12_vulkan_device.cpp`)**: `std::filesystem::create_directories(dir, ec)` succeeds with `!ec` if `<tmp>\leonida_shader_cache` already exists on disk even when the directory is not writable by the current user (whereas `testfiles::detail::writable_probe` also probes file creation). AI-assisted.
TheGeogeo commented 2026-11-29 14:17:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T14:17:26Z.


Already in main: #1600, the duplicate named in the check above, was merged on 2026-11-29 as 44ddf9b05 (in main 3535eb5c4) and fixes the same finding (GetTempPath falling back to C:\Windows with TMP, TEMP and USERPROFILE unset). This branch now conflicts with main in 35 files.

Re-checked in the tree on main c22a0a732, not from the history: main's runtime/test/test_temp_dir.h has testfiles::temp_dir(), which avoids the C:\Windows fallback. All 47 runtime/test .cpp files this branch edits already include it, and no file it touches still calls GetTempPath. The only part main lacks is this branch's writable-folder probe (detail::writable_probe), which goes beyond the reported finding.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257188047 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1579#issuecomment-7257188047). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T14:17:26Z. --- Already in main: #1600, the duplicate named in the check above, was merged on 2026-11-29 as `44ddf9b05` (in `main` `3535eb5c4`) and fixes the same finding (`GetTempPath` falling back to `C:\Windows` with TMP, TEMP and USERPROFILE unset). This branch now conflicts with `main` in 35 files. Re-checked in the tree on `main` `c22a0a732`, not from the history: `main`'s `runtime/test/test_temp_dir.h` has `testfiles::temp_dir()`, which avoids the `C:\Windows` fallback. All 47 `runtime/test` `.cpp` files this branch edits already include it, and no file it touches still calls `GetTempPath`. The only part `main` lacks is this branch's writable-folder probe (`detail::writable_probe`), which goes beyond the reported finding. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 14:30:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:30:28Z.


Closing as a duplicate of #1600, merged as 44ddf9b05 (in main), which fixes the same GetTempPath fallback to C:\Windows for every test. This branch now conflicts with main in 35 files. Thanks for the work!

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257356588 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1579#issuecomment-7257356588). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T14:30:28Z. --- Closing as a duplicate of #1600, merged as 44ddf9b05 (in main), which fixes the same GetTempPath fallback to C:\Windows for every test. This branch now conflicts with main in 35 files. Thanks for the work!
MoonEyes commented 2026-11-29 14:58:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:58:13Z.


Update after a closer check: #1600 does cover this. main now has testfiles::temp_dir, used by every file this PR touches; the one addition here, a writable-folder probe, goes beyond the reported problem. The closure as a duplicate of #1600 stands; reopen with a pointer if that probe is needed on its own.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257716796 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1579#issuecomment-7257716796). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T14:58:13Z. --- Update after a closer check: #1600 does cover this. main now has `testfiles::temp_dir`, used by every file this PR touches; the one addition here, a writable-folder probe, goes beyond the reported problem. The closure as a duplicate of #1600 stands; reopen with a pointer if that probe is needed on its own. AI-assisted: yes

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!1579
No description provided.