Skip to content
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

GCOV Fails to use g++? #999

Open
Ash-BV opened this issue Jan 20, 2025 · 4 comments
Open

GCOV Fails to use g++? #999

Ash-BV opened this issue Jan 20, 2025 · 4 comments

Comments

@Ash-BV
Copy link

Ash-BV commented Jan 20, 2025

I have created a YAML configuration file to test C++ files and generate a report using Ceedling. I would like to request verification of this file to ensure it is correctly configured.

=========================================================================

Ceedling - Test-Centered Build System for C

ThrowTheSwitch.org

Copyright (c) 2010-25 Mike Karlesky, Mark VanderVoord, & Greg Williams

SPDX-License-Identifier: MIT

=========================================================================


:project:
:which_ceedling: gem
:ceedling_version: 1.0.0

:use_mocks: TRUE
:use_test_preprocessor: :all # options are :none, :mocks, :tests, or :all
:use_backtrace: :simple # options are :none, :simple, or :gdb
:use_decorators: :auto # decorate Ceedling's output text. options are :auto, :all, or :none

:use_exceptions: FALSE
:use_auxiliary_dependencies: TRUE

:build_root: UTbuild
:test_file_prefix: test_
:default_tasks:
- test:all

:test_threads: 8
:compile_threads: 8

:environment:

:extension:
:c: c
:cpp: cpp
:h: h
:hpp: hpp
:executable: .out

:paths:
:source:
- app/src
- base/src
- gui/src
- test
- test/support
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/unity/src
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/cmock/src
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/c_exception/lib

:test:
- test
:support:
- test/support
:include:
- app/src
- base/src
- gui/src
- test/mocks
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/unity/src
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/cmock/src
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/c_exception/lib

:libraries: []

:cmock:
:mock_prefix: mock_
:mock_path: 'test/mocks'
:when_no_prototypes: :warn
:enforce_strict_ordering: TRUE
:plugins:
- :ignore
- :callback
- :expect_any_args
- :ignore_arg
- :return_thru_ptr
:treat_as:
uint8: HEX8
uint16: HEX16
uint32: UINT32
int8: INT8
bool: UINT8
:functions:
:exclude:
- XIic_IsIicBusy

:defines:

:common: &common_defines
- UNIT_TEST=1
:test:
- *common_defines
- TEST
- UNIT_TEST=1
- CEXCEPTION_USE_CONFIG_FILE
:test_preprocess:
- *common_defines
- TEST
- CEXCEPTION_USE_CONFIG_FILE

:libraries:
:placement: :end
:flag: "-l${1}"
:path_flag: "-L ${1}"
:system: [] # for example, you might list 'm' to grab the math library
:test: []
:release: []

:tools:
:gcov:
:executable: gcov
:name: 'gcov'
:args:
- -r
- .
- --html
- --html-details

:gcov_compiler:
:executable: g++
🎏
- "-std=c++11"
- "-Wall"
- "-Werror"
- "-fprofile-arcs"
- "-ftest-coverage"
- "-fno-exceptions"
:includes:
- "app/src"
- "base/src"
- "gui/src"
- "test"
- "test/support"
- "/usr/local/bundle/gems/ceedling-1.0.0/vendor/unity/src"
- "/usr/local/bundle/gems/ceedling-1.0.0/vendor/cmock/src"
:gcov_linker:
:executable: g++
🎏
- "-std=c++11"
- "-Wall"
- "-Werror"
- "-lgcov"

:plugins:
:enabled:
- gcov # gcov must be enabled as a plugin in order to generate a coverage report
- module_generator

:coverage:
:tool: gcovr
:gcovr:
:html: true
:html_details: true
:html_output: "UTbuild/artifacts/gcov/coverage_report.html"

:project_root: .

:output:
:coverage_html_report_path: UTbuild/coverage

:gcov:
:report_types:
- HTML
:html_report_type: detailed

@Letme
Copy link
Contributor

Letme commented Jan 20, 2025

Can you style it using code block https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks ?

Not sure what you mean with verification? If it produces what you want, then its verified.

I would advise you to use :flags: overall, instead of :arguments: (under :gcov_compiler:), as you will avoid hardcoded absolute paths for the includes of cmock, unity and c_exception (which are done by default). Just use default project.yml file as example.

@Ash-BV Ash-BV closed this as completed Jan 21, 2025
@Ash-BV Ash-BV reopened this Jan 21, 2025
@Ash-BV
Copy link
Author

Ash-BV commented Jan 21, 2025

Thank you for your response.

While testing a .c file that includes a .hpp file, I encountered the following error: fatal error: cstdlib: No such file or directory.

I am running Ceedling within a Docker environment.

@Ash-BV
Copy link
Author

Ash-BV commented Jan 21, 2025

To address the previous issue, I updated the YAML file paths as follows:

yaml
Copy
Edit
:paths:
:source:
- app/src
- base/src
- gui/src
- test
- test/support
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/unity/src
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/cmock/src
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/c_exception/lib

:test:
- test
:support:
- test/support
:include:
- app/src
- base/src
- gui/src
- test/mocks
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/unity/src
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/cmock/src
- /usr/local/bundle/gems/ceedling-1.0.0/vendor/c_exception/lib
- /usr/include/c++/12
- /usr/include/x86_64-linux-gnu/c++/12
- /usr/include/c++/12/backward

With this configuration, ceedling test:all runs successfully. However, ceedling gcov:all fails because gcov defaults to using gcc instead of g++. Could you advise on the necessary changes to ensure gcov uses g++?

@mkarlesky
Copy link
Member

mkarlesky commented Jan 21, 2025

@Ash-BV First, a request. When you post configurations, please use code formatting. Project configuration posted as simple text is quite difficult to read. You can highlight code or configuration and then click or tap the code <> button in the editing toolbar. Or, you can use Markdown syntax as I am showing below.

```yaml
:project:
  <project configuration>
```

Second, there is a shortcut you can use to change just the executable for a tool definition [documentation]. For your specific request of running g++ with GCov, it would look like this:

:tools_gcov_compiler:
   :executable: g++

:tools_gcov_linker:
   :executable: g++

I have not tested this configuration to see if running g++ with coverage options will produce what you want. It may take additional configuration to successfully mix C and C++ conventions and code.

@mvandervoord mvandervoord changed the title Verify YAML File for Testing C++ Files and Generating Report GCOV Fails to use g++? Jan 23, 2025
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

No branches or pull requests

3 participants