From a1c13eedc06e0a5f1e648b5093dd37ddd5b24c6c Mon Sep 17 00:00:00 2001 From: alph00 Date: Thu, 11 Jul 2024 04:51:29 +0000 Subject: [PATCH 1/2] Split the original UT CI job into two separate jobs: one with SPL and one without SPL --- ...ld-core-ut.yaml => build-core-spl-ut.yaml} | 27 +++--- .../workflows/build-core-withoutspl-ut.yaml | 90 +++++++++++++++++++ core/CMakeLists.txt | 1 + core/unittest/CMakeLists.txt | 58 ++++++------ scripts/gen_build_scripts.sh | 4 +- scripts/run_core_ut.sh | 2 + 6 files changed, 141 insertions(+), 41 deletions(-) rename .github/workflows/{build-core-ut.yaml => build-core-spl-ut.yaml} (87%) create mode 100644 .github/workflows/build-core-withoutspl-ut.yaml diff --git a/.github/workflows/build-core-ut.yaml b/.github/workflows/build-core-spl-ut.yaml similarity index 87% rename from .github/workflows/build-core-ut.yaml rename to .github/workflows/build-core-spl-ut.yaml index a1df4597ae..f669c051c3 100644 --- a/.github/workflows/build-core-ut.yaml +++ b/.github/workflows/build-core-spl-ut.yaml @@ -1,4 +1,4 @@ -# Copyright 2021 iLogtail Authors +# Copyright 2024 iLogtail Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,18 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Build Core Unit Test +name: Build Core SPL Unit Test on: pull_request: paths-ignore: - - 'docs/**' - - 'example_config/**' - - 'docker/**' - - 'k8s_template/**' - - 'changes/**' - - 'licenses/**' - - 'CHANGELOG.md' + - "docs/**" + - "example_config/**" + - "docker/**" + - "k8s_template/**" + - "changes/**" + - "licenses/**" + - "CHANGELOG.md" push: branches: - main @@ -51,7 +51,7 @@ jobs: sudo rm -rf "$AGENT_TOOLSDIRECTORY" sudo -E apt-get -qq autoremove --purge sudo -E apt-get -qq clean - + - name: Check disk space run: | df -hT $PWD @@ -66,18 +66,19 @@ jobs: with: submodules: true - - name: Build Unit Test + - name: Build SPL Unit Test env: BUILD_LOGTAIL: OFF BUILD_LOGTAIL_UT: ON ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON - MAKE_JOBS: 8 + ONLY_SPL_UT: ON + MAKE_JOBS: 16 # BUILD_TYPE: Debug # TODO: Uncomment when memory management is refined run: make core - - name: Unit Test + - name: SPL Unit Test run: make unittest_core result: diff --git a/.github/workflows/build-core-withoutspl-ut.yaml b/.github/workflows/build-core-withoutspl-ut.yaml new file mode 100644 index 0000000000..67527b6729 --- /dev/null +++ b/.github/workflows/build-core-withoutspl-ut.yaml @@ -0,0 +1,90 @@ +# Copyright 2024 iLogtail Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Build Core Unit Test Without SPL + +on: + pull_request: + paths-ignore: + - "docs/**" + - "example_config/**" + - "docker/**" + - "k8s_template/**" + - "changes/**" + - "licenses/**" + - "CHANGELOG.md" + push: + branches: + - main + - 1.* + +jobs: + CI: + runs-on: ${{ matrix.runner }} + timeout-minutes: 90 + strategy: + matrix: + go-version: [1.19] + # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on + runner: [arc-runner-set-ilogtail] + fail-fast: true + steps: + - name: prepare ubuntu environment + run: sudo apt-get clean && sudo apt-get update && sudo apt-get install -y libsystemd-dev build-essential git curl bc + # Clean up space to prevent action from running out of disk space. + - name: Free disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + sudo -E apt-get -qq autoremove --purge + sudo -E apt-get -qq clean + + - name: Check disk space + run: | + df -hT $PWD + + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + + - name: Check out code + uses: actions/checkout@v4 + with: + submodules: true + + - name: Build Unit Test Without SPL + env: + BUILD_LOGTAIL: OFF + BUILD_LOGTAIL_UT: ON + # ENABLE_COMPATIBLE_MODE: ON + ENABLE_STATIC_LINK_CRT: ON + WITHOUTGDB: ON + WITHOUTSPL: ON + MAKE_JOBS: 16 + # BUILD_TYPE: Debug # TODO: Uncomment when memory management is refined + run: make core + + - name: Unit Test Without SPL + run: make unittest_core + + result: + runs-on: arc-runner-set-ilogtail + timeout-minutes: 90 + needs: [CI] + steps: + - name: Build Result + run: echo "Just to make the GitHub merge button green" diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 10c2e00a11..ecee165937 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -32,6 +32,7 @@ cmake_dependent_option(ENABLE_STATIC_LINK_CRT "Build Logtail by linking CRT stat option(WITHOUTGDB "Build Logtail without gdb") option(WITHOUTSPL "Build Logtail and UT without SPL") option(BUILD_LOGTAIL_UT "Build unit test for Logtail") +option(ONLY_SPL_UT "Only build UT with SPL") if (ENABLE_ENTERPRISE) message(STATUS "Enable Enterprise Feature.") diff --git a/core/unittest/CMakeLists.txt b/core/unittest/CMakeLists.txt index f554f8eac7..8f59ddf00d 100644 --- a/core/unittest/CMakeLists.txt +++ b/core/unittest/CMakeLists.txt @@ -45,36 +45,40 @@ flusher_link(${PROJECT_NAME}) all_link(${PROJECT_NAME}) common_link(${PROJECT_NAME}) -add_subdirectory(app_config) -add_subdirectory(batch) -add_subdirectory(checkpoint) -add_subdirectory(common) -add_subdirectory(compression) -add_subdirectory(config) -add_subdirectory(config_sdk) -add_subdirectory(container_manager) -add_subdirectory(controller) -add_subdirectory(event) -add_subdirectory(event_handler) -add_subdirectory(file_source) -add_subdirectory(flusher) -add_subdirectory(input) -add_subdirectory(log_pb) -add_subdirectory(models) -add_subdirectory(monitor) -add_subdirectory(pipeline) -add_subdirectory(plugin) -add_subdirectory(polling) -add_subdirectory(processor) -add_subdirectory(queue) -add_subdirectory(reader) -add_subdirectory(sdk) -add_subdirectory(sender) -add_subdirectory(serializer) +if(NOT ONLY_SPL_UT) + add_subdirectory(app_config) + add_subdirectory(batch) + add_subdirectory(checkpoint) + add_subdirectory(common) + add_subdirectory(compression) + add_subdirectory(config) + add_subdirectory(config_sdk) + add_subdirectory(container_manager) + add_subdirectory(controller) + add_subdirectory(event) + add_subdirectory(event_handler) + add_subdirectory(file_source) + add_subdirectory(flusher) + add_subdirectory(input) + add_subdirectory(log_pb) + add_subdirectory(models) + add_subdirectory(monitor) + add_subdirectory(pipeline) + add_subdirectory(plugin) + add_subdirectory(polling) + add_subdirectory(processor) + add_subdirectory(queue) + add_subdirectory(reader) + add_subdirectory(sdk) + add_subdirectory(sender) + add_subdirectory(serializer) +endif() if (LINUX) if (NOT WITHOUTSPL) add_subdirectory(spl) endif () - add_subdirectory(observer) + if (NOT ONLY_SPL_UT) + add_subdirectory(observer) + endif() endif () \ No newline at end of file diff --git a/scripts/gen_build_scripts.sh b/scripts/gen_build_scripts.sh index 33dfe2e92e..0455fc6fcb 100755 --- a/scripts/gen_build_scripts.sh +++ b/scripts/gen_build_scripts.sh @@ -38,6 +38,8 @@ BUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT:-OFF} ENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE:-OFF} ENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT:-OFF} WITHOUTGDB==${WITHOUTGDB:-OFF} +WITHOUTSPL=${WITHOUTSPL:-OFF} +ONLY_SPL_UT=${ONLY_SPL_UT:-OFF} BUILD_SCRIPT_FILE=$GENERATED_HOME/gen_build.sh COPY_SCRIPT_FILE=$GENERATED_HOME/gen_copy_docker.sh MAKE_JOBS=${MAKE_JOBS:-$(nproc)} @@ -82,7 +84,7 @@ EOF if [ $CATEGORY = "plugin" ]; then echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} .. && cd plugin && make -s PluginAdapter && cd ../../.. && ./scripts/upgrade_adapter_lib.sh && ./scripts/plugin_build.sh mod c-shared ${OUT_DIR} ${VERSION} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE elif [ $CATEGORY = "core" ]; then - echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL=${BUILD_LOGTAIL} -DBUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} .. && make -sj${MAKE_JOBS}" >>$BUILD_SCRIPT_FILE + echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL=${BUILD_LOGTAIL} -DBUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} -DWITHOUTSPL=${WITHOUTSPL} -DONLY_SPL_UT=${ONLY_SPL_UT} .. && make -sj${MAKE_JOBS}" >>$BUILD_SCRIPT_FILE elif [ $CATEGORY = "all" ]; then echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} .. && make -sj\$nproc && cd - && ./scripts/upgrade_adapter_lib.sh && ./scripts/plugin_build.sh mod c-shared ${OUT_DIR} ${VERSION} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE elif [ $CATEGORY = "e2e" ]; then diff --git a/scripts/run_core_ut.sh b/scripts/run_core_ut.sh index 848292d263..c611f79b13 100755 --- a/scripts/run_core_ut.sh +++ b/scripts/run_core_ut.sh @@ -35,5 +35,7 @@ search_files() { } # Maybe some unittest depend on relative paths, so execute in the unittest directory +UT_BASE_PATH="$(pwd)/${TARGET_ARTIFACT_PATH:2}" +export LD_LIBRARY_PATH=${UT_BASE_PATH}:$LD_LIBRARY_PATH cd $TARGET_ARTIFACT_PATH search_files . From b9c2ed118c69ca53e43257cfe3dd7f99140487da Mon Sep 17 00:00:00 2001 From: alph00 Date: Thu, 11 Jul 2024 09:34:43 +0000 Subject: [PATCH 2/2] fix button behavior --- ...utspl-ut.yaml => build-core-nospl-ut.yaml} | 8 +++---- .github/workflows/build-core-spl-ut.yaml | 3 +-- .github/workflows/build-core.yaml | 24 ++++++++++--------- .github/workflows/build.yaml | 23 +++++++++--------- .github/workflows/e2e-framework.yaml | 23 +++++++++--------- .github/workflows/e2e.yaml | 23 +++++++++--------- core/CMakeLists.txt | 8 +++---- core/links.cmake | 2 +- core/unittest/CMakeLists.txt | 14 +++++------ .../development-environment.md | 4 ++-- scripts/gen_build_scripts.sh | 13 +++++----- 11 files changed, 75 insertions(+), 70 deletions(-) rename .github/workflows/{build-core-withoutspl-ut.yaml => build-core-nospl-ut.yaml} (94%) diff --git a/.github/workflows/build-core-withoutspl-ut.yaml b/.github/workflows/build-core-nospl-ut.yaml similarity index 94% rename from .github/workflows/build-core-withoutspl-ut.yaml rename to .github/workflows/build-core-nospl-ut.yaml index 67527b6729..96d3478409 100644 --- a/.github/workflows/build-core-withoutspl-ut.yaml +++ b/.github/workflows/build-core-nospl-ut.yaml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Build Core Unit Test Without SPL +name: Build Core NoSPL Unit Test on: pull_request: @@ -66,10 +66,10 @@ jobs: with: submodules: true - - name: Build Unit Test Without SPL + - name: Build NoSPL Unit Test env: BUILD_LOGTAIL: OFF - BUILD_LOGTAIL_UT: ON + BUILD_LOGTAIL_NOSPL_UT: ON # ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON @@ -78,7 +78,7 @@ jobs: # BUILD_TYPE: Debug # TODO: Uncomment when memory management is refined run: make core - - name: Unit Test Without SPL + - name: NoSPL Unit Test run: make unittest_core result: diff --git a/.github/workflows/build-core-spl-ut.yaml b/.github/workflows/build-core-spl-ut.yaml index f669c051c3..156f0adc96 100644 --- a/.github/workflows/build-core-spl-ut.yaml +++ b/.github/workflows/build-core-spl-ut.yaml @@ -69,11 +69,10 @@ jobs: - name: Build SPL Unit Test env: BUILD_LOGTAIL: OFF - BUILD_LOGTAIL_UT: ON + BUILD_LOGTAIL_SPL_UT: ON ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON - ONLY_SPL_UT: ON MAKE_JOBS: 16 # BUILD_TYPE: Debug # TODO: Uncomment when memory management is refined run: make core diff --git a/.github/workflows/build-core.yaml b/.github/workflows/build-core.yaml index f14e6b6c57..f90bedabe9 100644 --- a/.github/workflows/build-core.yaml +++ b/.github/workflows/build-core.yaml @@ -17,13 +17,13 @@ name: Build Core on: pull_request: paths-ignore: - - 'docs/**' - - 'example_config/**' - - 'docker/**' - - 'k8s_template/**' - - 'changes/**' - - 'licenses/**' - - 'CHANGELOG.md' + - "docs/**" + - "example_config/**" + - "docker/**" + - "k8s_template/**" + - "changes/**" + - "licenses/**" + - "CHANGELOG.md" push: branches: - main @@ -37,7 +37,7 @@ jobs: matrix: go-version: [1.19] # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on - runner: [ arc-runner-set-ilogtail ] + runner: [arc-runner-set-ilogtail] fail-fast: true steps: - name: prepare ubuntu environment @@ -60,7 +60,7 @@ jobs: uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} - + - name: Check out code uses: actions/checkout@v4 with: @@ -68,7 +68,8 @@ jobs: - name: Build Binary env: - BUILD_LOGTAIL_UT: OFF + BUILD_LOGTAIL_NOSPL_UT: OFF + BUILD_LOGTAIL_SPL_UT: OFF ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON @@ -77,7 +78,8 @@ jobs: - name: Check compatibility env: - BUILD_LOGTAIL_UT: OFF + BUILD_LOGTAIL_NOSPL_UT: OFF + BUILD_LOGTAIL_SPL_UT: OFF ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 224a18caa7..9c5727ffa5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,13 +17,13 @@ name: Build on: pull_request: paths-ignore: - - 'docs/**' - - 'example_config/**' - - 'docker/**' - - 'k8s_template/**' - - 'changes/**' - - 'licenses/**' - - 'CHANGELOG.md' + - "docs/**" + - "example_config/**" + - "docker/**" + - "k8s_template/**" + - "changes/**" + - "licenses/**" + - "CHANGELOG.md" push: branches: - main @@ -37,7 +37,7 @@ jobs: matrix: go-version: [1.19] # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on - runner: [ arc-runner-set-ilogtail ] + runner: [arc-runner-set-ilogtail] fail-fast: true steps: - name: prepare ubuntu environment @@ -51,7 +51,7 @@ jobs: sudo rm -rf "$AGENT_TOOLSDIRECTORY" sudo -E apt-get -qq autoremove --purge sudo -E apt-get -qq clean - + - name: Check disk space run: | df -hT $PWD @@ -60,7 +60,7 @@ jobs: uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} - + - name: Check out code uses: actions/checkout@v4 with: @@ -68,7 +68,8 @@ jobs: - name: Build Binary env: - BUILD_LOGTAIL_UT: OFF + BUILD_LOGTAIL_NOSPL_UT: OFF + BUILD_LOGTAIL_SPL_UT: OFF ENABLE_COMPATIBLE_MODE: ON ENABLE_STATIC_LINK_CRT: ON WITHOUTGDB: ON diff --git a/.github/workflows/e2e-framework.yaml b/.github/workflows/e2e-framework.yaml index b9bc3f4cb1..410145ff94 100644 --- a/.github/workflows/e2e-framework.yaml +++ b/.github/workflows/e2e-framework.yaml @@ -17,13 +17,13 @@ name: E2E Core Test on: pull_request: paths-ignore: - - 'docs/**' - - 'example_config/**' - - 'docker/**' - - 'k8s_template/**' - - 'changes/**' - - 'licenses/**' - - 'CHANGELOG.md' + - "docs/**" + - "example_config/**" + - "docker/**" + - "k8s_template/**" + - "changes/**" + - "licenses/**" + - "CHANGELOG.md" push: branches: - main @@ -34,8 +34,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - go-version: [ 1.19.10 ] - runner: [ ubuntu-latest ] + go-version: [1.19.10] + runner: [ubuntu-latest] fail-fast: true steps: # Clean up space to prevent action from running out of disk space. @@ -69,7 +69,8 @@ jobs: - name: E2E Plugin Framework Test env: - BUILD_LOGTAIL_UT: OFF + BUILD_LOGTAIL_NOSPL_UT: OFF + BUILD_LOGTAIL_SPL_UT: OFF WITHOUTGDB: ON run: make e2e-core @@ -81,7 +82,7 @@ jobs: result: runs-on: ubuntu-latest timeout-minutes: 60 - needs: [ CI ] + needs: [CI] steps: - name: Build Result run: echo "Just to make the GitHub merge button green" diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index d6c09edf81..a8175a6d9a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -17,13 +17,13 @@ name: E2E Test on: pull_request: paths-ignore: - - 'docs/**' - - 'example_config/**' - - 'docker/**' - - 'k8s_template/**' - - 'changes/**' - - 'licenses/**' - - 'CHANGELOG.md' + - "docs/**" + - "example_config/**" + - "docker/**" + - "k8s_template/**" + - "changes/**" + - "licenses/**" + - "CHANGELOG.md" push: branches: - main @@ -34,8 +34,8 @@ jobs: timeout-minutes: 60 strategy: matrix: - go-version: [ 1.19.10 ] - runner: [ ubuntu-latest ] + go-version: [1.19.10] + runner: [ubuntu-latest] fail-fast: true steps: # Clean up space to prevent action from running out of disk space. @@ -76,14 +76,15 @@ jobs: - name: E2E Behavior Test env: - BUILD_LOGTAIL_UT: OFF + BUILD_LOGTAIL_NOSPL_UT: OFF + BUILD_LOGTAIL_SPL_UT: OFF WITHOUTGDB: ON run: make e2e result: runs-on: ubuntu-latest timeout-minutes: 60 - needs: [ CI ] + needs: [CI] steps: - name: Build Result run: echo "Just to make the GitHub merge button green" diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index ecee165937..12ce17e064 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -30,9 +30,9 @@ option(ENABLE_ENTERPRISE "enable enterprise feature") cmake_dependent_option(ENABLE_COMPATIBLE_MODE "Build Logtail in compatible mode (for low version Linux)" OFF "LINUX" OFF) cmake_dependent_option(ENABLE_STATIC_LINK_CRT "Build Logtail by linking CRT statically" OFF "LINUX" OFF) option(WITHOUTGDB "Build Logtail without gdb") -option(WITHOUTSPL "Build Logtail and UT without SPL") -option(BUILD_LOGTAIL_UT "Build unit test for Logtail") -option(ONLY_SPL_UT "Only build UT with SPL") +option(WITHOUTSPL "Link Logtail without SPL") +option(BUILD_LOGTAIL_NOSPL_UT "Build noSPL unit test for Logtail") +option(BUILD_LOGTAIL_SPL_UT "Build SPL unit test for Logtail") if (ENABLE_ENTERPRISE) message(STATUS "Enable Enterprise Feature.") @@ -207,7 +207,7 @@ if (BUILD_LOGTAIL_SHARED_LIBRARY) endif () # Logtail UT. -if (BUILD_LOGTAIL_UT) +if (BUILD_LOGTAIL_NOSPL_UT OR BUILD_LOGTAIL_SPL_UT) message(STATUS "Build unittest.") include(CTest) enable_testing() diff --git a/core/links.cmake b/core/links.cmake index 0dde93ad60..fa43fb5741 100644 --- a/core/links.cmake +++ b/core/links.cmake @@ -13,7 +13,7 @@ # limitations under the License. macro(all_link target_name) - if (BUILD_LOGTAIL_UT) + if (BUILD_LOGTAIL_NOSPL_UT OR BUILD_LOGTAIL_SPL_UT) link_gtest(${target_name}) endif () link_protobuf(${target_name}) diff --git a/core/unittest/CMakeLists.txt b/core/unittest/CMakeLists.txt index 8f59ddf00d..ae7880e7d8 100644 --- a/core/unittest/CMakeLists.txt +++ b/core/unittest/CMakeLists.txt @@ -45,7 +45,7 @@ flusher_link(${PROJECT_NAME}) all_link(${PROJECT_NAME}) common_link(${PROJECT_NAME}) -if(NOT ONLY_SPL_UT) +if(BUILD_LOGTAIL_NOSPL_UT) add_subdirectory(app_config) add_subdirectory(batch) add_subdirectory(checkpoint) @@ -72,13 +72,13 @@ if(NOT ONLY_SPL_UT) add_subdirectory(sdk) add_subdirectory(sender) add_subdirectory(serializer) + if (LINUX) + add_subdirectory(observer) + endif () endif() -if (LINUX) - if (NOT WITHOUTSPL) +if(BUILD_LOGTAIL_SPL_UT) + if (LINUX) add_subdirectory(spl) endif () - if (NOT ONLY_SPL_UT) - add_subdirectory(observer) - endif() -endif () \ No newline at end of file +endif() \ No newline at end of file diff --git a/docs/cn/developer-guide/development-environment.md b/docs/cn/developer-guide/development-environment.md index f414bf4d84..81ec78cffa 100644 --- a/docs/cn/developer-guide/development-environment.md +++ b/docs/cn/developer-guide/development-environment.md @@ -144,10 +144,10 @@ cmake -D CMAKE_BUILD_TYPE=Debug .. 同理,若需要明确需要代码优化,则将上面的Debug改为Release。 -默认的编译开关没有打开UT,如果需要编译UT,需要增加BUILD_LOGTAIL_UT开关。替换上述第2行为 +默认的编译开关没有打开UT,如果需要编译UT,需要增加BUILD_LOGTAIL_NOSPL_UT或BUILD_LOGTAIL_SPL_UT开关。替换上述第2行为 ```bash -cmake -DBUILD_LOGTAIL_UT=ON .. +cmake -DBUILD_LOGTAIL_NOSPL_UT=ON .. ``` - 制作镜像 diff --git a/scripts/gen_build_scripts.sh b/scripts/gen_build_scripts.sh index 0455fc6fcb..81b5202289 100755 --- a/scripts/gen_build_scripts.sh +++ b/scripts/gen_build_scripts.sh @@ -34,7 +34,8 @@ GO_MOD_FILE=${9:-${GO_MOD_FILE:-go.mod}} BUILD_TYPE=${BUILD_TYPE:-Release} BUILD_LOGTAIL=${BUILD_LOGTAIL:-ON} -BUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT:-OFF} +BUILD_LOGTAIL_NOSPL_UT=${BUILD_LOGTAIL_NOSPL_UT:-OFF} +BUILD_LOGTAIL_SPL_UT=${BUILD_LOGTAIL_SPL_UT:-OFF} ENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE:-OFF} ENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT:-OFF} WITHOUTGDB==${WITHOUTGDB:-OFF} @@ -84,11 +85,11 @@ EOF if [ $CATEGORY = "plugin" ]; then echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} .. && cd plugin && make -s PluginAdapter && cd ../../.. && ./scripts/upgrade_adapter_lib.sh && ./scripts/plugin_build.sh mod c-shared ${OUT_DIR} ${VERSION} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE elif [ $CATEGORY = "core" ]; then - echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL=${BUILD_LOGTAIL} -DBUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} -DWITHOUTSPL=${WITHOUTSPL} -DONLY_SPL_UT=${ONLY_SPL_UT} .. && make -sj${MAKE_JOBS}" >>$BUILD_SCRIPT_FILE + echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL=${BUILD_LOGTAIL} -DBUILD_LOGTAIL_NOSPL_UT=${BUILD_LOGTAIL_NOSPL_UT} -DBUILD_LOGTAIL_SPL_UT=${BUILD_LOGTAIL_SPL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} -DWITHOUTSPL=${WITHOUTSPL} -DONLY_SPL_UT=${ONLY_SPL_UT} .. && make -sj${MAKE_JOBS}" >>$BUILD_SCRIPT_FILE elif [ $CATEGORY = "all" ]; then - echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} .. && make -sj\$nproc && cd - && ./scripts/upgrade_adapter_lib.sh && ./scripts/plugin_build.sh mod c-shared ${OUT_DIR} ${VERSION} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE + echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL_NOSPL_UT=${BUILD_LOGTAIL_NOSPL_UT} -DBUILD_LOGTAIL_SPL_UT=${BUILD_LOGTAIL_SPL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} .. && make -sj\$nproc && cd - && ./scripts/upgrade_adapter_lib.sh && ./scripts/plugin_build.sh mod c-shared ${OUT_DIR} ${VERSION} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE elif [ $CATEGORY = "e2e" ]; then - echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL_UT=${BUILD_LOGTAIL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} .. && make -sj\$nproc && cd - && ./scripts/plugin_gocbuild.sh ${OUT_DIR} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE + echo "mkdir -p core/build && cd core/build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLOGTAIL_VERSION=${VERSION} -DBUILD_LOGTAIL_NOSPL_UT=${BUILD_LOGTAIL_NOSPL_UT} -DBUILD_LOGTAIL_SPL_UT=${BUILD_LOGTAIL_SPL_UT} -DENABLE_COMPATIBLE_MODE=${ENABLE_COMPATIBLE_MODE} -DENABLE_STATIC_LINK_CRT=${ENABLE_STATIC_LINK_CRT} -DWITHOUTGDB=${WITHOUTGDB} .. && make -sj\$nproc && cd - && ./scripts/plugin_gocbuild.sh ${OUT_DIR} ${PLUGINS_CONFIG_FILE} ${GO_MOD_FILE}" >>$BUILD_SCRIPT_FILE fi } @@ -105,14 +106,14 @@ function generateCopyScript() { echo 'docker cp "$id":/src/core/build/ilogtail $BINDIR' >>$COPY_SCRIPT_FILE echo 'docker cp "$id":/src/core/build/go_pipeline/libPluginAdapter.so $BINDIR' >>$COPY_SCRIPT_FILE fi - if [ $BUILD_LOGTAIL_UT = "ON" ]; then + if [ $BUILD_LOGTAIL_NOSPL_UT = "ON" ] || [ $BUILD_LOGTAIL_SPL_UT = "ON"]; then echo 'docker cp "$id":/src/core/build core/build' >>$COPY_SCRIPT_FILE fi else echo 'docker cp "$id":/src/'${OUT_DIR}'/libPluginBase.so $BINDIR' >>$COPY_SCRIPT_FILE echo 'docker cp "$id":/src/core/build/ilogtail $BINDIR' >>$COPY_SCRIPT_FILE echo 'docker cp "$id":/src/core/build/go_pipeline/libPluginAdapter.so $BINDIR' >>$COPY_SCRIPT_FILE - if [ $BUILD_LOGTAIL_UT = "ON" ]; then + if [ $BUILD_LOGTAIL_NOSPL_UT = "ON" ] || [ $BUILD_LOGTAIL_SPL_UT = "ON"]; then echo 'docker cp "$id":/src/core/build core/build' >>$COPY_SCRIPT_FILE fi fi