Skip to content

Fork tests green: the iOS tests and the switch table follow the fork, across syncs - #51

Merged
LNPANDY merged 1 commit into
LNPANDY:mainfrom
v0lumehi:fork-tests-green
Oct 27, 2026
Merged

LNPANDY merged 1 commit into
LNPANDY:mainfrom
v0lumehi:fork-tests-green

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

With #48's test workflow, three test files fail on main. Each fails on a fork change that upstream's version of the file does not know about. This PR makes them pass and keeps them passing across syncs.

Rebased onto b54504e, after #39 and 9f7d421.

Test Cause Change
dm/ios/tests/test_romfs_startup.py The test compiles main.m's RomFS locator on its own. The fork's locator reads id and romfs_marker through dm_profile(), which the fixture did not stub. The fixture stubs dm_profile() with the marker the test already uses.
dm/ios/tests/test_profile_pack.py The test expects the RomFS in the IPA. The fork's default is the slim IPA; DM_FULL_ROMFS=1 packs the RomFS in. It checks that the RomFS stays out.
dm/tools/tests/test_env_switches.py docs/env_switches.tsv loses the rows of the switches only the fork reads (DM_FULL_ROMFS, DM_PROFILE) whenever upstream rewrites the table. 9f7d421 put the rows back by hand. A patcher restores them, in your wording.

Staying fixed across syncs. The two iOS tests and the switch table are carriers now. Each has a patcher that is idempotent and rebuilds this tree from upstream's files; I checked that against seedds/main. test_nro_header.py goes into OURS, because it tests your patch_nso.py carrier. A sync run with --old = --new ends SYNC OK. The three tests, test_nro_header and test_docs pass locally.

Two things for you:

  1. The NRO header bound. patch_patch_nso restores TEXT_LO = segs[0][1]. A real NRO shows that this value is 0: Hades' EOSSDK-Switch-Shipping.nro has text {0x0, 0xa41000}, with the header inside it. So the bound does not skip the header, and Fix: Skip the NRO header when scanning code ranges #14 is still open. The fix is upstream as seedds/nxnative#397, with a behavioural test; the details are in this comment.
  2. PATCHED. dm/host/front_mac.m, dm/tools/patch_nso.py and the Hades II game.tsv have patchers but are not in PATCHED. The sync still re-applies them in its second pass, but pr-scope will flag a PR that touches them.

The earlier dry run with #48 passed all six jobs: https://github.com/v0lumehi/NX2Apple/actions/runs/40489457905. That was before this rebase.

@v0lumehi

Copy link
Copy Markdown
Collaborator Author

The dry run has finished: all six jobs of #48's workflow pass with this PR (https://github.com/v0lumehi/NX2Apple/actions/runs/40489457905).

@v0lumehi
v0lumehi force-pushed the fork-tests-green branch 2 times, most recently from b1cb837 to 5027f32 Compare October 27, 2026 10:45
@v0lumehi v0lumehi changed the title Fork tests green: the iOS tests, the switch table and the NRO test follow the fork, across syncs Fork tests green: the iOS tests and the switch table follow the fork, across syncs Oct 27, 2026
… across syncs

With the tests running in CI (LNPANDY#48), three test files failed on main, each
on a fork change upstream's file does not know:

- test_romfs_startup compiles main.m's RomFS locator alone; the fork's
  locator reads id and romfs_marker through dm_profile(), which the
  fixture did not stub. The fixture gets one.
- test_profile_pack expects the RomFS in the IPA; the fork packs the
  slim IPA by default (DM_FULL_ROMFS=1 packs it), so it checks that the
  RomFS stays out.
- test_env_switches: docs/env_switches.tsv loses the rows of the switches
  only the fork reads (DM_FULL_ROMFS, DM_PROFILE) whenever upstream
  rewrites the table; 9f7d421 put them back, and a patcher keeps them.

The two iOS tests and the switch table are carriers: a patcher each,
idempotent, reproducing this tree from upstream's files. The NRO test is
in OURS (it tests the fork's patch_nso.py carrier). A sync run with
--old = --new ends SYNC OK.
v0lumehi added a commit to v0lumehi/NX2Apple that referenced this pull request Oct 27, 2026
…m the merge base

The five older workflows used actions/checkout@v4, setup-python@v5 and
upload-artifact@v4; they take the same pins as tests.yml (checkout
v7.0.1, setup-python v7.1.0, upload-artifact v7.0.2, by commit SHA), and
Dependabot keeps all of them current. checkout v6 moved the persisted
token to a file under RUNNER_TEMP; git push in sync-upstream.yml works
on as before (the action's notes: no workflow changes required).

pr-scope compared the base branch's tip with the PR's head (two dots), so
every commit main gained after a PR branched counted as the PR's: LNPANDY#51
failed on env_switches.py and docs/agents/README.md, which main had just
changed. It diffs from the merge base now (three dots, as its comment
said), with the history checked out for it.
@v0lumehi

v0lumehi commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

On point 1 (the NRO bound): I found a real NRO after all. Hades ships RomFS/nro/EOSSDK-Switch-Shipping.nro, and its header reads:

magic at 0x10: NRO0
text {offset, size} = (0x0, 0xa41000)
ro   {offset, size} = (0xa41000, 0x317000)
data {offset, size} = (0xd58000, 0x99000)

The text segment starts at offset 0, with the 0x80-byte header inside it. So TEXT_LO = segs[0][1] is 0 for an NRO, the scan still starts at the header, and #14 is not fixed by patch_patch_nso. The bound needs to be 0x80 if d[0x10:0x14] == b'NRO0' else 0 (the original report's proposal). test_nro_header passes anyway, because it checks for the source line, not for the behaviour. Update: the fix is upstream as seedds/nxnative#397. It adds code_start() (0x80 for an NRO) and code_ranges(), plus a behavioural test on a synthetic NRO whose build ID decodes as an x18 load. Hades' EOS NRO rewrites byte-identically before and after. Once it lands and syncs, patch_patch_nso can go, and test_nro_header with it, since the upstream test covers the behaviour.

@LNPANDY
LNPANDY merged commit dc3511e into LNPANDY:main Oct 27, 2026
1 check passed
@LNPANDY

LNPANDY commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Merged as dc3511ed. Thank you — this is better than what I had.

I had done two of these by hand this morning and they were the weaker version of the same idea: I edited docs/env_switches.tsv to add DM_FULL_ROMFS and DM_PROFILE meanings, and I put test_nro_header.py in OURS while fixing the NRO regression. Both were one-shot edits that the next sync would have quietly undone in the first case and kept by luck in the second. Your patch_env_switches and the OURS entry make them survive, which is the actual requirement.

Verified on top of today's main (451153aa, before this merge):

  • sync_upstream.py --old 75065df --new 75065df --skip-build → SYNC OK, every patcher agreeing with the tree, and env_switches.tsv fork rows (already patched) reported correctly rather than re-applied.
  • python3 -m unittest discover -s dm/tools/tests → 352 passed, 17 skipped, 0 failed.
  • python3 -m unittest discover -s dm/ios/tests → 31 passed, 0 failed.

Two notes, neither a request for a change:

  • patch_env_switches appends the missing rows and re-sorts the whole body by name. That means a merge conflict is impossible but a reordering diff is guaranteed whenever upstream inserts a row in the middle — I would rather have that than a conflict, so this is a note, not a complaint.
  • test_romfs_startup.py's stub now declares dm_profile() with a single hardcoded id. If the fork ever reads a second field from the profile in main.m, that stub is where the test will stop, and the failure will look like a compile error rather than a missing fixture. Worth a line in the stub's comment if you touch it again; I am not going to.

The row ordering moved DM_FULL_ROMFS and DM_PROFILE into place relative to their neighbours, and env_switches.py --check is clean after the merge.

v0lumehi added a commit to v0lumehi/NX2Apple that referenced this pull request Oct 27, 2026
…m the merge base

The five older workflows used actions/checkout@v4, setup-python@v5 and
upload-artifact@v4; they take the same pins as tests.yml (checkout
v7.0.1, setup-python v7.1.0, upload-artifact v7.0.2, by commit SHA), and
Dependabot keeps all of them current. checkout v6 moved the persisted
token to a file under RUNNER_TEMP; git push in sync-upstream.yml works
on as before (the action's notes: no workflow changes required).

pr-scope compared the base branch's tip with the PR's head (two dots), so
every commit main gained after a PR branched counted as the PR's: LNPANDY#51
failed on env_switches.py and docs/agents/README.md, which main had just
changed. It diffs from the merge base now (three dots, as its comment
said), with the history checked out for it.
@v0lumehi
v0lumehi deleted the fork-tests-green branch November 1, 2026 05:10
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.

2 participants