Skip to content

test(relinker): consolidate guest_none_relocations invalid cases - #14079

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
rooklz:test/guest-none-cases
Nov 6, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
rooklz:test/guest-none-cases

Conversation

@rooklz

@rooklz rooklz commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

What

Consolidates the guest_none_relocations invalid-case coverage into a single change. The harness gains the helpers and invalid_cases entries for guest dynamic-tag rejection (DT_REL, DT_RELA, DT_STRTAB, DT_SYMBOLIC, DT_TEXTREL, DT_UNUSED, DT_RPATH), duplicate dynamic segments and SCE dynamic data, unterminated terminators, unsupported dynamic flags, guest PT_TLS segment validation (alignment, memsz, outside file/load), guest lifecycle-array validation, guest preinit-without-init, and guest symbol/relocation rejection, including the Windows/macOS-only TLS cases. Replaces the parallel per-case pull requests on this file with one, so the file has a single open pull request.

Tested

Debian 12 x86-64, Python 3.12, relinker-only Release -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON:

  • ctest -R guest_none_relocations — pass.
  • ctest -j 8 — 540/540.
  • python3 tools/check_conventions.py --base upstream/main — passed.

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

This was referenced Oct 31, 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 — changes requested

The new macOS invalid-ELF cases call the converter but never assert its exit status, error message, or output files, so they cannot fail when the invalid image is accepted.

What I ran

Reviewed exact head 1590be17ddb643eecb39a1992e38fc1ba8ca0b87 against base ca073ec3ad0d766ea9f4658e418a5c977001a353. The no-build merge preview was clean. Environment: Linux x86-64, Python 3.11.2, Git 2.39.5. I did not build the relinker.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14079 --output-dir /tmp/anyps5-14079-review
gh api repos/boykopovar/AnyPS5/contents/core/relinker/relinker/tests/test_guest_none_relocations.py?ref=1590be17ddb643eecb39a1992e38fc1ba8ca0b87

Results

Check Result
Diff check Passed.
Conventions and PR template Passed locally and in hosted CI.
Python syntax Passed.
Python test registration Passed: 230 scripts are registered or workflow-run.
Merge preview against current main Clean.
Hosted Ubuntu relinker and ASan Passed.
Hosted Windows relinker In progress when checked.
Hosted macOS relinker jobs Queued when checked.
Product Linux/Windows and specialized jobs Skipped.
Test-quality heuristic Could not run because its helper is absent from the isolated PR snapshot.
Local relinker build or execution Not run; this test requires a built relinker binary.
Unedited precheck output
All conventions checks passed.
230 test script(s), each run by an add_test or a workflow

Negative control

Assertion Change to code under test Outcome
The two macOS TLS-invalid fixtures are rejected and produce no artifacts Make the converter accept either invalid fixture Could not be exercised: the new macOS loop does not inspect result, artifact, or output, so acceptance would not fail this test.

Findings

Blocking

In test_guest_none_relocations.py, both cases yielded by invalid_cases_macos() call convert() and discard the returned values. Unlike the Linux and Windows loops, there is no assertion that the converter returns 2 with the expected diagnostic or that it leaves no artifact/output. Thus these cases do not test the rejection they are intended to cover.

Please assert the expected status and diagnostic, and assert that neither artifact nor output is created, as the adjacent Linux and Windows invalid-case loops do.

Non-blocking

None.

Sources

Not verified

I did not build or execute the relinker locally, and the macOS relinker jobs were queued at the last check snapshot. No claim is made that these macOS fixtures passed or failed conversion.

To get this to a good state

Assert the macOS cases’ return code, diagnostic, and absence of output artifacts. I will rerun the same precheck and review the new head.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Reviewed at 1590be17dd. The new macOS invalid-case loop at test_guest_none_relocations.py:367-368 calls convert but never checks its result. Both invalid TLS cases therefore pass even if conversion succeeds, reports the wrong error, or leaves output artifacts.

Please assert exit code 2, the expected diagnostic, and absence of both the converted module and output executable, as the adjacent Linux and Windows loops do. Include the target system and case name in assertion context. Then rerun the complete Python test and confirm that a control which wrongly accepts a macOS invalid fixture makes it fail.

The previous invalid-case names are retained; the missing checks are confined to the new macOS loop.

@rooklz

rooklz commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Fixed at 7a61f80: the macOS invalid-case loop now asserts the same things as the Linux and Windows loops (exit code 2, the expected diagnostic, and absence of the converted module and output executable), so the two macOS TLS cases can no longer pass if the image is accepted. ctest -R guest_none_relocations passes and check_conventions.py --base upstream/main is clean.

@rooklz
rooklz force-pushed the test/guest-none-cases branch from 7a61f80 to 68d33bd Compare October 31, 2026 19:02
@rooklz

rooklz commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Updated at 68d33bd. The macOS invalid-case loop now asserts exit code 2, the expected diagnostic, and that neither the converted module nor the output executable exists, matching the Linux and Windows loops, and its assertion context includes the target system and case name.

Verification: ctest -j 6 540/540 and check_conventions.py --base upstream/main pass. As a negative control I temporarily removed the macOS TLS alignment/memory-size rejection from GuestTlsBlockSize; guest_none_relocations then failed at the new macOS assertion with (\"macos\", False, \"invalid-tls-segment-large-align\", \"\"). The source was restored and the suite re-passed.

@rooklz

rooklz commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The macOS invalid-case loop now asserts the same rejection properties as the Linux and Windows loops: result.returncode == 2 with the expected diagnostic in stderr, and neither artifact nor output created (commit 68d33bd, pushed after the review). All hosted relinker jobs (Ubuntu, Windows, macOS x86_64 and arm64, ASan) pass at that head. Please recheck when convenient.

@Ondra97

Ondra97 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Current-main follow-up for head 68d33bd7666d755c717e0a2898730e02e5067658: during the #10351 fixture investigation, applying this test-file change by a clean three-way file merge to main 48c8ef11fc4a44ef859f3cd95daf8ea4a0693d01 reproduces a stale diagnostic expectation at unsupported-dynamic-tag-rel. It expects Unsupported dynamic tag 17, but GuestImageReader now rejects tags 17/18/19 together with DT_REL relocations are not supported before the generic unsupported-tag check. Please refresh those three expectations against current main and rerun all target-system cases. This is separate from the previously fixed macOS missing assertions.

Main also contains merged #15526, which splits the fixture into plain and sce CTest registrations while retaining the 20-second limit. Please preserve both registrations during the refresh. #15751 is a separate batching proposal, not a dependency required for the current split.

The current-main fixture comparison ran on Windows with WinLibs GCC 15.2; I did not run a refreshed full #14079 CI composition. Details of the same comparison are recorded on #10351. AI-assisted: yes.

@rooklz
rooklz force-pushed the test/guest-none-cases branch from 68d33bd to 3ad8c73 Compare November 4, 2026 22:41
@rooklz

rooklz commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the follow-up. Rebased onto current main and refreshed the three expectations: unsupported-dynamic-tag-rel, unsupported-dynamic-tag-rela and unsupported-dynamic-tag-unused (tags 17/18/19) now expect DT_REL relocations are not supported, since GuestImageReader no longer rejects those tags itself and the pipeline's DT_REL/DT_RELSZ/DT_RELENT check fires first. The #15526 split is preserved — both guest_none_relocations (plain) and guest_none_relocations_sce registrations remain with the 20-second limit. Verified locally against the refreshed head 3ad8c730f3 on macOS: both modes pass, check_conventions.py --base origin/main passes. Not taking a dependency on #15751.

AI-assisted: yes

@rooklz
rooklz requested a review from MarcZX10 November 5, 2026 08:30
@adriadam10 adriadam10 self-assigned this Nov 6, 2026
@adriadam10
adriadam10 merged commit 669f067 into boykopovar:main Nov 6, 2026
13 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the new invalid cases against the harness (exit code 2, exact diagnostic, no converted module or output on Linux, macOS and Windows), the refreshed DT_REL/RELA/UNUSED expectations and the green relinker jobs on every platform; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants