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

Coverage data lost for death tests

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Server Programmability
    • ALL

      We don't dump gcov data in (all?) death tests. For example, consider status_test.cpp. Coveralls reports no coverage of the lines inside death tests bodies here. Since death tests are often used to cover error paths and other hard-to-reach lines, this may lead to false gaps being reported in our coverage.

      You can observe this happening locally without involving coveralls as follows.

      1. Initialize ninja build with gcc using --gcov, for instance: ./buildscripts/scons.py --opt=debug --dbg=on --gcov --link-model=dynamic --variables-files=etc/scons/mongodbtoolchain_stable_gcc.vars --ninja ICECC=icecc CCACHE=ccache
      2. Build and run a test that has a death test, such as status_test: ninja -j200 +status_test
      3. Find out what directory the build occurred in and contains the gcda files. For example, find . -name "*.gcda" shows me that the build directory is ./build/71527b04
      4. Use gcovr (you may need to install it) to get coverage for the file containing the death test, in this case status_test.cpp: gcovr -f src/mongo/base/status_test.cpp build/71527b04
      5.  Check the "Missing" column, and notice that it reports the bodies of all death tests as uncovered.

      I think the issue is that death tests tend to die via invariant failure (leading to std::abort). This path doesn't call into the quickExit path here, which has taken some steps to ensure coverage data is dumped on exit. Taking similar steps on abort would ensure coverage is dumped in those cases.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ryan.berryhill@mongodb.com Ryan Berryhill
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: