test(libc): cover heapsort record preservation and comparator calls #11833
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11833"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
66b4ecb13df784ba4a49c777d054bed39c260650on main3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4.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_qsortCTest once on each OS. All four frozen arms passed:3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a466b4ecb13df784ba4a49c777d054bed39c2606503483366e8300fd3c06c711026e7f7c15ae76e6a99741133de15e810cc06b4cc69fec378bdd053b04Eight 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
7b712ffa1705e2a4a66859b1e51c682b1e5afa4dordinarily merges freshly fetched upstream main4c8cff191609bc5f28bf9ee2f93672b531285aa4while retaining published3c5c61ed6fb646b6b1d6284aae9a0e02a668d78dancestry. 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: rebuiltguest_qsort_tests, thenctest --test-dir build-focused -R '^guest_qsort$' --output-on-failure --repeat until-fail:3 --no-tests=errorpassed all three executions, zero skips. The focused cache usesCMAKE_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 main65554e3ba84875781ba2e17c80f00f5adeb05105into 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: rebuiltguest_qsort_tests, thenctest --test-dir build-focused -R '^guest_qsort$' --output-on-failure --repeat until-fail:3 --no-tests=errorpassed the selected test in all three executions, with zero skips. Independent static and actual-log review passed, andpython tools/check_conventions.py --base origin/mainpassed 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 earlier0ef29edchead. 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
0ef29edc47and 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 commit0ef29edc47, 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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Frozen-main refresh qualification — 2026-10-31
Candidate
5fe20c33b60fdb125aeee7c21135aafa420f0472(treecf614d16f77c3e9d78a3272a26b996ee7647486c) is an ordinary merge of the preceding public head66b4ecb13df784ba4a49c777d054bed39c260650and frozen mainf776fddcffd1cfece220ecdd894371988b164f6a. Against that main it retains exactly the existing 75 added lines inGuestQsort.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_teststarget successfully. Each ranctest -R '^guest_qsort$' -V -j1 --timeout 20once: 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.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.
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.