Skip to content

Enable gcov #511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2024
Merged

Enable gcov #511

merged 2 commits into from
May 27, 2024

Conversation

KFilipek
Copy link
Contributor

Description

This pull request introduces support for gcov, a test coverage program that developers can use to assess the effectiveness of their test suites. The changes include:

  • An additional CMake option USE_GCOV to enable gcov support, which is turned off by default.
  • Modifications to CMakeLists.txt and cmake/helpers.cmake to ensure that the correct compile and link options are set when USE_GCOV is enabled. It also includes a check to ensure that gcov is only used with Debug builds.
  • Updates to CONTRIBUTING.md to guide contributors on how to use gcov to check code coverage for new functionality, including a sample workflow for generating a coverage report.
  • Documentation in README.md has been updated to include the new USE_GCOV option in the list of CMake options.

With these changes, contributors can now enable gcov support in their debug builds to generate coverage reports, helping to maintain and improve the quality of the test suite.

Checklist

  • Code compiles without errors locally
  • All tests pass locally
  • CI workflows execute properly
  • CI workflows, not executed per PR (e.g. Nightly), execute properly
  • New tests added, especially if they will fail without my changes
  • Added/extended example(s) to cover this functionality
  • Extended the README/documentation
  • All newly added source files have a license
  • All newly added source files are referenced in CMake files
  • Logger (with debug/info/... messages) is used

@KFilipek KFilipek requested a review from a team as a code owner May 22, 2024 13:26
@@ -104,6 +104,12 @@ function(add_umf_target_compile_options name)
${name} PRIVATE -Werror -fno-omit-frame-pointer
-fstack-protector-strong)
endif()
if(USE_GCOV)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "To use gcov, the build type must be Debug")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it truly a fatal error? I guess we get a different results for Release, but it should work, right...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the Clang documentation:

gcov - A GCC-compatible coverage implementation which operates on DebugInfo. This is enabled by -ftest-coverage or --coverage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soo.. it might work in the build type "RelWithDebInfo"...?

@KFilipek KFilipek force-pushed the gcov_enable branch 2 times, most recently from 2d25e3e to d409573 Compare May 23, 2024 13:40
KFilipek added 2 commits May 24, 2024 14:29
This commit introduces the option to enable gcov support in the build system.
The USE_GCOV option has been added to allow gcov instrumentation.
@lukaszstolarczuk
Copy link
Contributor

pls don't treat my last issue as a blocker 😉

@KFilipek KFilipek merged commit 5fbf9e5 into oneapi-src:main May 27, 2024
69 checks passed
@KFilipek KFilipek deleted the gcov_enable branch May 27, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants