Files
STM32F4-Base/test/host/vol_lock/stub/cmsis_os.h
T
wandering1 a2f5d1397a 主机单测:新增卷锁与时间同步两套用例(33+80 项)并登记钩子
- vol_lock(App/fs/vol_lock.c):33 用例。核心不变量是 fail-open——
  互斥量创建失败时 vol_lock_wait() 必须返回 1 且绝不阻塞,因为调用者
  defaultTask 是看门狗喂狗点;板端该路径只在内存耗尽时才可能走到。
- time_sync(App/sync/time_sync.c):80 用例。本模块是 N-17 看门狗风险的
  全部逻辑贡献者,用例钉死分片喂狗节奏、监听退避、报文重组(半包/粘连/
  EOF/真错/预算耗尽/tick 回绕)、重听门控;用 longjmp 跳出 for(;;) 任务循环。
- 两套均为纯逻辑主机侧测试,MSVC 离线编译真实源文件(#include 纳入)。
- 新增钩子 vol-lock-unit-test、time-sync-unit-test(7f/7g)。
- 全量主机单测:watchdog 39 + sys_clock 100 + cfg_file 149 + phasor 57
  + adc_input 70 + vol_lock 33 + time_sync 80 = 528 项,全绿。
2026-10-10 18:03:31 +08:00

57 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 主机侧单测桩:cmsis_os.h(CMSIS-RTOS v1 兼容层)
* 模块功能:为 App/fs/vol_lock.c 提供主机可编译的 CMSIS-RTOS 互斥量接口。
*
* ⚠ 仅供 test/host/vol_lock/ 使用,不参与 MCU 构建。
* 真实头来自 Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os.h,
* 会拖入整套 FreeRTOS(FreeRTOS.h / task.h / queue.h / semphr.h …),主机侧不引入。
*
* 保真点(对齐 cmsis_os.h + cmsis_os2.h):
* - osMutexId_t = void*(cmsis_os2.h:198);
* - osMutexNew(const osMutexAttr_t *attr)(cmsis_os2.h:552);
* - osMutexWait(osMutexId_t, uint32_t) —— 真实头是 `#define osMutexWait osMutexAcquire`,
* 两者签名一致(cmsis_os.h:617);
* - osMutexRelease(osMutexId_t)(cmsis_os.h:626);
* - osStatus_t 枚举含 osOK = 0(cmsis_os.h:204)。
* 三个接口由测试单元给强符号桩(可注入"创建失败 / 等待超时")。
*
* 创建日期:2026-10-10
*/
#ifndef CMSIS_OS_H
#define CMSIS_OS_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* 不透明句柄(真实定义见 cmsis_os2.h:195/198) */
typedef void *osMutexId_t;
typedef void *osEventFlagsId_t;
/* 状态码(cmsis_os.h:204 起的枚举;此处只保留被测代码用到的子集) */
typedef enum {
osOK = 0, /* 成功 */
osError = -1, /* 通用错误 */
osErrorTimeout = -2, /* 超时 */
osErrorResource = -3, /* 资源不可用 */
osErrorParameter = -4 /* 参数错误 */
} osStatus_t;
/* 互斥量属性:被测代码只传 NULL,故仅占位 */
typedef struct {
uint32_t attr_bits;
} osMutexAttr_t;
osMutexId_t osMutexNew(const osMutexAttr_t *attr);
osStatus_t osMutexWait(osMutexId_t mutex_id, uint32_t millisec);
osStatus_t osMutexRelease(osMutexId_t mutex_id);
#ifdef __cplusplus
}
#endif
#endif /* CMSIS_OS_H */