~myrrc/tinycov

Code coverage library for C/C++ projects compiled by clang
re-add python symbolizer
trying test writing
calc only visited stats

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~myrrc/tinycov
read/write
git@git.sr.ht:~myrrc/tinycov

You can also use your local clone with git send-email.

#tinycov

A code coverage library for C/C++ projects. It can be used to obtain visited functions, basic blocks, and lines. tinycov is targeted at gathering and displaying multiple test reports at once.

#caveats

  1. Works only with ELF binaries built by clang for Unix.
  2. Full recompilation of project is needed.

#usage

  • Insert coverage callbacks.
  • Build target binary with coverage runtime:
    • Build with -O0 -g.
    • Link with libtinycov-runtime.a.
    • Pass -fpass-plugin=libtinycov-pass.so to clang if you don't have exclude paths.
    • Pass -Xclang -load -Xclang libtinycov-pass.so -fpass-plugin=libtinycov-pass.so -mllvm --tc-exclude='exclude_regex' otherwise (why you have to duplicate library name).
  • After running target binary, run python3 symbolize.py [report] [notes_dir] to get JSON with per-test statistics. Set TC_LINESET=1 environment variable if you need visited and not visited lines (only aggregated statistics will be displayed otherwise).

When in doubt, refer to examples/ folder.

#excluding paths

exclude_regex is POSIX ERE. Please note that file paths checked against regex may be relative or absolute, and that depends entirely on your build system.

#structure of packages

apt install libxxhash-dev clang-15
LLVM_CONFIG=llvm-config-15 make

You can use other versions of clang/llvm.

Do not follow this link