Scripts: harden bvhb_shaders CLI argument handling, validation, and test coverage #1848
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1858"
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 ivall/xcl. Originally posted by heditrigui on 2026-11-24T21:58:22Z.
Summary
Hardens CLI argument handling and validation in
scripts/re/bvhb_shaders.pyand expands unit test coverage inscripts/test_bvhb_shaders.py:-hand--helpCLI option support with usage docstrings and clean exit code 0.error: file not found: '<dll_path>'on stderr and exits code 1) instead of crashing with unhandled Python exceptions.extract_shaders(dll_bytes, out_dir=None)andmain(argv=None, out=None)functions so the module can be cleanly imported without executing top-level logic.scripts/test_bvhb_shaders.pyfrom 1 to 7 tests covering CLI argument flags, exit codes, missing files, shaders without RTS0 root signatures, and direct Python API extraction.Tested
python -m unittest scripts/test_bvhb_shaders.py(7 passed in 0.37s).python -m pytest scripts/(22 passed in 0.74s).scripts/pr_check.py --local.Not tested
scripts/tools are non-runtime code).AI use
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T22:36:58Z.
Tested exact head
ebf6f96, script tests only, since this PR has no test report yet.Tested
python -m pytest scripts/test_bvhb_shaders.pyat the head: 7 passed, 2 subtests passed.689f2db): does not get to run: collection fails withFileNotFoundError: ... '-q', because main'sbvhb_shaders.pyreadssys.argvat import time (which this PR changes).bvhb_shaders) conflict:git merge-treeof the two heads reports conflicts inscripts/re/bvhb_shaders.pyandscripts/test_bvhb_shaders.py, so whichever lands second needs a rebase.Not tested
AI use
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T01:27:47Z.
Tested
Clean checkout of
ebf6f96c60414ca63bf22792a7ff92ad697462acon Windows 11 Enterprise Evaluation 25H2 (build 26200.9974), AMD Ryzen 7 3800X, portable CPython 3.13.7 x64. This adds native Windows path and byte-for-byte extraction coverage to the earlier Python 3.14.3 pytest report.I compiled a one-function synthetic pixel shader with the Windows SDK 10.0.26100.0 x64
fxc.exe /nologo /T ps_5_0 /E main /Fo fixture.dxbc fixture.hlsland embedded the resulting 452-byte DXBC after a 16-byte prefix in a scratch wrapper. The working directory, wrapper path, and explicit output path contained spaces and Unicode (é,日).From the scratch working directory, with
$pythonpointing to the portable executable and$scriptto the checkout’sscripts/re/bvhb_shaders.py, I ran these seven checks with stdout and stderr captured through pipes.& $python -B $script -hand& $python -B $script --helpeach exited 0 and printed usage to stdout.& $python -B $scriptexited 2 and printed usage to stdout.& $python -B $script 'absent café shader.dll'and& $python -B $script $missingAbsoluteeach exited 1 with a file-not-found diagnostic on stderr and empty stdout. Redirected cp1252 stderr preservedéand escaped日in the absolute path as literal\u65e5.& $python -B $script $source $outputand& $python -B $script $sourceeach exited 0 and reported one container at0x10withRS: -. Both the explicit Unicode directory and the defaultbvhb_shadersdirectory contained exactly one00.dxbc, byte-identical to the 452-byte compiler output.7 passed, 0 failed, 0 ignored, 0 skipped.
Not tested
Coverage was limited to the Python CLI with a valid synthetic shader and missing-path diagnostics. Cargo, GPU execution, and retail assets were outside this run.
AI use
Codex (
gpt-6.2-sol) ran the checks and wrote this report.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T01:28:52Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-26T04:31:23Z.
Tested
ebf6f96c60414ca63bf22792a7ff92ad697462ac. The original #1759 patch does not apply directly to eitherscripts/re/bvhb_shaders.pyor its test file here. Candidate on this PR's head carries over the register-space formatting and the ASCII spelling for unbounded ranges. It keeps this PR's extraction API and CLI tests.I compiled two root signatures with Windows
d3dcompiler_47.dll(rootsig_1_0androotsig_1_1). Each used constants at b1/space2, a CBV at b2/space3 and a table with both finite and unbounded SRV ranges. I put the two DXBC containers in both orders and ranpython -B scripts/re/bvhb_shaders.py <input> <out-dir>with redirected UTF-8 and strict CP1252 output.On this PR, UTF-8 extracted both files but omitted the spaces. Under CP1252 each order stopped after writing the first file. On the candidate all four runs exited 0, both output files were byte-identical to the compiler output, and all summaries showed the expected spaces and counts.
The seven focused tests passed on the original head. On the candidate,
python -B -m unittest discover -s scripts -p "test_*.py"passed all 24 tests with no skips. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ported the formatting and ran the tests. No game files, GPU execution or Rust build.Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T05:40:01Z.
Review: COMMENTED
Could candidate extraction distinguish an invalid part table from a valid DXBC container without
RTS0? Hereparts()skips an out-of-range chunk offset, butextract_shaders()still writes the candidate. With a synthetic 44-byte DXBC whose sole part offset is0x1000, followed by a valid-structureSHEXcontainer, the CLI exits 0, writes the malformed bytes as00.dxbc, and shifts the valid container to01.dxbc. Rejecting that candidate while preserving the no-RTS0case, plus a malformed-then-valid fixture, would make extraction and numbering reliable. Reproduced at exact headebf6f96c60414ca63bf22792a7ff92ad697462acwith synthetic bytes only; no DLL or GPU test. AI-assisted review with Codex.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T17:24:29Z.
Tested head
ebf6f96c60414ca63bf22792a7ff92ad697462ac, merge-base with main1d027e5c76c9a86a7ee2ca1cc677edf0be95d331. Windows 11 Pro 26100, CPython 3.13.0.py -3.13 -B -m unittest -v scripts/test_bvhb_shaders.py: 7 passed at head (1 at merge-base).py -3.13 -B -m unittest discover -s scripts -p "test_*.py": 22 passed, 0 failed at head; 16 passed, 0 failed at merge-base. pytestscripts: 22 passed.Not tested: retail data, GPU, Cargo.
AI-assisted (Claude Code, Claude Sonnet 5.5).
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:35:47Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:00:40Z.
Triage (#1607) – head
ebf6f96#1493 (opened first) also hardens
scripts/re/bvhb_shaders.pyagainst truncated and false-positive DXBC matches, but differently: it validates the container header (version 1, total size = blob size, part offsets in range) and skips invalid matches. This PR only bounds-checks reads, so a false-positiveDXBCwith an in-range size is still written out asNN.dxbcand listed; it also adds-h/exit codes andextract_shaders/main.The two conflict in
extract_shaders/the top-level loop; whichever lands second needs a rebase. No test exercises the new truncation guards (the new tests cover the CLI, the import API and a shader without RTS0).Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.