From 586b2386e4374e16476fcc508227286dcc293485 Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Tue, 19 Jan 2021 13:40:17 -0500 Subject: [PATCH] lib: event-filter - Expose internal functions to allow for unit testing We'll need these to avoid code duplication when unit testing the boolean expression evaluation logic. --- src/lib/event-filter-private.h | 9 +++++++++ src/lib/event-filter.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/event-filter-private.h b/src/lib/event-filter-private.h index 6e25bbc766..9db1d0b377 100644 --- a/src/lib/event-filter-private.h +++ b/src/lib/event-filter-private.h @@ -92,4 +92,13 @@ int event_filter_parser_parse(struct event_filter_parser_state *state); void event_filter_parser_set_extra(void *user, void *yyscanner); void event_filter_parser_error(void *scan, const char *e); +/* the following are exposed to allow for unit testing */ +bool +event_filter_query_match_eval(struct event_filter_node *node, + struct event *event, const char *source_filename, + unsigned int source_linenum, + enum event_filter_log_type log_type); +const char * +event_filter_category_from_log_type(enum event_filter_log_type log_type); + #endif diff --git a/src/lib/event-filter.c b/src/lib/event-filter.c index 40a1406be7..d9a0ac2f44 100644 --- a/src/lib/event-filter.c +++ b/src/lib/event-filter.c @@ -161,7 +161,7 @@ bool event_filter_category_to_log_type(const char *name, return FALSE; } -static const char * +const char * event_filter_category_from_log_type(enum event_filter_log_type log_type) { unsigned int i; @@ -591,7 +591,7 @@ event_filter_query_match_cmp(struct event_filter_node *node, i_unreached(); } -static bool +bool event_filter_query_match_eval(struct event_filter_node *node, struct event *event, const char *source_filename, unsigned int source_linenum, -- 2.47.3