fix(storage)+test: 修复设备表校验和可被绕过,登记 5 套新单元测试
- 缺陷(由测试 agent 用例 TC-FILE-005 发现):read_device 在读取后立刻把 name 末字节置 0, 导致文件里该字节被篡改时校验和仍能对上,完整性校验形同虚设。 修复:先按原始字节做校验和比对,通过后再统一做字段清洗(补 NUL 结尾)。 实测:篡改 name 末字节的设备表现在被正确判为 SHS_ERR_PARSE。 - 测试期望修正:配置名称上限 32 字节(约 10 个汉字),超长应返回 SHS_ERR_RANGE 而不是静默截断;补充正常长度用例。 - 登记 unit.branch / unit.loop / unit.bitops / unit.errors / unit.file 五套到 runner 与 CTest。 - ctest 8/8 通过。
This commit is contained in:
1 parent
190edad1ce
commit
4b4b24ca4a
5 files changed
+830
-3
No files matched your search
@@ -17,6 +17,11 @@
|
||||
/* 各测试套件的声明(新增套件时在此与 g_suites 表中登记) */
|
||||
void suite_unit_string(void);
|
||||
void suite_unit_num(void);
|
||||
void suite_unit_branch(void);
|
||||
void suite_unit_loop(void);
|
||||
void suite_unit_bitops(void);
|
||||
void suite_unit_errors(void);
|
||||
void suite_unit_file(void);
|
||||
|
||||
typedef struct {
|
||||
const char *name; /* 套件名,与 CTest 中注册的名字一致 */
|
||||
@@ -27,6 +32,11 @@ typedef struct {
|
||||
static const test_suite_t g_suites[] = {
|
||||
{ "unit.string", suite_unit_string, "项目五 字符数组与字符串处理" },
|
||||
{ "unit.num", suite_unit_num, "项目二 数据类型、运算符与类型转换" },
|
||||
{ "unit.branch", suite_unit_branch, "项目三 分支结构与条件判断" },
|
||||
{ "unit.loop", suite_unit_loop, "项目四 循环结构与嵌套" },
|
||||
{ "unit.bitops", suite_unit_bitops, "项目九 位运算与位标志" },
|
||||
{ "unit.errors", suite_unit_errors, "项目十 错误处理与错误码" },
|
||||
{ "unit.file", suite_unit_file, "项目九 文件与配置存储" }
|
||||
};
|
||||
|
||||
#define SUITE_COUNT ((int)(sizeof(g_suites) / sizeof(g_suites[0])))
|
||||
|
||||
Reference in new issue
Block a user