Files
STM32F4-Base/test/host/sys_clock/stub/dbg_log.h
T

34 lines
1.2 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.
/*
* 主机侧单测桩:dbg_log.h
* 模块功能:为 sys_clock.c 提供主机可编译的日志宏(打印 + 计数)。
*
* ⚠ 仅供 test/host/sys_clock/ 使用,不参与 MCU 构建。
*
* 与 simulator/dbg_log.h 同思路:MCU 版依赖 sys_clock(RTC 时间戳)与 USART,
* 主机侧替换为 printf(可按需开启),并把 DBG_ERROR 计入计数器供单测断言
* ("RTC 异常时是否打了降级/故障日志"是可观测行为的一部分)。
*
* 创建日期:2026-10-02
*/
#ifndef DBG_LOG_H
#define DBG_LOG_H
#include <stdio.h>
/* 测试期望的错误日志计数(在 sys_clock_test.c 实现,单测断言其增量) */
extern int g_sclk_err_count;
/* DBG_ERROR 仅在需要定位问题时打开 VERBOSE;默认静默并计数 */
#ifdef SYS_CLOCK_TEST_VERBOSE
#define DBG_INFO(fmt, ...) do { printf("[CLK] " fmt "\n", ##__VA_ARGS__); } while (0)
#define DBG_DEBUG(fmt, ...) do { } while (0)
#define DBG_ERROR(fmt, ...) do { g_sclk_err_count++; printf("[CLK][ERR] " fmt "\n", ##__VA_ARGS__); } while (0)
#else
#define DBG_INFO(fmt, ...) do { } while (0)
#define DBG_DEBUG(fmt, ...) do { } while (0)
#define DBG_ERROR(fmt, ...) do { g_sclk_err_count++; } while (0)
#endif
#endif /* DBG_LOG_H */