test(libSceAmpr): cover the wait command sizes, the buffer size and sceAmprUdivti3 #13990

Merged
LeandroLP23 merged 1 commit from upstream-pr/13990 into main 2026-11-05 08:52:39 +00:00
LeandroLP23 commented 2026-10-31 14:31:43 +00:00 (Migrated from github.com)

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


What

sceAmprMeasureCommandSizeWaitOnAddress, sceAmprMeasureCommandSizeWaitOnCounter, sceAmprCommandBufferGetSize and sceAmprUdivti3 had no test. Two cases are added to GuestAmpr.cpp:

  • TestMeasuredWaitsAndBufferSize: a 2048-byte APR buffer reports 2048 from sceAmprCommandBufferGetSize before and after recording. It records one WaitOnAddress and one WaitOnCounter. The existing RequireAppended checks that each grows the buffer by its measured size, adds one command, and writes a header with its opcode and size.
  • TestUdivti3: sceAmprUdivti3 equals the compiler's unsigned __int128 division for six pairs: dividends and divisors above 2^64, a divisor larger than the dividend, all-ones by all-ones, and a small pair.

Test only.

Tested

  • Windows 11, WinLibs GCC 15.2.0 UCRT r7, Release: guest_ampr_markers passed.
  • Changing the expected buffer size, or the expected quotient, made it fail. The new cases run.
  • tools/check_conventions.py --base origin/main passed.
  • tools/pr_overlap.py could not compare #10025, which conflicts with main and also edits GuestAmpr.cpp. Its diff is about AMM PRT zero pages and does not touch these functions.

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:5098462917 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13990). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-31T14:31:43Z. --- ### What `sceAmprMeasureCommandSizeWaitOnAddress`, `sceAmprMeasureCommandSizeWaitOnCounter`, `sceAmprCommandBufferGetSize` and `sceAmprUdivti3` had no test. Two cases are added to `GuestAmpr.cpp`: - **`TestMeasuredWaitsAndBufferSize`:** a 2048-byte APR buffer reports 2048 from `sceAmprCommandBufferGetSize` before and after recording. It records one `WaitOnAddress` and one `WaitOnCounter`. The existing `RequireAppended` checks that each grows the buffer by its measured size, adds one command, and writes a header with its opcode and size. - **`TestUdivti3`:** `sceAmprUdivti3` equals the compiler's `unsigned __int128` division for six pairs: dividends and divisors above 2^64, a divisor larger than the dividend, all-ones by all-ones, and a small pair. Test only. ### Tested - Windows 11, WinLibs GCC 15.2.0 UCRT r7, Release: `guest_ampr_markers` passed. - Changing the expected buffer size, or the expected quotient, made it fail. The new cases run. - `tools/check_conventions.py --base origin/main` passed. - `tools/pr_overlap.py` could not compare #10025, which conflicts with `main` and also edits `GuestAmpr.cpp`. Its diff is about AMM PRT zero pages and does not touch these functions. ### 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:39:11 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed — looks good

At head 03c305a73f81eb905ff60f6f0cc813baafab3394, the new assertions check the recorded wait-command opcodes and measured sizes, preserve the command-buffer capacity, and compare wide unsigned division results with the compiler’s unsigned __int128 operation (tests, size/measurement implementations, division export). Hosted Windows, conventions, library portability, intake, labels, and eligibility passed. The author reports the focused test and mutation checks passed; I did not run a local build or test, and product CI jobs were skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5723333790 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13990#pullrequestreview-5723333790). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T14:39:11Z. **Review:** APPROVED --- # Reviewed — looks good At head `03c305a73f81eb905ff60f6f0cc813baafab3394`, the new assertions check the recorded wait-command opcodes and measured sizes, preserve the command-buffer capacity, and compare wide unsigned division results with the compiler’s `unsigned __int128` operation ([tests](https://github.com/boykopovar/AnyPS5/blob/03c305a73f81eb905ff60f6f0cc813baafab3394/core/libs/tests/GuestAmpr.cpp#L263-L282), [size/measurement implementations](https://github.com/boykopovar/AnyPS5/blob/73f4f7e06e4f210a8c6570e335fd654dc0a86134/core/libs/prx/libSceAmpr/Export.cpp#L275-L278), [division export](https://github.com/boykopovar/AnyPS5/blob/73f4f7e06e4f210a8c6570e335fd654dc0a86134/core/libs/prx/libSceAmpr/Export.cpp#L866-L869)). Hosted Windows, conventions, library portability, intake, labels, and eligibility passed. The author reports the focused test and mutation checks passed; I did not run a local build or test, and product CI jobs were skipped.
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!13990
No description provided.