Skip to content

Commit

Permalink
Adjust code coverage workflow
Browse files Browse the repository at this point in the history
Extract lcov setup to a stand-alone file. Remove obsolete check on
gcov symbols. Forward code coverage flags to ccache to regenerate
.gcno files when building CUDA object files.
  • Loading branch information
jngrad committed Jun 27, 2024
1 parent e9b30ec commit df93f80
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
2 changes: 2 additions & 0 deletions cmake/FindCUDACompilerNVCC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ target_compile_options(
$<$<CONFIG:Coverage>:-Xptxas=-O3 -Xcompiler=-Og,-g,--coverage,-fprofile-abs-path>
$<$<CONFIG:RelWithAssert>:-Xptxas=-O3 -Xcompiler=-O3,-g>
$<$<BOOL:${CMAKE_OSX_SYSROOT}>:-Xcompiler=-isysroot;-Xcompiler=${CMAKE_OSX_SYSROOT}>
# workaround for https://github.com/espressomd/espresso/issues/4943
$<$<BOOL:${ESPRESSO_BUILD_WITH_CCACHE}>:$<$<CONFIG:Coverage>:--coverage -fprofile-abs-path>>
)

function(espresso_add_gpu_library)
Expand Down
18 changes: 2 additions & 16 deletions maintainer/CI/build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,8 @@ end "BUILD"
# library. See details in https://github.com/espressomd/espresso/issues/2249
# Can't do this check on CUDA though because nvcc creates a host function
# that just calls exit() for each device function, and can't do this with
# coverage because gcov 9.0 adds code that calls exit(), and can't do this
# with walberla because the library calls exit() in assertions.
if [[ "${with_coverage}" == false && ( "${with_cuda}" == false || "${with_cuda_compiler}" != "nvcc" ) && "${with_walberla}" != "true" ]]; then
if [[ ( "${with_cuda}" == false || "${with_cuda_compiler}" != "nvcc" ) && "${with_walberla}" != "true" ]]; then
if nm -o -C $(find . -name '*.so') | grep '[^a-z]exit@@GLIBC'; then
echo "Found calls to exit() function in shared libraries."
exit 1
Expand Down Expand Up @@ -355,20 +354,7 @@ if [ "${with_coverage}" = true ] || [ "${with_coverage_python}" = true ]; then
if [ "${with_coverage}" = true ]; then
echo "Running lcov and gcov..."
codecov_opts="${codecov_opts} --gcov"
lcov --gcov-tool "${GCOV:-gcov}" \
--quiet \
--ignore-errors graph,mismatch,mismatch,gcov,unused \
--directory . \
--filter brace,blank,range,region \
--capture \
--rc lcov_json_module="JSON::XS" \
--exclude "/usr/*" \
--exclude "$(realpath .)/_deps/*" \
--exclude "$(realpath .)/src/python/espressomd/*" \
--exclude "$(realpath "${srcdir}")/src/walberla_bridge/src/*/generated_kernels/*" \
--exclude "$(realpath "${srcdir}")/libs/*" \
--exclude "*/tmpxft_*cudafe1.stub.*" \
--output-file coverage.info
./run_lcov.sh coverage.info
fi
if [ "${with_coverage_python}" = true ]; then
echo "Running python3-coverage..."
Expand Down
45 changes: 45 additions & 0 deletions maintainer/CI/run_lcov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env sh
#
# Copyright (C) 2017-2024 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

set -e

output="${1:-coverage.info}"
bindir="$(realpath .)"
srcdir="$(sed -nr "s/^ESPResSo_SOURCE_DIR:STATIC=(.+)/\1/p" "${bindir}/CMakeCache.txt")"

if [ "${srcdir}" = "" ]; then
echo "Cannot extract ESPResSo_SOURCE_DIR variable from the CMake cache" >&2
exit 2
fi

lcov --gcov-tool "${GCOV:-gcov}" \
--quiet \
--ignore-errors graph,mismatch,mismatch,gcov,unused \
--directory . \
--filter brace,blank,range,region \
--capture \
--rc lcov_json_module="JSON::XS" \
--exclude "/usr/*" \
--exclude "*/tmpxft_*cudafe1.stub.*" \
--exclude "${bindir}/_deps/*" \
--exclude "${bindir}/src/python/espressomd/*" \
--exclude "${srcdir}/src/walberla_bridge/src/*/generated_kernels/*" \
--exclude "${srcdir}/libs/*" \
--output-file "${output}"

0 comments on commit df93f80

Please sign in to comment.