test(libc): cover strlcpy and case-insensitive comparisons #1490

Closed
cubersu wants to merge 1 commit from upstream-pr/1490 into main
cubersu commented 2026-10-08 09:08:13 +00:00 (Migrated from github.com)

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, strcasecmp and strncasecmp (Strings.cpp). Test-only change, no implementation changes.

  • strlcpy: return value is the source length in every case; truncation keeps size - 1 bytes plus the terminator; exact fit and one-byte overflow; size 1 writes only the terminator; size 0 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, n of 0, stopping at n, and n larger than both strings.

Expected values follow FreeBSD strlcpy(3) and POSIX strcasecmp in the C locale. Only the sign of comparison results is checked.

strncpy_s is 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 in strlcpy, inverted strcasecmp sign, comparison without tolower, strncasecmp ignoring n). Windows not tested. tools/check_conventions.py --base origin/main passes.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01ULF8vCbJFyzxVsW3SfiWC5

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4784452492 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1490). Originally posted by [cubersu](https://github.com/cubersu) on 2026-10-08T09:08:13Z. --- ### What Adds behavioural tests for three libc exports that had no coverage: `strlcpy`, `strcasecmp` and `strncasecmp` ([Strings.cpp](core/libs/prx/libc/src/Strings.cpp)). Test-only change, no implementation changes. - `strlcpy`: return value is the source length in every case; truncation keeps `size - 1` bytes plus the terminator; exact fit and one-byte overflow; `size` 1 writes only the terminator; `size` 0 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, `n` of 0, stopping at `n`, and `n` larger than both strings. Expected values follow FreeBSD `strlcpy(3)` and POSIX `strcasecmp` in the C locale. Only the sign of comparison results is checked. `strncpy_s` is 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 in `strlcpy`, inverted `strcasecmp` sign, comparison without `tolower`, `strncasecmp` ignoring `n`). Windows not tested. `tools/check_conventions.py --base origin/main` passes. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ULF8vCbJFyzxVsW3SfiWC5
popcoder565 commented 2026-10-08 09:59:00 +00:00 (Migrated from github.com)

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 main 73ac9ef7 together with #1477, #1482 and #1490 to share one build.

  • guest_strings: 5 of 5 runs pass.
  • Full ctest on that build: 430 of 431 pass. The one failure is agc_driver_srgb8_color_target, an NVIDIA import flake (#1434).

Tested with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6057381465 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1490#issuecomment-6057381465). Originally posted by [popcoder565](https://github.com/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 `main` 73ac9ef7 together with #1477, #1482 and #1490 to share one build. - `guest_strings`: 5 of 5 runs pass. - Full ctest on that build: 430 of 431 pass. The one failure is `agc_driver_srgb8_color_target`, an NVIDIA import flake (#1434). Tested with AI assistance (Claude Code).
oneandonlydean commented 2026-10-09 08:53:29 +00:00 (Migrated from github.com)

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 strlcpy or strcasecmp behaving differently from the console, reopen with that case.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077687108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1490#issuecomment-6077687108). Originally posted by [oneandonlydean](https://github.com/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 `strlcpy` or `strcasecmp` behaving differently from the console, reopen with that case.

Pull request closed

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!1490
No description provided.