Files
Gleb Chesnokov 2f8ff7ea63 scripts: Integrate Sparse and Smatch with reviewed policy
Run the native checkers through the ordered SCST module build with C=2.
Preserve Kbuild flags, full raw output and every attempted CHECK record.
Keep full, diff and explicit input selection on the shared scope; diff
selection triggers the complete configured module analysis.

Read exact diagnostic exceptions from policy/sparse.json and
smatch.json: two reviewed Smatch IRQ reports and the external FC
flexible-array warning. Keep the existing SCST matching boundaries and
reasons. Smatch uses its matching installed kernel data without
engine-specific additions.

Reject build, checker, frontend and truncation failures even when Kbuild
returns success. Retain per-invocation records and a machine-readable
run summary, and detect printed CHECK steps without a record. Require
selected C inputs to occur in the build. Keep findings distinct from
incompleteness.

Check native compatibility before compilation, and forward external
kernel capability probes to the real checker instead of skipping them as
inputs outside SCST. Include the pinned Smatch typeof frontend
correction and isolated fixtures for failure propagation and exact
exception boundaries.
2026-10-19 21:38:56 +03:00

29 lines
1.1 KiB
Python

"""Native checker options; never modify installed tools or Smatch models."""
import os
from pathlib import Path
import shutil
def checker_command(tool):
if tool not in ("sparse", "smatch"):
raise ValueError(f"unsupported checker: {tool}")
executable = shutil.which(tool)
if not executable:
raise ValueError(f"{tool} is not installed")
options = [executable]
if tool == "smatch":
binary = Path(executable).resolve()
explicit = os.environ.get("SMATCH_DATA_DIR")
candidates = ([Path(explicit)] if explicit else [
binary.parent / "smatch_data",
binary.parent.parent / "share/smatch/smatch_data",
Path.home() / "share/smatch/smatch_data",
])
data = next((p.resolve() for p in candidates
if (p / "kernel.unreachable.turn_off").is_file()), None)
if data is None:
raise ValueError("Smatch data not found; install matching smatch_data or set SMATCH_DATA_DIR")
options += ["-p=kernel", "--data=" + str(data)]
return options