mirror of
https://github.com/optim-enterprises-bv/nDPId-2.git
synced 2025-10-29 17:32:27 +00:00
CMake: add coverage-clean target and fix coverage dependency issue.
* improve/fix README Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
@@ -239,6 +239,11 @@ if(ENABLE_COVERAGE)
|
||||
COMMAND genhtml -o "${CMAKE_BINARY_DIR}/coverage_report" "${CMAKE_BINARY_DIR}/lcov.info"
|
||||
DEPENDS nDPId nDPId-test nDPIsrvd
|
||||
)
|
||||
add_custom_target(coverage-clean)
|
||||
add_custom_command(
|
||||
TARGET coverage-clean
|
||||
COMMAND find "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/libnDPI" -name "*.gcda" -delete
|
||||
)
|
||||
add_custom_target(coverage-view)
|
||||
add_custom_command(
|
||||
TARGET coverage-view
|
||||
@@ -460,6 +465,9 @@ if(BUILD_EXAMPLES)
|
||||
"${GCRYPT_LIBRARY}" "${GCRYPT_ERROR_LIBRARY}" "${PCAP_LIBRARY}")
|
||||
|
||||
add_executable(nDPIsrvd-analysed examples/c-analysed/c-analysed.c utils.c)
|
||||
if(BUILD_NDPI)
|
||||
add_dependencies(nDPIsrvd-analysed libnDPI)
|
||||
endif()
|
||||
target_compile_definitions(nDPIsrvd-analysed PRIVATE ${NDPID_DEFS})
|
||||
target_include_directories(nDPIsrvd-analysed PRIVATE
|
||||
"${STATIC_LIBNDPI_INC}" "${DEFAULT_NDPI_INCLUDE}" "${CMAKE_SOURCE_DIR}" ${NDPID_DEPS_INC})
|
||||
@@ -469,7 +477,7 @@ if(BUILD_EXAMPLES)
|
||||
target_include_directories(nDPIsrvd-simple PRIVATE ${NDPID_DEPS_INC})
|
||||
|
||||
if(ENABLE_COVERAGE)
|
||||
add_dependencies(coverage nDPIsrvd-analysed nDPIsrvd-collectd nDPIsrvd-captured nDPIsrvd-simple)
|
||||
add_dependencies(coverage libnDPI nDPIsrvd-analysed nDPIsrvd-collectd nDPIsrvd-captured nDPIsrvd-simple)
|
||||
endif()
|
||||
|
||||
if(ENABLE_DBUS)
|
||||
|
||||
54
README.md
54
README.md
@@ -193,9 +193,10 @@ ccmake ..
|
||||
or to build with a staticially linked libnDPI:
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DSTATIC_LIBNDPI_INSTALLDIR=[path/to/your/libnDPI/installdir] -DNDPI_NO_PKGCONFIG=ON
|
||||
cmake -S . -B ./build \
|
||||
-DSTATIC_LIBNDPI_INSTALLDIR=[path/to/your/libnDPI/installdir] \
|
||||
-DNDPI_NO_PKGCONFIG=ON
|
||||
cmake --build ./build
|
||||
```
|
||||
|
||||
If you use the latter, make sure that you've configured libnDPI with `./configure --prefix=[path/to/your/libnDPI/installdir]`
|
||||
@@ -205,17 +206,19 @@ You'll also need to use `-DNDPI_NO_PKGCONFIG=ON` if `STATIC_LIBNDPI_INSTALLDIR`
|
||||
e.g.:
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DSTATIC_LIBNDPI_INSTALLDIR=[path/to/your/libnDPI/installdir] -DNDPI_WITH_GCRYPT=ON -DNDPI_WITH_PCRE=OFF -DNDPI_WITH_MAXMINDDB=OFF
|
||||
cmake -S . -B ./build \
|
||||
-DSTATIC_LIBNDPI_INSTALLDIR=[path/to/your/libnDPI/installdir] \
|
||||
-DNDPI_NO_PKGCONFIG=ON \
|
||||
-DNDPI_WITH_GCRYPT=ON -DNDPI_WITH_PCRE=OFF -DNDPI_WITH_MAXMINDDB=OFF
|
||||
cmake --build ./build
|
||||
```
|
||||
|
||||
Or let a shell script do the work for you:
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DBUILD_NDPI=ON
|
||||
cmake -S . -B ./build \
|
||||
-DBUILD_NDPI=ON
|
||||
cmake --build ./build
|
||||
```
|
||||
|
||||
The CMake cache variable `-DBUILD_NDPI=ON` builds a version of `libnDPI` residing as a git submodule in this repository.
|
||||
@@ -312,24 +315,35 @@ Format: `subopt` (unit, comment): description
|
||||
The recommended way to run regression / diff tests:
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DBUILD_NDPI=ON
|
||||
make nDPId-test test
|
||||
cmake -S . -B ./build-like-ci \
|
||||
-DBUILD_NDPI=ON -DENABLE_ZLIB=ON -DBUILD_EXAMPLES=ON
|
||||
# optional: -DENABLE_CURL=ON -DENABLE_SANITIZER=ON
|
||||
./test/run_tests.sh ./libnDPI ./build-like-ci/nDPId-test
|
||||
# or: make -C ./build-like-ci test
|
||||
```
|
||||
|
||||
Alternatively you can run some integration tests manually:
|
||||
|
||||
`./test/run_tests.sh [/path/to/libnDPI/root/directory] [/path/to/nDPId-test]`
|
||||
|
||||
e.g.:
|
||||
|
||||
`./test/run_tests.sh "${HOME}/git/nDPI "${HOME}/git/nDPId/build/nDPId-test"`
|
||||
Run `./test/run_tests.sh` to see some usage information.
|
||||
|
||||
Remember that all test results are tied to a specific libnDPI commit hash
|
||||
as part of the `git submodule`. Using `test/run_tests.sh` for other commit hashes
|
||||
will most likely result in PCAP diffs.
|
||||
|
||||
# Code Coverage
|
||||
|
||||
You may generate code coverage by using:
|
||||
|
||||
```shell
|
||||
cmake -S . -B ./build-coverage \
|
||||
-DENABLE_COVERAGE=ON -DENABLE_ZLIB=ON
|
||||
# optional: -DBUILD_NDPI=ON
|
||||
make -C ./build-coverage coverage-clean
|
||||
make -C ./build-coverage clean
|
||||
make -C ./build-coverage all
|
||||
./test/run_tests.sh ./libnDPI ./build-coverage/nDPId-test
|
||||
make -C ./build-coverage coverage
|
||||
make -C ./build-coverage coverage-view
|
||||
```
|
||||
|
||||
# Contributors
|
||||
|
||||
Special thanks to Damiano Verzulli ([@verzulli](https://github.com/verzulli)) from [GARRLab](https://www.garrlab.it) for providing server and test infrastructure.
|
||||
|
||||
Reference in New Issue
Block a user