Commit 4c186748 authored by Steffen Jaeckel's avatar Steffen Jaeckel Committed by Derek Konigsberg

Add coverage make target

Which runs the tests and creates code coverage using lcov

Excluded upstream and generated source files from coverage report

Closes #1
parent a91cf1eb
......@@ -30,6 +30,20 @@ IF(HAVE_MEMSET_S)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_MEMSET_S=1")
ENDIF(HAVE_MEMSET_S)
IF(COVERAGE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
SET(LINK_FLAGS "${LINK_FLAGS} -fprofile-arcs -ftest-coverage")
add_custom_command(OUTPUT run_coverage
COMMAND ctest
COMMAND lcov -q --capture --directory src --output-file coverage.info.total
COMMAND lcov -q --remove coverage.info.total 'vpool.*' 'ut*.h' '*.pb-c.*' 'protobuf-c/*' 'curve25519/*' --output-file coverage.info
COMMAND genhtml -q coverage.info --output-directory coverage
COMMENT Collecting and creating coverage information
)
add_custom_target( coverage DEPENDS run_coverage )
ENDIF(COVERAGE)
add_subdirectory(src)
IF(BUILD_TESTING)
......
......@@ -10,13 +10,15 @@ environments. See the [Java library](https://github.com/whispersystems/libaxolot
### Build dependencies
* [CMake](http://www.cmake.org/) 2.8.4 or higher
* [Check](http://check.sourceforge.net/)
* [OpenSSL](https://www.openssl.org/) 1.0 or higher
* [Check *1](http://check.sourceforge.net/)
* [OpenSSL *1](https://www.openssl.org/) 1.0 or higher
* [LCOV *2](http://ltp.sourceforge.net/coverage/lcov.php)
Most of these dependencies are required just for the unit test suite and
development of the library itself. When integrating into actual applications,
you should not need anything beyond CMake. Alternatively, you may integrate
the code using a build system of your choice.
Items marked with *1 are required for tests, with *2 are additionaliy required for code coverage.
### Setting up a fresh source tree
......@@ -29,8 +31,17 @@ the code using a build system of your choice.
### Running the unit tests
$ cd /path/to/libaxolotl-c/build
$ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=1 ..
$ ctest
### Creating the code coverage
$ cd /path/to/libaxolotl-c/build
$ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=1 -DCOVERAGE=1 ..
$ make coverage
And find the generated code coverage in `/path/to/libaxolotl-c/build/coverage`
### Eclipse project setup
CMake provides a tutorial on Eclipse project setup here:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment