Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ misc/systemd/*.service
*.gcno
*.gcda
*.trace
cfengine-lcov-base.info
cfengine-lcov.info
coverage-html/
coverage/

# links
/nova
Expand Down
20 changes: 20 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,26 @@ Tip: In order to trigger assert() calls in the code, build with
`--enable-debug` (passed to either `./autogen.sh` or `./configure`). If you get
very large binary sizes you can also pass `CFLAGS='-g -O0'` to reduce that.

Code Coverage
-------------
We strive to always increase code coverage. If you wish to generate code
coverage information then you must autogen or configure with --enable-debug
and --enable-coverage as well as ensure lcov is installed (typically an lcov
package is available in a distribution).
We use gcov to instrument and process coverage information. .gcno files are
generated at compile-time and will not be regenerated if the source code
does not change. So be careful about cleaning those files. .gcda files are
like index files which can be used to generate the .gcov files which lcov
uses to generate lcov.info and the HTML report in the coverage-html directory.
Many IDEs and editors expect a <root>/coverage/lcov.info summary of coverage
information. After running `make check` you can run `make coverage` and
generate this lcov.info summary for use with other tools. If you wish to only
run a few tests which will add to coverage data you can update lcov.info with
`make collect-coverage` which will only collect coverage data, not compile or
run any tests.

For the atom editor, install the package atom-lcov-info.


Unsafe Tests
------------
Expand Down
12 changes: 7 additions & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ run-coverage:


collect-coverage:
$(LCOV) $(LCOV_FLAGS) --capture --initial --directory . --output-file cfengine-lcov-base.info
$(LCOV) $(LCOV_FLAGS) --capture --directory . --output-file cfengine-lcov.info --test-name CFENGINE --no-checksum --compat-libtool
$(LCOV) $(LCOV_FLAGS) -a cfengine-lcov-base.info -a cfengine-lcov.info --output-file cfengine-lcov.info
$(LCOV) $(LCOV_FLAGS) --remove cfengine-lcov.info '/usr/include/*' --output-file cfengine-lcov.info
LANG=C $(LCOV_GENHTML) $(LCOV_FLAGS) --prefix . --output-directory coverage-html --title "CFEngine Code Coverage" --legend --show-details cfengine-lcov.info
mkdir -p coverage
$(LCOV) $(LCOV_FLAGS) --capture --initial --directory . --output-file coverage/cfengine-lcov-base.info
$(LCOV) $(LCOV_FLAGS) --capture --directory . --output-file coverage/lcov.info --test-name CFENGINE --no-checksum --compat-libtool
$(LCOV) $(LCOV_FLAGS) -a coverage/cfengine-lcov-base.info -a coverage/lcov.info --output-file coverage/cfengine-lcov.info
$(LCOV) $(LCOV_FLAGS) --remove coverage/lcov.info '/usr/include/*' --output-file coverage/lcov.info
LANG=C $(LCOV_GENHTML) $(LCOV_FLAGS) --prefix . --output-directory coverage-html --title "CFEngine Code Coverage" --legend --show-details coverage/lcov.info
@echo
@echo " Code coverage information: file://"`pwd`"/coverage-html/index.html"
@echo " Code coverage summary for IDEs: file://"`pwd`"/coverage/lcov.info"
@echo

coverage: clean-coverage run-coverage collect-coverage
Expand Down