Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions components/embed_claw/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@ idf_component_register(
embed_claw
)

set(EC_TEST_CONFIG_HEADER "${CMAKE_CURRENT_LIST_DIR}/ec_config.h")
if(EXISTS "${EC_TEST_CONFIG_HEADER}")
target_compile_options(${COMPONENT_LIB} PRIVATE
"-include"
"${EC_TEST_CONFIG_HEADER}"
)
set(EC_TEST_DEFAULT_CONFIG_HEADER "${CMAKE_CURRENT_LIST_DIR}/ec_test_config.h")
set(EC_TEST_LOCAL_CONFIG_HEADER "${CMAKE_CURRENT_LIST_DIR}/ec_config.h")

idf_component_get_property(embed_claw_lib embed_claw COMPONENT_LIB)
target_compile_options(${embed_claw_lib} PRIVATE
"-include"
"${EC_TEST_CONFIG_HEADER}"
)
if(NOT EXISTS "${EC_TEST_DEFAULT_CONFIG_HEADER}")
message(FATAL_ERROR "Missing tracked test config header: ${EC_TEST_DEFAULT_CONFIG_HEADER}")
endif()

idf_component_get_property(embed_claw_lib embed_claw COMPONENT_LIB)

foreach(test_target ${COMPONENT_LIB} ${embed_claw_lib})
if(EXISTS "${EC_TEST_LOCAL_CONFIG_HEADER}")
target_compile_options(${test_target} PRIVATE
"SHELL:-include ${EC_TEST_LOCAL_CONFIG_HEADER}"
)
endif()

target_compile_options(${test_target} PRIVATE
"SHELL:-include ${EC_TEST_DEFAULT_CONFIG_HEADER}"
)
endforeach()
8 changes: 8 additions & 0 deletions components/embed_claw/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
```text
components/embed_claw/test/
├── CMakeLists.txt
├── ec_test_config.h
├── partitions.csv
├── README.md
├── sdkconfig.defaults
Expand Down Expand Up @@ -208,6 +209,13 @@ components/embed_claw/test/

需要注意:

- `ec_test_config.h`
- 仓库内可提交的测试默认配置
- 供 CI 和干净 checkout 的 `unit-test-app` 构建直接使用
- 当前会提供最小 QQ dummy 配置,保证 QQ 相关测试编译路径始终可用
- `ec_config.h`
- 本地私有、可选覆盖,默认不提交
- 如果存在,会先于 `ec_test_config.h` 注入;`ec_test_config.h` 只补齐未定义的测试宏
- `sdkconfig.defaults`
- 保留测试镜像自己的关键配置,当前显式关闭了 `PSRAM`,避免 `unit-test-app` 在 heap poisoning 下把临时分配落到 PSRAM,导致无关的堆损坏噪声
- `partitions.csv`
Expand Down
21 changes: 21 additions & 0 deletions components/embed_claw/test/ec_test_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef __EC_TEST_CONFIG_H__
#define __EC_TEST_CONFIG_H__

/*
* Tracked test defaults for CI and clean checkouts.
* Local overrides can be placed in components/embed_claw/test/ec_config.h.
*/

#ifndef EC_QQ_ENABLE
#define EC_QQ_ENABLE 1
#endif

#ifndef EC_QQ_APP_ID
#define EC_QQ_APP_ID "test-app-id"
#endif

#ifndef EC_QQ_CLIENT_SECRET
#define EC_QQ_CLIENT_SECRET "test-client-secret"
#endif

#endif // __EC_TEST_CONFIG_H__
Loading