Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-33484

Code coverage can't distinguish between files with identical names

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v3.6, v3.4
    • Sprint:
      TIG 2018-03-26

      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:

      [2018/02/26 09:28:29.035] File 'src/mongo/db/session.cpp'
      [2018/02/26 09:28:29.035] Lines executed:9.39% of 330
      ......
      [2018/02/26 09:28:31.500] File 'src/mongo/scripting/mozjs/session.cpp'
      [2018/02/26 09:28:31.500] Lines executed:90.70% of 43
      ......
      [2018/02/26 09:28:32.055] File 'src/mongo/transport/session.cpp'
      [2018/02/26 09:28:32.055] Lines executed:52.94% of 17
      

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: