diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c72c1018..631da73b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -97,6 +97,9 @@ jobs: cd ../../ mkdir -p linux_build && cd linux_build && cmake .. -DOPENSSL_ROOT_DIR=/root/install -DCMAKE_BUILD_TYPE=Release && make -j $(nproc) + # 执行门禁用例(见 tests/CMakeLists.txt 的 GATING_TESTS),失败则中断流水线 + # Run the gating cases (see GATING_TESTS in tests/CMakeLists.txt); a failure breaks the pipeline + ctest --output-on-failure " - name: 设置环境变量 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b2caeee6..084f1b93 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -35,6 +35,13 @@ jobs: cmakeAppendedArgs: '' cmakeBuildType: 'Release' + - name: 执行门禁用例 + working-directory: '${{github.workspace}}/build' + # 门禁用例见 tests/CMakeLists.txt 的 GATING_TESTS。多配置生成器需以 -C 指定配置 + # Gating cases are listed in GATING_TESTS in tests/CMakeLists.txt. + # Multi-config generators require the configuration to be given with -C + run: ctest -C Release --output-on-failure + - name: 设置环境变量 run: | echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr -s "/\?%*:|\"<>" "_")" >> $GITHUB_ENV diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index cb6b8bfe..f59ed973 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -29,6 +29,13 @@ jobs: cmakeAppendedArgs: '' cmakeBuildType: 'Release' + - name: 执行门禁用例 + working-directory: '${{github.workspace}}/build' + # 门禁用例见 tests/CMakeLists.txt 的 GATING_TESTS。多配置生成器需以 -C 指定配置 + # Gating cases are listed in GATING_TESTS in tests/CMakeLists.txt. + # Multi-config generators require the configuration to be given with -C + run: ctest -C Release --output-on-failure + - name: 设置环境变量 run: | $dateString = Get-Date -Format "yyyy-MM-dd" diff --git a/CMakeLists.txt b/CMakeLists.txt index 27807005..11cf6528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -596,6 +596,7 @@ endif() #cpp测试demo程序 #cpp test demo program if (ENABLE_TESTS) + enable_testing() add_subdirectory(tests) endif () diff --git a/package/build_linux_arm64.sh b/package/build_linux_arm64.sh index c5693586..e163e52e 100644 --- a/package/build_linux_arm64.sh +++ b/package/build_linux_arm64.sh @@ -155,6 +155,10 @@ cmake .. \ -DCMAKE_BUILD_TYPE=Release make -j"$(nproc)" +# 执行门禁用例(见 tests/CMakeLists.txt 的 GATING_TESTS),失败即中断构建 +# Run the gating cases (see GATING_TESTS in tests/CMakeLists.txt); a failure aborts the build +ctest --output-on-failure + echo "Build finished. Artifacts under: ${ROOT_DIR}/release" ls -la "${ROOT_DIR}/release" || true find "${ROOT_DIR}/release" -type f | head -50 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2737ff30..ceeef7f0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -25,6 +25,24 @@ aux_source_directory(. TEST_SRC_LIST) find_package(PCAP QUIET) +# 门禁用例白名单:仅收录不依赖网络、命令行参数与外部文件,且执行完即以退出码 +# 表明结果的测试程序。本目录其余程序多为服务型或压测工具(运行后不会自行退出), +# 全量注册会使 ctest 永远挂起,故采用白名单而非自动收录。 +# Gating test whitelist: only programs that need no network, no command-line arguments and no +# external files, and that finish on their own and report the outcome through the exit code. +# Most of the other programs here are long-running services or benchmarks that never exit by +# themselves, so registering everything would hang ctest; hence a whitelist rather than +# automatic discovery. +# 仅收录仓库中确实存在、且已实测可通过的用例。其余候选的现状: +# test_vp9_rtp 当前为失败状态,待单独修复后并入 +# test_rtcp_nack/test_webrtc_regression 仅在启用 WebRTC 时构建,尚未验证 +# Only cases that exist in the repository and are verified to pass are listed. The remaining +# candidates: test_vp9_rtp currently fails and will be added once fixed; test_rtcp_nack and +# test_webrtc_regression are built only with WebRTC enabled and are not verified yet. +set(GATING_TESTS + test_amf + test_sortor) + foreach(TEST_SRC ${TEST_SRC_LIST}) get_filename_component(TEST_EXE_NAME ${TEST_SRC} NAME_WE) @@ -60,6 +78,13 @@ foreach(TEST_SRC ${TEST_SRC_LIST}) else() target_link_libraries(${TEST_EXE_NAME} ${MK_LINK_LIBRARIES}) endif() + + if(${TEST_EXE_NAME} IN_LIST GATING_TESTS) + add_test(NAME ${TEST_EXE_NAME} COMMAND ${TEST_EXE_NAME}) + # 单个用例正常在秒级内结束,超时即判失败,避免卡住整条流水线 + # A single case finishes within seconds; time out instead of stalling the pipeline + set_tests_properties(${TEST_EXE_NAME} PROPERTIES TIMEOUT 120) + endif() endforeach() if(TARGET test_rtp_pcap)