From 0d87ced65bd6fc29b8878bff068f70fd34b03f5d Mon Sep 17 00:00:00 2001 From: Changho Hwang Date: Thu, 26 Oct 2023 01:08:07 +0000 Subject: [PATCH] check if works --- .github/workflows/ut-backup.yml | 18 ++++++++++++++++++ CMakeLists.txt | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/.github/workflows/ut-backup.yml b/.github/workflows/ut-backup.yml index df8db2cbb..620fe46c6 100644 --- a/.github/workflows/ut-backup.yml +++ b/.github/workflows/ut-backup.yml @@ -21,6 +21,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: InstallLcov + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends lcov + - name: Build run: | mkdir build && cd build @@ -51,3 +56,16 @@ jobs: set -e cd build && make pylib-copy mpirun --allow-run-as-root -tag-output -np 8 $(which pytest) ../python/test/test_mscclpp.py -x + + - name: ReportCoverage + run: | + cd build + lcov --capture --directory . --output-file coverage.info + lcov --remove coverage.info \ + '/usr/*' \ + '/tmp/*' \ + '*/python/*' \ + '*/test/*' \ + '*/tools/*' \ + --output-file coverage.info + lcov --list coverage.info diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aef18aa3..ba67bc941 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,18 @@ set(CMAKE_CUDA_STANDARD 17) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -Wall,-Wextra") +# Code coverage from https://github.com/codecov/example-cpp11-cmake +add_library(coverage_config INTERFACE) +if(CMAKE_BUILD_TYPE MATCHES "Debug" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + # Add required flags (GCC & LLVM/Clang) + target_compile_options(coverage_config INTERFACE + -O0 # no optimization + -g # generate debug info + --coverage # sets all required flags + ) + target_link_options(coverage_config INTERFACE --coverage) +endif() + list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # Format targets