fix(tests): give each RTC test run its own title directory #10642

Merged
maximilianfv merged 1 commit from upstream-pr/10642 into main 2026-10-25 06:00:53 +00:00
maximilianfv commented 2026-10-24 14:16:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by maximilianfv on 2026-10-24T14:16:41Z.


What

guest_rtc and guest_rtc_ps5_title run the same binary (guest_rtc_tests). Each run makes a title directory under the temporary directory and works there; guest_rtc writes a PS4 param.sfo (CUSA00000) into it, while the ps5-title run expects no title file and so applies the PS5 range rules (ps4Title() in libSceRtc/Export.cpp reads the title id from app0/sce_sys/param.sfo in the working directory).

EnterTitleDirectory named that directory after std::chrono::steady_clock::now(). When ctest -j starts both tests at once they can read the same value and share one directory; the PS5 run then reads the PS4 title, applies the PS4 rules and aborts. This names the directory with std::random_device, as the other tests that make temporary directories do (GuestAppIcon.cpp, GuestEntitlements.cpp, CpuTopology.cpp). <chrono> had no other use in the file and is dropped. Test-only change.

The ps5-title mode and the title directory came in with 2120035611 (ntamas94).

Tested

Apple M1 Pro, macOS 27.0.1, x86_64 build under Rosetta 2, in a tree made of mugurc's macOS series (ci/macos-series-2, 27e968974) merged with main at 522e32e3b6, plus other open macOS fixes, toggling only this change.

  • In a full ctest -j4 run, guest_rtc_ps5_title aborted while guest_rtc ran beside it; alone it passes 5 of 5.
  • Starting guest_rtc_tests and guest_rtc_tests ps5-title together 200 times: the ps5-title run failed 64 times without this change and 0 times with it.
  • Cause check without the change: 50 such pairs left 91 rtc-test-* directories instead of 100, with exactly 9 failures, so each failure was a shared directory. ps5-title started beside itself (it writes no param.sfo) failed 0 of 100 times. steady_clock advances in 83 ns steps on this machine.
  • With the change, ctest -R '^guest_rtc' passes (2 tests).

Not tested on Linux or Windows; the race only needs two runs that read the same clock value, so any parallel ctest can hit 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 (Claude Code found the race, made the change, ran the stress tests and wrote this description; I am responsible for every line)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4996152943 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10642). Originally posted by [maximilianfv](https://github.com/maximilianfv) on 2026-10-24T14:16:41Z. --- ### What `guest_rtc` and `guest_rtc_ps5_title` run the same binary (`guest_rtc_tests`). Each run makes a title directory under the temporary directory and works there; `guest_rtc` writes a PS4 `param.sfo` (`CUSA00000`) into it, while the `ps5-title` run expects no title file and so applies the PS5 range rules (`ps4Title()` in `libSceRtc/Export.cpp` reads the title id from `app0/sce_sys/param.sfo` in the working directory). `EnterTitleDirectory` named that directory after `std::chrono::steady_clock::now()`. When `ctest -j` starts both tests at once they can read the same value and share one directory; the PS5 run then reads the PS4 title, applies the PS4 rules and aborts. This names the directory with `std::random_device`, as the other tests that make temporary directories do (`GuestAppIcon.cpp`, `GuestEntitlements.cpp`, `CpuTopology.cpp`). `<chrono>` had no other use in the file and is dropped. Test-only change. The `ps5-title` mode and the title directory came in with 2120035611 (ntamas94). ### 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. --> Apple M1 Pro, macOS 27.0.1, x86_64 build under Rosetta 2, in a tree made of mugurc's macOS series (`ci/macos-series-2`, `27e968974`) merged with `main` at `522e32e3b6`, plus other open macOS fixes, toggling only this change. - In a full `ctest -j4` run, `guest_rtc_ps5_title` aborted while `guest_rtc` ran beside it; alone it passes 5 of 5. - Starting `guest_rtc_tests` and `guest_rtc_tests ps5-title` together 200 times: the `ps5-title` run failed 64 times without this change and 0 times with it. - Cause check without the change: 50 such pairs left 91 `rtc-test-*` directories instead of 100, with exactly 9 failures, so each failure was a shared directory. `ps5-title` started beside itself (it writes no `param.sfo`) failed 0 of 100 times. `steady_clock` advances in 83 ns steps on this machine. - With the change, `ctest -R '^guest_rtc'` passes (2 tests). Not tested on Linux or Windows; the race only needs two runs that read the same clock value, so any parallel `ctest` can hit 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 (Claude Code found the race, made the change, ran the stress tests and wrote this description; I am responsible for every line) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-24 14:19:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T14:19:14Z.

Review: APPROVED


Reviewed exact head 28f3f43842. The previous steady-clock value could collide when parallel processes create their temporary title directories; using std::random_device matches the established unique-temp-path pattern already used by several guest tests in this repository. The removed <chrono> include had no remaining use in this file. Hosted eligibility, conventions, intake and labels pass; product tests were skipped, and I have not independently run the reported 200-pair race reproduction. No blocking issue found in this focused test-only change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638570729 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10642#pullrequestreview-5638570729). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T14:19:14Z. **Review:** APPROVED --- Reviewed exact head 28f3f438427d920c7ccc451adfc004ed0ced4f7d. The previous steady-clock value could collide when parallel processes create their temporary title directories; using `std::random_device` matches the established unique-temp-path pattern already used by several guest tests in this repository. The removed `<chrono>` include had no remaining use in this file. Hosted eligibility, conventions, intake and labels pass; product tests were skipped, and I have not independently run the reported 200-pair race reproduction. No blocking issue found in this focused test-only change.
THEMANnt commented 2026-10-25 04:55:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T04:55:32Z.

Review: APPROVED


Reviewed head 28f3f438427d920c7ccc451adfc004ed0ced4f7d against 5ed5427bace6512fec69caa706874e4c847f8865: approve. No actionable findings in this fixture-only change.

The patch replaces the timestamp-derived temporary directory suffix with random_device and adjusts the includes. Both title modes still create and enter their own fixture directory before RTC use; metadata-writing behavior remains consistent with their callers.

Validation: head and baseline GuestRtc.cpp passed GCC syntax checks. A compiled Windows fixture using the exact changed EnterTitleDirectory helper ran 100 invocations alternating a title ID and nullptr, verified distinct observed directories, and checked that only the title-ID mode created param.sfo. This observation is not a mathematical uniqueness guarantee. Conventions, whitespace and test registration passed. The full RTC executable and pinned production library were not built or run; hosted native jobs were skipped. Approval is scoped to the directory-name change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641623474 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10642#pullrequestreview-5641623474). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-25T04:55:32Z. **Review:** APPROVED --- Reviewed head `28f3f438427d920c7ccc451adfc004ed0ced4f7d` against `5ed5427bace6512fec69caa706874e4c847f8865`: approve. No actionable findings in this fixture-only change. The patch replaces the timestamp-derived temporary directory suffix with random_device and adjusts the includes. Both title modes still create and enter their own fixture directory before RTC use; metadata-writing behavior remains consistent with their callers. Validation: head and baseline GuestRtc.cpp passed GCC syntax checks. A compiled Windows fixture using the exact changed EnterTitleDirectory helper ran 100 invocations alternating a title ID and nullptr, verified distinct observed directories, and checked that only the title-ID mode created param.sfo. This observation is not a mathematical uniqueness guarantee. Conventions, whitespace and test registration passed. The full RTC executable and pinned production library were not built or run; hosted native jobs were skipped. Approval is scoped to the directory-name change.
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!10642
No description provided.