add: coverage in cmake
fix: remove unsed cli call 'test'
This commit is contained in:
		
							parent
							
								
									d5f4820196
								
							
						
					
					
						commit
						251389a454
					
				
					 4 changed files with 27 additions and 32 deletions
				
			
		| 
						 | 
					@ -5,8 +5,7 @@ add_executable(core main.c)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (OFF)" OFF)
 | 
					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 -fprofile-arcs -ftest-coverage")
 | 
				
			||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -luuid -lsqlite3 -g")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
 | 
					string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
 | 
				
			||||||
add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}")
 | 
					add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}")
 | 
				
			||||||
| 
						 | 
					@ -61,3 +60,8 @@ add_custom_target(test
 | 
				
			||||||
    DEPENDS core
 | 
					    DEPENDS core
 | 
				
			||||||
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
 | 
					    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}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,15 +8,11 @@
 | 
				
			||||||
#include <helpers.h>
 | 
					#include <helpers.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char *const usage[] = {
 | 
					static const char *const usage[] = {
 | 
				
			||||||
    "controller [options] [[--] args]",
 | 
					    "core [options] [[--] args]",
 | 
				
			||||||
    "controller [options]",
 | 
					    "core [options]",
 | 
				
			||||||
    NULL,
 | 
					    NULL,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define PERM_READ  (1<<0)
 | 
					 | 
				
			||||||
#define PERM_WRITE (1<<1)
 | 
					 | 
				
			||||||
#define PERM_EXEC  (1<<2)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
helper_parse_cli(int argc, const char **argv, config_t *config)
 | 
					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)
 | 
					    if(argc == 1)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        config->run_type = RUN_TYPE_INVALID;
 | 
				
			||||||
        if(strcmp(argv[0], "start") == 0)
 | 
					        if(strcmp(argv[0], "start") == 0)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            config->run_type = RUN_TYPE_START;
 | 
					            config->run_type = RUN_TYPE_START;
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if(strcmp(argv[0], "test") == 0)
 | 
					        LOG_FATAL("bad action '%s' given ('start')\n", argv[0]);
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            config->run_type = RUN_TYPE_TEST;
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        LOG_FATAL("bad action '%s' given ('start', 'test')\n", argv[0]);
 | 
					 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        LOG_FATAL("no action given ('start', 'test')\n");
 | 
					        LOG_FATAL("no action given ('start')\n");
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,22 @@
 | 
				
			||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <confini.h>
 | 
					#include <confini.h>
 | 
				
			||||||
#include <enums.h>
 | 
					
 | 
				
			||||||
 | 
					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
 | 
					typedef struct
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,20 +37,4 @@ typedef enum
 | 
				
			||||||
    RELAY_DRIVER_PIFACE,
 | 
					    RELAY_DRIVER_PIFACE,
 | 
				
			||||||
} relay_driver_t;
 | 
					} 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 */
 | 
					#endif /* CORE_ENUMS_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue