#!/usr/bin/env python3 # -*- coding: utf-8 -*- """频率测量层(L2 派生量,B8)主机侧单元测试运行器(L0.5,纯标准库)。 做什么:用本机 MSVC 离线编译 test/host/freq/freq_test.c(#include 纳入生产 源文件 App/algo/freq.c + phasor.c + sample_ring.c),验证相位解缠绕 测频的精度判据 J1~J6(45~55 Hz 扫频 / 噪声 / 收敛 / 阶跃 / 浮空 / 假值钳制 / 源回退),判据数字见 freq_test.c 文件头与 docs/算法/采集与算法层设计说明.md §7.2。 用法(仓库根目录): & '.venv\\Scripts\\python.exe' test/host/freq/run_unit_test.py 退出码:0=PASS / 1=测试失败 / 2=环境错误。 设计依据:docs/算法/继电保护功能复现规划.md §3.3(过频 / 低频)、§4.2(测频范围)。 创建日期:2026-10-12(B8) """ 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="Freq Tests", src=os.path.join(HERE, "freq_test.c"), include_dirs=[ os.path.join(ROOT, "App", "algo"), HERE, ], summary_marker="=== Freq Tests:", ) if __name__ == "__main__": sys.exit(run_host_unit_test(BUILD))