test(libc): cover heapsort record preservation and comparator calls #11833

Merged
B-Howell merged 5 commits from upstream-pr/11833 into main 2026-11-02 12:26:57 +00:00
B-Howell commented 2026-10-27 09:08:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-10-27T09:08:31Z.


What

Extend the merged heapsort implementation's guest_qsort coverage with record-preservation checks across eight array sizes, exact byte-array output, three-byte records, extra count-one/null-input cases, and an APS5_VABI comparator probe. Duplicate-key arrays must retain every tagged record with its original key; three-byte records must retain both payload bytes.

The comparator probe requires at least one element-aligned argument inside the input array on each call. It permits a scratch-element argument, as FreeBSD 11.4 heapsort does, and uses uintptr_t bounds checks rather than relational comparison/subtraction of unrelated pointers. This tests-only follow-up replaces the overlapping implementation proposal in #11629 after #11400 merged. No production implementation changes.

Tested

Frozen-main refresh qualification: 66b4ecb13df784ba4a49c777d054bed39c260650 on main 3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4.

Windows/MSYS2 UCRT64 GCC 16.2.0 Rev6 and Linux/WSL GCC 11.4, Release, separate new build directories, at most two jobs, serial arms/platforms. The isolated PR candidate passed the existing guest_qsort CTest once on each OS. All four frozen arms passed:

Arm Commit Windows Linux
Main 3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4 1 pass 1 pass
Heapsort fixture PR 66b4ecb13df784ba4a49c777d054bed39c260650 1 pass 1 pass
Mergesort PR 3483366e8300fd3c06c711026e7f7c15ae76e6a9 1 pass 1 pass
Private combined check 9741133de15e810cc06b4cc69fec378bdd053b04 1 pass 1 pass

Eight native executions total, zero failures/skips; one registered test per arm, 20-second test timeout. Source groups differ as the PRs add their regressions. Every arm built production libc and its own fixture; Windows PE/CTest search paths and Linux ldd resolve the corresponding module. Recorded conventions checks passed on all eight arms. Independent source and result reviews passed.

The heapsort contribution remains the original 75 fixture lines; main qsort_r ordering and validation coverage is retained. The private combined check preserves both helper groups and calls; its result is separate from either public PR and does not establish landing order. Historical algorithm, corpus, negative-control and hosted results below retain their original pins and were not repeated by this refresh. Dependency agreements, current-tip follow-through, human/hosted-CI review, remaining overlap obligations and verified main landing remain open.

Earlier verification — original pins retained:

Current-main refresh, 2026-10-29: candidate 7b712ffa1705e2a4a66859b1e51c682b1e5afa4d ordinarily merges freshly fetched upstream main 4c8cff191609bc5f28bf9ee2f93672b531285aa4 while retaining published 3c5c61ed6fb646b6b1d6284aae9a0e02a668d78d ancestry. The contribution against that main remains only GuestQsort.cpp +75 lines; production code is unchanged by this PR. Native Windows / MSYS2 UCRT64 GCC 16.2.0 / Ninja Release: rebuilt guest_qsort_tests, then ctest --test-dir build-focused -R '^guest_qsort$' --output-on-failure --repeat until-fail:3 --no-tests=error passed all three executions, zero skips. The focused cache uses CMAKE_SKIP_INSTALL_RULES=ON; install/export rules were not tested. Required conventions and whitespace checks passed. Independent read-only source and actual-log review found no blocking issue. Current-head Linux, full-suite, console/game and performance execution are not claimed. The older approvals and Linux evidence below retain their original tested-head limits; new-head hosted CI and renewed human review remain pending.

Current-main integration, candidate 3c5c61ed6fb646b6b1d6284aae9a0e02a668d78d: merged upstream main 65554e3ba84875781ba2e17c80f00f5adeb05105 into the existing PR ancestry. The diff against that main remains only the 75-line GuestQsort.cpp test addition; no production change. Native Windows / MSYS2 UCRT64 GCC 16.2.0 / Ninja Release: rebuilt guest_qsort_tests, then ctest --test-dir build-focused -R '^guest_qsort$' --output-on-failure --repeat until-fail:3 --no-tests=error passed the selected test in all three executions, with zero skips. Independent static and actual-log review passed, and python tools/check_conventions.py --base origin/main passed after refreshing upstream main. This is the recorded integration baseline, not a claim to include every later main commit. Linux has not been executed on this new head; the Linux run below names the earlier 0ef29edc head. The older hosted Windows success had its CTest step skipped and does not prove new-head execution. No full-suite, console/game or performance claim.

Ubuntu 22.04 under WSL, GCC 11.4, Release: rebuilt guest_qsort_tests on unchanged commit 0ef29edc47 and passed guest_qsort 1/1 (CTest total 0.06 seconds). This is a focused local Linux run. Hosted Windows job 122103093579 (run 40478537305) completed successfully, but its CTest step was skipped and the host-only linking step reported no applicable executables. It is not evidence of hosted guest_qsort execution; the verified executions are the local Windows and Linux runs described here.

Windows, MinGW/UCRT, main 5bc84038c4: built guest_qsort_tests and ran ctest --test-dir build-focused -R '^guest_qsort$' --output-on-failure. Passed 1/1 on final commit 0ef29edc47, including the distinct payload-byte checks. Independent static review found no blocking issues. check_conventions.py --base origin/main and git diff --check passed. No console/game run or performance claim. pr_overlap.py --branch codex/libc-heapsort-tests-on-11400 completed with no overlap with open pull requests.

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

Frozen-main refresh qualification — 2026-10-31

Candidate 5fe20c33b60fdb125aeee7c21135aafa420f0472 (tree cf614d16f77c3e9d78a3272a26b996ee7647486c) is an ordinary merge of the preceding public head 66b4ecb13df784ba4a49c777d054bed39c260650 and frozen main f776fddcffd1cfece220ecdd894371988b164f6a. Against that main it retains exactly the existing 75 added lines in GuestQsort.cpp; no implementation changes were added.

On Windows, WinLibs GCC 15.2.0 r7 / Release / Ninja, both frozen main and candidate configured and built the real guest_qsort_tests target successfully. Each ran ctest -R '^guest_qsort$' -V -j1 --timeout 20 once: 1/1 passed, exit 0, no skips (0.04 seconds child time on each arm; total CTest times 0.75 and 0.34 seconds). Both used the same production libc/runtime library binaries and CTest registration. This is two focused CPU test executions, with no new Linux, console, GPU or combined-PR result. Earlier Windows/Linux and combined-source results above retain their original pins.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5031348380 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11833). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-10-27T09:08:31Z. --- ### What Extend the merged heapsort implementation's guest_qsort coverage with record-preservation checks across eight array sizes, exact byte-array output, three-byte records, extra count-one/null-input cases, and an APS5_VABI comparator probe. Duplicate-key arrays must retain every tagged record with its original key; three-byte records must retain both payload bytes. The comparator probe requires at least one element-aligned argument inside the input array on each call. It permits a scratch-element argument, as FreeBSD 11.4 heapsort does, and uses uintptr_t bounds checks rather than relational comparison/subtraction of unrelated pointers. This tests-only follow-up replaces the overlapping implementation proposal in #11629 after #11400 merged. No production implementation changes. ### Tested Frozen-main refresh qualification: `66b4ecb13df784ba4a49c777d054bed39c260650` on main `3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4`. Windows/MSYS2 UCRT64 GCC 16.2.0 Rev6 and Linux/WSL GCC 11.4, Release, separate new build directories, at most two jobs, serial arms/platforms. The isolated PR candidate passed the existing `guest_qsort` CTest once on each OS. All four frozen arms passed: | Arm | Commit | Windows | Linux | |---|---|---|---| | Main | `3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4` | 1 pass | 1 pass | | Heapsort fixture PR | `66b4ecb13df784ba4a49c777d054bed39c260650` | 1 pass | 1 pass | | Mergesort PR | `3483366e8300fd3c06c711026e7f7c15ae76e6a9` | 1 pass | 1 pass | | Private combined check | `9741133de15e810cc06b4cc69fec378bdd053b04` | 1 pass | 1 pass | Eight native executions total, zero failures/skips; one registered test per arm, 20-second test timeout. Source groups differ as the PRs add their regressions. Every arm built production libc and its own fixture; Windows PE/CTest search paths and Linux ldd resolve the corresponding module. Recorded conventions checks passed on all eight arms. Independent source and result reviews passed. The heapsort contribution remains the original 75 fixture lines; main qsort_r ordering and validation coverage is retained. The private combined check preserves both helper groups and calls; its result is separate from either public PR and does not establish landing order. Historical algorithm, corpus, negative-control and hosted results below retain their original pins and were not repeated by this refresh. Dependency agreements, current-tip follow-through, human/hosted-CI review, remaining overlap obligations and verified main landing remain open. **Earlier verification — original pins retained:** Current-main refresh, 2026-10-29: candidate `7b712ffa1705e2a4a66859b1e51c682b1e5afa4d` ordinarily merges freshly fetched upstream main `4c8cff191609bc5f28bf9ee2f93672b531285aa4` while retaining published `3c5c61ed6fb646b6b1d6284aae9a0e02a668d78d` ancestry. The contribution against that main remains only GuestQsort.cpp +75 lines; production code is unchanged by this PR. Native Windows / MSYS2 UCRT64 GCC 16.2.0 / Ninja Release: rebuilt `guest_qsort_tests`, then `ctest --test-dir build-focused -R '^guest_qsort$' --output-on-failure --repeat until-fail:3 --no-tests=error` passed all three executions, zero skips. The focused cache uses `CMAKE_SKIP_INSTALL_RULES=ON`; install/export rules were not tested. Required conventions and whitespace checks passed. Independent read-only source and actual-log review found no blocking issue. Current-head Linux, full-suite, console/game and performance execution are not claimed. The older approvals and Linux evidence below retain their original tested-head limits; new-head hosted CI and renewed human review remain pending. Current-main integration, candidate `3c5c61ed6fb646b6b1d6284aae9a0e02a668d78d`: merged upstream main `65554e3ba84875781ba2e17c80f00f5adeb05105` into the existing PR ancestry. The diff against that main remains only the 75-line GuestQsort.cpp test addition; no production change. Native Windows / MSYS2 UCRT64 GCC 16.2.0 / Ninja Release: rebuilt `guest_qsort_tests`, then `ctest --test-dir build-focused -R '^guest_qsort$' --output-on-failure --repeat until-fail:3 --no-tests=error` passed the selected test in all three executions, with zero skips. Independent static and actual-log review passed, and `python tools/check_conventions.py --base origin/main` passed after refreshing upstream main. This is the recorded integration baseline, not a claim to include every later main commit. Linux has not been executed on this new head; the Linux run below names the earlier `0ef29edc` head. The older hosted Windows success had its CTest step skipped and does not prove new-head execution. No full-suite, console/game or performance claim. Ubuntu 22.04 under WSL, GCC 11.4, Release: rebuilt guest_qsort_tests on unchanged commit 0ef29edc474c14fbb71790d9523eb15eded068f2 and passed guest_qsort 1/1 (CTest total 0.06 seconds). This is a focused local Linux run. Hosted Windows job 122103093579 (run 40478537305) completed successfully, but its CTest step was skipped and the host-only linking step reported no applicable executables. It is not evidence of hosted guest_qsort execution; the verified executions are the local Windows and Linux runs described here. Windows, MinGW/UCRT, main 5bc84038c490a0427ff272e39e2a1cdf6fdc3c0e: built guest_qsort_tests and ran ctest --test-dir build-focused -R '^guest_qsort$' --output-on-failure. Passed 1/1 on final commit 0ef29edc47, including the distinct payload-byte checks. Independent static review found no blocking issues. check_conventions.py --base origin/main and git diff --check passed. No console/game run or performance claim. pr_overlap.py --branch codex/libc-heapsort-tests-on-11400 completed with no overlap with open pull requests. <!-- 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. --> ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> #### Frozen-main refresh qualification — 2026-10-31 Candidate `5fe20c33b60fdb125aeee7c21135aafa420f0472` (tree `cf614d16f77c3e9d78a3272a26b996ee7647486c`) is an ordinary merge of the preceding public head `66b4ecb13df784ba4a49c777d054bed39c260650` and frozen main `f776fddcffd1cfece220ecdd894371988b164f6a`. Against that main it retains exactly the existing 75 added lines in `GuestQsort.cpp`; no implementation changes were added. On Windows, WinLibs GCC 15.2.0 r7 / Release / Ninja, both frozen main and candidate configured and built the real `guest_qsort_tests` target successfully. Each ran `ctest -R '^guest_qsort$' -V -j1 --timeout 20` once: 1/1 passed, exit 0, no skips (0.04 seconds child time on each arm; total CTest times 0.75 and 0.34 seconds). Both used the same production libc/runtime library binaries and CTest registration. This is two focused CPU test executions, with no new Linux, console, GPU or combined-PR result. Earlier Windows/Linux and combined-source results above retain their original pins.
MarcZX10 commented 2026-10-27 09:15:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T09:15:02Z.

Review: APPROVED


The focused Windows job has now completed successfully at this head, and the conventions, intake, labels, and eligibility checks pass. The test additions exercise record preservation across varied counts and record sizes, comparator invocation/ordering, and the documented early-return cases; the checks avoid assuming a particular heapsort comparison count or scratch-buffer implementation. I found no blocking issue in the diff reviewed and approve this test-only change.

Linux and the other path-filtered build jobs were skipped, so this approval is based on the focused Windows run and the code review; it does not claim those jobs ran.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5664679917 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11833#pullrequestreview-5664679917). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T09:15:02Z. **Review:** APPROVED --- The focused Windows job has now completed successfully at this head, and the conventions, intake, labels, and eligibility checks pass. The test additions exercise record preservation across varied counts and record sizes, comparator invocation/ordering, and the documented early-return cases; the checks avoid assuming a particular heapsort comparison count or scratch-buffer implementation. I found no blocking issue in the diff reviewed and approve this test-only change. Linux and the other path-filtered build jobs were skipped, so this approval is based on the focused Windows run and the code review; it does not claim those jobs ran.
THEMANnt commented 2026-10-28 16:39:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-28T16:39:00Z.

Review: APPROVED


Reviewed 0ef29edc474c14fbb71790d9523eb15eded068f2 — approve. The heapsort cases verify sorted order plus tagged-record preservation, one- and three-byte element widths, comparator invocation and boundary no-op inputs. The comparator check permits one temporary operand while requiring an operand from the source array.

Windows/GCC 15.3 Release native validation from pinned sources: head: 1 passed, 0 skipped; guest_qsort; author base was source-compared: production sources are unchanged; its runtime was not built or executed for this review. This changes test coverage, not production behavior, so an old-production failure is not required. The build reuses matching dependency source pins and the existing FFmpeg package; no full product or game execution is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5686276312 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11833#pullrequestreview-5686276312). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-28T16:39:00Z. **Review:** APPROVED --- Reviewed `0ef29edc474c14fbb71790d9523eb15eded068f2` — approve. The heapsort cases verify sorted order plus tagged-record preservation, one- and three-byte element widths, comparator invocation and boundary no-op inputs. The comparator check permits one temporary operand while requiring an operand from the source array. Windows/GCC 15.3 Release native validation from pinned sources: head: 1 passed, 0 skipped; `guest_qsort`; author base was source-compared: production sources are unchanged; its runtime was not built or executed for this review. This changes test coverage, not production behavior, so an old-production failure is not required. The build reuses matching dependency source pins and the existing FFmpeg package; no full product or game execution is claimed.
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!11833
No description provided.