test(libkernel): check the libc++ steady clock errno around the host sleep #24116

Merged
Romannachwievor merged 1 commit from upstream-pr/24116 into main 2026-11-20 10:58:27 +00:00
Romannachwievor commented 2026-11-20 06:37:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Romannachwievor on 2026-11-20T06:37:58Z.


Title: test(libkernel): check the libc++ steady clock errno around the host sleep

What

guest_kernel_clock aborts on macOS since #23862 added TestLibcxxSteadyClock. The test sets guest errno to 97, calls steady_clock::now, sleeps with std::this_thread::sleep_for, calls now again, and then requires errno to still be 97.

The guest errno is the host errno (__error_nid_postfix returns &errno). On macOS, nanosleep sets errno to ETIMEDOUT (60) even when the sleep succeeds, so the check fails because of the host sleep, not because of steady_clock::now. A plain host program shows the same thing: errno is 60 after a 2 ms sleep_for, both as x86_64 and as arm64.

The test now checks errno right after the first now call and sets it back to 97 after the sleep. Both now calls are still checked for leaving errno alone, and the sleep is no longer part of the check. The library code is unchanged.

Tested

macOS 26.5, Apple M1, x86_64 Release under Rosetta 2, on main a4d1053d4b plus #17425 and #11049.

  • Before: guest_kernel_clock aborts every time.
  • After: ctest -R '^guest_kernel_clock$' passes, three runs in a row.
  • python3 tools/check_conventions.py --base origin/main passes on this branch.
  • Linux x86_64, Ubuntu 24.04, GCC 13.3 (Docker Offload, 16 CPUs), main 240d7aa391 and this branch: guest_kernel_clock passes on both, three runs each.
  • Not tested: Windows.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5408987194 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24116). Originally posted by [Romannachwievor](https://github.com/Romannachwievor) on 2026-11-20T06:37:58Z. --- Title: test(libkernel): check the libc++ steady clock errno around the host sleep ### What `guest_kernel_clock` aborts on macOS since #23862 added `TestLibcxxSteadyClock`. The test sets guest errno to 97, calls `steady_clock::now`, sleeps with `std::this_thread::sleep_for`, calls `now` again, and then requires errno to still be 97. The guest errno is the host errno (`__error_nid_postfix` returns `&errno`). On macOS, `nanosleep` sets errno to `ETIMEDOUT` (60) even when the sleep succeeds, so the check fails because of the host sleep, not because of `steady_clock::now`. A plain host program shows the same thing: errno is 60 after a 2 ms `sleep_for`, both as x86_64 and as arm64. The test now checks errno right after the first `now` call and sets it back to 97 after the sleep. Both `now` calls are still checked for leaving errno alone, and the sleep is no longer part of the check. The library code is unchanged. ### Tested macOS 26.5, Apple M1, x86_64 Release under Rosetta 2, on main `a4d1053d4b` plus #17425 and #11049. - Before: `guest_kernel_clock` aborts every time. - After: `ctest -R '^guest_kernel_clock$'` passes, three runs in a row. - `python3 tools/check_conventions.py --base origin/main` passes on this branch. - Linux x86_64, Ubuntu 24.04, GCC 13.3 (Docker Offload, 16 CPUs), main `240d7aa391` and this branch: `guest_kernel_clock` passes on both, three runs each. - Not tested: Windows. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted: yes (Claude Code)
PrivacyOnion commented 2026-11-20 06:40:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T06:40:31Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 772cfd6b72:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_kernel_clock_tests built cleanly.
  • CTest (guest_kernel_clock):
    1/1 Test #5680: guest_kernel_clock ...............   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified that checking errno right after _ZNSt3__16chrono12steady_clock3nowEv_nid_postfix() correctly asserts steady_clock::now preserves errno before std::this_thread::sleep_for executes
    • Verified that re-setting *__error_nid_postfix() = 97 after sleep_for isolates the test from host sleep errno clobbering (e.g. macOS nanosleep setting ETIMEDOUT=60)
    • Verified that the second call to _ZNSt3__16chrono12steady_clock3nowEv_nid_postfix() is still verified to preserve errno (checked on the subsequent assertion)
    • Verified AGENTS.md compliance: no comments added, no debt fragments required, PR conventions and formatting preserved

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5988547671 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24116#pullrequestreview-5988547671). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T06:40:31Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `772cfd6b72`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_kernel_clock_tests` built cleanly. - **CTest** (`guest_kernel_clock`): ``` 1/1 Test #5680: guest_kernel_clock ............... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Code reading**: - Verified that checking errno right after _ZNSt3__16chrono12steady_clock3nowEv_nid_postfix() correctly asserts steady_clock::now preserves errno before std::this_thread::sleep_for executes - Verified that re-setting *__error_nid_postfix() = 97 after sleep_for isolates the test from host sleep errno clobbering (e.g. macOS nanosleep setting ETIMEDOUT=60) - Verified that the second call to _ZNSt3__16chrono12steady_clock3nowEv_nid_postfix() is still verified to preserve errno (checked on the subsequent assertion) - Verified AGENTS.md compliance: no comments added, no debt fragments required, PR conventions and formatting preserved Looks Good To Me
MarcZX10 commented 2026-11-20 06:46:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T06:46:38Z.

Review: COMMENTED


Reviewed — comments

The prepared bundle contains no diff or changed-file entries, so I cannot verify the proposed test change or justify a formal approval or change request.

What I ran

  • Inspected the prepared description, commit list, manifest, diff, and review-folder listing for head 772cfd6b724152336c72c7bd637bdd146515a5ad.
  • No tests or repository commands were run.

Results

Check Result Note
Review bundle failed No changed files or diff supplied
Tests not run No code change available to assess

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

  • The proposed change to core/libs/tests/GuestKernelClock.cpp; the description identifies it as excluded, but it does not appear among the manifest's changed files and no diff was supplied.
  • The description's reported macOS and Linux test results.
  • No changed source files were read. The bundle reports no changed files under reviewed; thus there are no files read to compare against files reviewed.

To get this to a good state

Provide a complete prepared diff and changed-file manifest for this head so the code and changed lines can be reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5988604342 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24116#pullrequestreview-5988604342). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T06:46:38Z. **Review:** COMMENTED --- # Reviewed — comments The prepared bundle contains no diff or changed-file entries, so I cannot verify the proposed test change or justify a formal approval or change request. ## What I ran - Inspected the prepared description, commit list, manifest, diff, and review-folder listing for head `772cfd6b724152336c72c7bd637bdd146515a5ad`. - No tests or repository commands were run. ## Results | Check | Result | Note | |---|---|---| | Review bundle | failed | No changed files or diff supplied | | Tests | not run | No code change available to assess | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified - The proposed change to `core/libs/tests/GuestKernelClock.cpp`; the description identifies it as excluded, but it does not appear among the manifest's changed files and no diff was supplied. - The description's reported macOS and Linux test results. - No changed source files were read. The bundle reports no changed files under `reviewed`; thus there are no files read to compare against files reviewed. ## To get this to a good state Provide a complete prepared diff and changed-file manifest for this head so the code and changed lines can be reviewed.
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!24116
No description provided.