From 99d8102e6f9b13bd5181be5111622e645b78b79f Mon Sep 17 00:00:00 2001 From: Sergey Agievich Date: Fri, 10 May 2024 23:20:37 +0300 Subject: [PATCH] Coverage (#1) * Update actions/coverage * Update actions/coverage * Update actions/coverage * Update actions/coverage * Update actions/coverage * Update actions/coverage * Update actions/coverage * Update actions/coverage --- .github/workflows/coverage.yml | 22 ++++++++++++---------- CMakeLists.txt | 9 +-------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index fad374e..280593c 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -4,33 +4,35 @@ name: coverage on: push: - branches: coverage + branches: master pull_request: - branches: coverage + branches: master jobs: run: name: Measure code coverage runs-on: ubuntu-latest steps: - - name: Install lcov - run: sudo apt install -y lcov + - name: Install llvm + run: sudo apt install -y llvm - name: Get source uses: actions/checkout@v3 - name: Configure CMake run: > - CXX=g++-13 cmake -B ${{github.workspace}}/build + CXX=clang cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Coverage - name: Build run: cmake --build ${{github.workspace}}/build - name: Run tests working-directory: ${{github.workspace}}/build run: | - lcov -c -i -d .. -o coverage_base.info + export LLVM_PROFILE_FILE=./gf2.profraw test/testgf2 + llvm-profdata merge -sparse gf2.profraw -o gf2.profdata + llvm-cov show ./test/testgf2 -instr-profile=gf2.profdata > coverage.txt - name: Upload coverage reports to Codecov working-directory: ${{github.workspace}}/build - run: | - lcov -c -d .. -o coverage_test.info - lcov -a coverage_base.info -a coverage_test.info -o coverage.info - bash <(curl -s https://codecov.io/bash) -f coverage.info + env: + CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} + run: + bash <(curl -s https://codecov.io/bash) -f coverage.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 0700a5f..068fef2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ if(CMAKE_COMPILER_IS_CLANG) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3") set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -O0 -g3 \ - --coverage") + -fprofile-instr-generate -fcoverage-mapping") set(CMAKE_CXX_FLAGS_ASAN "${CMAKE_CXX_FLAGS_ASAN} -fno-common -O3 \ -fsanitize=address -fsanitize=undefined -fno-sanitize-recover \ -fsanitize-undefined-trap-on-error") @@ -79,13 +79,6 @@ if(CMAKE_COMPILER_IS_MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _CRT_SECURE_NO_WARNINGS") endif(CMAKE_COMPILER_IS_MSVC) -if(CMAKE_BUILD_TYPE STREQUAL "Coverage") - if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \ - -fprofile-arcs -ftest-coverage") - endif() -endif() - if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++") endif()