Ceedling icon indicating copy to clipboard operation
Ceedling copied to clipboard

gcov outputs result twice in text mode

Open ErdlingProductions opened this issue 4 years ago • 2 comments

Hello,

when using gcov in text mode, the resulting code coverage is shown twice. I noticed in my regular project and replicated in a minimal example, which is attached. It does not happen, when I create an html output.

test_gcc_compile.zip

The output looks like this:

Test 'test_add.c'
-----------------
Running test_add.out...
Creating gcov results report(s) in 'build/artifacts/gcov'... Done in 0.104 seconds.
------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                    Branches   Taken  Cover   Missing
------------------------------------------------------------------------------
src/add.c                                      0       0    --%   
------------------------------------------------------------------------------
TOTAL                                          0       0    --%
------------------------------------------------------------------------------
Creating a gcov text report... Done in 0.098 seconds.
------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                    Branches   Taken  Cover   Missing
------------------------------------------------------------------------------
src/add.c                                      0       0    --%   
------------------------------------------------------------------------------
TOTAL                                          0       0    --%
------------------------------------------------------------------------------

--------------------------
GCOV: OVERALL TEST SUMMARY
--------------------------
TESTED:  1
PASSED:  1
FAILED:  0
IGNORED: 0


---------------------------
GCOV: CODE COVERAGE SUMMARY
---------------------------
add.c Lines executed:100.00% of 2
add.c No branches
add.c No calls
add.c Lines executed:100.00% of 2

Is this a bug or an issue with my setup? Thanks and BR

ErdlingProductions avatar Nov 16 '21 07:11 ErdlingProductions

Hi @ErdlingProductions ,

I checked your project.yml file. I think you are missing ':text_artifact_filename: ' in gcovr configuration section. Referring to documentation: https://github.com/ThrowTheSwitch/Ceedling/blob/master/plugins/gcov/README.md#text-reports

the gcov configuration should look this way.



:gcov:
  :gcovr:
    # Text report filename.
    # The text report is printed to the console when no filename is provided.
    :text_artifact_filename: <output>


Second thing: Why do we see twice output. In case of text format, the Ceedling is mostly running test twice. The first call of the tests is done in : https://github.com/ThrowTheSwitch/Ceedling/blob/master/plugins/gcov/lib/gcovr_reportinator.rb#L32 the second call of the tests is done in: https://github.com/ThrowTheSwitch/Ceedling/blob/master/plugins/gcov/lib/gcovr_reportinator.rb#L59


About your case ( BUG in Ceedling):

I think your case is somehow unique. As you didn't pass in your project.yml any other report formats, and you did not pass the file name. So we mostly see twice the same information.

I think the additional call of TEXT was added as debug option, to print lets say in CI, more readable log output from gcov analysis run.

Solution to bug:

There might be added additional filter check, wherever the args created in : https://github.com/ThrowTheSwitch/Ceedling/blob/master/plugins/gcov/lib/gcovr_reportinator.rb#L26

looks similar to args created and passed to run under TEXT section: https://github.com/ThrowTheSwitch/Ceedling/blob/master/plugins/gcov/lib/gcovr_reportinator.rb#L271

If yes, the second run might not have any sens, as it will duplicate similar run, which was done previously in ln: https://github.com/ThrowTheSwitch/Ceedling/blob/master/plugins/gcov/lib/gcovr_reportinator.rb#L32

lukzeg avatar Jan 02 '23 16:01 lukzeg

Hi @ErdlingProductions,

The fix for described by you issue was merged. Can you check it latest master branch and confirm, if the problem was fixed in your opinion? If yes, can you close this topic?

lukzeg avatar Jan 24 '23 09:01 lukzeg