[SERVER-33484] Code coverage can't distinguish between files with identical names Created: 26/Feb/18 Updated: 29/Oct/23 Resolved: 21/Mar/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Testing Infrastructure |
| Affects Version/s: | 3.7.2 |
| Fix Version/s: | 3.4.15, 3.6.4, 3.7.4 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Robert Guo (Inactive) | Assignee: | Jonathan Abrahams |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Backwards Compatibility: | Fully Compatible | ||||
| Operating System: | ALL | ||||
| Backport Requested: |
v3.6, v3.4
|
||||
| Sprint: | TIG 2018-03-26 | ||||
| Participants: | |||||
| Description |
|
gcov generates coverage data files using the name of the source file by default, which is how we invoke it in etc/evergreen.yml This causes subsequent files of the same name to override previous coverage files. An example is session.cpp. In the mongo repo, there are three session.cpp files in the following directories respectively: src/mongo/db/, src/mongo/transport/, and src/mongo/scripting/mozjs/. When we gather the coverage information at the end of each Evergreen task with: /opt/mongodbtoolchain/v2/bin/gcov -i $gcda_file, a file called session.gcda.gcov is generated and placed at the top-level directory for each of the three session.cpp files. Subsequent files will override previous ones. As a result, only information about one session.cpp is retained; the lucky file is whichever one happens to be parsed last. This bug can easily be verified by looking at the task log for any code coverage Evergreen build and finding the following lines:
The above can be compared with the content of the content of the "gcov intermediate files - Execution 0" task artifact, which only has one session.gcda.gcov; opening up that file will show that it always corresponds to the last session.cpp We should use the --preserve-paths or the --hash-filenames flag to have the file names be unique. --hash-filenames seems like the better option to ensure the file names are short but is not supported on the version of gcov that we use. Thanks to siyuan.zhou for noticing this issue. |
| Comments |
| Comment by Githook User [ 05/Apr/18 ] | |||||||||||||||||||||||||||||
|
Author: {'email': 'jonathan@mongodb.com', 'name': 'Jonathan Abrahams', 'username': 'hptabster'}Message: (cherry picked from commit 220a857ffc84cf755fa7d387f19d537a249bd099) | |||||||||||||||||||||||||||||
| Comment by Githook User [ 05/Apr/18 ] | |||||||||||||||||||||||||||||
|
Author: {'email': 'jonathan@mongodb.com', 'name': 'Jonathan Abrahams', 'username': 'hptabster'}Message: (cherry picked from commit 220a857ffc84cf755fa7d387f19d537a249bd099) | |||||||||||||||||||||||||||||
| Comment by Githook User [ 21/Mar/18 ] | |||||||||||||||||||||||||||||
|
Author: {'email': 'jonathan@mongodb.com', 'name': 'Jonathan Abrahams', 'username': 'hptabster'}Message: | |||||||||||||||||||||||||||||
| Comment by Jonathan Abrahams [ 20/Mar/18 ] | |||||||||||||||||||||||||||||
|
Looks like we cannot use the --preserve-paths option, as it is not available when generating the intermediate file (using the --intermediate-format option). | |||||||||||||||||||||||||||||
| Comment by Max Hirschhorn [ 20/Mar/18 ] | |||||||||||||||||||||||||||||
jonathan.abrahams, I think Robert had made a similar realization that --hash-filenames is only available in versions of GCC newer than 6.4.
Given that we'd still be far from the 255 character limit on the filename for most filesystems even after mangling in the directories leading up to the file, I'd like to see if we can use the --preserve-paths command line option when invoking gcov on the .gcda file to address this issue for the time being.
| |||||||||||||||||||||||||||||
| Comment by Jonathan Abrahams [ 19/Mar/18 ] | |||||||||||||||||||||||||||||
|
The version of gcov that we have does not have the --hash-filenames option:
|