# CMake 错误：测试 'test_network' 以退出码 137 (SIGKILL) 退出。这可能表示超时或内存耗尽。

- **ID:** `cmake/ctest-timeout-unexpected-exit`
- **领域:** cmake
- **类别:** test_error
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

CTest 测试被操作系统杀死，通常是由于超过 CTest 设置的超时限制或内存不足（OOM 杀手）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.15 | active | — | — |
| 3.19 | active | — | — |
| 3.23 | active | — | — |
| 3.27 | active | — | — |

## 解决方案

1. ```
   增加 CTest 的测试超时时间：ctest --timeout 600 或在 CMakeLists.txt 中添加 set_tests_properties(test_network PROPERTIES TIMEOUT 600)。
   ```
2. ```
   优化测试以减少内存使用：使用 valgrind 或地址清理器检查内存泄漏，并减少数据结构。
   ```
3. ```
   在启动 ctest 之前使用更高的资源限制运行测试：ulimit -v 4194304（4 GB 虚拟内存）。
   ```

## 无效尝试

- **Increasing system memory without adjusting CTest timeout** — If the test hangs or is slow, adding memory does not fix the timeout; the test still gets killed at the same wall-clock limit. (80% 失败率)
- **Disabling the test entirely in CTest configuration** — This hides the problem but does not resolve the underlying issue (e.g., infinite loop or resource leak). The test may be critical for CI. (90% 失败率)
- **Setting CMAKE_CTEST_TIMEOUT to 0 (infinite) globally** — Infinite timeout can cause CI pipelines to hang indefinitely if the test never completes, leading to resource exhaustion. (85% 失败率)
