shader: accept argv and guard file and path errors in disasm_rdna2 with CLI suite #2338
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2346"
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-25T13:05:29Z.
Change
Update
tools/disasm_rdna2.pyCLI entry point and add a dedicated pure-Python unit and CLI validation suite (tests/disasm_rdna2_cli_check.py, registered asrdna2_cli_checksinCMakeLists.txt):main(argv: list[str] | None = None) -> intforwardsargvtoparser.parse_args(argv).--hexinput viaparser.error(exit code 2, no traceback).--outputcollisions with input.binfiles (single-file and directory targets) usingPath.resolve()andPath.samefile()so input binaries are never overwritten.--outputdirectory checks, target file/directory reads, and atomic--outputlisting writes (tempfile.NamedTemporaryFile+Path.replacewithfinallytemp cleanup) insidetry/except OSError, suppressing partial output when any target fails and exiting cleanly with code 1 and zero raw tracebacks.Verification
Verified on commit
dac64774(rebased ontoupstream/main14e8b6a5):out/pe-env/Scripts/python.exe -B tests/disasm_rdna2_cli_check.py->Ran 11 tests in 0.394s/OK(exit 0)out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py->Ran 156 tests in 4.934s/OK (skipped=19)(exit 0; 19 LLVM cross-check tests skipped becauseLLVM_LIBis unset in this environment)out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py->form coverage checks passed(exit 0)out/pe-env/Scripts/python.exe -B tests/docs_links_check.py->Self-test passed. Checked 19 Markdown files and 453 links.(exit 0)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py->Self-test passed. Checked 1631 tracked source, script and build/CI files: no bidirectional controls.(exit 0)Evidence and follow-up
tests/disasm_rdna2_cli_check.pyare synthetic RDNA 2 machine-code words constructed in-memory (s_nop,s_mov_b32with 32-bit literal,s_endpgm, and truncated/trailing byte tails).--output, empty/whitespace/odd/invalid--hex, missing targets with no--hex, unreadable file/directoryOSErrorpaths,--outputpath collisions (direct,..-resolved, directory-mode, and hardlink/samefile), existing-directory--output, unwritable parent paths, and atomic replace failure temp cleanup.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:13:57Z.
Review: COMMENTED
Review of head
dac64774fdResult: 0 P1, 0 P2.
Scope:
tools/disasm_rdna2.py(main takes argv, returns an exit code, guards file and path errors, writes the listing atomically, refuses an output path that collides with an input), the newtests/disasm_rdna2_cli_check.py, and therdna2_cli_checksCTest registration inCMakeLists.txt. The disassembly logic is unchanged and no ISA semantics are touched. Clean-room: only public code and in-repo fixtures are used.Checked:
--hexaccepts whitespace and rejects empty input.--outputis rejected.tools/disasm_rdna2.py.Commands run locally:
python3 -B tests/disasm_rdna2_cli_check.py: 11 tests OKpython3 tests/docs_links_check.py: OK (453 links)python3 tests/bidi_controls_check.py: OKgit diff --check origin/main...HEAD: cleannot had_errorguard on writing the listing. The suite FAILED (1 failure).return 1 if had_error else 0changed toreturn 0. The suite FAILED (1 failure).git checkout -- ..python3 x2w_pipe.py win2025 2346 --wait 3600: Debug (dev preset) 40/40 PASS and Release -O2 40/40 PASS, includingrdna2_cli_checksandrdna2_tools_check.Build and test on Windowsis SUCCESS.AI-assisted; commands listed were executed locally.