test(S6): 补齐 app 层与 HTTP 第二组集成测试,行覆盖率 72.2%→80.3%(NFR-05 达标)

新增
- tests/integration/test_menu.c:菜单 14 项全分派、命令全集正/负例、参数解析、脚本化 stdin 主循环
- tests/integration/test_http_api.c:其余 11 个接口 + 错误路径(400/404/协议层 400)
- src/app/app_options.c:app_parse_args/app_print_usage 从 main.c 迁入静态库(app.h 声明此前无实现)
- app_clear_stop():复用主循环时清除退出标志
- tools/coverage.sh:A10 覆盖率门限自动判定;acceptance 扩到 A1~A10 共 25 项

修复(本轮集成测试暴露)
- menu_render 漏渲染首项「设备列表」(行号 0 既当标题又当表项 0)
- http_server_stop 只置标志不关套接字,导致同进程无法二次启动(聚合运行 70 项失败)
- POST /api/config 未匹配到字段时假成功(现返回 400)
- CRC/I2C 字节序、采样路数、离线设备负例等此前已在集成阶段修复

实测:CTest 19/19;聚合运行 19 套件 2450 断言 0 失败;ASan 19/19;覆盖率 80.3%
This commit is contained in:
sambu committed 2026-09-14 22:23:17 +08:00
1 parent 870a16f25a
commit 3e10ee8488
22 files changed
+1418 -244

No files matched your search

+4
View File
@@ -18,6 +18,8 @@ typedef struct {
const char *replay; /**< 回放脚本路径 */
const char *data_dir; /**< 数据目录覆盖 */
bool help; /**< 是否请求帮助 */
char bind_addr[SHS_NAME_MAX]; /**< --bind 指定的监听地址,空串表示用配置值 */
bool selftest; /**< --selftest:仅运行系统自检后退出 */
} AppOptions;
/** 参数解析:成功返回 SHS_OK;非法参数返回负错误码 */
@@ -32,6 +34,8 @@ shs_err_t app_run_web(SmartHomeSystem *sys, uint16_t port);
shs_err_t app_replay_script(SmartHomeSystem *sys, const char *script_path);
/** 执行一条文本命令(CLI 与回放共用),结果写入 out */
shs_err_t app_execute_command(SmartHomeSystem *sys, const char *line, char *out, size_t out_size);
/** 清除退出请求(测试或嵌入场景里复用主循环时使用;与 app_request_stop 配对) */
void app_clear_stop(void);
/** 请求主循环退出(信号处理或测试调用) */
void app_request_stop(void);
bool app_stop_requested(void);