Skip to content

tests: seven runtime tests use a temp folder of their own process (two copies at once no longer race) - #8213

Open
myokex wants to merge 1 commit into
ItsNotRexed:mainfrom
myokex:fix/test-temp-dirs-per-process
Open

myokex wants to merge 1 commit into
ItsNotRexed:mainfrom
myokex:fix/test-temp-dirs-per-process

Conversation

@myokex

@myokex myokex commented Nov 23, 2026

Copy link
Copy Markdown

Claim: new item in #8047 (comment).

Seven runtime tests wrote their shader library under one fixed %TEMP% name. Two copies at once (ctest -j from two checkouts, or two suites sharing one TMPDIR / Wine prefix) remove or overwrite each other's modules: the race runtime/test/test_temp_dir.h describes, and the one #6221 / #6184 fix for d3d12_bindless_churn (left out here so this doesn't overlap them).

  • d3d12_depth24_draw, d3d12_geometry, d3d12_mesh: they already remove_all the folder at the end, so only the name changes: testfiles::process_temp_dir(<same name>).
  • d3d12_depth_resolve, d3d12_f16_halves, d3d12_state_sweep, d3d12_stores_atomics: they never removed the folder, so a per-process name alone would leave one folder per run. They use testfiles::ScratchDir, which creates it and removes it when main returns. In d3d12_depth_resolve it is declared before the block, because the device reads the library through info.shader_dir after it.
  • bink_audio / bink_decode also use fixed names, but for output files a person may want to look at, and they need a movie from the game; not touched.

Tested on Windows 11, AMD Radeon RX 7800 XT (driver 32.0.32029.2010), MSVC 2022 RelWithDebInfo, Vulkan SDK 1.4.363.0, synthetic only, no game files. 4 copies of each test started at once, 3 rounds (12 runs), main dde82f27e vs this branch:

test main failed this PR failed main failure
d3d12_depth24_draw 9/12 0/12 h.run(...) at lines 348/364/378/413
d3d12_geometry 5/12 0/12 CreateGraphicsPipelineState at lines 129/131
d3d12_mesh 4/12 0/12 create(...) at lines 207/212
d3d12_f16_halves, d3d12_state_sweep, d3d12_stores_atomics 0/12 0/12

Every test passes run alone on both sides, and no leonida_* folder is left in %TEMP% after the branch's runs. d3d12_depth_resolve fails on this card on both sides, alone too, with the same AMD host stencil-resolve differences (63 of 97 match, 18 host quirks against the AMD host, 71 of 71 against WARP): not this change.

🤖 Generated with Claude Code

d3d12_depth24_draw, d3d12_depth_resolve, d3d12_f16_halves, d3d12_geometry,
d3d12_mesh, d3d12_state_sweep and d3d12_stores_atomics wrote their shader
library under one fixed %TEMP% name. Two copies at once (ctest -j with two
checkouts, or two suites sharing one TMPDIR or Wine prefix) then removed or
overwrote each other's modules, the race test_temp_dir.h describes.

- depth24_draw, geometry, mesh (they already remove the folder at the end):
  testfiles::process_temp_dir(<same name>).
- depth_resolve, f16_halves, state_sweep, stores_atomics (they never removed
  it, so a per-process name alone would leave one folder per run):
  testfiles::ScratchDir, which creates the folder and removes it on return.
  In depth_resolve it lives outside the block, because the device reads the
  library through info.shader_dir afterwards.

Measured on Windows 11, RX 7800 XT, 4 copies at once, 3 rounds (12 runs) each,
on main dde82f2 vs this change: depth24_draw 9 -> 0 failed, geometry 5 -> 0,
mesh 4 -> 0 (at PSO creation / h.run); f16_halves, state_sweep, stores_atomics
0 -> 0; no folder left in %TEMP%. depth_resolve fails alone on both sides with
the same AMD host differences, unrelated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@tupacfan04 tupacfan04 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The seven changed tests are correct, but two other synthetic runtime tests still share one fixed temp folder — and one copy's cleanup deletes another copy's files.

  1. d3d12_shader_cache_test still uses leonida_shader_cache_disk_test. runtime/test/d3d12_shader_cache_test.cpp:289-302 removes and recreates that fixed folder, then current_path(temp_dir); the RestoreCwd destructor (:296-300) removes the same fixed folder. Two copies at once (parallel CTest from two checkouts, or a shared TMPDIR/Wine prefix) race: one startup/teardown remove_all deletes the other's cache and working directory. The PR body excludes only bink_audio/bink_decode, so this one is unmentioned.

  2. xgameruntime_gamesave_test still uses leonida_gamesave_test. runtime/test/xgameruntime_gamesave_test.cpp:125-128 removes that fixed root and sets LEONIDA_SAVE_DIR to it; :371 removes it at the end. Two copies share saves and one cleanup deletes the other's. The same per-process ScratchDir/process_temp_dir fix applies.

The bink_audio/bink_decode exclusions are reasonable (inspection output/movie input), but these two are synthetic and unconstrained.

Test gap: no committed two-copy test. The PR body's manual table is useful, but three of the seven (d3d12_f16_halves, d3d12_state_sweep, d3d12_stores_atomics) were 0/12 on main as well, so their two-copy case was never reproduced, and d3d12_depth_resolve fails on the author's card on both sides. Add a two-copy test (shared temp dir, both must pass) to catch a future fixed-path regression.

Minor: the three process_temp_dir tests rely on remove_all(library) at the end, so an early return/crash leaves a per-PID folder; d3d12_mesh handles its early skip, the other two may not. ScratchDir for all seven would make cleanup uniform. Correct: per-PID paths, no cross-process deletion in the changed tests, no path escape. Synthetic/code-read only; no game files. AI-assisted (OpenCode).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants