tests: resolve a writable temp dir instead of crashing on C:\Windows #1579
Closed
leonida/mandy
whoalin1 wants to merge 0 commits from
test-tempdir-robust into main
pull from: test-tempdir-robust
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!1579
Loading…
Reference in a new issue
No description provided.
Delete branch "test-tempdir-robust"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claimed in the coordination issue: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7152024965
What
With
TMP/TEMP/USERPROFILEunset,GetTempPathWreturnsC:\Windows, which is not writable. Dozens of test binaries then die with0xc0000409(uncaughtstd::filesystemexception) instead of running or skipping — reproduced onmainasctest -R d3d12_mesh→ exit0xc0000409.runtime/test/test_temp_dir.hgains a writable-dir probe chain (LEONIDA_TEST_DIR→temp_directory_path→current_path, each proven by an actual create/write/delete) andensure_temp_env(), a pre-maininitializer that repairsTMP/TEMP/TMPDIRwhen the effective temp dir is not writable — which also fixes the loader's ownGetTempPathWclone dir, unreachable from test code.scratch_dir()/process_temp_dir()now resolve through it, covering everyScratchDiruser (~17 suites), and the ~15 sites that threw directly (create_directories,copy_file,ofstream,_sopen_scapture) getempty → 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.cppdefault_shader_cache_dir()probes the temp-based dir and falls back tocwd/leonida_shader_cache— without itd3d12_shader_cachereached its disk section and returnedE_FAILunder a stripped env. Writable-temp behavior is byte-identical to before.runtime/CMakeLists.txt: the 14 ctest entries that executegta6rt/loader guests which the test exes' header cannot reach getENVIRONMENT "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_cmdlineTLS 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)
0xc0000409.run_tiny_*+run_startup_cmdlinectest entries pass (were all failing).LEONIDA_VK_VALIDATIONnot 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).
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:0xc0000409in all nine. They were built at 0d80bc5df, and none of these files has changed on main since.The per-process folders also fix running two copies at once. I started two copies of
d3d12_shader_cachetogether, 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_testandd3d12_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 andindex.json). With the environment stripped, the folders land in the working directory, which is the build folder under ctest.testfiles::ScratchDir, already intest_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:248andxgameruntime_gamesave_test.cpp:126. When two copies ofxgameruntime_gamesave_teststart 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 aClearAllnow creates an empty%TEMP%\leonida_shader_cachewhen 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.
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.cppandxgameruntime_gamesave_test.cpp, so whichever of the two lands second will conflict. The details are on #1952.AI-assisted.
Thanks for the thorough review, @Diegobecker07 — especially the concurrent-copy experiment. Pushed
edd15f364addressing point 1: all four tests (d3d12_depth_resolve_test,d3d12_f16_halves_test,d3d12_state_sweep_test,d3d12_stores_atomics_test) now usetestfiles::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 viais_directoryafter construction, sinceScratchDiralways falls back to a path). Syntax-checked each translation unit with MSVCcl /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).
Rebased onto current main (
db1a22d29) asf4a906884and squashed the four ScratchDir commits into one for a single conflict-resolution pass. The only textual conflict wasrun_tiny_first_run_uiinruntime/CMakeLists.txt; resolution unions main'sLEONIDA_KEYBOARD_PADreset 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 --checkis clean; a fresh MSVC runtime build is running locally as a sanity check, and CI will provide the full matrix. AI-assisted with Devin.Duplicate check (diff reading only, no build): #1579 and #1600 fix the same finding (
GetTempPathgivesC:\Windowswith 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 totestfiles::temp_dir().Two parts of this PR are not in #1600 and could come back as a follow-up:
runtime/shims/d3d12_vulkan_device.cpp;gta6rt, where #1600 changespe_loader.cppinstead.AI-assisted (Claude Code).
Windows 11 + MSVC
19.44+ RTX 3090 Verification — PASS (f4a9068844)Verified
f4a9068844merged ontoorigin/main(829530dbd0and48bae6cade,0conflicts, plus a 5-way combined merge alongside#1918,#1628,#2198, and#900) on native Windows 11 (10.0.26200.9974) with MSVC19.44.35228, NVIDIA GeForce RTX 3090, andVK_LAYER_KHRONOS_validation1.4.363.1.Checks Run
detail::kTempEnvEnsuredpre-maindynamic initializer under/O2 /Gw /Gy /OPT:REF:#include "test_temp_dir.h"without referencing anytestfiles::symbol inmain(), linked with/OPT:REF, and verified Win32GetTempPathW()insidemain():TMPandTEMPset to a non-creatable path (...\drivers\etc\hosts\unwritable_temp) andUSERPROFILEunset ->GetTempPathW()resolved to the writable working directory (rc=0).TMP,TEMP, andUSERPROFILEall stripped from the process environment (where Windows defaultsGetTempPathW()toC:\Windows\) ->writable_proberejectedC:\Windows\and updatedTMP/TEMPbeforemain()soGetTempPathW()resolved to the writable working directory (rc=0).TMP/TEMP:shader_fixture_path_test.exe: Red crash0xc0000409(__fastfailon uncaughtstd::filesystem::filesystem_errorbeforetry) onorigin/main-> Greenrc=0on#1579 + origin/main.pipeline_cache_file_test.exe: Red crash0xc0000409onorigin/main-> Greenrc=0on#1579 + origin/main.d3d12_shader_cache_test.exeon NVIDIA GeForce RTX 3090 with unwritableTMP/TEMP,LEONIDA_VK_VALIDATION=1, andVK_VALIDATE_SYNC=1(exercising bothtestfiles::scratch_diranddefault_shader_cache_dir()inruntime/shims/d3d12_vulkan_device.cpp):rc=0,0VUID-/ validation errors.tests/test_ctest_registration.pyandtests/test_ci_registration.pypassed (rc=0).Non-Blocking Notes
gta6rtCTest entries added onmainsince#1579's base: Four newergta6rttests on currentmain(run_tiny_async,run_tiny_gdk_load,run_tiny_bundled_load, andrun_tiny_atexitinruntime/CMakeLists.txt, wheretiny_atexitexercisesthread_localTLS host clones) sit just above#1579'sforeach(test_name ...)ENVIRONMENT "TMP=...;TEMP=..."block and could be added to thatforeachlist in a follow-up for stripped-environment CTest runs.default_shader_cache_dir()(runtime/shims/d3d12_vulkan_device.cpp):std::filesystem::create_directories(dir, ec)succeeds with!ecif<tmp>\leonida_shader_cachealready exists on disk even when the directory is not writable by the current user (whereastestfiles::detail::writable_probealso probes file creation).AI-assisted.
Already in main: #1600, the duplicate named in the check above, was merged on 2026-11-29 as
44ddf9b05(inmain3535eb5c4) and fixes the same finding (GetTempPathfalling back toC:\Windowswith TMP, TEMP and USERPROFILE unset). This branch now conflicts withmainin 35 files.Re-checked in the tree on
mainc22a0a732, not from the history:main'sruntime/test/test_temp_dir.hhastestfiles::temp_dir(), which avoids theC:\Windowsfallback. All 47runtime/test.cppfiles this branch edits already include it, and no file it touches still callsGetTempPath. The only partmainlacks is this branch's writable-folder probe (detail::writable_probe), which goes beyond the reported finding.AI-assisted (Claude Code).
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!
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