ffx: harden ffx_working_set_delta validation and add unit suite #1941
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1948"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T21:59:20Z.
Change
Wrap
tools/ffx_working_set_delta.pyCLI execution in an explicitmain(argv=None)entry point that exits cleanly (status1, no Python traceback) onOSError,ValueError, andpefile.PEFormatError, and register a synthetic AMD64 PE32+ unit and refusal suite intests/ffx_working_set_delta_check.py(run viaCMakeLists.txtasffx_working_set_delta_check).tests/ffx_working_set_delta_check.py): synthesizes an AMD64 PE32+ DLL exportingcreate_deltaandrelease_deltawith.pdataentries and verifies bothgenerate(image, False)andmain(argv)/ subprocess CLI output..cppoutput) on--packageSHA-256 mismatch, missingcreate_delta/release_deltaexports, missing or multi-range.pdata, non-AMD64 / non-PE32+ images, non-.cppor input-aliasing output paths, and missing/corrupt input files.AI-assisted.
Verification
ctest --preset dev -Nandctest --preset release -N:1238total tests in both presets (ffx_working_set_delta_checkregistered as test#1224).ctest --preset dev --no-tests=error -R "^(ffx_working_set_delta_check|ffx_create_context_check|ffx_dispatch_profile_check)$" -V:3/3passed (ffx_dispatch_profile_check10 tests,ffx_create_context_check6 tests,ffx_working_set_delta_check7 tests).ctest --preset release --no-tests=error -R "^(ffx_working_set_delta_check|ffx_create_context_check|ffx_dispatch_profile_check)$" -V:3/3passed.python -B tests/ffx_working_set_delta_check.py -v:7/7tests passed.python -B tests/form_coverage_check.py,python -B tests/docs_links_check.py, andpython -B tests/bidi_controls_check.py: all exited0.Evidence and follow-up
All fixtures in
tests/ffx_working_set_delta_check.pyare constructed synthetically in memory with zero external or game-specific inputs.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:12:15Z.
Ran the suite, broke four paths, all four caught
Windows 11 build 26300.9974:
Mutations to
tools/ffx_working_set_delta.py, each reverted:except (OSError, ValueError, pefile.PEFormatError)→except (KeyboardInterrupt,)parser.exit(1, …)→parser.exit(0, …)if args.output.suffix.lower() != ".cpp" or args.output.resolve() == args.image.resolve():→if False:The third and fourth are the ones I would have expected to slip, because they are refusals whose outcome (exit 1, no file
written) can be produced by a later error instead of the guard. Here they do not slip — and I think that is deliberate: the refusals
assert the message text, not only the exit code.
That is the difference between "it failed" and "it failed for the reason the test is about". Compare with #1933, where the same-file
case passed with the guard removed because
generate()raised a different error first; the two suites look alike but this one pinsthe cause.
The positive control is not a smoke test either
Five anchors, including both the
+and-paths of the delta, so an inverted counter or a dropped subtraction in the emitterwould fail rather than producing plausible-looking C++.
What I did not do
I did not build the generated
.cppor link it against an upscaler image —FFX_UPSCALER_IMAGEis not set on this machine, sothe translated ranges and the
--packagehash path are only exercised through the synthetic PE. That matches what the descriptionscopes to a unit suite.
Verdict
Reviewed. The refusals are pinned by cause and the positive output by content; both are what the earlier hardening PRs in this
series were missing.
Notes
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T22:38:01Z.
Resolved the CMake registration conflict with main while preserving both Bink checks and the FFX working-set delta check. Windows Release CTest ran all three (3/3).