From 7410d5f4a48ee8cba3d7bf805d4105b7714a3dbd Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Mon, 27 Jan 2020 17:56:29 +0100 Subject: [PATCH] tests: exclude arg parsing Belongs to integration tests Change-Id: I1c26dddd73dbc0434479aa9244110cc63484f062 Signed-off-by: Michal Bloch --- src/logger/logger.c | 62 ++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/logger/logger.c b/src/logger/logger.c index 0a441b2..fc418e2 100644 --- a/src/logger/logger.c +++ b/src/logger/logger.c @@ -43,9 +43,7 @@ static void dispatch_event_reader_sink(struct logger *server, struct epoll_event static void dispatch_event_reader_source(struct logger *server, struct epoll_event *event); void reader_free(struct reader* reader); static void logger_free(struct logger* l); -static int parse_args(int argc, char **argv, struct buf_params *b); int socket_initialize(struct sock_data *sock, struct log_buffer *buffer, service_socket_t service_socket, struct socket_config_data *data); -static void help(); /** global state when logger is not interrupted by any handled signals */ static volatile sig_atomic_t g_logger_run = 1; @@ -2137,6 +2135,35 @@ static void free_config_data(struct logger_config_data *data) } /** + * @brief Parse logfile line + * @detail Parses a logfile config line + * @param[in] key Config entry key + * @param[in] value Config entry value + * @param[in] userdata Userdata + */ +void parse_logfile_config(void *value, void *userdata) +{ + assert(value); + assert(userdata); + + struct logger *server = (struct logger *) userdata; + struct reader *rd = NULL; + char *configline = (char *) value; + + int r = parse_command_line(configline, NULL, server, &rd); + if (r == 0) + add_reader(server, rd); + else { + errno = -r; + printf("Warning: unable to add logutil reader for provided configuration. Ignoring.\n" + " Config line: %s\n" + " Reason given: %m\n", + configline); + } +} + +#ifndef UNIT_TEST +/** * @brief Print help * @details Prints basic usage tips */ @@ -2157,7 +2184,7 @@ static void help() * @param[out] b Buffering parameters * @return 0 or 1 on success, else -errno. Nonzero if the program is to close. */ -int parse_args(int argc, char **argv, struct buf_params *b) +static int parse_args(int argc, char **argv, struct buf_params *b) { int option; @@ -2189,34 +2216,6 @@ int parse_args(int argc, char **argv, struct buf_params *b) } /** - * @brief Parse logfile line - * @detail Parses a logfile config line - * @param[in] key Config entry key - * @param[in] value Config entry value - * @param[in] userdata Userdata - */ -void parse_logfile_config(void *value, void *userdata) -{ - assert(value); - assert(userdata); - - struct logger *server = (struct logger *) userdata; - struct reader *rd = NULL; - char *configline = (char *) value; - - int r = parse_command_line(configline, NULL, server, &rd); - if (r == 0) - add_reader(server, rd); - else { - errno = -r; - printf("Warning: unable to add logutil reader for provided configuration. Ignoring.\n" - " Config line: %s\n" - " Reason given: %m\n", - configline); - } -} - -/** * @brief Finalize initialisation * @details Do misc stuff needed at the end of the initialisation * @param[in] data configuration dat to read logfiles config lines from @@ -2235,7 +2234,6 @@ static int finalize_init(struct logger_config_data *data, struct logger *server) return 0; } -#ifndef UNIT_TEST /** * @brief The logger * @return 0 on success, nonzero on failure -- 2.7.4