diff --git a/cmake/ev-targets.cmake b/cmake/ev-targets.cmake index 2b1a5a73b..e0e82ad3c 100644 --- a/cmake/ev-targets.cmake +++ b/cmake/ev-targets.cmake @@ -6,6 +6,7 @@ set_target_properties(everest_targets PROPERTIES LIBRARIES "" MODULES "" + TESTS "" ) function(_ev_register_target TYPE NAME) @@ -28,6 +29,10 @@ function(ev_register_module_target NAME) _ev_register_target(MODULES ${NAME}) endfunction() +function(ev_register_test_target NAME) + _ev_register_target(TESTS ${NAME}) +endfunction() + function(ev_get_targets NAME TYPE) get_target_property(tmp everest_targets ${TYPE}) if (NOT tmp STREQUAL "" AND NOT tmp) diff --git a/lib/staging/can_dpm1000/CMakeLists.txt b/lib/staging/can_dpm1000/CMakeLists.txt index 5f0c54325..bf22387ac 100644 --- a/lib/staging/can_dpm1000/CMakeLists.txt +++ b/lib/staging/can_dpm1000/CMakeLists.txt @@ -1,5 +1,7 @@ add_library(can_dpm1000) add_library(can_protocols::dpm1000 ALIAS can_dpm1000) +ev_register_library_target(can_dpm1000) + target_include_directories(can_dpm1000 PUBLIC $ @@ -10,8 +12,6 @@ target_sources(can_dpm1000 src/dpm1000.cpp ) -ev_register_library_target(can_dpm1000) - if(BUILD_DEV_TESTS) add_subdirectory(tests) endif() diff --git a/lib/staging/evse_security/CMakeLists.txt b/lib/staging/evse_security/CMakeLists.txt index 6e12b99d7..d2ccc4ddb 100644 --- a/lib/staging/evse_security/CMakeLists.txt +++ b/lib/staging/evse_security/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(evse_security_conversions STATIC) add_library(everest::evse_security_conversions ALIAS evse_security_conversions) +ev_register_library_target(evse_security_conversions) target_sources(evse_security_conversions PRIVATE @@ -19,5 +20,3 @@ target_link_libraries(evse_security_conversions everest::evse_security everest::framework ) - -ev_register_library_target(evse_security_conversions) diff --git a/lib/staging/external_energy_limits/CMakeLists.txt b/lib/staging/external_energy_limits/CMakeLists.txt index d57215bf6..d2bf6957b 100644 --- a/lib/staging/external_energy_limits/CMakeLists.txt +++ b/lib/staging/external_energy_limits/CMakeLists.txt @@ -2,6 +2,7 @@ add_library(external_energy_limits STATIC) add_library(everest::external_energy_limits ALIAS external_energy_limits) +ev_register_library_target(external_energy_limits) target_sources(external_energy_limits PRIVATE @@ -20,5 +21,3 @@ target_link_libraries(external_energy_limits PRIVATE everest::framework ) - -ev_register_library_target(external_energy_limits) diff --git a/lib/staging/gpio/CMakeLists.txt b/lib/staging/gpio/CMakeLists.txt index 639b9b8d4..6a73be477 100644 --- a/lib/staging/gpio/CMakeLists.txt +++ b/lib/staging/gpio/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(gpio STATIC) add_library(everest::gpio ALIAS gpio) +ev_register_library_target(gpio) target_sources(gpio PRIVATE @@ -14,6 +15,3 @@ target_include_directories(gpio target_link_libraries(gpio PRIVATE ) - -ev_register_library_target(gpio) - diff --git a/lib/staging/helpers/CMakeLists.txt b/lib/staging/helpers/CMakeLists.txt index 1cf52d724..932ffae54 100644 --- a/lib/staging/helpers/CMakeLists.txt +++ b/lib/staging/helpers/CMakeLists.txt @@ -2,6 +2,7 @@ add_library(everest_staging_helpers STATIC) add_library(everest::staging::helpers ALIAS everest_staging_helpers) +ev_register_library_target(everest_staging_helpers) target_sources(everest_staging_helpers PRIVATE @@ -32,8 +33,6 @@ target_link_libraries(everest_staging_helpers add_dependencies(everest_staging_helpers generate_cpp_files) -ev_register_library_target(everest_staging_helpers) - if (BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/lib/staging/helpers/tests/CMakeLists.txt b/lib/staging/helpers/tests/CMakeLists.txt index 217f72525..220de6dcd 100644 --- a/lib/staging/helpers/tests/CMakeLists.txt +++ b/lib/staging/helpers/tests/CMakeLists.txt @@ -13,3 +13,5 @@ target_link_libraries(${TEST_TARGET_NAME} include(GoogleTest) gtest_discover_tests(${TEST_TARGET_NAME}) + +ev_register_test_target(${TEST_TARGET_NAME}) diff --git a/lib/staging/ocpp/CMakeLists.txt b/lib/staging/ocpp/CMakeLists.txt index dd7682b6a..e83c80cad 100644 --- a/lib/staging/ocpp/CMakeLists.txt +++ b/lib/staging/ocpp/CMakeLists.txt @@ -2,6 +2,7 @@ add_library(ocpp_evse_security STATIC) add_library(everest::ocpp_evse_security ALIAS ocpp_evse_security) +ev_register_library_target(ocpp_evse_security) target_sources(ocpp_evse_security PRIVATE @@ -28,13 +29,12 @@ target_link_libraries(ocpp_evse_security everest::framework ) -ev_register_library_target(ocpp_evse_security) - # OCPP conversions add_library(ocpp_conversions STATIC) add_library(everest::ocpp_conversions ALIAS ocpp_conversions) +ev_register_library_target(ocpp_conversions) target_sources(ocpp_conversions PRIVATE @@ -60,6 +60,3 @@ target_link_libraries(ocpp_conversions everest::ocpp everest::framework ) - -ev_register_library_target(ocpp_conversions) - diff --git a/lib/staging/slac/fsm/ev/CMakeLists.txt b/lib/staging/slac/fsm/ev/CMakeLists.txt index 822bd1a95..e9ab9aa2c 100644 --- a/lib/staging/slac/fsm/ev/CMakeLists.txt +++ b/lib/staging/slac/fsm/ev/CMakeLists.txt @@ -1,5 +1,7 @@ add_library(slac_fsm_ev) add_library(slac::fsm::ev ALIAS slac_fsm_ev) +ev_register_library_target(slac_fsm_ev) + target_include_directories(slac_fsm_ev PUBLIC $ @@ -17,5 +19,3 @@ target_link_libraries(slac_fsm_ev slac::slac fsm::fsm ) - -ev_register_library_target(slac_fsm_ev) diff --git a/lib/staging/slac/fsm/evse/CMakeLists.txt b/lib/staging/slac/fsm/evse/CMakeLists.txt index 8e673c815..45c0f76ac 100644 --- a/lib/staging/slac/fsm/evse/CMakeLists.txt +++ b/lib/staging/slac/fsm/evse/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(slac_fsm_evse) add_library(slac::fsm::evse ALIAS slac_fsm_evse) +ev_register_library_target(slac_fsm_evse) target_include_directories(slac_fsm_evse PUBLIC @@ -20,5 +21,3 @@ target_link_libraries(slac_fsm_evse slac::slac fsm::fsm ) - -ev_register_library_target(slac_fsm_evse) diff --git a/lib/staging/slac/io/CMakeLists.txt b/lib/staging/slac/io/CMakeLists.txt index f9e3d4de7..81927f122 100644 --- a/lib/staging/slac/io/CMakeLists.txt +++ b/lib/staging/slac/io/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(slac_io) add_library(slac::io ALIAS slac_io) +ev_register_library_target(slac_io) target_include_directories(slac_io PUBLIC @@ -15,5 +16,3 @@ target_link_libraries(slac_io PUBLIC slac::slac ) - -ev_register_library_target(slac_io) diff --git a/lib/staging/tls/CMakeLists.txt b/lib/staging/tls/CMakeLists.txt index 53ebc8700..611029a0c 100644 --- a/lib/staging/tls/CMakeLists.txt +++ b/lib/staging/tls/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(tls STATIC) add_library(everest::tls ALIAS tls) +ev_register_library_target(tls) find_package(OpenSSL 3) @@ -35,5 +36,3 @@ target_link_libraries(tls if(EVEREST_CORE_BUILD_TESTING) add_subdirectory(tests) endif() - -ev_register_library_target(tls) diff --git a/lib/staging/tls/tests/CMakeLists.txt b/lib/staging/tls/tests/CMakeLists.txt index 00f69ef81..82517b489 100644 --- a/lib/staging/tls/tests/CMakeLists.txt +++ b/lib/staging/tls/tests/CMakeLists.txt @@ -140,3 +140,4 @@ target_link_libraries(${TLS_PATCH_NAME} ) add_test(${TLS_GTEST_NAME} ${TLS_GTEST_NAME}) +ev_register_test_target(${TLS_GTEST_NAME}) diff --git a/lib/staging/util/CMakeLists.txt b/lib/staging/util/CMakeLists.txt index 8b61985bf..5271d7774 100644 --- a/lib/staging/util/CMakeLists.txt +++ b/lib/staging/util/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(everest_staging_util INTERFACE) add_library(everest::staging::util ALIAS everest_staging_util) +ev_register_library_target(everest_staging_helpers) target_include_directories(everest_staging_util INTERFACE @@ -9,5 +10,3 @@ target_include_directories(everest_staging_util if (BUILD_TESTING) add_subdirectory(tests) endif() - -ev_register_library_target(everest_staging_helpers) diff --git a/modules/API/tests/CMakeLists.txt b/modules/API/tests/CMakeLists.txt index b3519bf91..2241b8bd9 100644 --- a/modules/API/tests/CMakeLists.txt +++ b/modules/API/tests/CMakeLists.txt @@ -17,3 +17,4 @@ target_link_libraries(${TEST_TARGET_NAME} PRIVATE ) add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) +ev_register_test_target(${TEST_TARGET_NAME}) diff --git a/modules/Auth/lib/CMakeLists.txt b/modules/Auth/lib/CMakeLists.txt index 0e56410a1..975affdea 100644 --- a/modules/Auth/lib/CMakeLists.txt +++ b/modules/Auth/lib/CMakeLists.txt @@ -1,6 +1,7 @@ set(INCLUDE_DIR "${PROJECT_SOURCE_DIR}/modules/Auth/include") add_library(auth_handler STATIC) +ev_register_library_target(auth_handler) target_sources(auth_handler PRIVATE AuthHandler.cpp @@ -35,5 +36,3 @@ if(EVEREST_ENABLE_COMPILE_WARNINGS) PRIVATE ${EVEREST_COMPILE_OPTIONS} ) endif() - -ev_register_library_target(auth_handler) diff --git a/modules/Auth/tests/CMakeLists.txt b/modules/Auth/tests/CMakeLists.txt index eedf297cd..56b1dc498 100644 --- a/modules/Auth/tests/CMakeLists.txt +++ b/modules/Auth/tests/CMakeLists.txt @@ -37,3 +37,4 @@ target_link_libraries(${TEST_TARGET_NAME} PRIVATE ) add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) +ev_register_test_target(${TEST_TARGET_NAME}) diff --git a/modules/EnergyManager/tests/CMakeLists.txt b/modules/EnergyManager/tests/CMakeLists.txt index 6997de421..2c941b833 100644 --- a/modules/EnergyManager/tests/CMakeLists.txt +++ b/modules/EnergyManager/tests/CMakeLists.txt @@ -32,3 +32,4 @@ target_link_libraries(${TEST_TARGET_NAME} PRIVATE ) add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) +ev_register_test_target(${TEST_TARGET_NAME}) diff --git a/modules/ErrorHistory/tests/CMakeLists.txt b/modules/ErrorHistory/tests/CMakeLists.txt index 161d0923a..b406816dc 100644 --- a/modules/ErrorHistory/tests/CMakeLists.txt +++ b/modules/ErrorHistory/tests/CMakeLists.txt @@ -27,3 +27,4 @@ if(NOT DISABLE_EDM) endif() add_test(${TARGET_NAME} ${TARGET_NAME}) +ev_register_test_target(${TARGET_NAME}) diff --git a/modules/EvManager/tests/CMakeLists.txt b/modules/EvManager/tests/CMakeLists.txt index f5868f509..d7b12a5e5 100644 --- a/modules/EvManager/tests/CMakeLists.txt +++ b/modules/EvManager/tests/CMakeLists.txt @@ -34,3 +34,4 @@ if (NOT DISABLE_EDM) endif () add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) +ev_register_test_target(${TEST_TARGET_NAME}) diff --git a/modules/EvseManager/tests/CMakeLists.txt b/modules/EvseManager/tests/CMakeLists.txt index 2bccddf3d..f3b18c260 100644 --- a/modules/EvseManager/tests/CMakeLists.txt +++ b/modules/EvseManager/tests/CMakeLists.txt @@ -31,3 +31,4 @@ target_link_libraries(${TEST_TARGET_NAME} PRIVATE ) add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) +ev_register_test_target(${TEST_TARGET_NAME}) diff --git a/modules/EvseV2G/tests/CMakeLists.txt b/modules/EvseV2G/tests/CMakeLists.txt index 82f81f20b..76a08b190 100644 --- a/modules/EvseV2G/tests/CMakeLists.txt +++ b/modules/EvseV2G/tests/CMakeLists.txt @@ -92,3 +92,4 @@ target_link_libraries(${V2G_MAIN_NAME} PRIVATE # runs fine locally, fails in CI add_test(${TLS_GTEST_NAME} ${TLS_GTEST_NAME}) +ev_register_test_target(${TLS_GTEST_NAME}) diff --git a/modules/LemDCBM400600/tests/CMakeLists.txt b/modules/LemDCBM400600/tests/CMakeLists.txt index a61dabddb..b9b142751 100644 --- a/modules/LemDCBM400600/tests/CMakeLists.txt +++ b/modules/LemDCBM400600/tests/CMakeLists.txt @@ -31,6 +31,7 @@ target_link_libraries(${TEST_TARGET_NAME} PRIVATE add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) +ev_register_test_target(${TEST_TARGET_NAME}) ## Time sync helper test set(TEST_TARGET_NAME ${PROJECT_NAME}_lem_time_sync_helper_tests) @@ -65,6 +66,7 @@ target_link_libraries(${TEST_TARGET_NAME} PRIVATE ) add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) +ev_register_test_target(${TEST_TARGET_NAME}) ## http client integration client @@ -80,7 +82,7 @@ target_include_directories(integration_test_http_client PRIVATE ${GENERATED_INCLUDE_DIR} ) -# + target_link_libraries(integration_test_http_client PRIVATE GTest::gmock_main everest::timer diff --git a/modules/MicroMegaWattBSP/umwc_comms/CMakeLists.txt b/modules/MicroMegaWattBSP/umwc_comms/CMakeLists.txt index 116e12a77..1ec707570 100644 --- a/modules/MicroMegaWattBSP/umwc_comms/CMakeLists.txt +++ b/modules/MicroMegaWattBSP/umwc_comms/CMakeLists.txt @@ -11,6 +11,8 @@ find_package(Threads REQUIRED) # add the executable add_library(umwc_comms STATIC) +ev_register_library_target(umwc_comms) + target_sources(umwc_comms PRIVATE evSerial.cpp @@ -32,5 +34,3 @@ target_link_libraries(umwc_comms everest::framework everest::gpio ) - -ev_register_library_target(umwc_comms) diff --git a/modules/OCPP201/tests/CMakeLists.txt b/modules/OCPP201/tests/CMakeLists.txt index 3105f2262..89c8f4c75 100644 --- a/modules/OCPP201/tests/CMakeLists.txt +++ b/modules/OCPP201/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -set(TEST_TARGET_NAME ${PROJECT_NAME}transaction_handler_tests) +set(TEST_TARGET_NAME ${PROJECT_NAME}_transaction_handler_tests) add_executable(${TEST_TARGET_NAME} transaction_handler_tests.cpp) set(INCLUDE_DIR @@ -16,3 +16,4 @@ target_link_libraries(${TEST_TARGET_NAME} PRIVATE target_sources(${TEST_TARGET_NAME} PRIVATE "../transaction_handler.cpp") add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) +ev_register_test_target(${TEST_TARGET_NAME}) diff --git a/modules/PN532TokenProvider/pn532_serial/CMakeLists.txt b/modules/PN532TokenProvider/pn532_serial/CMakeLists.txt index d9a64f2c1..7f181533c 100644 --- a/modules/PN532TokenProvider/pn532_serial/CMakeLists.txt +++ b/modules/PN532TokenProvider/pn532_serial/CMakeLists.txt @@ -12,8 +12,7 @@ find_package(Threads REQUIRED) # add the executable add_library(pn532_serial STATIC PN532Serial.cpp) +ev_register_library_target(pn532_serial) target_include_directories(pn532_serial PUBLIC "${PROJECT_BINARY_DIR}") target_link_libraries(pn532_serial PRIVATE Threads::Threads everest::framework) - -ev_register_library_target(pn532_serial) diff --git a/modules/PhyVersoBSP/phyverso_gpio/CMakeLists.txt b/modules/PhyVersoBSP/phyverso_gpio/CMakeLists.txt index baa0da76f..f52f68590 100644 --- a/modules/PhyVersoBSP/phyverso_gpio/CMakeLists.txt +++ b/modules/PhyVersoBSP/phyverso_gpio/CMakeLists.txt @@ -7,6 +7,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) add_library(phyverso_gpio STATIC) +ev_register_library_target(phyverso_gpio) + target_sources(phyverso_gpio PRIVATE evGpio.cpp @@ -29,5 +31,3 @@ target_link_libraries(phyverso_gpio phyverso_config fmt::fmt ) - -ev_register_library_target(phyverso_gpio) diff --git a/modules/PhyVersoBSP/phyverso_mcu_comms/CMakeLists.txt b/modules/PhyVersoBSP/phyverso_mcu_comms/CMakeLists.txt index 3d47d654d..74bb5562f 100644 --- a/modules/PhyVersoBSP/phyverso_mcu_comms/CMakeLists.txt +++ b/modules/PhyVersoBSP/phyverso_mcu_comms/CMakeLists.txt @@ -7,6 +7,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) add_library(phyverso_config STATIC) +ev_register_library_target(phyverso_config) + target_sources(phyverso_config PRIVATE evConfig.cpp @@ -25,9 +27,9 @@ target_link_libraries(phyverso_config fmt::fmt ) -ev_register_library_target(phyverso_config) - add_library(phyverso_mcu_comms STATIC) +ev_register_library_target(phyverso_mcu_comms) + target_sources(phyverso_mcu_comms PRIVATE evSerial.cpp @@ -51,5 +53,3 @@ target_link_libraries(phyverso_mcu_comms everest::framework phyverso_config ) - -ev_register_library_target(phyverso_mcu_comms) diff --git a/modules/Setup/tests/CMakeLists.txt b/modules/Setup/tests/CMakeLists.txt index 3f87fdd02..5d3eab06a 100644 --- a/modules/Setup/tests/CMakeLists.txt +++ b/modules/Setup/tests/CMakeLists.txt @@ -15,3 +15,4 @@ target_link_libraries(${TEST_TARGET_NAME} PRIVATE ) add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) +ev_register_test_target(${TEST_TARGET_NAME}) diff --git a/modules/YetiDriver/yeti_comms/CMakeLists.txt b/modules/YetiDriver/yeti_comms/CMakeLists.txt index 0c1f99870..07afde555 100644 --- a/modules/YetiDriver/yeti_comms/CMakeLists.txt +++ b/modules/YetiDriver/yeti_comms/CMakeLists.txt @@ -8,6 +8,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) # add the executable add_library(yeti_comms STATIC) +ev_register_library_target(yeti_comms) + target_sources(yeti_comms PRIVATE evSerial.cpp @@ -29,5 +31,3 @@ target_link_libraries(yeti_comms everest::framework everest::gpio ) - -ev_register_library_target(yeti_comms) diff --git a/modules/YetiEvDriver/evyeti_comms/CMakeLists.txt b/modules/YetiEvDriver/evyeti_comms/CMakeLists.txt index f34c22ebb..2a025ced7 100644 --- a/modules/YetiEvDriver/evyeti_comms/CMakeLists.txt +++ b/modules/YetiEvDriver/evyeti_comms/CMakeLists.txt @@ -11,6 +11,8 @@ configure_file(config.h.in config.h) # add the executable add_library(evyeti_comms STATIC) +ev_register_library_target(evyeti_comms) + target_sources(evyeti_comms PRIVATE evSerial.cpp @@ -32,5 +34,3 @@ target_link_libraries(evyeti_comms Pal::Sigslot everest::framework ) - -ev_register_library_target(evyeti_comms) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f65181201..200bdf85f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,7 +4,7 @@ evc_include(CodeCoverage) # add compiler flags to all targets which should be coveraged -foreach(type MODULES LIBRARIES) +foreach(type MODULES LIBRARIES TESTS) ev_get_targets(targets ${type}) foreach(target ${targets}) @@ -18,8 +18,8 @@ endforeach() get_target_property(GENERATED_OUTPUT_DIR generate_cpp_files EVEREST_GENERATED_OUTPUT_DIR) setup_target_for_coverage_gcovr_html( - NAME ${PROJECT_NAME}_gcovr_coverage - EXCLUDE "${GENERATED_OUTPUT_DIR}/*" + NAME ${PROJECT_NAME}_create_coverage + EXCLUDE "${GENERATED_OUTPUT_DIR}/*" ".*tests/" ) add_subdirectory(everest-core_tests) diff --git a/tests/README.md b/tests/README.md index 2d16c2b8c..0a50e2794 100644 --- a/tests/README.md +++ b/tests/README.md @@ -90,3 +90,96 @@ For the moment, there is a *workaround available:* Use a new test-set (another p **Cause:** Currently there is a bug in the EVSE manager implementation in everest-core, causing a race-condition between resetting the "amount charged" parameter and the event reporting for a "*transaction_finished*" event. Sometimes it reports correctly, other times it reports a value of 0.0kWh charged. **Solution:** This problem is known and a fix is under way. For the moment, just re-run the test. Usually, this should then produce a passing result. + + +# Code coverage + +To activate code coverage, you need to configure the project with +`BUILD_TESTING` enabled. Furthermore, `gcovr` needs to be installed. + +## Generating coverage reports + +Before generating a coverage report you will typically need to run some +executables or tests, which contain or link to code, that generates coverage +statistics. + +After that, just run: +```bash +cmake --build build --target everest-core_create_coverage +# or ninja -C build everest-core_create_coverage +``` + +The generated `index.html` will be available at +`build/everest-core_create_coverage/index.html`. + +**Note**: the code coverage for a specific compilation unit (cpp file) will +accumulate if you run multiple executables that use this compilation unit. The +code coverage is recorded in `gcda` files. If you want to get separate coverage +reports for different executables, these `gcda` files need to be deleted for +each new *run*. + + +## Adding code/targets to code coverage + +By default, all *cpp* modules are added automatically to a list of targets that +will be compiled with coverage flags. If additional libraries or tests need to +be added to code coverage, you should use the following functions in your +*cmake* code: +```cmake +ev_register_library_target(LIBRARY_TARGET_NAME) +ev_register_test_target(TEST_TARGET_NAME) +``` + +## Conventions + +For the `ev_register_*_target` functions, call these function close to their +scope of detail - meaning near `add_library` for libraries like: + +```cmake +add_library(evse_security_conversions STATIC) +add_library(everest::evse_security_conversions ALIAS evse_security_conversions) +ev_register_library_target(evse_security_conversions) +``` + +and near `add_test` for tests like: + +```cmake +add_test(${TLS_GTEST_NAME} ${TLS_GTEST_NAME}) +ev_register_test_target(${TLS_GTEST_NAME}) +``` + +and not scattered around. + +--- + +By default, all directories ending with `tests` will be excluded from the code +coverage report (because we're not interested in the code coverage of the unit +test code itself). So when adding unit tests for code coverage, place them into +a `tests` folder. + +## Troubleshooting + +`no_working_dir_found`: while developing code (e.g. an `example.cpp`), it might +happen, that the created object file `example.cpp.o` will get out of sync with +its corresponding `example.cpp.gcno` (`gcov` note file) and/or +`example.cpp.gcda` (`gcov` data file). When creating a report, `gcovr` will +complain, because it can't find the corresponding `example.cpp.o` file for a +stale `example.cpp.gcno` file. It might also not be able to find the +`example.cpp.gcno` file for a stale `example.cpp.gcda` file or an older `gcda` +file might got out of sync due to a newer `gcno` file and so forth. Do not +simply ignore these warnings/errors, as the report might not be accurate +anymore. + +The current sledgehammer approach is to manually delete the files in question or +just do (**be careful** with `rm` commands and wildcards!): +```bash +find ./build -name "*.gcno" | xargs rm +find ./build -name "*.gcda" | xargs rm +ninja -C build clean +ninja -C build +# run code +# create coverage +``` + +We're currently trying to write some tooling around this to make this more +usable.