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
- Each
metricsreport is read. Thedefined-functionsnode provides the number of calls of every reached symbol, and theentry-pointsnode lists the traversed symbols. - Frama-C symbol instances are canonicalised: a
_<n>suffix denotes astaticinstance and a__fc_inline_<n>suffix astatic inlineone. All the instances of a given function are merged into a single entry, and their call counts are summed. - 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.
- 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/#elsein the same file, only the first one is reported. - A
staticfunction defined with the same name in several translation units cannot be distinguished from themetricsoutput. 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-vto 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14918bb70b84b76988c9a1a8303a20bae0a724945a682b8b4584143eba1e2515
|
|
| MD5 |
e9ef12c59d086c189792155d181d4522
|
|
| BLAKE2b-256 |
54328c81a1b69b96abd8e00aff421815e622d38df544f8a7fa3b90e3571dced0
|