Skip to main content

FramaCovr

FramaCovr turns the JSON coverage reports emitted by the Frama-C metrics plugin into a gcovr compliant JSON report.

The resulting file can then be consumed by gcovr itself in order to produce an HTML report, a SonarQube coverage import file, a Cobertura report, and so on.

Usage

framacovr \
  --framac-metrics-files given-framac-run-metrics-coverage.json \
                         another-framac-run-metrics-coverage.json \
  --source-dirs kernel/src kernel/include \
  --source-root . \
  -o framacovr.json

Then, with gcovr:

mkdir -p coverage-html
gcovr \
  --root . \
  --json-add-tracefile framacovr.json \
  --html-details coverage-html/coverage.html
gcovr \
  --root . \
  --json-add-tracefile framacovr.json \
  --sonarqube coverage.xml
gcovr \
  --root . \
  --json-add-tracefile framacovr.json \
  --txt

Use the same directory for FraMaCovr --source-root and gcovr --root so that gcovr can resolve the source paths written in the JSON report. The --html-details output path also controls where gcovr writes the generated HTML, CSS and per-file pages.

FraMaCovr options

Option Description
--framac-metrics-files FILE... Frama-C metrics reports in JSON format
--source-dirs DIR... Directories holding the analysed .c and .h files.
--source-root DIR Directory to strip from source paths written in the gcovr report, . by default.
-o, --output FILE Destination of the gcovr report, absolute or relative to the current directory, framacovr.json by default.
--gcovr-format-version VERSION gcovr JSON format version to emit, 0.6 by default (gcovr 7.x).
-v, --verbose Increase verbosity, may be repeated.

gcovr options used above

Option Description
--root DIR Root directory used by gcovr to resolve source paths from the JSON report. Use the same value as --source-root.
--json-add-tracefile FILE Read the JSON tracefile generated by FraMaCovr.
--html-details FILE Generate the HTML report with per-file detail pages next to the given output file.
--sonarqube FILE Export the same coverage data to SonarQube XML.
--txt Print a text summary, useful to verify the total coverage percentage.

How it works

  1. Each metrics report is read. The defined-functions node provides the number of calls of every reached symbol, and the entry-points node lists the traversed symbols.
  2. Frama-C symbol instances are canonicalised: a _<n> suffix denotes a static instance and a __fc_inline_<n> suffix a static inline one. All the instances of a given function are merged into a single entry, and their call counts are summed.
  3. The source directories are walked and parsed with tree-sitter and its C grammar, in order to bind each function name to its implementation file and to its executable source lines.
  4. A gcovr JSON document is emitted. A function called at least once is considered covered, and all its executable lines carry its call count. Source paths are reported relatively to --source-root, which defaults to the current working directory.

Limitations

  • Frama-C only provides a function level coverage. Line counts are therefore uniform inside a function, and no branch, condition or decision coverage is reported.
  • Sources are parsed without being preprocessed. When a function has several variants guarded by #if/#else in the same file, only the first one is reported.
  • A static function defined with the same name in several translation units cannot be distinguished from the metrics output. The merged call count is then reported for each implementation.
  • Functions reported by Frama-C but implemented outside of the given source directories (libc stubs, builtins, specified-only-functions) are not part of the report. Run with -v to get their number.

Development

The project requires Python 3.11 or newer. Run all quality checks with:

tox

Build the source and wheel distributions with:

python -m build

License

FraMaCovr is distributed under the Apache License 2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

framacovr-0.1-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file framacovr-0.1-py3-none-any.whl.

File metadata

  • Download URL: framacovr-0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for framacovr-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 14918bb70b84b76988c9a1a8303a20bae0a724945a682b8b4584143eba1e2515
MD5 e9ef12c59d086c189792155d181d4522
BLAKE2b-256 54328c81a1b69b96abd8e00aff421815e622d38df544f8a7fa3b90e3571dced0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page