test(libc): cover strlcpy and case-insensitive comparisons #1490
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1490"
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 cubersu on 2026-10-08T09:08:13Z.
What
Adds behavioural tests for three libc exports that had no coverage:
strlcpy,strcasecmpandstrncasecmp(Strings.cpp). Test-only change, no implementation changes.strlcpy: return value is the source length in every case; truncation keepssize - 1bytes plus the terminator; exact fit and one-byte overflow;size1 writes only the terminator;size0 leaves the destination untouched; no padding past the terminator.strcasecmp/strncasecmp: equality across case, sign of the result for ordered and prefix strings, comparison after lowering ("A"vs"["), unsigned comparison of bytes above 0x7f,nof 0, stopping atn, andnlarger than both strings.Expected values follow FreeBSD
strlcpy(3)and POSIXstrcasecmpin the C locale. Only the sign of comparison results is checked.strncpy_sis left out on purpose: #1336 already adds tests for it in the same file.Tested
Linux (Ubuntu 24.04, GCC 13.3),
ctest -R guest_strings. Each new check was also confirmed to fail against a deliberately broken implementation (off-by-one instrlcpy, invertedstrcasecmpsign, comparison withouttolower,strncasecmpignoringn). Windows not tested.tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01ULF8vCbJFyzxVsW3SfiWC5
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-08T09:59:00Z.
Tested on Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, Intel Core i7-12700H (20 logical CPUs). I merged it onto
main73ac9ef7together with #1477, #1482 and #1490 to share one build.guest_strings: 5 of 5 runs pass.agc_driver_srgb8_color_target, an NVIDIA import flake (#1434).Tested with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T08:53:29Z.
Closing: the tests pass on main and no fix or title comes with them. If a title shows
strlcpyorstrcasecmpbehaving differently from the console, reopen with that case.Pull request closed