Skip to content

test(libSceHmd2): check the named calls' measured answers before initialization - #14112

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
LeandroLP23:test/hmd2-named-calls-before-initialize
Nov 5, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
LeandroLP23:test/hmd2-named-calls-before-initialize

Conversation

@LeandroLP23

Copy link
Copy Markdown
Contributor

What

docs/dev/debt/libSceHmd2.md records what the console answers before sceHmd2Initialize, measured with every argument null and with every argument pointing at zeroed memory. 22 of the named exports in those groups had no test. GuestHmd2.cpp now calls each of them before initialization with null or zero arguments and checks the recorded answer:

Answer Calls
0 sceHmd2SetIpdOffset, sceHmd2InternalTrackingOpen/Close, sceHmd2InternalLedDetectorOpen/Close
-1 sceHmd2InternalTrackingStart/Stop, sceHmd2InternalLedDetectorStart/Stop
0x8a720004 sceHmd2GazeStartUserCalibration, StopUserCalibration, SetUserCalibrationPoint, SetEnabledEye
0x8a720008 sceHmd2GazeGetCalibrationData, SetUserCalibrationData, ObjectSelectionInitialize
0x8a72000b sceHmd2ReprojectionSetUserEventStart/End, ClearUserEventStart/End
0x8a72002c sceHmd2GazeObjectSelectionTerminate

For every call, the value in Export.cpp matches the one the debt file gives for its group. Test only; no behaviour change.

Tested

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

LeandroLP23 and others added 2 commits October 31, 2026 20:16
…ialization

The debt file records what the console answers before sceHmd2Initialize
for each named export, but 22 of those named calls had no test. Call each
of them before initialization with null or zero arguments, as the
measurement did, and check the recorded answer: 0, -1, 0x8a720004,
0x8a720008, 0x8a72000b or 0x8a72002c.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…event calls

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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 — looks good

The 21 new pre-initialization assertions match the recorded answers for their named exports, and the exact-head Windows test job passes.

What I ran

Reviewed head 04e7368707b801d75ed995a29d2a7d3a465aa5ae against base 76d08bc10b302d54345963a3befe31a1b8be6040; GitHub reports the PR mergeable. Environment: Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0.

git diff --check 76d08bc10b302d54345963a3befe31a1b8be6040...04e7368707b801d75ed995a29d2a7d3a465aa5ae
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14112
gh run view 41233735805 -R boykopovar/AnyPS5 --job 124633706007 --log

Results

Check Result
Diff check Passed.
Conventions, eligibility, intake, and library portability Passed on the PR head.
Windows hosted test job Passed; its log lists guest_hmd2_tests under the changed guest core/libs tests.
Dependency/mergeability precheck Passed.
Test-quality helper Could not run in the isolated PR worktree because the local-only helper script is absent there; this is a tooling limitation.
Labels Pending when checked.
Linux product, relinker, sanitizer, and console behavior Not run or not applicable to this test-only path.
Unedited relevant output
All conventions checks passed.

windows Build and run changed guest core/libs tests [2/4] Building CXX object core/libs/prx/libSceHmd2/CMakeFiles/guest_hmd2_tests.dir/__/__/tests/GuestHmd2.cpp.obj
windows Build and run changed guest core/libs tests [3/4] Linking CXX executable tests\guest_hmd2_tests.exe
windows Build and run changed guest core/libs tests Guest core/libs tests:
windows Build and run changed guest core/libs tests guest_hmd2_tests
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-14112-04e7368707b8/head-04e7368707b8-fb7673b8/tools/pr_test_quality.py': [Errno 2] No such file or directory

Negative control

Assertion Mutation Outcome
sceHmd2GazeObjectSelectionTerminate returns the recorded pre-initialization result. The author reports changing the expected value to 0x8a720004. The author reports guest_hmd2 failed with that call's message; I did not independently rerun this mutation.

Sources

Not verified

I did not build or run the test locally. macOS, Linux product behavior, and PS5 console behavior were not tested. The Windows hosted job passed for the exact head.

@slopgobblercobbler slopgobblercobbler 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.

The additions in core/libs/tests/GuestHmd2.cpp provide clean, comprehensive test coverage for the 22 named libSceHmd2 exports called prior to initialization.

Key Observations

  1. Contract Consistency with Hardware Measurements:

    • The asserted return values strictly align with the console probe measurements documented in docs/dev/debt/libSceHmd2.md and their declarations in Export.cpp:
      • Returns 0: sceHmd2SetIpdOffset, sceHmd2InternalTrackingOpen, sceHmd2InternalTrackingClose, sceHmd2InternalLedDetectorOpen, sceHmd2InternalLedDetectorClose.
      • Returns -1: sceHmd2InternalTrackingStart, sceHmd2InternalTrackingStop, sceHmd2InternalLedDetectorStart, sceHmd2InternalLedDetectorStop.
      • Returns Hmd2::Error0004 (0x8a720004): sceHmd2GazeStartUserCalibration, sceHmd2GazeStopUserCalibration, sceHmd2GazeSetUserCalibrationPoint, sceHmd2GazeSetEnabledEye.
      • Returns Hmd2::ParameterNull (0x8a720008): sceHmd2GazeGetCalibrationData, sceHmd2GazeSetUserCalibrationData, sceHmd2GazeObjectSelectionInitialize.
      • Returns Hmd2::ReprojectionNotInitialized (0x8a72000b): sceHmd2ReprojectionSetUserEventStart, sceHmd2ReprojectionSetUserEventEnd, sceHmd2ReprojectionClearUserEventStart, sceHmd2ReprojectionClearUserEventEnd.
      • Returns Hmd2::Error002C (0x8a72002c): sceHmd2GazeObjectSelectionTerminate.
  2. Test Structure & State Isolation:

    • Isolating these calls within TestNamedCallsBeforeInitialize() and executing them directly after TestBeforeInitialize() (and before headset/session setup in TestWithoutHeadset()) ensures that device state remains clean and uncontaminated by subsequent routines.
    • Using standard Require() assertions with descriptive error contexts keeps failures immediate and easy to pinpoint if pre-init contracts regress.
  3. Conventions:

    • No unnecessary comments added to test source.
    • Clean C++20 conventions maintained throughout.

Looks good and solid to merge.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 8645 core/libs/tests/GuestHmd2.cpp

@oneandonlydean oneandonlydean self-assigned this Nov 5, 2026
@oneandonlydean
oneandonlydean merged commit 874a1e7 into boykopovar:main Nov 5, 2026
11 checks passed
@LeandroLP23
LeandroLP23 deleted the test/hmd2-named-calls-before-initialize branch November 5, 2026 08:50
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.

4 participants