diff --git a/.drone.yml b/.drone.yml index 632b863..6a40479 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,7 +20,7 @@ steps: image: registry.nadal-fr.com/buildroot_dev commands: - mkdir -p domo-iot/build - - cd domo-iot/build && cmake .. + - cd domo-iot/build && cmake .. -DDOMO_BUILD_TEST=ON - make - name: test @@ -29,5 +29,11 @@ steps: - cd domo-iot/build - ./bin/test_device +- name: codecov + image: registry.nadal-fr.com/buildroot_dev + commands: + - cd domo-iot/build + - gcovr -v --object-directory=. -r .. + image_pull_secrets: - dockerconfigjson diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 262f31c..9eb26f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,8 @@ project(domo-iot) set (CMAKE_MODULE_PATH "${MODULE_PATH}") set(CMAKE_EXPORT_COMPILE_COMMANDS On) +option(DOMO_BUILD_TEST "Build Domo test and coverage" OFF) + link_directories(${CMAKE_SOURCE_DIR}/build/lib) include_directories (${CMAKE_SOURCE_DIR}/lib/include) @@ -45,6 +47,10 @@ target_link_libraries (${PROJECT_NAME} ) # Tests +if(DOMO_BUILD_TEST) +add_definitions("-fprofile-arcs -ftest-coverage") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov --coverage") + add_executable (test_device devices/devices_manager.c devices/device.c @@ -59,8 +65,9 @@ target_link_libraries (test_device nats_static qlibc-static json-c + gcov ) - +endif(DOMO_BUILD_TEST) install (TARGETS ${PROJECT_NAME} DESTINATION local/bin)