From 314de7c03cc90b4e3b300e8c74eb86df46a7e153 Mon Sep 17 00:00:00 2001 From: Shokunin <30949000+tetrisgm@users.noreply.github.com> Date: Mon, 28 Sep 2026 20:47:05 -0700 Subject: [PATCH] ws_cull_edge_interp_test: capture stderr through a named file tmpfile() on MSYS2 MinGW64 (msvcrt) creates its file in the root of the current drive and fails for a normal account; the test then ran without a capture and failed its overflow-log check. It now writes to a file named by argv[1] (ctest passes one in the build directory), fails with a clear message if that cannot be opened, and removes it afterwards. Co-Authored-By: Claude Opus 5.5 --- recompiler/CMakeLists.txt | 3 ++- runtime/tests/test_ws_cull_edge_interp.c | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/recompiler/CMakeLists.txt b/recompiler/CMakeLists.txt index b2d8ec89..0e6c2cf7 100644 --- a/recompiler/CMakeLists.txt +++ b/recompiler/CMakeLists.txt @@ -542,7 +542,8 @@ if(BUILD_TESTING) target_link_libraries(ws_cull_edge_interp_test PRIVATE m) endif() add_test(NAME ws_cull_edge_interp_test - COMMAND ws_cull_edge_interp_test) + COMMAND ws_cull_edge_interp_test + ${CMAKE_CURRENT_BINARY_DIR}/ws_cull_edge_interp_stderr.txt) endif() add_executable(recompiler_patch_cxx17_header_test diff --git a/runtime/tests/test_ws_cull_edge_interp.c b/runtime/tests/test_ws_cull_edge_interp.c index 5739d8d2..09e17b5a 100644 --- a/runtime/tests/test_ws_cull_edge_interp.c +++ b/runtime/tests/test_ws_cull_edge_interp.c @@ -152,11 +152,21 @@ static uint32_t load(CPUState *cpu, uint32_t pc, uint32_t insn) { static void put_half(uint32_t addr, uint16_t v) { memcpy(test_ram + (addr & 0x1FFFFFu), &v, 2); } static void put_word(uint32_t addr, uint32_t v) { memcpy(test_ram + (addr & 0x1FFFFFu), &v, 4); } +/* stderr is captured through a named file (argv[1]; ctest passes one in its + * binary directory) rather than tmpfile(): on MSYS2 MinGW64 (msvcrt) + * tmpfile() creates its file in the root of the current drive, which fails + * for a normal account. */ +static const char *s_capture_path = "ws_cull_edge_interp_stderr.txt"; + /* Runs `fn` with stderr captured into `buf`. */ static void capture_stderr(void (*fn)(void), char *buf, size_t cap) { - FILE *tmp = tmpfile(); + FILE *tmp = fopen(s_capture_path, "w+b"); buf[0] = '\0'; - if (!tmp) { fn(); return; } + if (!tmp) { + CHECK(0, "cannot open the stderr capture file %s", s_capture_path); + fn(); + return; + } fflush(stderr); int saved = dup(fileno(stderr)); dup2(fileno(tmp), fileno(stderr)); @@ -168,6 +178,7 @@ static void capture_stderr(void (*fn)(void), char *buf, size_t cap) { size_t n = fread(buf, 1, cap - 1, tmp); buf[n] = '\0'; fclose(tmp); + remove(s_capture_path); } /* ---- store ----------------------------------------------------------------- */ @@ -378,7 +389,8 @@ static void test_interpreter(void) { gpu_ws_set_clip_edge_x_load_sites(NULL, 0, 0); } -int main(void) { +int main(int argc, char **argv) { + if (argc > 1) s_capture_path = argv[1]; test_store(); test_helpers(); test_interpreter();