test(libc): cover getcwd zero-size buffer #1369
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1369"
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 MarcZX10 on 2026-10-08T00:33:41Z.
What
Add regression coverage for
getcwdwith a non-null buffer and a zero size. It must return null and setEINVAL; this distinguishes that branch from the adjacentERANGEcase.Tested
Current head
d809ccf79779a42a32d126ef1dabbaf53ebd233d, rebased onto upstreammainf8c2f072463465f875dedb0d20b66c339160c1a1:guest_working_directory_tests;guest_working_directorypassed (1/1). The local build checkout also contained a separate, unrelated AGC fix; the PR diff itself remains the single assertion shown above.python3 tools/check_conventions.py --base upstream/mainandgit diff --check upstream/main...HEADpass on the rebased PR tree.Earlier Windows evidence on the pre-rebase head
09a410df(based ond70b8998):guest_working_directorypassed with no skipped cases. The aggregate CTest run passed 519/519 but needed local fixes to unrelated #1611, #1796, and #1824. That run is not evidence for the current PR head or an unmodified upstream Build.The required upstream Linux/Windows Build and relinker matrix has not been run on current head
d809ccf. No PS5 hardware or title runtime was tested.Checklist
main; no other open PR implements the same behaviorImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T02:24:57Z.
Review: COMMENTED
Built and ran it, and checked the assertion is not vacuous.
Linux (CachyOS, GCC, Release):
The assertion bites, proven by mutation.
General.cpp:136is an explicit branch:Changing only the value it sets (22 → 34) while keeping your test:
So the line is pinned to that branch and to
EINVAL, rather than passing on whatevergetcwdhappens to return.Why the line earns its place rather than repeating line 27. The test already asserts the ERANGE case (
getcwd(tiny, 2) == nullptr && errno == 34). Your case is a different input reaching a different branch, and the two are genuinely adjacent:For
buffer != NULL, size == 0the ERANGE guard is also true ((buffer || size)holds,0 < requiredholds), so if the explicit EINVAL branch were ever removed or reordered, this call would silently start returning34— and only your assertion would notice, because line 27 uses a non-zero size. That is the gap this closes, and it is the right one.The function's other outcomes are already covered: the normal path (lines 16, 23), too-small with
ERANGE(27), size 0 withEINVAL(29, yours) and the allocating path (30). I did not find a branch ofgetcwdin this implementation left unpinned by the file after your change, so I have nothing to ask for.Nothing further from me — this is coverage of behaviour that already existed, correctly, and it now fails loudly if that behaviour changes.
This is a comment, not an approval — I have no merge rights here.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T05:12:55Z.
Please fill in the PR template (What, Tested, Checklist); the conventions check fails without those sections.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-08T11:43:40Z.
The PR description now has the requested What / Tested / Checklist sections. The current Linux, Windows, Conventions and Progress report checks all pass, and the PR is cleanly mergeable against
main.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-08T19:26:59Z.
Rebased this one-line test change directly onto current
upstream/main(0447793). I rebuiltguest_working_directory_tests; focused CTest passes (1/1), conventions pass, andgit diff --checkpasses. The updated head is372f4a4, but upstream currently reports no checks or workflow runs for it. Per CONTRIBUTING, fork workflows may need maintainer approval; could an authorized maintainer approve the runs so CI can validate this head?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-08T21:23:28Z.
Rebased this one-assertion test onto current upstream
main(364a56b). The full diff still checksgetcwd(path, 0)returnsnullptrand setsEINVAL; the focused CTest passed (1/1) on the prior head. Conventions andgit diff --checkpass. No checks are reported for the rebased head yet.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-08T21:24:43Z.
The Build/Conventions workflow runs for current head
35cd29c5c28ef152f52a7671e968a311a27d8858are markedaction_requiredand have no jobs, so upstream CI has not run yet. CONTRIBUTING requires maintainer approval for fork workflows. Could an authorized maintainer approve these current-head runs?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-08T21:53:17Z.
Rebased the one-assertion test onto current upstream
main(94b1eecb; heade58a7d40). It still checksgetcwd(path, 0)returnsnullptrand setsEINVAL; focused CTest passed on the prior head. Conventions andgit diff --checkpass. Current Build/Conventions/Progress runs areaction_requiredwith no jobs; could a maintainer approve this final head?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T00:13:46Z.
Rebased the one-assertion
getcwdtest onto current upstreammainf1451396at head8cb00eea. The focused CTest passed 1/1 on the rebased source; conventions andgit diff --checkpass. Could a maintainer approve the upstream Build and Conventions runs for this new head under the fork workflow policy?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:35:12Z.
Rebased the one-assertion regression onto current upstream
main6cc0503d; the full diff remains a single assertion. Current Linuxguest_working_directoryCTest passes (1/1, 0.00 s), and conventions/diff checks pass. Fork Build 37905837164 is running on the new head. The existing independent review confirmed the assertion is non-vacuous by mutation testing.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:38:00Z.
Addressed: the PR now has explicit What, Tested and Checklist sections with current-base, focused CTest and conventions evidence. The one-assertion diff is rebased onto
6cc0503d; current-head fork Build is running.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:47:12Z.
Fork Build completed with Linux and Windows blocked on the unrelated
agc_shader_fusion_testscompile error:VulkanTestDevice.hppcannot findspirv/unified1/spirv.hpp. All three relinker jobs passed. I recorded the result in the PR description and linked #2093 as the dependency fix.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T11:23:05Z.
Useful to have this on the record, and it matches what a full build shows here:
agc_shader_fusion_testscompiles on this box, because SPIRV-Headers is present in the tree — so thespirv/unified1/spirv.hppfailure is your fork's dependency wiring rather than anything in your change. Linking #2093 as the dependency fix is the right call, and stating it in the description rather than leaving the Fork Build line unexplained is exactly the habit that makes a blocked run readable.The assertion itself I did verify when I first looked: it pins the
EINVALbranch for a zero-size buffer and fails when that branch's errno changes, so it is real coverage rather than a test that passes for the wrong reason.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:45:18Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
09a410df, merged ontomaind70b8998in one build with 38 other PRs that had no Windows run.guest_working_directory. None of them reported skipping a case.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T17:35:09Z.
Thanks for the exact-head Windows run. I added the focused test result and aggregate CTest result to the PR description, including the local fixes to unrelated PRs so the batch is not presented as an unmodified upstream Build. The required upstream matrix and title testing remain outstanding.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T17:39:48Z.
I rebased this existing PR onto current
main(f8c2f072); the full diff remains the singleEINVALassertion. The focused Linux build and test pass 1/1, and Conventions is queued on the updated head. The earlier Windows result was on the pre-rebase head, so the current-head Windows and full upstream Build matrix remain outstanding.