Files
STM32F4-Base/test/storage_test.h
2026-08-27 18:22:44 +08:00

58 lines
1.6 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.
/*
* 模块名称Storage Test Suite
* 模块功能FTL + FatFS 存储测试的声明与断言宏。实现见 storage_test_task.c
* 统一由 ch395fTestTask 调度;正常产品构建下由 defaultTask 调用,
* 行为与原 defaultTask 内联逻辑一致。
* 适用平台STM32F4 系列
* 作者:王建锋
* 创建日期2026-08-26
*/
#ifndef __STORAGE_TEST_H
#define __STORAGE_TEST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
typedef struct {
uint16_t total;
uint16_t passed;
uint16_t failed;
} storage_test_stats_t;
extern storage_test_stats_t g_storage_stats;
#define STORAGE_TEST_CHECK(cond, fmt, ...) do { \
g_storage_stats.total++; \
if (cond) { \
g_storage_stats.passed++; \
DBG_INFO(" [PASS] " fmt, ##__VA_ARGS__); \
} else { \
g_storage_stats.failed++; \
DBG_ERROR(" [FAIL] " fmt, ##__VA_ARGS__); \
} \
} while (0)
#define STORAGE_TEST_REPORT(name) do { \
DBG_INFO("=== %s: %d/%d PASSED (failed=%d) ===", \
name, g_storage_stats.passed, g_storage_stats.total, \
g_storage_stats.failed); \
} while (0)
/* 存储测试入口FTL + FatFS 文件系统与性能测试 */
void storage_test_run(void);
/* 存储套件恢复测试(默认关闭):取消注释并编译 STORAGE 套件运行一次,
* 即可重建 BBT清除 TC-STO-03 等注入的坏块)并重新格式化,恢复设备干净态。
* 恢复完成后建议重新注释并编译正常构建。 */
//#define ENABLE_STORAGE_RECOVERY_TESTS
#ifdef __cplusplus
}
#endif
#endif /* __STORAGE_TEST_H */