Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • T TestCov
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Activity
  • Graph
  • Commits
Collapse sidebar
  • SoSy-Lab
  • Software
  • TestCov
  • Merge requests
  • !11

Resolve "Add proper branch coverage measurement"

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Max Wiesholler requested to merge 19-add-proper-branch-coverage-measurement into master Aug 30, 2019
  • Overview 0
  • Commits 4
  • Changes 8

Closes #19

If branch coverage is specified as goal, the program is instrumented by adding labels after program branches.

Unfortunately, an empty statement like BRANCH_1:; is fully ignored by llvm gcov and there exists no configuration to change this behaviour. To handle this problem, the instrumented program gets for each branch two new program lines with a goto statement and a label statement. The goto statement is noticed by llvm gcov. For instance:

if(x == 2){
  goto BRANCH_0;
  BRANCH_0:;
  ...
} else 
  goto BRANCH_1;
  BRANCH_1:;
  ...
...

If another coverage is specified (line coverage, condition coverage), branch coverage is None and the resulting coverage will always return zero as branch coverage.

Note: gcc with gcov/lcov notices empty statements. However, clang with llvm gcov should be still preferred. The tests in test_execution.py are adapted to clang with llvm gcov. A gcc gcov/lcov version outputs different coverage results compared to the llvm version that emulates gcov 4.2, for instance they differ when looking at lines with just a curly bracket. Moreover, gcc with gcov/lcov always shows coverage greater than zero for the lines in the last else statement in a program, even though these lines are never hit. This seems to be a bug.

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: 19-add-proper-branch-coverage-measurement