#!/usr/bin/env python3 # -*- coding: utf-8 -*- """保护元件框架(L3,P1 子集)主机侧单元测试运行器(L0.5,纯标准库)。 做什么:用本机 MSVC 离线编译 test/host/prot_elm/prot_elm_test.c(#include 纳入 生产源文件 prot_elm.c + prot_set.c + phasor.c + sample_ring.c),验证 越限滞回 / 定时限 / 欠量方向 / 投退 / 定值闭锁联动 / 时基回绕 / 位图聚合。 用法(仓库根目录): & '.venv\\Scripts\\python.exe' test/host/prot_elm/run_unit_test.py 退出码:0=PASS / 1=测试失败 / 2=环境错误。 设计依据:docs/算法/继电保护功能复现规划.md §3.3(L3-1/3/4/6)、§8(验收判据)。 创建日期:2026-10-11 """ import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.dirname(os.path.dirname(os.path.dirname(HERE))) sys.path.insert(0, os.path.join(ROOT, "test", "host", "common")) from unit_test_harness import TestBuild, run_host_unit_test # noqa: E402 BUILD = TestBuild( name="Prot Elm Tests", src=os.path.join(HERE, "prot_elm_test.c"), include_dirs=[ os.path.join(ROOT, "App", "algo"), HERE, ], summary_marker="=== Prot Elm Tests:", ) if __name__ == "__main__": sys.exit(run_host_unit_test(BUILD))