测试
测试套件概览
Section titled “测试套件概览”| 套件 | 数量 | 框架 | 覆盖范围 |
|---|---|---|---|
| 单元测试 | 786 | GoogleTest | 解析器、执行器、目录遍历器 |
| 属性测试 | 124 | RapidCheck | 模糊测试、不变量 |
| 兼容性测试 | 52 | GoogleTest | Apache 行为匹配 |
| 配置转换器测试 | 55 | GoogleTest | 配置转换器 |
| 总计 | 1,036 |
# 全部测试ctest --test-dir build --output-on-failure -j$(nproc)
# 特定套件ctest --test-dir build -R "unit_tests" --output-on-failurectest --test-dir build -R "property_tests" --output-on-failurectest --test-dir build -R "compat_tests" --output-on-failurectest --test-dir build -R "confconv_tests" --output-on-failure验证全部 83 种指令类型在解析器、打印器、执行器、目录遍历器、释放和生成器中均有实现:
bash tests/check_consistency.sh# 使用 libFuzzer 构建解析器模糊测试器clang -g -O1 -fsanitize=fuzzer,address -I include \ -DHTACCESS_UNIT_TEST \ tests/fuzz/fuzz_parser.cpp \ src/htaccess_parser.c src/htaccess_directive.c src/htaccess_expires.c \ -lstdc++ -lm -o fuzz_parser
# 运行 5 分钟mkdir -p fuzz_corpus && cp tests/fuzz/corpus/* fuzz_corpus/timeout 300 ./fuzz_parser fuzz_corpus/ -max_len=4096 -timeout=5# 基于 Docker 的 OLS 指令测试docker build -t ols-e2e -f tests/e2e/Dockerfile .docker run -d --name ols-e2e -p 8088:8088 ols-e2ebash tests/e2e/test_directives.sh
# 集成测试(WordPress、Laravel、Nextcloud、Drupal)docker compose -f integration-tests/docker-compose.yml up -d --buildbash integration-tests/apps/wordpress/verify.shCI 流水线
Section titled “CI 流水线”- PR 门禁 (ci.yml):构建、单元/属性/兼容性测试、ASan/UBSan、Apache 对比、OLS E2E
- 手动发布门禁:runtime image 构建、heavy apps-matrix 和 DO VPS 验证只通过显式 workflow 运行
- 发布 (release.yml):x86_64 平台构建、RPM 打包和发布资产上传