refactor: refactor embedded C policy and enhance warning checks

- Updated the default output path in  to .
- Introduced a new  file to define excluded prefixes, compatibility files, and forbidden calls for embedded C sources.
- Modified  to improve compiler flags and source file organization.
- Added scripts for checking C warnings and embedded C compliance, ensuring self-owned sources are validated against the policy.
- Implemented regression tests to capture and report self-owned C compiler warnings during builds.
- Created a new test suite for runtime tests of SDK utilities, ensuring deterministic behavior.
- Enhanced existing test scripts to include checks for C warnings and compliance with the embedded C policy.
This commit is contained in:
maksyuki committed 2026-07-11 12:43:26 +08:00
1 parent 42f902e995
commit 0d4999a794
206 files changed
+6338 -5471

No files matched your search

+20
View File
@@ -22,6 +22,7 @@ sys.path.insert(0, str(FILELIST_SCRIPT_DIR))
from filelist import atomic_write, parse_filelists, write_filelist # noqa: E402
from generate_filelist import generate_all # noqa: E402
from scripts.analyze_warnings import normalize # noqa: E402
from scripts.check_c_warnings import self_owned_warnings # noqa: E402
from scripts.dependency_lock import LockError, load_lock # noqa: E402
from scripts.install_toolchain import safe_extract # noqa: E402
from scripts.setup_helpers import download_file, ensure_git_repo # noqa: E402
@@ -398,6 +399,25 @@ def test_warning_normalization_keeps_ranges_and_removes_variant_hash(tmp_path: P
)
def test_c_warning_filter_excludes_vendored_sources(tmp_path: Path) -> None:
policy_dir = tmp_path / "quality"
policy_dir.mkdir()
(policy_dir / "embedded_c_policy.json").write_text(
(ROOT / "quality/embedded_c_policy.json").read_text(encoding="utf-8"),
encoding="utf-8",
)
output = "\n".join(
(
f"{tmp_path}/crt/src/hal/timer.c:9:1: warning: self-owned warning",
f"{tmp_path}/app/coremark/coremark-main/core_main.c:4:1: warning: vendor warning",
)
)
warnings = self_owned_warnings(tmp_path, output)
assert warnings == ["crt/src/hal/timer.c:9: warning: self-owned warning"]
def test_metrics_collection_and_observe_policy(tmp_path: Path) -> None:
variant = tmp_path / "variant"
(variant / "sw").mkdir(parents=True)