tooling: validate family names in expected_values and add unit and CLI suite #2043
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2050"
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-24T23:39:09Z.
Change
Validate family and size inputs in
tools/mesh_od_pipeline.py, harden cleanup and error handling, and add a pure-Python unit and CLI test suite (tests/mesh_od_pipeline_check.py) registered inCMakeLists.txt(mesh_od_pipeline_check,TIMEOUT 30):expected_values()rejects unknown family names (FAMILIES = ("control", "chain", "branches", "loops")), non-int/bool/negativesize, and non-zerocontrolsizes withValueErrorinstead of silently returning the unmodified seed.variant_info()rejects non-strinputs withValueError.run_draw()moves process monitor thread stop/join andclose_process(handle)cleanup intofinally.main()movesTemporaryDirectory/--work-dirsetup insidetry/finallyand catches(RuntimeError, OSError)onmeasure()andOSErroronwrite_report(), printing a conciseerror: ...message to stderr and exiting1without a raw Python traceback or leftover temporary directories.tests/mesh_od_pipeline_check.pycovers deterministic reference math, HLSL embedding, binary fixture layout, allclassify_draw()outcomes,summarize(), CSV/JSONwrite_report(),--list-variantsdirect and subprocess CLI execution, mocked--checkpass and capability-skip (exit77) paths, plus negative controls forexpected_values(),variant_info(),check_failures(), CLI flag validation (exit2), and temp-directory cleanup on failure.Verification
Tested on commit
bf9bd9a9(rebased onupstream/main06cdc47d, Windows x64, Python viaout/pe-env):.\out\pe-env\Scripts\python.exe -B tests/mesh_od_pipeline_check.pyRan 13 tests in 0.383s—OK(exit 0)..\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.pyform coverage checks passed(exit 0)..\out\pe-env\Scripts\python.exe -B tests/docs_links_check.pySelf-test passed. Checked 18 Markdown files and 391 links.(exit 0)..\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.pySelf-test passed. Checked 1404 tracked source, script and build/CI files: no bidirectional controls.(exit 0).Note: No C++ targets were modified;
mesh_od_pipeline_checkis pure Python and registered once underif(adapter STREQUAL "hardware")next tomesh_od_pipeline_${adapter}inCMakeLists.txt.Evidence and follow-up
tests/mesh_od_pipeline_check.pyare synthetic, self-contained, and run without external binaries or GPU hardware (the GPU/DXC end-to-end tests remain inmesh_od_pipeline_hardware/mesh_od_pipeline_warp).ValueError) and CLI exit codes (2for argument errors,1for runtime/IO errors,77for capability skip), verify zero raw Python tracebacks, and confirm temporary directories are cleaned up on both success and failure.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:49:26Z.
Ran it, broke the validator seven ways — all caught, including the two I expected to slip
tools/mesh_od_pipeline.pyfamilywhitelist removedisinstance(size, bool)term dropped (soTruepasses as 1)size < 0term droppedcontrolrequiressize == 0rule droppedsize > MAX_SIZEupper bound droppedsize < 1lower bound dropped (allowingchain_0)VARIANT_RE.fullmatch→matchThe two I expected to survive were
isinstance(size, bool)and thefullmatchchange:intin Python, so dropping theboolterm makeschain_Truebehave aschain_1— and there must be a fixture that passesTrue;matchinstead offullmatchacceptschain_64xyz, which is the classic validator hole, and it is also covered.The validator, checked by hand against the table
expected_valuesrefusesfamilyoutsideFAMILIES, a non-int or negativesize, abool, andcontrolwith a non-zero size;variant_infoaddsthe
1..MAX_SIZErange, the string type check and the exact-match name. Reading the seven mutations against that list, every clause now has a testthat fails when it is deleted, which is the property that matters for a validator — the failure mode of a validator is silence, not a wrong answer.
The one thing I would add
variant_infocomputesexpectedand then formats it into the generated source. Nothing checks that the generated HLSL body corresponds to thesame
family/sizethat producedexpected:_body(family, size)andexpected_values(family, size)are two independent implementations, which isthe right design, but a fixture that only calls
variant_infocannot tell if_bodywas passed a different size. If one of the 13 tests compares theemitted
static const uint expected[3]table againstexpected_valuesfor a range of sizes, ignore this — I could not tell from the run output.What I did not run
The parts that need
dxcand a renderer (measure,run_draw,classify_draw). Everything above is the pure-Python validation path, which is whatthe PR changes.
Notes
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T23:56:59Z.
Updated PR #2050 (commit
478e48cb) to address the review suggestion: addedtest_variant_info_hlsl_body_matches_expected_and_sizeintests/mesh_od_pipeline_check.py, which parses every generated HLSL body line forcontrol,chain_{1,4},branches_{1,5}, andloops_{1,3}, checks exact step indices/count, and simulates the emitted HLSL body for threads 0..2 againstexpected_values(). Spot-checked by mutating_body(family, size)to_body(family, max(0, size - 1))(all 6 non-control subtests failed; restored). Re-verifiedtests/mesh_od_pipeline_check.py(14 tests OK),ctest --preset devandctest --preset release-R '^mesh_od_pipeline_check$'(1/1 Passed in both), plusform_coverage_check.py,docs_links_check.py, andbidi_controls_check.py. AI-assisted.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:24:55Z.
Review: COMMENTED
Review of head
478e48cb3cc9081701f7c4f6d8c2a5e64413416b.Scope:
tools/mesh_od_pipeline.pyinput validation and cleanup hardening, newtests/mesh_od_pipeline_check.py, one CMake registration. No GPU/shader change, so no Windows GPU run was needed. CI on this head: Linux checks, gfx1013 fixtures and Windows build/test are green. The PR is mergeable. The title is neutral.Commands run locally (Linux)
git diff --stat origin/main...HEAD: 3 files, +787/-21.python3 tests/mesh_od_pipeline_check.py: Ran 14 tests, OK.python3 tests/docs_links_check.py: 391 links OK.python3 tests/bidi_controls_check.py: OK.git diff --check origin/main...HEAD: clean.Mutation checks (each reverted with
git checkout -- .)expected_values(): 6 failures.size < 0rejection: 2 failures.main()except (RuntimeError, OSError)toKeyError: 1 error.All three were caught.
Findings
CMakeLists.txt, newadd_test): the pure-Python suite is registered inside the per-adapter loop behindif(adapter STREQUAL "hardware"). It works and avoids a duplicate test name. It would be cleaner outside the loop, so the test does not look tied to an adapter.tools/mesh_od_pipeline.py,main()):except (RuntimeError, OSError)returns 1 for any such error, including a skip-worthy capability case. The mocked capability-skip (exit 77) test covers the intended path, so this is fine as is.The validation is correct and the
finallycleanup inrun_draw()is sound. The tests guard real behavior.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T05:42:14Z.
Review: APPROVED
Verified head
478e48cbon Windows x64 (devpreset, MSVC19.44.35228.0, Python 3.12).ctest --preset dev --no-tests=error -R '^mesh_od_pipeline_check$' -V-> 1/1 passed (Ran 14 tests in 0.231s,OK)Verdict: Approved at
478e48cb.