test(libScePad): cover motion sensor, tilt correction, and orientation reset handle setters #13344

Merged
slopgobblercobbler merged 1 commit from upstream-pr/13344 into main 2026-10-30 18:52:28 +00:00
slopgobblercobbler commented 2026-10-30 13:08:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-10-30T13:08:18Z.


What

Adds unit test coverage in core/libs/tests/GuestPad.cpp for controller handle state setters:

  • scePadSetMotionSensorState: covers enabling and disabling motion sensors on handle2 (port 1), verifying through the read path (scePadReadState) that motion sample values are read back when enabled and zeroed when disabled, while verifying port 0 motion state remains untouched (per-port isolation); covers invalid handle rejection (PAD_ERROR_INVALID_HANDLE) for unknown (handle2 + 99) and negative (-1) handles.
  • scePadSetTiltCorrectionState & scePadResetOrientation: covers orientation settling on handle2 through SettleOrientationW(1) when disabled and enabled, verifying port 0 orientation settling is unaffected; covers invalid handle rejection for unknown and negative handles.

Tested

  • python tools/check_conventions.py --base upstream/main --head HEAD: 0 findings.
  • Windows 11 verification courtesy of @maskym: Windows 11 build 26300 (Intel i7-12700K, WinLibs GCC 15.2.0 Release, BUILD_TESTING=ON), ctest -R '^(guest_kernel_sys|guest_pad|unwind_record_bounds)' passed 27/27 clean across 3 runs.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5084844083 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13344). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-10-30T13:08:18Z. --- ### What Adds unit test coverage in `core/libs/tests/GuestPad.cpp` for controller handle state setters: - `scePadSetMotionSensorState`: covers enabling and disabling motion sensors on `handle2` (port 1), verifying through the read path (`scePadReadState`) that motion sample values are read back when enabled and zeroed when disabled, while verifying port 0 motion state remains untouched (per-port isolation); covers invalid handle rejection (`PAD_ERROR_INVALID_HANDLE`) for unknown (`handle2 + 99`) and negative (`-1`) handles. - `scePadSetTiltCorrectionState` & `scePadResetOrientation`: covers orientation settling on `handle2` through `SettleOrientationW(1)` when disabled and enabled, verifying port 0 orientation settling is unaffected; covers invalid handle rejection for unknown and negative handles. ### Tested - `python tools/check_conventions.py --base upstream/main --head HEAD`: 0 findings. - Windows 11 verification courtesy of @maskym: Windows 11 build 26300 (Intel i7-12700K, WinLibs GCC 15.2.0 Release, `BUILD_TESTING=ON`), `ctest -R '^(guest_kernel_sys|guest_pad|unwind_record_bounds)'` passed 27/27 clean across 3 runs. ### 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) - [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
MarcZX10 commented 2026-10-30 13:15:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T13:15:56Z.

Review: COMMENTED


Tests run and reviewed — exact-head execution pending

The handle-validity assertions are registered and conventions pass, but this C++ test change has not yet been executed on its exact head.

What I ran

Reviewed head 42988003b2b8480aa8f51cce0a9c5c977df51b97 against base ee9a9a66cffb77ba42781b66d764e96d22843554. Environment: Debian 12 x86-64, Python 3.11.2, Git 2.39.5. I did not build or compile.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13344
python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/tests/GuestPad.cpp
git show ee9a9a66cffb77ba42781b66d764e96d22843554:core/libs/prx/libScePad/CMakeLists.txt | grep -n -A5 -B2 'GuestPad.cpp'
git diff --check ee9a9a66cffb77ba42781b66d764e96d22843554...42988003b2b8480aa8f51cce0a9c5c977df51b97

Results

Check Result
Diff check and conventions/template Passed in the precheck.
CMake test registration Confirmed: guest_pad_tests includes tests/GuestPad.cpp and is registered as guest_pad.
Test-quality heuristic Flagged possible missing C++ registration; manual inspection confirmed the existing subdirectory CMake registration, so this is a false positive.
Source review The added assertions cover valid, unknown, and negative handles for the three named calls; no source-level defect found in this test-only diff.
Exact-head C++ test/build Not run locally.
Hosted CI Eligibility, conventions, intake, labels, and library-portability were queued at final refresh.
Unedited local check output

Conventions:

All conventions checks passed.

Test-quality heuristic:

{
  "findings": [
    {
      "path": "core/libs/tests/GuestPad.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}

Findings

Blocking

None confirmed from the source review.

Non-blocking

The PR adds C++ assertions, so the exact-head test executable still needs to run. Hosted checks were queued when I checked; this review is a comment rather than an approval until execution evidence is available.

Sources

Not verified

The guest_pad executable and other build-dependent tests were not run locally. No runtime result is available yet for this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5712776880 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13344#pullrequestreview-5712776880). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T13:15:56Z. **Review:** COMMENTED --- # Tests run and reviewed — exact-head execution pending The handle-validity assertions are registered and conventions pass, but this C++ test change has not yet been executed on its exact head. ## What I ran Reviewed head `42988003b2b8480aa8f51cce0a9c5c977df51b97` against base `ee9a9a66cffb77ba42781b66d764e96d22843554`. Environment: Debian 12 x86-64, Python 3.11.2, Git 2.39.5. I did not build or compile. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13344 python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/tests/GuestPad.cpp git show ee9a9a66cffb77ba42781b66d764e96d22843554:core/libs/prx/libScePad/CMakeLists.txt | grep -n -A5 -B2 'GuestPad.cpp' git diff --check ee9a9a66cffb77ba42781b66d764e96d22843554...42988003b2b8480aa8f51cce0a9c5c977df51b97 ``` ## Results | Check | Result | |---|---| | Diff check and conventions/template | Passed in the precheck. | | CMake test registration | Confirmed: `guest_pad_tests` includes `tests/GuestPad.cpp` and is registered as `guest_pad`. | | Test-quality heuristic | Flagged possible missing C++ registration; manual inspection confirmed the existing subdirectory CMake registration, so this is a false positive. | | Source review | The added assertions cover valid, unknown, and negative handles for the three named calls; no source-level defect found in this test-only diff. | | Exact-head C++ test/build | Not run locally. | | Hosted CI | Eligibility, conventions, intake, labels, and library-portability were queued at final refresh. | <details><summary>Unedited local check output</summary> Conventions: ```text All conventions checks passed. ``` Test-quality heuristic: ```json { "findings": [ { "path": "core/libs/tests/GuestPad.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } ``` </details> ## Findings ### Blocking None confirmed from the source review. ### Non-blocking The PR adds C++ assertions, so the exact-head test executable still needs to run. Hosted checks were queued when I checked; this review is a comment rather than an approval until execution evidence is available. ## Sources - [Added handle assertions at the reviewed commit](https://github.com/boykopovar/AnyPS5/blob/42988003b2b8480aa8f51cce0a9c5c977df51b97/core/libs/tests/GuestPad.cpp#L973-L982). - [Existing `guest_pad` CMake registration at the reviewed base](https://github.com/boykopovar/AnyPS5/blob/ee9a9a66cffb77ba42781b66d764e96d22843554/core/libs/prx/libScePad/CMakeLists.txt#L8-L16). ## Not verified The `guest_pad` executable and other build-dependent tests were not run locally. No runtime result is available yet for this head.
adriadam10 commented 2026-10-30 14:36:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-30T14:36:53Z.

Review: CHANGES_REQUESTED


Thanks for the test. As written it mostly repeats coverage that is already on main:

  • scePadSetTiltCorrectionState / scePadResetOrientation: CheckTiltCorrection (core/libs/tests/GuestPad.cpp:119-129) already checks valid and invalid handles and the effect on the settled orientation.
  • scePadSetMotionSensorState: lines 881-883 already cover enable, disable and an invalid handle; 414-417 covers the special handle.

What the new lines add is the same return codes on port 1 (handle2) plus handle -1. None of them would fail if the setter changed the wrong port or stopped applying the state, because only PAD_OK / PAD_ERROR_INVALID_HANDLE is checked.

To make it pin behaviour:

  • Toggle each state on handle2 and check the effect through the read path (for tilt correction, SettleOrientationW() like line 127-129; for motion, a published motion sample read back with motion off and on), and
  • check that port 0's state is unchanged afterwards (per-port isolation, the thing PortOf(handle) is there for).

The -1 / unknown handle rows are fine to keep.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5713857353 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13344#pullrequestreview-5713857353). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-30T14:36:53Z. **Review:** CHANGES_REQUESTED --- Thanks for the test. As written it mostly repeats coverage that is already on main: - `scePadSetTiltCorrectionState` / `scePadResetOrientation`: `CheckTiltCorrection` (`core/libs/tests/GuestPad.cpp:119-129`) already checks valid and invalid handles and the effect on the settled orientation. - `scePadSetMotionSensorState`: lines 881-883 already cover enable, disable and an invalid handle; 414-417 covers the special handle. What the new lines add is the same return codes on port 1 (`handle2`) plus handle `-1`. None of them would fail if the setter changed the wrong port or stopped applying the state, because only `PAD_OK` / `PAD_ERROR_INVALID_HANDLE` is checked. To make it pin behaviour: - Toggle each state on `handle2` and check the effect through the read path (for tilt correction, `SettleOrientationW()` like line 127-129; for motion, a published motion sample read back with motion off and on), and - check that port 0's state is unchanged afterwards (per-port isolation, the thing `PortOf(handle)` is there for). The `-1` / unknown handle rows are fine to keep.
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!13344
No description provided.