From 251389a454b7afb5de0efdfbba9c9189e2e9f0cc Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Mon, 25 May 2020 01:10:37 +0200 Subject: [PATCH] add: coverage in cmake fix: remove unsed cli call 'test' --- CMakeLists.txt | 8 ++++++-- helpers/parse_cli.c | 18 +++++------------- include/config.h | 17 ++++++++++++++++- include/enums.h | 16 ---------------- 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84587e8..25ecfb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,7 @@ add_executable(core main.c) option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (OFF)" OFF) -#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -Werror -Wpedantic -lwiringPi -lwiringPiDev -luuid -llmdb -g") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -luuid -lsqlite3 -g") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -luuid -lsqlite3 -g -fprofile-arcs -ftest-coverage") string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE) add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}") @@ -61,3 +60,8 @@ add_custom_target(test DEPENDS core WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests ) +add_custom_target(coverage + COMMAND gcovr -s --root ${CMAKE_SOURCE_DIR} -e ${CMAKE_SOURCE_DIR}/vendor --html-details ${CMAKE_BINARY_DIR}/coverage.html --html-title "Emgauwa Core Coverage" ${CMAKE_BINARY_DIR}/CMakeFiles/core.dir + DEPENDS test + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +) diff --git a/helpers/parse_cli.c b/helpers/parse_cli.c index f9fac01..10f9aa7 100644 --- a/helpers/parse_cli.c +++ b/helpers/parse_cli.c @@ -8,15 +8,11 @@ #include static const char *const usage[] = { - "controller [options] [[--] args]", - "controller [options]", + "core [options] [[--] args]", + "core [options]", NULL, }; -#define PERM_READ (1<<0) -#define PERM_WRITE (1<<1) -#define PERM_EXEC (1<<2) - void helper_parse_cli(int argc, const char **argv, config_t *config) { @@ -40,22 +36,18 @@ helper_parse_cli(int argc, const char **argv, config_t *config) if(argc == 1) { + config->run_type = RUN_TYPE_INVALID; if(strcmp(argv[0], "start") == 0) { config->run_type = RUN_TYPE_START; return; } - if(strcmp(argv[0], "test") == 0) - { - config->run_type = RUN_TYPE_TEST; - return; - } - LOG_FATAL("bad action '%s' given ('start', 'test')\n", argv[0]); + LOG_FATAL("bad action '%s' given ('start')\n", argv[0]); exit(1); } else { - LOG_FATAL("no action given ('start', 'test')\n"); + LOG_FATAL("no action given ('start')\n"); exit(1); } return; diff --git a/include/config.h b/include/config.h index 2dd10c9..80e9007 100644 --- a/include/config.h +++ b/include/config.h @@ -4,7 +4,22 @@ #include #include -#include + +typedef enum +{ + RUN_TYPE_START, + RUN_TYPE_INVALID, +} run_type_t; + +typedef enum +{ + LOG_LEVEL_TRACE = 5, + LOG_LEVEL_DEBUG = 4, + LOG_LEVEL_INFO = 3, + LOG_LEVEL_WARN = 2, + LOG_LEVEL_ERROR = 1, + LOG_LEVEL_FATAL = 0, +} log_level_t; typedef struct { diff --git a/include/enums.h b/include/enums.h index 606c94c..943efa7 100644 --- a/include/enums.h +++ b/include/enums.h @@ -37,20 +37,4 @@ typedef enum RELAY_DRIVER_PIFACE, } relay_driver_t; -typedef enum -{ - RUN_TYPE_START, - RUN_TYPE_TEST, -} run_type_t; - -typedef enum -{ - LOG_LEVEL_TRACE = 5, - LOG_LEVEL_DEBUG = 4, - LOG_LEVEL_INFO = 3, - LOG_LEVEL_WARN = 2, - LOG_LEVEL_ERROR = 1, - LOG_LEVEL_FATAL = 0, -} log_level_t; - #endif /* CORE_ENUMS_H */