test(libSceNpCommon): wake condition waiters and mask and cancel event flags #13978

Merged
LeandroLP23 merged 2 commits from upstream-pr/13978 into main 2026-11-03 08:10:48 +00:00
LeandroLP23 commented 2026-10-31 14:24:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-31T14:24:47Z.


What

The NP condition wrappers were only tested with no waiter: sceNpCondInit, Signal, Timedwait and Destroy in the sync case. sceNpCondWait, sceNpCondSignalAll, sceNpCondSignalTo and every sceNpLwCond* call had no test. sceNpClearEventFlag and sceNpCancelEventFlag had none either.

  • New wake case in GuestNpCommon.cpp (registered with the other guest_np_common_* cases, same 20 s timeout). For the plain and the lightweight condition:
    • real threads take the mutex and wait in sceNpCondWait / sceNpLwCondWait until a flag is set;
    • the main thread waits until all of them are inside the wait, sets the flag under the mutex, and wakes them with Signal (one waiter), SignalAll (two waiters) or SignalTo (the target thread);
    • every waiter must return from its wait and be joined, and sceNpLwCondInit / sceNpLwCondDestroy create and destroy the lightweight condition.
  • GuestNpCommonRuntime.cpp:
    • after bits 1 and 6 are set, sceNpClearEventFlag(flag, 5) keeps bits 1 and 4 and clears bit 2;
    • sceNpCancelEventFlag(flag, 0x10, &waiting) reports no waiters and leaves the pattern at 0x10.

Test only.

Tested

  • Windows 11, WinLibs GCC 15.2.0 UCRT r7, Release: all six guest_np_common* tests passed. guest_np_common_wake also passed 50 of 50 runs with ctest --repeat until-fail:50.
  • tools/check_conventions.py --base origin/main passed.
  • tools/pr_overlap.py found no confirmed overlap. It could not compare 11 PRs that conflict with main and share core/libs/CMakeLists.txt; none of their diffs touch the guest_np_common tests.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5098400370 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13978). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-31T14:24:47Z. --- ### What The NP condition wrappers were only tested with no waiter: `sceNpCondInit`, `Signal`, `Timedwait` and `Destroy` in the `sync` case. `sceNpCondWait`, `sceNpCondSignalAll`, `sceNpCondSignalTo` and every `sceNpLwCond*` call had no test. `sceNpClearEventFlag` and `sceNpCancelEventFlag` had none either. - **New `wake` case in `GuestNpCommon.cpp`** (registered with the other `guest_np_common_*` cases, same 20 s timeout). For the plain and the lightweight condition: - real threads take the mutex and wait in `sceNpCondWait` / `sceNpLwCondWait` until a flag is set; - the main thread waits until all of them are inside the wait, sets the flag under the mutex, and wakes them with `Signal` (one waiter), `SignalAll` (two waiters) or `SignalTo` (the target thread); - every waiter must return from its wait and be joined, and `sceNpLwCondInit` / `sceNpLwCondDestroy` create and destroy the lightweight condition. - **`GuestNpCommonRuntime.cpp`:** - after bits 1 and 6 are set, `sceNpClearEventFlag(flag, 5)` keeps bits 1 and 4 and clears bit 2; - `sceNpCancelEventFlag(flag, 0x10, &waiting)` reports no waiters and leaves the pattern at `0x10`. Test only. ### Tested - Windows 11, WinLibs GCC 15.2.0 UCRT r7, Release: all six `guest_np_common*` tests passed. `guest_np_common_wake` also passed 50 of 50 runs with `ctest --repeat until-fail:50`. - `tools/check_conventions.py --base origin/main` passed. - `tools/pr_overlap.py` found no confirmed overlap. It could not compare 11 PRs that conflict with `main` and share `core/libs/CMakeLists.txt`; none of their diffs touch the `guest_np_common` tests. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-31 14:38:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T14:38:56Z.

Review: APPROVED


Reviewed — looks good

At head 11e2833b9b1334261dd73fae3c4b8843b84986f9, the new cases exercise plain and lightweight condition waits, signal/broadcast/signal-to wakeups, and event-flag mask/cancel forwarding (condition wrappers, event-flag wrappers, wake tests, flag tests). Hosted Windows, conventions, and library portability passed; the author reports 50 consecutive wake-test passes. I did not run a local C++ build or test, and Linux product CI was skipped.

Non-blocking coverage note: SignalTo is tested with one waiter, so the test confirms that its call wakes a waiter but does not distinguish targeted wakeup from ordinary single-waiter signaling.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5723333141 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13978#pullrequestreview-5723333141). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T14:38:56Z. **Review:** APPROVED --- # Reviewed — looks good At head `11e2833b9b1334261dd73fae3c4b8843b84986f9`, the new cases exercise plain and lightweight condition waits, signal/broadcast/signal-to wakeups, and event-flag mask/cancel forwarding ([condition wrappers](https://github.com/boykopovar/AnyPS5/blob/73f4f7e06e4f210a8c6570e335fd654dc0a86134/core/libs/prx/libSceNpCommon/Runtime.cpp#L281-L315), [event-flag wrappers](https://github.com/boykopovar/AnyPS5/blob/73f4f7e06e4f210a8c6570e335fd654dc0a86134/core/libs/prx/libSceNpCommon/Runtime.cpp#L329-L343), [wake tests](https://github.com/boykopovar/AnyPS5/blob/11e2833b9b1334261dd73fae3c4b8843b84986f9/core/libs/tests/GuestNpCommon.cpp#L97-L157), [flag tests](https://github.com/boykopovar/AnyPS5/blob/11e2833b9b1334261dd73fae3c4b8843b84986f9/core/libs/tests/GuestNpCommonRuntime.cpp#L75-L86)). Hosted Windows, conventions, and library portability passed; the author reports 50 consecutive wake-test passes. I did not run a local C++ build or test, and Linux product CI was skipped. Non-blocking coverage note: `SignalTo` is tested with one waiter, so the test confirms that its call wakes a waiter but does not distinguish targeted wakeup from ordinary single-waiter signaling.
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!13978
No description provided.