diff options
| author | thiefyzheng <thiefyzheng@users.noreply.github.com> | 2026-11-25 05:33:21 +0000 |
|---|---|---|
| committer | WeiZheng Huang <thiefyzheng@users.noreply.github.com> | 2026-11-28 19:01:06 +0000 |
| commit | b17397f0dd77280e107de489fc0f2a92471ace60 (patch) | |
| tree | ab3a56da6b81a758c308493f3871df746eb30f58 /runtime/test/d3d12_queue_handover_test.cpp | |
| parent | 54d27d98836ad90f62969f12179b92cbb0153859 (diff) | |
tests: derive every test's scratch folder from test_temp_dir::temp_dir, not GetTempPath (TEST-TEMPDIR-STRIPPED-ENV)
With TMP, TEMP and USERPROFILE all 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. runtime/test/test_temp_dir.h grows one entry, testfiles::temp_dir(): LEONIDA_TEST_DIR when set, the current directory when the temp environment is stripped (Windows), else the standard temp resolution. Fifty-two test files and the tiny_game fixture that called GetTempPathA/W or temp_directory_path directly now use it; d3d12_queue_handover_test.cpp also checks the _sopen_s result in capture_stderr 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). Rebased onto current main after its D3D-448 additions to d3d12_mesh_test.cpp (3-way; the mesh test keeps both). Verification on a Windows VM: stripped environment - the previously crashing d3d12 tests exit 77 (no usable Vulkan device) instead of aborting, file_system_test runs all 505 checks and loader_test all 95 with zero failures; normal environment - identical outcomes; LEONIDA_TEST_DIR honored under a fully stripped environment (the scratch folder observed mid-run inside it, cleaned up after the pass). The finding is whoalin1's (coordination issue #14, 02:37:44Z).
AI-assisted.
Diffstat (limited to 'runtime/test/d3d12_queue_handover_test.cpp')
| -rw-r--r-- | runtime/test/d3d12_queue_handover_test.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/runtime/test/d3d12_queue_handover_test.cpp b/runtime/test/d3d12_queue_handover_test.cpp index 1fabcfb4e..41799ece7 100644 --- a/runtime/test/d3d12_queue_handover_test.cpp +++ b/runtime/test/d3d12_queue_handover_test.cpp | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | // compared byte for byte with the data written by the CPU: a consumer replayed against the layout from before its | 17 | // compared byte for byte with the data written by the CPU: a consumer replayed against the layout from before its |
| 18 | // producer ran reads a zero-filled texture and fails here (and with LEONIDA_VK_VALIDATION=1 under sync validation). | 18 | // producer ran reads a zero-filled texture and fails here (and with LEONIDA_VK_VALIDATION=1 under sync validation). |
| 19 | // No game data. | 19 | // No game data. |
| 20 | #include "test_temp_dir.h" | ||
| 20 | #include "vk_test_device.h" | 21 | #include "vk_test_device.h" |
| 21 | #include "../shims/d3d12_com.h" | 22 | #include "../shims/d3d12_com.h" |
| 22 | 23 | ||
| @@ -388,12 +389,18 @@ bool cpu_gate(Rig& rig, Type producer, Type consumer, bool signal_first, int see | |||
| 388 | // Runs `body` with stderr redirected to a file and returns what it wrote. | 389 | // Runs `body` with stderr redirected to a file and returns what it wrote. |
| 389 | std::string capture_stderr(const std::function<void()>& body) { | 390 | std::string capture_stderr(const std::function<void()>& body) { |
| 390 | char dir[MAX_PATH], path[MAX_PATH]; | 391 | char dir[MAX_PATH], path[MAX_PATH]; |
| 391 | GetTempPathA(MAX_PATH, dir); | 392 | strcpy_s(dir, testfiles::temp_dir().string().c_str()); |
| 392 | GetTempFileNameA(dir, "qho", 0, path); | 393 | GetTempFileNameA(dir, "qho", 0, path); |
| 393 | std::fflush(stderr); | 394 | std::fflush(stderr); |
| 394 | const int saved = _dup(2); | 395 | const int saved = _dup(2); |
| 395 | int file = -1; | 396 | int file = -1; |
| 396 | _sopen_s(&file, path, _O_RDWR | _O_CREAT | _O_TRUNC | _O_BINARY, _SH_DENYNO, _S_IREAD | _S_IWRITE); | 397 | const errno_t open_error = |
| 398 | _sopen_s(&file, path, _O_RDWR | _O_CREAT | _O_TRUNC | _O_BINARY, _SH_DENYNO, _S_IREAD | _S_IWRITE); | ||
| 399 | if (open_error != 0) { | ||
| 400 | if (saved >= 0) _close(saved); | ||
| 401 | std::remove(path); | ||
| 402 | return "capture_stderr: _sopen_s failed with error " + std::to_string(open_error) + " for " + path; | ||
| 403 | } | ||
| 397 | _dup2(file, 2); | 404 | _dup2(file, 2); |
| 398 | body(); | 405 | body(); |
| 399 | std::fflush(stderr); | 406 | std::fflush(stderr); |