shader: validate input paths and add OSError/struct guards in mesh_loop_census with CLI suite #2566

Merged
Ammmae0x merged 2 commits from upstream-pr/2574 into main 2026-11-25 21:36:47 +00:00
Ammmae0x commented 2026-11-25 21:27:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T21:27:50Z.


Summary

Hardens tools/mesh_loop_census.py CLI argument validation and error handling and registers a pure-Python CLI test suite in CTest:

  • Input path and backend validation (_validate_directory, _validate_backend): Reject nonexistent or non-directory input paths (upfront in main() and eagerly in read_programs() before returning the iterator), and reject empty, whitespace-only, or existing-directory --llvm / --llvm-mc values before wiring the backend or scanning files.
  • Structured CLI error handling (main(argv)): Type-annotate main(argv: Sequence[str] | None = None) -> int with raise SystemExit(main()), catch (OSError, ValueError, struct.error) and exit cleanly via parser.exit(1, f"mesh_loop_census: {error}\n") without raw tracebacks, while preserving per-container ValueError / KeyError / struct.error tallies in Population and aggregate Markdown output.
  • Pure-Python CLI and mutation test suite (tests/mesh_loop_census_cli_check.py, CMakeLists.txt): Register mesh_loop_census_cli_check covering loop-free/counted/duplicate/non-DXBC/malformed classification without filename/register leakage, --llvm-mc disassembler wiring and sys.argv/__main__ entrypoint forwarding, missing/file directory and empty/directory backend rejection, OSError/ValueError/struct.error guards (including subprocess runs against nonexistent backends), and Python 3.14-compatible argparse error checks.

Verification

Rebased onto upstream/main (18f2f85c) and verified:

  • out\pe-env\Scripts\python.exe -B tests\mesh_loop_census_cli_check.py -v -> Ran 6 tests in 12.426s / OK (exit 0)
  • out\pe-env\Scripts\python.exe -B tests\mesh_loop_census_check.py -> Mesh loop census classified 14 source-built programs; 14 mutants changed category (exit 0)
  • 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 488 links. (exit 0)
  • out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py -> Self-test passed. Checked 1802 tracked source, script and build/CI files: no bidirectional controls. (exit 0)
  • Temp-copy adversarial mutation verification against tools/mesh_loop_census.py: killed 12/12 mutations across _validate_directory, _validate_backend, eager read_programs, and main(argv) error guards.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6614102134 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2574). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T21:27:50Z. --- ## Summary Hardens `tools/mesh_loop_census.py` CLI argument validation and error handling and registers a pure-Python CLI test suite in CTest: - **Input path and backend validation (`_validate_directory`, `_validate_backend`)**: Reject nonexistent or non-directory input paths (upfront in `main()` and eagerly in `read_programs()` before returning the iterator), and reject empty, whitespace-only, or existing-directory `--llvm` / `--llvm-mc` values before wiring the backend or scanning files. - **Structured CLI error handling (`main(argv)`)**: Type-annotate `main(argv: Sequence[str] | None = None) -> int` with `raise SystemExit(main())`, catch `(OSError, ValueError, struct.error)` and exit cleanly via `parser.exit(1, f"mesh_loop_census: {error}\n")` without raw tracebacks, while preserving per-container `ValueError` / `KeyError` / `struct.error` tallies in `Population` and aggregate Markdown output. - **Pure-Python CLI and mutation test suite (`tests/mesh_loop_census_cli_check.py`, `CMakeLists.txt`)**: Register `mesh_loop_census_cli_check` covering loop-free/counted/duplicate/non-DXBC/malformed classification without filename/register leakage, `--llvm-mc` disassembler wiring and `sys.argv`/`__main__` entrypoint forwarding, missing/file directory and empty/directory backend rejection, `OSError`/`ValueError`/`struct.error` guards (including subprocess runs against nonexistent backends), and Python 3.14-compatible argparse error checks. ## Verification Rebased onto `upstream/main` (`18f2f85c`) and verified: - `out\pe-env\Scripts\python.exe -B tests\mesh_loop_census_cli_check.py -v` -> `Ran 6 tests in 12.426s` / `OK` (exit 0) - `out\pe-env\Scripts\python.exe -B tests\mesh_loop_census_check.py` -> `Mesh loop census classified 14 source-built programs; 14 mutants changed category` (exit 0) - `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 488 links.` (exit 0) - `out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py` -> `Self-test passed. Checked 1802 tracked source, script and build/CI files: no bidirectional controls.` (exit 0) - Temp-copy adversarial mutation verification against `tools/mesh_loop_census.py`: killed 12/12 mutations across `_validate_directory`, `_validate_backend`, eager `read_programs`, and `main(argv)` error guards. AI-assisted.
upstream-sync closed this pull request 2026-11-25 22:02:10 +00:00
tedin7 commented 2026-11-25 22:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:32:13Z.

Review: COMMENTED


Review of head 19b53833 (same change as 59e72ebd, plus the merge of main).

Checked: tools/mesh_loop_census.py validation (_validate_directory, _validate_backend, eager read_programs, main error guard) and the new CTest registration mesh_loop_census_cli_check next to mesh_loop_census. Sibling test mesh_loop_census_check is unchanged and still passes. No other open or merged PR covers this slice (#2284 added the tool, #2508 is a lowerer change).

Commands run:

  • python3 -B tests/mesh_loop_census_cli_check.py -> Ran 6 tests, OK
  • python3 -B tests/mesh_loop_census_check.py -> 14 programs classified; 14 mutants changed category
  • python3 tests/docs_links_check.py -> self-test passed
  • python3 tests/bidi_controls_check.py -> no bidirectional controls
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: drop the "not a directory" check in _validate_directory -> new suite FAILS (1 failure)
  • Mutation 2: drop OSError from the main except clause -> new suite FAILS (1 error)

No blocking findings. Win2025 WARP run follows separately.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6065263412 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2574#pullrequestreview-6065263412). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T21:32:13Z. **Review:** COMMENTED --- Review of head 19b53833 (same change as 59e72ebd, plus the merge of main). Checked: tools/mesh_loop_census.py validation (`_validate_directory`, `_validate_backend`, eager `read_programs`, `main` error guard) and the new CTest registration `mesh_loop_census_cli_check` next to `mesh_loop_census`. Sibling test `mesh_loop_census_check` is unchanged and still passes. No other open or merged PR covers this slice (#2284 added the tool, #2508 is a lowerer change). Commands run: - `python3 -B tests/mesh_loop_census_cli_check.py` -> Ran 6 tests, OK - `python3 -B tests/mesh_loop_census_check.py` -> 14 programs classified; 14 mutants changed category - `python3 tests/docs_links_check.py` -> self-test passed - `python3 tests/bidi_controls_check.py` -> no bidirectional controls - `git diff --check origin/main...HEAD` -> clean - Mutation 1: drop the "not a directory" check in `_validate_directory` -> new suite FAILS (1 failure) - Mutation 2: drop `OSError` from the `main` except clause -> new suite FAILS (1 error) No blocking findings. Win2025 WARP run follows separately. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 22:02:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:36:07Z.


Win2025 WARP receipt for head 19b53833 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 19b5383383d356874860bf77ed9244042ca80853:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 1.71s (configure 2.08s)
    • Test (ctest --preset dev -R 'mesh_loop_census' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (4.71s: mesh_loop_census 0.70s, mesh_loop_census_cli_check 4.57s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 4.72s (configure 2.28s)
    • Test (ctest --preset release -R 'mesh_loop_census' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (3.83s: mesh_loop_census 0.66s, mesh_loop_census_cli_check 3.70s)
  • Windows Python checks: tests/mesh_loop_census_check.py ok (0.5s)
  • sccache: 18/46 hits; wall 20.2s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175294312 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2574#issuecomment-7175294312). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T21:36:07Z. --- Win2025 WARP receipt for head 19b53833 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `19b5383383d356874860bf77ed9244042ca80853`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 2`): `1.71s` (configure `2.08s`) - Test (`ctest --preset dev -R 'mesh_loop_census' --parallel 4 --no-tests=error --output-on-failure`): **2/2 passed** (`4.71s`: `mesh_loop_census` `0.70s`, `mesh_loop_census_cli_check` `4.57s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 2`): `4.72s` (configure `2.28s`) - Test (`ctest --preset release -R 'mesh_loop_census' --parallel 4 --no-tests=error --output-on-failure`): **2/2 passed** (`3.83s`: `mesh_loop_census` `0.66s`, `mesh_loop_census_cli_check` `3.70s`) - **Windows Python checks**: `tests/mesh_loop_census_check.py` ok (`0.5s`) - `sccache`: 18/46 hits; wall `20.2s` AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2566
No description provided.