Skip to content

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

Merged
tedin7 merged 2 commits into
R0Y00:mainfrom
Ammmae0x:shader/mesh-loop-census-cli
Nov 25, 2026
Merged

tedin7 merged 2 commits into
R0Y00:mainfrom
Ammmae0x:shader/mesh-loop-census-cli

Conversation

@Ammmae0x

Copy link
Copy Markdown
Contributor

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.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 19b5383 (same change as 59e72eb, 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

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP receipt for head 19b5383 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.

@tedin7
tedin7 merged commit 2f7fd28 into R0Y00:main Nov 25, 2026
5 checks passed
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.

2 participants