[PR #1600] tests: derive every test's scratch folder from test_temp_dir::temp_dir, not GetTempPath (TEST-TEMPDIR-STRIPPED-ENV) #1616

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

📋 Pull Request Information

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

Base: main ← Head: fix/test-tempdir-stripped-env


📝 Commits (1)

  • 03d00ae tests: derive every test's scratch folder from test_temp_dir::temp_dir, not GetTempPath (TEST-TEMPDIR-STRIPPED-ENV)

📊 Changes

48 files changed (+142 additions, -70 deletions)

View changed files

📝 runtime/src/pe_loader.cpp (+9 -0)
📝 runtime/test/bink_audio_test.cpp (+2 -1)
📝 runtime/test/bink_decode_test.cpp (+2 -1)
📝 runtime/test/d3d12_bindless_churn_test.cpp (+2 -1)
📝 runtime/test/d3d12_conservative_raster_test.cpp (+2 -1)
📝 runtime/test/d3d12_conservative_tier2_test.cpp (+2 -1)
📝 runtime/test/d3d12_conservative_tier3_test.cpp (+2 -1)
📝 runtime/test/d3d12_depth24_draw_test.cpp (+2 -1)
📝 runtime/test/d3d12_depth_resolve_test.cpp (+2 -1)
📝 runtime/test/d3d12_execute_indirect_validation_test.cpp (+2 -1)
📝 runtime/test/d3d12_existing_heap_test.cpp (+4 -3)
📝 runtime/test/d3d12_f16_halves_test.cpp (+2 -1)
📝 runtime/test/d3d12_geometry_test.cpp (+2 -1)
📝 runtime/test/d3d12_indirect_dispatch_count_test.cpp (+2 -1)
📝 runtime/test/d3d12_mesh_test.cpp (+2 -1)
📝 runtime/test/d3d12_multi_viewport_test.cpp (+2 -1)
📝 runtime/test/d3d12_present_test.cpp (+2 -1)
📝 runtime/test/d3d12_queue_handover_test.cpp (+9 -2)
📝 runtime/test/d3d12_shader_cache_test.cpp (+2 -1)
📝 runtime/test/d3d12_state_sweep_test.cpp (+2 -1)

...and 28 more files

📄 Description

What

One entry added to runtime/test/test_temp_dir.h — testfiles::temp_dir(): LEONIDA_TEST_DIR when set, else the current directory when the temp environment is stripped (TMP, TEMP and USERPROFILE all unset on Windows), else the standard temp resolution. 45 test files and the tiny_game fixture that called GetTempPathA/GetTempPathW/temp_directory_path directly now use it, and d3d12_queue_handover_test.cpp's capture_stderr checks its _sopen_s result instead of silently returning empty stderr. One runtime source function needed the same fallback because tests exercise it: tls_host_clone_dir in runtime/src/pe_loader.cpp (the loader_tls* tests) — the only non-test change in this PR, called out deliberately.

Claimed as TEST-TEMPDIR-STRIPPED-ENV on #14 (the finding is @whoalin1's, 02:37:44Z).

Why

With TMP/TEMP/USERPROFILE unset, GetTempPathW returns C:\Windows\, and the throwing create_directories/copy_file/ofstream on C:\Windows\leonida_* aborts with 0xc0000409 before the test body runs — the ~20 d3d12_* sites of the finding plus the further direct users found by enumerating ("d3d12_mesh/bindless_churn/conservative_raster(+tier2/tier3)/depth24_draw/depth_resolve/execute_indirect_validation/f16_halves/geometry/indirect_dispatch_count/multi_viewport/shader_cache/state_sweep/stores_atomics/present/queue_handover/existing_heap + bink_audio/bink_decode/device_proxy/dstorage/file_system/int3_skip/kernel_writes/large_module_gate_loader(4)/module_names/pe_loader(fuzz/test/bounds)/pipeline_cache(file/seed)/shader_fixture_path/startup_trace/title_write_watch/unimplemented_policy/xbox_present/xdxr_build_output/xgameruntime(gamesave/test/user)/xmem + fixtures/tiny_game"). The helper used by 15 test files already existed; this PR is the mechanical consolidation the finding asked for.

What I ran (Windows 11 VM, VS build of every affected target, current main lineage)

  • Stripped environment (TMP/TEMP/USERPROFILE unset): the previously crashing d3d12 tests now exit 77 ("no usable Vulkan device" — this VM has no GPU, which is a graceful outcome where the abort used to happen first); file_system_test runs all 505 checks, 0 failures; loader_test all 95 checks, 0 failed; xgameruntime_test exit 0. No 0xc0000409 anywhere in any run.
  • Normal environment: identical outcomes (505/0, 95/0, same exit codes) — no behavior change when the environment is intact.
  • LEONIDA_TEST_DIR honored: set to C:\work\tdir under a fully stripped environment, the process's leonida_file_system_<pid> scratch folder was captured mid-run inside it and cleaned up after the 505-check pass.
  • The pre-change crash shape is the finding's ("before-shape: not reproduced locally" — a full pristine second build was not spent reproducing a documented abort; every post-fix run proves the temp stage now completes).

Notes for the reviewer

  • Current main moved during verification (its D3D-448 additions to d3d12_mesh_test.cpp): the mesh test was merged by 3-way and keeps both changes.
  • scripts/check_no_game_data.py clean; synthetic fixtures only; no game data.

AI-assisted: a pi coding agent operated by the repo contributor ran the enumeration, the Windows build and the three verification phases; the finding is @whoalin1's.


🔄 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/1600 **Author:** [@thiefyzheng](https://github.com/thiefyzheng) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/test-tempdir-stripped-env` --- ### 📝 Commits (1) - [`03d00ae`](https://github.com/ubiquitarianism/leonida/commit/03d00ae27516552f4a05ba257fe4728157022f07) tests: derive every test's scratch folder from test_temp_dir::temp_dir, not GetTempPath (TEST-TEMPDIR-STRIPPED-ENV) ### 📊 Changes **48 files changed** (+142 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/pe_loader.cpp` (+9 -0) 📝 `runtime/test/bink_audio_test.cpp` (+2 -1) 📝 `runtime/test/bink_decode_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_bindless_churn_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_conservative_raster_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_conservative_tier2_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_conservative_tier3_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_depth24_draw_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_depth_resolve_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_execute_indirect_validation_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_existing_heap_test.cpp` (+4 -3) 📝 `runtime/test/d3d12_f16_halves_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_geometry_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_indirect_dispatch_count_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_mesh_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_multi_viewport_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_present_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_queue_handover_test.cpp` (+9 -2) 📝 `runtime/test/d3d12_shader_cache_test.cpp` (+2 -1) 📝 `runtime/test/d3d12_state_sweep_test.cpp` (+2 -1) _...and 28 more files_ </details> ### 📄 Description ## What One entry added to `runtime/test/test_temp_dir.h` — `testfiles::temp_dir()`: `LEONIDA_TEST_DIR` when set, else the current directory when the temp environment is stripped (TMP, TEMP and USERPROFILE all unset on Windows), else the standard temp resolution. **45 test files and the `tiny_game` fixture** that called `GetTempPathA`/`GetTempPathW`/`temp_directory_path` directly now use it, and `d3d12_queue_handover_test.cpp`'s `capture_stderr` checks its `_sopen_s` result instead of silently returning empty stderr. **One runtime source function** needed the same fallback because tests exercise it: `tls_host_clone_dir` in `runtime/src/pe_loader.cpp` (the `loader_tls*` tests) — the only non-test change in this PR, called out deliberately. Claimed as **TEST-TEMPDIR-STRIPPED-ENV** on #14 (the finding is @whoalin1's, 02:37:44Z). ## Why With TMP/TEMP/USERPROFILE unset, `GetTempPathW` returns `C:\Windows\`, and the throwing `create_directories`/`copy_file`/`ofstream` on `C:\Windows\leonida_*` aborts with 0xc0000409 before the test body runs — the ~20 `d3d12_*` sites of the finding plus the further direct users found by enumerating ("d3d12_mesh/bindless_churn/conservative_raster(+tier2/tier3)/depth24_draw/depth_resolve/execute_indirect_validation/f16_halves/geometry/indirect_dispatch_count/multi_viewport/shader_cache/state_sweep/stores_atomics/present/queue_handover/existing_heap + bink_audio/bink_decode/device_proxy/dstorage/file_system/int3_skip/kernel_writes/large_module_gate_loader(4)/module_names/pe_loader(fuzz/test/bounds)/pipeline_cache(file/seed)/shader_fixture_path/startup_trace/title_write_watch/unimplemented_policy/xbox_present/xdxr_build_output/xgameruntime(gamesave/test/user)/xmem + fixtures/tiny_game"). The helper used by 15 test files already existed; this PR is the mechanical consolidation the finding asked for. ## What I ran (Windows 11 VM, VS build of every affected target, current main lineage) - **Stripped environment** (TMP/TEMP/USERPROFILE unset): the previously crashing d3d12 tests now exit 77 ("no usable Vulkan device" — this VM has no GPU, which is a graceful outcome where the abort used to happen first); `file_system_test` runs all **505 checks, 0 failures**; `loader_test` all **95 checks, 0 failed**; `xgameruntime_test` exit 0. No 0xc0000409 anywhere in any run. - **Normal environment**: identical outcomes (505/0, 95/0, same exit codes) — no behavior change when the environment is intact. - **LEONIDA_TEST_DIR honored**: set to `C:\work\tdir` under a fully stripped environment, the process's `leonida_file_system_<pid>` scratch folder was captured mid-run inside it and cleaned up after the 505-check pass. - The pre-change crash shape is the finding's ("before-shape: not reproduced locally" — a full pristine second build was not spent reproducing a documented abort; every post-fix run proves the temp stage now completes). ## Notes for the reviewer - Current main moved during verification (its D3D-448 additions to `d3d12_mesh_test.cpp`): the mesh test was merged by 3-way and keeps both changes. - `scripts/check_no_game_data.py` clean; synthetic fixtures only; no game data. **AI-assisted**: a pi coding agent operated by the repo contributor ran the enumeration, the Windows build and the three verification phases; the finding is @whoalin1's. --- <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#1616
No description provided.