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

Open
opened 2026-11-26 20:21:48 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1579
Author: @whoalin1
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: test-tempdir-robust


📝 Commits (1)

  • f4a9068 tests: resolve a writable temp dir instead of crashing on C:\Windows

📊 Changes

48 files changed (+375 additions, -81 deletions)

View changed files

📝 runtime/CMakeLists.txt (+12 -1)
📝 runtime/shims/d3d12_vulkan_device.cpp (+12 -2)
📝 runtime/test/bink_audio_test.cpp (+2 -1)
📝 runtime/test/bink_decode_test.cpp (+2 -1)
📝 runtime/test/d3d12_bindless_churn_test.cpp (+7 -3)
📝 runtime/test/d3d12_conservative_raster_test.cpp (+6 -2)
📝 runtime/test/d3d12_conservative_tier2_test.cpp (+3 -2)
📝 runtime/test/d3d12_conservative_tier3_test.cpp (+3 -2)
📝 runtime/test/d3d12_depth24_draw_test.cpp (+6 -2)
📝 runtime/test/d3d12_depth_resolve_test.cpp (+7 -2)
📝 runtime/test/d3d12_execute_indirect_validation_test.cpp (+7 -3)
📝 runtime/test/d3d12_existing_heap_test.cpp (+1 -0)
📝 runtime/test/d3d12_f16_halves_test.cpp (+7 -2)
📝 runtime/test/d3d12_geometry_test.cpp (+6 -2)
📝 runtime/test/d3d12_indirect_dispatch_count_test.cpp (+7 -3)
📝 runtime/test/d3d12_mesh_test.cpp (+6 -2)
📝 runtime/test/d3d12_multi_viewport_test.cpp (+7 -3)
📝 runtime/test/d3d12_present_test.cpp (+1 -0)
📝 runtime/test/d3d12_queue_handover_test.cpp (+20 -7)
📝 runtime/test/d3d12_shader_cache_test.cpp (+6 -1)

...and 28 more files

📄 Description

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).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1579 **Author:** [@whoalin1](https://github.com/whoalin1) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `test-tempdir-robust` --- ### 📝 Commits (1) - [`f4a9068`](https://github.com/ubiquitarianism/leonida/commit/f4a9068844183be2747fdd6607c87213700ebee7) tests: resolve a writable temp dir instead of crashing on C:\Windows ### 📊 Changes **48 files changed** (+375 additions, -81 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+12 -1) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+12 -2) 📝 `runtime/test/bink_audio_test.cpp` (+2 -1) 📝 `runtime/test/bink_decode_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_bindless_churn_test.cpp` (+7 -3) 📝 `runtime/test/d3d12_conservative_raster_test.cpp` (+6 -2) 📝 `runtime/test/d3d12_conservative_tier2_test.cpp` (+3 -2) 📝 `runtime/test/d3d12_conservative_tier3_test.cpp` (+3 -2) 📝 `runtime/test/d3d12_depth24_draw_test.cpp` (+6 -2) 📝 `runtime/test/d3d12_depth_resolve_test.cpp` (+7 -2) 📝 `runtime/test/d3d12_execute_indirect_validation_test.cpp` (+7 -3) 📝 `runtime/test/d3d12_existing_heap_test.cpp` (+1 -0) 📝 `runtime/test/d3d12_f16_halves_test.cpp` (+7 -2) 📝 `runtime/test/d3d12_geometry_test.cpp` (+6 -2) 📝 `runtime/test/d3d12_indirect_dispatch_count_test.cpp` (+7 -3) 📝 `runtime/test/d3d12_mesh_test.cpp` (+6 -2) 📝 `runtime/test/d3d12_multi_viewport_test.cpp` (+7 -3) 📝 `runtime/test/d3d12_present_test.cpp` (+1 -0) 📝 `runtime/test/d3d12_queue_handover_test.cpp` (+20 -7) 📝 `runtime/test/d3d12_shader_cache_test.cpp` (+6 -1) _...and 28 more files_ </details> ### 📄 Description 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1599
No description provided.