cmake: Compiling for test coverage (low-priority workaround exists) #31638

issue jimhashhq openend this issue on January 10, 2025
  1. jimhashhq commented at 10:43 pm on January 10, 2025: none

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    When following Compiling for Test Coverage instructions: doc/developer-notes-CompilingForTestCoverage

    I encounter error:

    0CMake Error: File /home/alicebob/wkspc1/presets/bitcoin/cmake/cov_tool_wrapper.sh.in does not exist.
    1CMake Error at /home/alicebob/wkspc1/build/bitcoin/CoverageInclude.cmake:14 (configure_file):
    2  configure_file Problem configuring file
    3Call Stack (most recent call first):
    4  /home/alicebob/wkspc1/build/bitcoin/Coverage.cmake:5 (include)
    

    Expected behaviour

    Driver for functional tests should run, generating instrumentation report HTML.

    Steps to reproduce

    1. Compile for coverage. Following are sample cmake cache variables for the CLang tool chain:
    0"CMAKE_C_COMPILER": "clang",
    1"CMAKE_CXX_COMPILER": "clang++",
    2"CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage",
    3"CMAKE_BUILD_TYPE": "Coverage",
    
    1. Follow instructions in developer notes to compile for coverage: doc/developer-notes-CompilingForTestCoverage

    Relevant log output

    CMake Error: File /home/alicebob/wkspc1/presets/bitcoin/cmake/cov_tool_wrapper.sh.in does not exist.
    CMake Error at /home/alicebob/wkspc1/build/bitcoin/CoverageInclude.cmake:14 (configure_file):
      configure_file Problem configuring file
    Call Stack (most recent call first):
      /home/alicebob/wkspc1/build/bitcoin/Coverage.cmake:5 (include)
    

    How did you obtain Bitcoin Core

    Compiled from source

    What version of Bitcoin Core are you using?

    v28.99.0-37e49c2c7ca5

    Operating system and version

    Ubuntu 24.04.1 LTS

    Machine specifications

    Unix/Intel

  2. jimhashhq commented at 10:50 pm on January 10, 2025: none

    Assuming this is not an execution or environment issue on my side, something like the following one-line addition to the top level project CMakeLists.txt resolves this (though maybe this can be simplified):

    $ git diff
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index 4b21646ca1..6753211ee5 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -433,6 +433,7 @@ endif()
     configure_file(cmake/script/Coverage.cmake Coverage.cmake USE_SOURCE_PERMISSIONS COPYONLY)
     configure_file(cmake/script/CoverageFuzz.cmake CoverageFuzz.cmake USE_SOURCE_PERMISSIONS COPYONLY)
     configure_file(cmake/script/CoverageInclude.cmake.in CoverageInclude.cmake USE_SOURCE_PERMISSIONS [@ONLY](/bitcoin-bitcoin/contributor/only/))
    +configure_file(cmake/cov_tool_wrapper.sh.in cmake/cov_tool_wrapper.sh.in USE_SOURCE_PERMISSIONS COPYONLY)
     configure_file(contrib/filter-lcov.py filter-lcov.py USE_SOURCE_PERMISSIONS COPYONLY)
    

    Also a tiny update to developer-notes.md may be helpful?:

    $ git diff developer-notes.md
    diff --git a/doc/developer-notes.md b/doc/developer-notes.md
    index 37e594e762..bbf599fc65 100644
    --- a/doc/developer-notes.md
    +++ b/doc/developer-notes.md
    @@ -493,7 +493,8 @@ To enable LCOV report generation during test runs:
     ```shell
     cmake -B build -DCMAKE_BUILD_TYPE=Coverage
     cmake --build build
    -cmake -P build/Coverage.cmake
    +cd build
    +cmake -P Coverage.cmake
    
  3. hebasto added the label Build system on Jan 11, 2025
  4. Andrewsr84 commented at 11:43 am on January 12, 2025: none
    Thank for the help

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-01-18 03:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me