Skip to content

test(libkernel_sys): cover __getcwd - #16856

Closed
juanpimg wants to merge 4 commits into
boykopovar:mainfrom
juanpimg:test/libkernel-sys-getcwd
Closed

juanpimg wants to merge 4 commits into
boykopovar:mainfrom
juanpimg:test/libkernel-sys-getcwd

Conversation

@juanpimg

@juanpimg juanpimg commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds coverage for libkernel_sys's __getcwd_nid_postfix to the existing guest_kernel_sys_module_internal test: a valid buffer returns 0 and a /-rooted guest path, a buffer of the exact required size succeeds, one byte less returns -1 with ERANGE, a null buffer returns -1 with EFAULT, and a one-byte buffer returns -1 with ERANGE, and a mkdir/chdir/__getcwd/chdir("/")/remove cycle confirms the export tracks the guest working directory (the guest getcwd path returns a virtual path, not the host working directory). No production code changes.

Tested

CachyOS Linux, kernel 7.3.1-1-cachyos, GCC 16.2.1, CMake 3.31.6, Ninja 1.12.1, Release build.

  • cmake --build build --target guest_kernel_sys_module_internal_tests: builds and links cleanly.
  • ctest --test-dir build -R "^guest_kernel_sys_module_internal$" --output-on-failure: 1/1 pass.
  • python3 tools/check_conventions.py --base origin/main: passes.
  • git diff --check: clean.
  • No title was run: the contributor has no PS5 and no game dumps.

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

@JJenkx

JJenkx commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Windows check of head c24f3e625c, merged onto main 78976e2657 (bc1ca4ca42, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_kernel_sys_module_internal passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@gabichuuuuu gabichuuuuu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows run of head c24f3e625c, merged onto main 286b14d2f7 in one tree with 47 other small open PRs that touch different files. Setup: Windows 11, WinLibs GCC 15.2 r7 (x86_64-ucrt-posix-seh, the CI toolchain), Release, BUILD_TESTING=ON.

  • guest_kernel_sys_module_internal with --repeat until-fail:5: 5 / 5 pass.
  • This PR only changes tests, so there's no negative control.

@adriadam10 adriadam10 self-assigned this Nov 11, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the test. Two expectations no longer match main since ac1d6d7 (fix(libkernel_sys): answer raw __getcwd errors in FreeBSD's order and kinds), so the test fails once merged onto current main:

  • GuestKernelSysModuleInternal.cpp:135: a buffer one byte short returns -1 with ENOMEM (Export.cpp:815), not ERANGE. The raw __getcwd syscall reports ENOMEM; ERANGE is what libc's getcwd derives from it.
  • GuestKernelSysModuleInternal.cpp:148: a one-byte buffer returns EINVAL (size < 2, Export.cpp:810), not ERANGE.

Please rebase on main and change those two expectations (a size-0 or size-1 case for EINVAL is worth keeping). The Windows runs above predate that commit, so they don't cover this.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

One detail for the line 135 case: at that point the guest working directory is still /, so required is 2 and the short buffer has size 1. Export.cpp:810 answers that with EINVAL, not ENOMEM. To cover ENOMEM (Export.cpp:817), I would run the one byte short check while the working directory is /cwd-test, where the short buffer is 9 bytes.

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head c24f3e625c, applied with git apply on main fd4aeed483 together with the other 25 PRs of one batch (#24107, #24132, #24238, #15143, #22088, #22685, #23739, #24032, #16054, #20001, #20344, #24170, #24396, #17298, #20497, #23347, #24426, #24554, #24598, #21376, #21556, #22047, #22082, #14124, #18476).

This PR makes guest_kernel_sys_module_internal fail. The test passes on main and fails in the batch tree, in the full run and alone (ctest -R, 3 of 3 runs). In the batch tree, with this PR reverted the test passes, and with it applied again it fails again. I did not look for the cause inside the change.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. NVIDIA GeForce RTX 3080 (driver 621.24). No validation layer.

AI-assisted: yes (Claude Code)

This was referenced Nov 21, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing blocks this test-only change; the points below are optional.

What I ran

Reviewed head c24f3e625c4e5c59b7fb85edc1aaab1a94547263. I inspected the prepared diff and source; I ran no commands or tests.

Results

Check Result Note
Changed test source passed Read in full
Related implementation and existing test passed Read relevant ranges
Build and test commands not run Author reports successful build and test

Findings

Blocking

None.

Non-blocking

  • The test removes /cwd-test before creating it and ignores the removal result. If that path is a non-empty directory, creation will fail; consider using a unique test directory or checking cleanup before setup. (core/libs/tests/GuestKernelSysModuleInternal.cpp:127)

Not verified

No build or test was run in this review. The author's reported Linux build, test, conventions check, and diff check were not independently verified. The sole changed file, core/libs/tests/GuestKernelSysModuleInternal.cpp, was read in full; no files were excluded by the review manifest. The implementation and existing raw-getcwd test were read only in relevant ranges.

To get this to a good state

Nothing is required. The setup cleanup concern is optional.

@juanpimg juanpimg closed this by deleting the head repository Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants