Giter Club home page Giter Club logo

Comments (10)

cbagwell avatar cbagwell commented on May 20, 2024

Digging a little deeper, this appears to be a bigger issue for autotools based packages as apposed to the hand coded single test Makefile in gcovr/tests/nested. If you use a single Makefile to compile, the subdir paths get embedded into objects and gcov reports.

If you have a package that uses automake then you tend to have a Makefile per subdirectory and the path names no longer get embedded and generating all gcov reports in starting_dir will greatly confuse gcovr.

To help see issue, I modified nested test to have a Makefile in subdir/A and subdir/Makefile to link in those precompiled objects. Here is result of gcovr from that modifications. Notice how most items under subdir/A are missing from report:

$ ../../../../scripts/gcovr -r . -k -v
Scanning directory . for gcda/gcno files...
Found 12 files (and will process 9)
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/B/main.gcno --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/B' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file2.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file7.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file1.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/file5.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/file5.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A/C'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/file5.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A'
Parsing coverage data for file /home/test/src/gcovr/gcovr/tests/n/subdir/C/file5.cpp
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file4.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/main.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Parsing coverage data for file /home/test/src/gcovr/gcovr/tests/n/subdir/main.cpp
Parsing coverage data for file /usr/include/c++/4.8.3/iostream
  Filtering coverage data for file /usr/include/c++/4.8.3/iostream
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D/file6.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D/file6.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D/file6.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A/C'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D/file6.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A'
Parsing coverage data for file /home/test/src/gcovr/gcovr/tests/n/subdir/C/D/file6.cpp
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file3.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Gathered coveraged data for 3 files
------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: /home/test/src/gcovr/gcovr/tests/n/subdir
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
C/D/file6.cpp                                  4       3    75%   4
C/file5.cpp                                    4       3    75%   4
main.cpp                                       9       9   100%   
------------------------------------------------------------------------------
TOTAL                                         17      15    88%
------------------------------------------------------------------------------
$ ls -R
.:
A/                  main.cpp       Makefile
B/                  main.cpp.gcov  testcase*
C#D#file6.cpp.gcov  main.gcda      #usr#include#c++#4.8.3#iostream.gcov
C#file5.cpp.gcov    main.gcno
coverage.txt        main.o

./A:
C/                  file1.gcda  file2.o     file4.cpp   file7.gcda
C#D#file6.cpp.gcov  file1.o     file3.cpp   file4.gcda  file7.o
C#file5.cpp.gcov    file2.cpp   file3.gcda  file4.o     Makefile
file1.cpp           file2.gcda  file3.o     file7.cpp

./A/C:
C#D#file6.cpp.gcov  D/         file5.gcda  file5.o
C#file5.cpp.gcov    file5.cpp  file5.gcno

./A/C/D:
C#D#file6.cpp.gcov  file6.cpp  file6.gcda  file6.gcno  file6.o

./B:
main.cpp  main.gcno  main.o

from gcovr.

whart222 avatar whart222 commented on May 20, 2024

Given the difference that you note, is this a gcovr issue or a gcov issue?
I'm wondering if gcov is providing gcovr information that confuses these
files.

Can you provide a test example that we can use to motivate a fix?

On Sun, Aug 3, 2014 at 5:27 PM, Chris Bagwell [email protected]
wrote:

Digging a little deeper, this appears to be a bigger issue for autotools
based packages as apposed to the hand coded single test Makefile in
gcovr/tests/nested. If you use a single Makefile to compile, the subdir
paths get embedded into objects and gcov reports.

If you have a package that uses automake then you tend to have a Makefile
per subdirectory and the path names no longer get embedded and generating
all gcov reports in starting_dir will greatly confuse gcovr.

To help see issue, I modified nested test to have a Makefile in subdir/A
and subdir/Makefile to link in those precompiled objects. Here is result of
gcovr from that modifications. Notice how most items under subdir/A are
missing from report:

$ ../../../../scripts/gcovr -r . -k -v
Scanning directory . for gcda/gcno files...
Found 12 files (and will process 9)
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/B/main.gcno --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/B' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file2.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file7.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file1.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/file5.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/file5.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A/C'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/file5.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A'
Parsing coverage data for file /home/test/src/gcovr/gcovr/tests/n/subdir/C/file5.cpp
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file4.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/main.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Parsing coverage data for file /home/test/src/gcovr/gcovr/tests/n/subdir/main.cpp
Parsing coverage data for file /usr/include/c++/4.8.3/iostream
Filtering coverage data for file /usr/include/c++/4.8.3/iostream
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D/file6.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D' in '/home/test/src/gcovr/gcovr/tests/n/subdir'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D/file6.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D/file6.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A/C'
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D/file6.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A/C/D' in '/home/test/src/gcovr/gcovr/tests/n/subdir/A'
Parsing coverage data for file /home/test/src/gcovr/gcovr/tests/n/subdir/C/D/file6.cpp
Running gcov: 'gcov /home/test/src/gcovr/gcovr/tests/n/subdir/A/file3.gcda --branch-counts --branch-probabilities --preserve-paths --object-directory /home/test/src/gcovr/gcovr/tests/n/subdir/A' in '/home/test/src/gcovr/gcovr/tests/n/subdir'

Gathered coveraged data for 3 files

                       GCC Code Coverage Report

Directory: /home/test/src/gcovr/gcovr/tests/n/subdir

File Lines Exec Cover Missing

C/D/file6.cpp 4 3 75% 4
C/file5.cpp 4 3 75% 4

main.cpp 9 9 100%

TOTAL 17 15 88%

$ ls -R
.:
A/ main.cpp Makefile
B/ main.cpp.gcov testcase*
C#D#file6.cpp.gcov main.gcda #usr#include#c++#4.8.3#iostream.gcov
C#file5.cpp.gcov main.gcno
coverage.txt main.o

./A:
C/ file1.gcda file2.o file4.cpp file7.gcda
C#D#file6.cpp.gcov file1.o file3.cpp file4.gcda file7.o
C#file5.cpp.gcov file2.cpp file3.gcda file4.o Makefile
file1.cpp file2.gcda file3.o file7.cpp

./A/C:
C#D#file6.cpp.gcov D/ file5.gcda file5.o
C#file5.cpp.gcov file5.cpp file5.gcno

./A/C/D:
C#D#file6.cpp.gcov file6.cpp file6.gcda file6.gcno file6.o

./B:
main.cpp main.gcno main.o


Reply to this email directly or view it on GitHub
#60 (comment).

from gcovr.

cbagwell avatar cbagwell commented on May 20, 2024

I think its likely a gcovr issue with assuming the root of all compiles is starting_dir. I'm new to gcovr but it may have worked fine before 3.2 when it starting chdir()'ing before running gcov.

Let me find some time to package up a modified version of 'nested' example distributed with gcovr and we can go from there.

from gcovr.

mikael-s avatar mikael-s commented on May 20, 2024

Hi,
I do have the same issue (if I understand well what @cbagwell means). When having a Makefile by subdirectory, you end up with a report that completely removes all the subdirectories.

I created an example in 23b7d41 (highly inspired from the nested test). The current version of gcovr would produce that output (when launched with gcovr -r subdir)

------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: subdir/
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
B/main.cpp                                     9       9   100%   
------------------------------------------------------------------------------
TOTAL                                          9       9   100%
------------------------------------------------------------------------------

Or that output when launched with gcovr -r .

                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
file1.cpp                                      4       3    75%   4
file2.cpp                                      7       4    57%   8-11
file3.cpp                                      9       4    44%   8-14
file4.cpp                                      4       3    75%   6
file5.cpp                                      4       3    75%   4
file6.cpp                                      4       3    75%   4
file7.cpp                                      2       0     0%   1-3
subdir/B/main.cpp                              9       9   100%   
------------------------------------------------------------------------------
TOTAL                                         43      29    67%
------------------------------------------------------------------------------

The second case is better but still all the subdirectories are ignored (except for main.cpp). With my commit 6fa250f the output is now (when launching gcovr -r subdir):

                           GCC Code Coverage Report
Directory: subdir
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
A/C/D/file6.cpp                                4       3    75%   4
A/C/file5.cpp                                  4       3    75%   4
A/file1.cpp                                    4       3    75%   4
A/file2.cpp                                    7       4    57%   8,10-11
A/file3.cpp                                    9       4    44%   8,10-12,14
A/file4.cpp                                    4       3    75%   6
A/file7.cpp                                    2       0     0%   1,3
B/main.cpp                                     9       9   100%   
------------------------------------------------------------------------------
TOTAL                                         43      29    67%
------------------------------------------------------------------------------

which totally reflects the directory hierarchy.

However the tests in shared_lib now fails. I need help to understand if that's an issue or not. There is a difference in the coverage.txt, but my version seems better to me. There is also a difference in the coverage.xml file (in the package tag) but I'm unable to tell if the difference matters.

I think correcting this issue #60 is very important since it makes gcovr unusable with Cobertura plugins as soon as you have several Makefiles (which is not unusual with large projects).

from gcovr.

cbagwell avatar cbagwell commented on May 20, 2024

Thanks for creating a test case with issue, @mikael-s . I hadn't found time to push one myself.

Also, I see you have prototype fix for issue on your fix_nexted_makefiles branch. I had a similar work around that I've been using. For my case, I commented out the call to os.chdir() in process_gcov_data() and this 1 line change works for my nested Makefile cases. I'm guessing it causes other problems but lets me keep using Cobertura plugins.

from gcovr.

michaelgallacher avatar michaelgallacher commented on May 20, 2024

@cbagwell, just curious, which of the os.chdir() calls in process_gov_data did you comment out? I'd like to try it on my setup. Thx!

from gcovr.

cbagwell avatar cbagwell commented on May 20, 2024

I commented out only the first os.chdir() call in process_gcov_data(). The one that says os.chdir(starting_dir).

As kinda mentioned in comment #2, this os.chdir(starting_dir) means gcovr supports 1 Makefile that references files in nested subdirectories but doesn't handle well nested subdirectories with a Makefile per directory.

In former case, subdirectory info is stored in gcov data and so temp files are created of form $starting_dir/path#to#filename but in later case temp files are created of form $starting_dir/filename and thus risk overwriting each other.

Another bad thing that happens in later case is that since subdirectory names are missing, you also don't see them in gcovr reports and everything looks like its in root directory. Commenting out os.chdir(starting_dir) fixes that issue as well.

from gcovr.

michaelgallacher avatar michaelgallacher commented on May 20, 2024

Wow! Removing the os.chdir(starting_dir) solved several issues I was having. I still have the problem of a few duplicate header files, but the large majority were resolved. Also resolved was the issue where I specify a root directory and all the files show up in in a flat list. They now show up in relative directories. Seems like a nice change. I don't see a downside to it. Yet. :) Thanks!

from gcovr.

michaelgallacher avatar michaelgallacher commented on May 20, 2024

FYI, I found out what removing that line breaks. "--html-details" no longer works for me after removing the os.chdir(starting_dir).

from gcovr.

latk avatar latk commented on May 20, 2024

This issue has not seen any progress in a while, so I am closing it for now. If the problem persists, please add further details so it can be re-opened. If someone else is experiencing a similar issue, please create a new issue.

In particular, the test case added by @mikael-s in 23b7d41 seems to pass. If that test case does not describe the intended behaviour or if the test case did not reproduce the actual problem, please explain in more detail.
@cbagwell, you seem to understand this issue better than me. Does the problem still exist with an up to date gcovr?

from gcovr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.