test: 登记 6 个新套件(func/struct/protocol/hal/json + integration.http),CTest 14/14 绿
- shs_tests 链接补上 shs_applib/shs_net:集成测试与 JSON 套件需要网络层目标, 此前只链 shs_core,链接期才暴露 undefined reference - runner 套件表补全并修正逗号;CMake 源文件表按实际文件重建 - unit.list 从套件表移除(它由独立 add_test 注册,重复注册会被 CMake 拒绝)
This commit is contained in:
1 parent
09bbe23697
commit
2b64f4a255
2 files changed
+33
-8
No files matched your search
+20
-7
@@ -115,17 +115,24 @@ if(SHS_BUILD_TESTS)
|
|||||||
set(SHS_TEST_SOURCES
|
set(SHS_TEST_SOURCES
|
||||||
tests/framework/test_framework.c
|
tests/framework/test_framework.c
|
||||||
tests/test_runner.c
|
tests/test_runner.c
|
||||||
tests/unit/test_string.c
|
|
||||||
tests/unit/test_num.c
|
|
||||||
tests/unit/test_branch.c
|
|
||||||
tests/unit/test_loop.c
|
|
||||||
tests/unit/test_bitops.c
|
tests/unit/test_bitops.c
|
||||||
|
tests/unit/test_branch.c
|
||||||
tests/unit/test_errors.c
|
tests/unit/test_errors.c
|
||||||
tests/unit/test_file.c
|
tests/unit/test_file.c
|
||||||
tests/unit/test_pointer.c)
|
tests/unit/test_func.c
|
||||||
|
tests/unit/test_hal.c
|
||||||
|
tests/unit/test_json.c
|
||||||
|
tests/unit/test_loop.c
|
||||||
|
tests/unit/test_num.c
|
||||||
|
tests/unit/test_pointer.c
|
||||||
|
tests/unit/test_protocol.c
|
||||||
|
tests/unit/test_string.c
|
||||||
|
tests/unit/test_struct.c
|
||||||
|
tests/integration/test_http.c
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(shs_tests ${SHS_TEST_SOURCES})
|
add_executable(shs_tests ${SHS_TEST_SOURCES})
|
||||||
target_link_libraries(shs_tests PRIVATE shs_core shs_warnings)
|
target_link_libraries(shs_tests PRIVATE shs_applib shs_net shs_core shs_warnings)
|
||||||
target_include_directories(shs_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/tests)
|
target_include_directories(shs_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/tests)
|
||||||
|
|
||||||
# 每个测试套件在 CTest 中独立注册(ctest -R unit.string)
|
# 每个测试套件在 CTest 中独立注册(ctest -R unit.string)
|
||||||
@@ -137,7 +144,13 @@ if(SHS_BUILD_TESTS)
|
|||||||
unit.bitops
|
unit.bitops
|
||||||
unit.errors
|
unit.errors
|
||||||
unit.file
|
unit.file
|
||||||
unit.pointer)
|
unit.func
|
||||||
|
unit.struct
|
||||||
|
unit.protocol
|
||||||
|
unit.hal
|
||||||
|
unit.json
|
||||||
|
integration.http
|
||||||
|
)
|
||||||
foreach(suite IN LISTS SHS_TEST_SUITES)
|
foreach(suite IN LISTS SHS_TEST_SUITES)
|
||||||
add_test(NAME ${suite} COMMAND shs_tests --suite ${suite})
|
add_test(NAME ${suite} COMMAND shs_tests --suite ${suite})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|||||||
+13
-1
@@ -15,6 +15,12 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* 各测试套件的声明(新增套件时在此与 g_suites 表中登记) */
|
/* 各测试套件的声明(新增套件时在此与 g_suites 表中登记) */
|
||||||
|
void suite_unit_func(void);
|
||||||
|
void suite_unit_struct(void);
|
||||||
|
void suite_unit_protocol(void);
|
||||||
|
void suite_unit_hal(void);
|
||||||
|
void suite_unit_json(void);
|
||||||
|
void suite_integration_http(void);
|
||||||
void suite_unit_string(void);
|
void suite_unit_string(void);
|
||||||
void suite_unit_num(void);
|
void suite_unit_num(void);
|
||||||
void suite_unit_branch(void);
|
void suite_unit_branch(void);
|
||||||
@@ -38,7 +44,13 @@ static const test_suite_t g_suites[] = {
|
|||||||
{ "unit.bitops", suite_unit_bitops, "项目九 位运算与位标志" },
|
{ "unit.bitops", suite_unit_bitops, "项目九 位运算与位标志" },
|
||||||
{ "unit.errors", suite_unit_errors, "项目十 错误处理与错误码" },
|
{ "unit.errors", suite_unit_errors, "项目十 错误处理与错误码" },
|
||||||
{ "unit.file", suite_unit_file, "项目九 文件与配置存储" },
|
{ "unit.file", suite_unit_file, "项目九 文件与配置存储" },
|
||||||
{ "unit.pointer", suite_unit_pointer, "项目七 指针、出参与函数指针" }
|
{ "unit.pointer", suite_unit_pointer, "项目七 指针、出参与函数指针" },
|
||||||
|
{ "unit.func", suite_unit_func, "项目六 函数、递归与 static 生命周期" },
|
||||||
|
{ "unit.struct", suite_unit_struct, "项目八 结构体、共用体与位域" },
|
||||||
|
{ "unit.protocol", suite_unit_protocol, "通信帧与 CRC 校验" },
|
||||||
|
{ "unit.hal", suite_unit_hal, "GPIO/I2C/UART 硬件抽象层" },
|
||||||
|
{ "unit.json", suite_unit_json, "JSON 序列化与解析" },
|
||||||
|
{ "integration.http", suite_integration_http, "集成:HTTP 接口端到端" },
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SUITE_COUNT ((int)(sizeof(g_suites) / sizeof(g_suites[0])))
|
#define SUITE_COUNT ((int)(sizeof(g_suites) / sizeof(g_suites[0])))
|
||||||
|
|||||||
Reference in new issue
Block a user