Skip to content

tools: compare XCL's synthetic test title under gta6rt and under XCL (TEST-845) - #3878

Open
mariuslozo-boop wants to merge 4 commits into
ItsNotRexed:mainfrom
mariuslozo-boop:test/xcl-compare
Open

mariuslozo-boop wants to merge 4 commits into
ItsNotRexed:mainfrom
mariuslozo-boop:test/xcl-compare

Conversation

@mariuslozo-boop

@mariuslozo-boop mariuslozo-boop commented Nov 22, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: TEST-845 (claim).

What and why

tools/xcl_compare.py runs XCL's synthetic console executable (its test title: kernelx, xgameruntime, xmem, d3d12_xs and a bundled game DLL, about 50 checks) under gta6rt --run and under XCL, and reports where the two runtimes disagree. XCL already runs retail Xbox Series titles, so a check that passes there and fails here is a lead for the loader, the shims or the D3D12 layer.

  • For each check it records the result, the reason, the unimplemented imports hit while it ran, and, for a hang, the stacks of the title's threads (cdb -pv from the Windows SDK debugging tools).
  • After a hang it restarts the title with that check skipped. If the title ignores the skip, it stops instead of hanging again.
  • It writes report.json. With --gui it shows the checks live in a window (tkinter).
  • Standard library only. It runs with python -I and writes text with LF line endings.

docs/xcl_compare.md covers the licence boundary, how to run the tool, and the first result: XCL 50 pass; gta6rt 5 pass, 43 fail, 2 hang. Each difference is either mapped to an existing item or recorded as a lead:

Licence and provenance: XCL is GPL-2.0-only. This PR holds no XCL code, headers, tables or output. The tool only starts binaries built in a separate XCL checkout. I read XCL's README, its HANDOFF.md and its test title's source, to learn what each check does and how to run it. Two small local changes to the test title's check function (a [RUN] line and a skip variable) are described in the doc, not included here.

Tested

  • Windows 11 Pro (26300), RTX 5070 Ti (driver 616.92), MSVC 19.44, Windows SDK 10.0.26100, Python 3.12.10. Runtime built with CMake at f847748c. XCL at 055b0ad.
  • Full runs:
    • with the locally changed title: XCL 50 pass; gta6rt 5 pass, 43 fail, 2 hang (restarted past both)
    • with the upstream title: the tool stops after the repeated hang (5 pass, 21 fail, 1 hang, 23 not run)
  • --gui was checked by eye on the same run.
  • python -I tests/test_xcl_compare.py (8 tests) passes.
  • These also pass: test_docs_links.py, test_docs_repo_paths.py, test_docs_list_items.py, test_text_write_line_endings.py, test_i18n_index.py, test_docs_design_rows.py, and python -m compileall.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change.)

AI-assisted (Claude Code).

🤖 Generated with Claude Code

tools/xcl_compare.py starts XCL's fake console executable under gta6rt --run
and under XCL, records each check's result, the unimplemented imports it hit,
and the thread stacks of a hung check (cdb), restarts after a hang with that
check skipped, and writes report.json; --gui shows the checks live. It holds
no XCL code: it only runs binaries from a separate XCL checkout.

docs/xcl_compare.md has the licence boundary, how to run it, and the first
result (XCL 50/50, gta6rt 5 pass, 43 fail, 2 hang), with each difference
mapped to an open item or recorded as a lead. Both hangs are the documented
deadlock of XTaskQueueTerminate(wait = true) from a manual queue's
dispatching thread, not a runtime bug.

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

shdann commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 87d608f on Windows, CPython 3.14.7, CPU only (no GPU, no game files, no external runtime, no GUI). python -m pytest -q tests/test_xcl_compare.py (venv with the pinned tests/requirements.txt): 8 passed. The tool is new, so there is no merge-base control.

One small thing, reproduced: Run.log is written but never read. In this diff it appears only as self.log = [] and run.log.append(line) in run_title; the CLI and GUI get the same lines through the events. So every output line of the title stays in memory for the life of the Run for nothing.

import gc, os, sys, tracemalloc
sys.path.insert(0, "tools")
import xcl_compare as x
class Sink:
    def put(self, event): pass
for n in (1000, 4000, 16000):
    r = x.Run("synthetic")
    gc.collect(); tracemalloc.start()
    cmd = [sys.executable, "-I", "-c", f"for i in range({n}): print('a'*256)"]
    x.run_title(cmd, os.environ, os.getcwd(), r, [], 15, None, Sink(), [])
    gc.collect(); before = tracemalloc.get_traced_memory()[0]
    count = len(r.log); r.log.clear(); gc.collect()
    print(count, before - tracemalloc.get_traced_memory()[0], r.exit_code)
    tracemalloc.stop()

Clearing the list frees 305,736, 1,220,960 and 4,888,544 bytes for 1,000, 4,000 and 16,000 lines of 256 characters (about 300 bytes a line, growing with the title's output). Dropping the list and the append, or writing the lines to a file if a transcript is wanted, removes it. Non-blocking.

AI-assisted.

Run.log collected every line a title printed and nothing read it. The lines
now go to xcl_output.txt and leonida_output.txt in the work folder (named in
report.json), and Run keeps none of them. A test checks the transcript and
that Run has no log.

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

Copy link
Copy Markdown
Author

Thanks, fixed in c4806f5. Run.log is gone. Each title's output now goes to xcl_output.txt and leonida_output.txt in the work folder, which report.json names under transcripts. Nothing is kept on the Run. A new test in tests/test_xcl_compare.py runs a small title through run_title, then checks the transcript and that Run has no log.

Tested: python -I tests/test_xcl_compare.py (9 tests), test_text_write_line_endings.py, test_docs_links.py and test_docs_repo_paths.py pass. I also did a full run on Windows 11 with an RTX 5070 Ti. The results are the same as before (XCL 50 pass; gta6rt 5 pass, 43 fail, 2 hang), with transcripts of 269 and 476 lines.

AI-assisted (Claude Code).

@mariuslozo-boop mariuslozo-boop changed the title tools: compare XCL's synthetic test title under gta6rt and under XCL tools: compare XCL's synthetic test title under gta6rt and under XCL (TEST-845) Nov 22, 2026
tests/test_tool_stdout_encoding.py requires every tool's __main__ block to
start with sys.stdout.reconfigure(errors="replace"); the tool did it inside
main() instead, so the check failed.

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

Copy link
Copy Markdown
Contributor

Tested on Windows 11 / Python 3.13.0: the 9 new tests pass, the docs-area tests 18/18, compileall clean, merge clean, and origin/main fails the test file with ModuleNotFoundError: xcl_compare.

The comparison is scoped correctly: check names/statuses/reasons/unimplemented imports/stacks only, no game data, nothing copied into the repo, and it records differences/same without asserting equality on this machine. Output goes to %TEMP%\leonida_xcl_compare\report.json plus both logs, stdout and --gui.

Minor:

  • tools/xcl_compare.py:273-275 does not create the --out parent, so a full run dies writing the report - the same class as make_game: reject a --out or --work that is a file before the build #2968.
  • Child stdout is never closed (:142,147; ResourceWarning at tests/test_xcl_compare.py:83).
  • same compares status only (:296), hiding same-status/different-reason.
  • The hang/restart path is untested.

Pass with those. AI-assisted review, no game files, no GPU.

…ces, restart tests)

- Create the --out parent folder before writing the report.
- Close the title's stdout pipe when the reader thread finishes.
- Count a check as different when the status or the reason differs.
- Move the hang restart loop into run_with_restarts and test it with a stand-in title.
- kill_tree falls back to Popen.kill outside Windows.

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

Copy link
Copy Markdown
Author

Thanks @tupacfan04, all four are fixed in 8aa2579:

  • --out: the parent folder is created before the report is written.
  • The reader thread closes the title's stdout when it finishes (with proc.stdout:). The tests now pass under -X dev -W error::ResourceWarning.
  • same compares the status and the reason, so a check that fails in both runs for different reasons counts as a difference. The console line shows both reasons. There is a new test for it.
  • The restart loop moved from run_all into run_with_restarts. Two tests run it against a stand-in title (a small Python script that prints the title's line format): one where the hung check is skipped and the rest run, and one where the title ignores XCL_TESTTITLE_SKIP and the tool stops after the repeat hang. kill_tree falls back to Popen.kill outside Windows, so this also runs on the Linux CI job.

python -I tests/test_xcl_compare.py: 12/12 pass. test_tool_stdout_encoding and test_docs_repo_paths pass, and the branch still merges cleanly into main.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 8aa2579 merged with main 98fa503 on Linux (Python 3.12.16): pass. test_xcl_compare.py; the four tests/test_docs_*.py 5/5 ok.

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