fix(tests): refresh staged test libraries when a library is rebuilt #17895

Merged
adam25136 merged 1 commit from upstream-pr/17895 into main 2026-11-12 06:24:53 +00:00
adam25136 commented 2026-11-09 21:05:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adam25136 on 2026-11-09T21:05:12Z.


What

Since #7645, a Windows test executable loads the .prx files staged next to it in build/tests/, which its POST_BUILD step copies only when the executable relinks. The libraries under core/libs keep their import library unchanged unless their exports change (the <TARGET_IMPLIB>.new link rule in core/libs/CMakeLists.txt), so a change inside a library relinks no test executable and its staged copy keeps the old library. Windows loads a DLL from the executable's folder before PATH, so a local test of a library change runs the old code, and can pass. Before #7645 the tests loaded the library just built through PATH.

With BUILD_TESTING, configure_windows_unwind now also runs cmake/RefreshStagedRuntime.cmake for shared libraries, after its unwind section rename. When tests/<library> exists and differs from the finished library, it is replaced. If the copy fails (a running test holding the file), the build only warns, and that copy stays old until the library is rebuilt again; this path is read from the code, not tested. The script adds no file to tests/, never touches tests/nostage, and skips a library built into tests/ itself (job_manager_reference.prx).

configure_windows_unwind is called in each library's own directory, which a POST_BUILD command needs, and its step is the last one that writes the library: 406 of the 407 libraries in core/libs/libs/unpatched have it, and so do 10 test fixture libraries outside it. The other, libSceAgcVsh, does not call it, and no test stages it.

From build.ninja, not measured: an executable that stages a library links only after that library's build step, which ends with the refresh, so the refresh never overlaps an executable's copy of the same file.

The first build after this change relinks every library that has the step (415 relinked here; job_manager_reference.prx was not part of that build), because its POST_BUILD command changed, and so replaces copies that are already stale. The same relink without the refresh (its condition set to FALSE) left 207 stale copies.

Not addressed: the parallel staging copies into the shared tests/ can fail ("Error copying file"), as JJenkx measured on #8043. One full rebuild with an earlier version of this change, after a branch switch, hit it once in an executable's own copy; rerunning the build completed it.

Tested

Windows 10 Pro 22H2 (19045), i9-12900KF, NVIDIA GeForce RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 r7, CMake 4.3.1, Ninja, Release, BUILD_TESTING=ON, on main 6719b01bf3.

  • A script builds agc_driver_indirect_arguments_pending_producer_tests and libs, replaces any stale staged copy so it starts clean, changes only the text of libSceAgcDriver's Selected GPU log line, rebuilds the same two targets, and runs that test with ctest -V. Each time, 8 objects compile and the test executable is not relinked.
    • On main: tests/libSceAgcDriver.prx differs from the library just built, and the test prints the old Selected GPU name= line and passes.
    • With this change: the staged copy is identical to the built library, and the test prints the new line.
    • With this change and the refresh disabled (its condition set to FALSE): the copy differs and the test prints the old line, as on main.
  • main's full suite (4,852 tests) and this change merged onto it (4,852, the whole suite selected), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1: both fail only agc_driver_quad_pixel_mask (#14237) and time out guest_kernel_sys_paths_symlinkat and guest_kernel_sys_paths_symlinkat_patched, and the same 14 tests skip on both.
  • In that build tree, a script compared each staged copy with the library just built before each run and replaced the stale ones, so both sides' suites ran on fresh copies. Before the suites it found one stale copy on main and none with this change. After main's validation build, which relinked one library (libSceJson2), it found one; after this change's validation build, which relinked five, it found none.
  • Validation, the 1,615 tests per side that match ^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu, with VK_LAYER_KHRONOS_validation: no VUID- line on either side, the same 61 warnings in the same 14 tests, and only agc_driver_quad_pixel_mask failing on both.
  • python tools/check_conventions.py --base origin/main with this title and description passes, and so does python tools/check_test_registration.py build.
  • Rebased onto main f439f7f3a0 before opening (head 84ba66c37f, ef38cc1210 rebased); none of the 95 commits since 6719b01bf3 touches CMakeLists.txt, core/libs/CMakeLists.txt or cmake/, and the script above gives the same result there with this change.
  • tools/pr_overlap.py --branch (in a full clone, 1,939 open pull requests): 50 share a file with this branch, and none of those it compared conflicts. The patches of core/libs/CMakeLists.txt of the 15 it could not compare contain no line of configure_windows_unwind's body, not even as context.

Not covered: Linux and macOS (the change is inside if(MINGW)), generators other than Ninja, and a CMake older than 3.21, where the refresh is skipped as the staging is.

Related: #7645, #8043 (plokmklo) and JJenkx's comments on it.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5231169345 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17895). Originally posted by [adam25136](https://github.com/adam25136) on 2026-11-09T21:05:12Z. --- ### What Since #7645, a Windows test executable loads the `.prx` files staged next to it in `build/tests/`, which its POST_BUILD step copies only when the executable relinks. The libraries under `core/libs` keep their import library unchanged unless their exports change (the `<TARGET_IMPLIB>.new` link rule in `core/libs/CMakeLists.txt`), so a change inside a library relinks no test executable and its staged copy keeps the old library. Windows loads a DLL from the executable's folder before `PATH`, so a local test of a library change runs the old code, and can pass. Before #7645 the tests loaded the library just built through `PATH`. With `BUILD_TESTING`, `configure_windows_unwind` now also runs `cmake/RefreshStagedRuntime.cmake` for shared libraries, after its unwind section rename. When `tests/<library>` exists and differs from the finished library, it is replaced. If the copy fails (a running test holding the file), the build only warns, and that copy stays old until the library is rebuilt again; this path is read from the code, not tested. The script adds no file to `tests/`, never touches `tests/nostage`, and skips a library built into `tests/` itself (`job_manager_reference.prx`). `configure_windows_unwind` is called in each library's own directory, which a POST_BUILD command needs, and its step is the last one that writes the library: 406 of the 407 libraries in `core/libs/libs/unpatched` have it, and so do 10 test fixture libraries outside it. The other, `libSceAgcVsh`, does not call it, and no test stages it. From `build.ninja`, not measured: an executable that stages a library links only after that library's build step, which ends with the refresh, so the refresh never overlaps an executable's copy of the same file. The first build after this change relinks every library that has the step (415 relinked here; `job_manager_reference.prx` was not part of that build), because its POST_BUILD command changed, and so replaces copies that are already stale. The same relink without the refresh (its condition set to `FALSE`) left 207 stale copies. Not addressed: the parallel staging copies into the shared `tests/` can fail ("Error copying file"), as JJenkx measured on #8043. One full rebuild with an earlier version of this change, after a branch switch, hit it once in an executable's own copy; rerunning the build completed it. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 10 Pro 22H2 (19045), i9-12900KF, NVIDIA GeForce RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 r7, CMake 4.3.1, Ninja, Release, `BUILD_TESTING=ON`, on `main` `6719b01bf3`. - A script builds `agc_driver_indirect_arguments_pending_producer_tests` and `libs`, replaces any stale staged copy so it starts clean, changes only the text of libSceAgcDriver's `Selected GPU` log line, rebuilds the same two targets, and runs that test with `ctest -V`. Each time, 8 objects compile and the test executable is not relinked. - On `main`: `tests/libSceAgcDriver.prx` differs from the library just built, and the test prints the old `Selected GPU name=` line and passes. - With this change: the staged copy is identical to the built library, and the test prints the new line. - With this change and the refresh disabled (its condition set to `FALSE`): the copy differs and the test prints the old line, as on `main`. - `main`'s full suite (4,852 tests) and this change merged onto it (4,852, the whole suite selected), with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`: both fail only `agc_driver_quad_pixel_mask` (#14237) and time out `guest_kernel_sys_paths_symlinkat` and `guest_kernel_sys_paths_symlinkat_patched`, and the same 14 tests skip on both. - In that build tree, a script compared each staged copy with the library just built before each run and replaced the stale ones, so both sides' suites ran on fresh copies. Before the suites it found one stale copy on `main` and none with this change. After `main`'s validation build, which relinked one library (`libSceJson2`), it found one; after this change's validation build, which relinked five, it found none. - Validation, the 1,615 tests per side that match `^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu`, with `VK_LAYER_KHRONOS_validation`: no `VUID-` line on either side, the same 61 warnings in the same 14 tests, and only `agc_driver_quad_pixel_mask` failing on both. - `python tools/check_conventions.py --base origin/main` with this title and description passes, and so does `python tools/check_test_registration.py build`. - Rebased onto `main` `f439f7f3a0` before opening (head `84ba66c37f`, `ef38cc1210` rebased); none of the 95 commits since `6719b01bf3` touches `CMakeLists.txt`, `core/libs/CMakeLists.txt` or `cmake/`, and the script above gives the same result there with this change. - `tools/pr_overlap.py --branch` (in a full clone, 1,939 open pull requests): 50 share a file with this branch, and none of those it compared conflicts. The patches of `core/libs/CMakeLists.txt` of the 15 it could not compare contain no line of `configure_windows_unwind`'s body, not even as context. Not covered: Linux and macOS (the change is inside `if(MINGW)`), generators other than Ninja, and a CMake older than 3.21, where the refresh is skipped as the staging is. Related: #7645, #8043 (plokmklo) and JJenkx's comments on it. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
boykopovar/AnyPS5!17895
No description provided.