Skip to content

Commit

Permalink
temp: log_path_options_init followup in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Szilard Parrag <[email protected]>
  • Loading branch information
OverOrion committed Oct 14, 2024
1 parent dc0d6f0 commit 10c0aab
Show file tree
Hide file tree
Showing 34 changed files with 220 additions and 68 deletions.
12 changes: 9 additions & 3 deletions lib/ack-tracker/tests/test_batched_ack_tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ Test(batched_ack_tracker, bookmark_saving)
log_source_post(src, msg1);
cr_expect_eq(window_size_counter_get(&src->window_size, NULL), 9);
cr_assert_eq(msg1->ack_record->tracker, ack_tracker);
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
log_msg_ack(msg1, &path_options, AT_PROCESSED);
cr_expect_eq(saved_ctr, 0);
cr_expect_eq(destroy_ctr, 0);
Expand Down Expand Up @@ -260,7 +262,9 @@ Test(batched_ack_tracker, batch_timeout)
log_source_post(src, msg1);
cr_expect_eq(window_size_counter_get(&src->window_size, NULL), 9);
cr_assert_eq(msg1->ack_record->tracker, ack_tracker);
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
log_msg_ack(msg1, &path_options, AT_PROCESSED);
cr_expect_eq(saved_ctr, 0);
cr_expect_eq(destroy_ctr, 0);
Expand Down Expand Up @@ -300,7 +304,9 @@ Test(batched_ack_tracker, deinit_acks_partial_batch)
log_source_post(src, msg1);
cr_expect_eq(window_size_counter_get(&src->window_size, NULL), 9);
cr_assert_eq(msg1->ack_record->tracker, ack_tracker);
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
log_msg_ack(msg1, &path_options, AT_PROCESSED);
cr_expect_eq(saved_ctr, 0);
cr_expect_eq(destroy_ctr, 0);
Expand Down
8 changes: 6 additions & 2 deletions lib/ack-tracker/tests/test_instant_ack_tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ Test(instant_ack_tracker_bookmarkless, bookmark_save_not_called_when_acked)
// this is why we need a dummy 'destination' : keep back ACK
cr_expect_eq(window_size_counter_get(&src->window_size, NULL), 9);
cr_assert_eq(msg->ack_record->tracker, ack_tracker);
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
log_msg_ack(msg, &path_options, AT_PROCESSED);
// okay, ACK is done, but save counter is 0 -> so Bookmark::save not called
cr_expect_eq(saved_ctr, 0);
Expand Down Expand Up @@ -221,7 +223,9 @@ Test(instant_ack_tracker, bookmark_saving)
// this is why we need a dummy 'destination' : keep back ACK
cr_expect_eq(window_size_counter_get(&src->window_size, NULL), 9);
cr_assert_eq(msg->ack_record->tracker, ack_tracker);
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
log_msg_ack(msg, &path_options, AT_PROCESSED);
// okay, ACK is done, save counter is 1
cr_expect_eq(saved_ctr, 1);
Expand Down
4 changes: 3 additions & 1 deletion lib/filter/tests/test_filters_statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ create_log_filter_pipe(void)
static void
queue_and_assert_statistics(LogFilterPipe *pipe, gchar *msg, guint32 matched_expected, guint32 not_matched_expected)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
LogMessage *logmsg = msg_format_parse(&parse_options, (const guchar *) msg, strlen(msg));
LogPipe *p = (LogPipe *)pipe;
p->queue(p, logmsg, &path_options);
Expand Down
24 changes: 18 additions & 6 deletions lib/logmsg/tests/test_log_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ assert_log_msg_clear_clears_all_properties(LogMessage *message, NVHandle nv_hand
NVHandle sd_handle, const gchar *tag_name)
{
message->flags |= LF_LOCAL + LF_UTF8 + LF_INTERNAL + LF_MARK;
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);

log_msg_make_writable(&message, &path_options);
log_msg_clear(message);
Expand Down Expand Up @@ -146,7 +148,9 @@ log_message_test_params_free(LogMessageTestParams *params)
LogMessage *
log_message_test_params_clone_message(LogMessageTestParams *params)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
params->cloned_message = log_msg_clone_cow(params->message, &path_options);

return params->cloned_message;
Expand Down Expand Up @@ -214,7 +218,9 @@ Test(log_message, test_log_msg_clear_handles_cloned_noninline_tags_properly)
log_msg_set_tag_by_name(msg, tag_name);
}

LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
LogMessage *cloned = log_msg_clone_cow(msg, &path_options);

log_msg_clear(cloned);
Expand Down Expand Up @@ -882,7 +888,9 @@ Test(log_message, test_cow_writing_cloned_message)
LogMessage *msg = _construct_log_message();
log_msg_set_value_by_name(msg, "orig_name", "orig_value", -1);

LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
LogMessage *cloned = log_msg_clone_cow(msg, &path_options);

log_msg_set_value_by_name(cloned, "cloned_name", "cloned_value", -1);
Expand Down Expand Up @@ -912,7 +920,9 @@ Test(log_message, test_cow_make_writable)

LogMessage *orig_msg = log_msg_ref(msg);

LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
log_msg_make_writable(&msg, &path_options);

log_msg_set_value_by_name(msg, "orig_name2", "orig_value2", -1);
Expand All @@ -934,7 +944,9 @@ Test(log_message, test_cow_unset_value)

LogMessage *orig_msg = log_msg_ref(msg);

LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
log_msg_make_writable(&msg, &path_options);

log_msg_unset_value_by_name(msg, "orig_name");
Expand Down
2 changes: 2 additions & 0 deletions lib/logmsg/tests/test_logmsg_ack.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct _AckRecord
{
LogMessage *original;
LogPathOptions path_options;
FilterXEvalContext filterx_context;
gboolean acked;
void (*init)(AckRecord *);
void (*deinit)(AckRecord *);
Expand Down Expand Up @@ -79,6 +80,7 @@ ack_record_new(void)
self->original = log_msg_new_empty();
self->original->ack_func = self->ack_message;
self->original->ack_record = self;
log_path_options_init(&self->path_options, &self->filterx_context);
self->path_options.ack_needed = TRUE;
return self;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/rewrite/tests/test_rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ LogMessage *msg;
static void
_perform_rewrite(LogRewrite *rewrite, LogMessage *msg_)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);

cr_assert(log_pipe_init(&rewrite->super));
log_pipe_queue(&rewrite->super, log_msg_ref(msg_), &path_options);
Expand Down
4 changes: 3 additions & 1 deletion lib/rewrite/tests/test_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ create_message_with_field(const char *field_name, const char *field_value)
void
invoke_rewrite_rule(LogRewrite *pipe_, LogMessage *msg)
{
LogPathOptions po = LOG_PATH_OPTIONS_INIT;
LogPathOptions po;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&po, &filterx_eval_context);
log_pipe_queue((LogPipe *) pipe_, log_msg_ref(msg), &po);
};

Expand Down
4 changes: 3 additions & 1 deletion lib/rewrite/tests/test_set_facility.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ _create_template(const gchar *str)
static void
_perform_rewrite(LogRewrite *rewrite, LogMessage *msg_)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);

log_pipe_init(&rewrite->super);
log_pipe_queue(&rewrite->super, log_msg_ref(msg_), &path_options);
Expand Down
4 changes: 3 additions & 1 deletion lib/rewrite/tests/test_set_matches.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ LogMessage *msg;
static void
_perform_rewrite(LogRewrite *rewrite, LogMessage *msg_)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);

log_pipe_init(&rewrite->super);
log_pipe_queue(&rewrite->super, log_msg_ref(msg_), &path_options);
Expand Down
4 changes: 3 additions & 1 deletion lib/rewrite/tests/test_set_pri.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ _create_template(const gchar *str)
static void
_perform_rewrite(LogRewrite *rewrite, LogMessage *msg_)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);

log_pipe_init(&rewrite->super);
log_pipe_queue(&rewrite->super, log_msg_ref(msg_), &path_options);
Expand Down
4 changes: 3 additions & 1 deletion lib/rewrite/tests/test_set_severity.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ _create_template(const gchar *str)
static void
_perform_rewrite(LogRewrite *rewrite, LogMessage *msg_)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);

log_pipe_init(&rewrite->super);
log_pipe_queue(&rewrite->super, log_msg_ref(msg_), &path_options);
Expand Down
4 changes: 3 additions & 1 deletion lib/rewrite/tests/test_set_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ _create_template(const gchar *str)
static void
_perform_rewrite(LogRewrite *rewrite, LogMessage *msg_)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);

log_pipe_init(&rewrite->super);
log_pipe_queue(&rewrite->super, log_msg_ref(msg_), &path_options);
Expand Down
4 changes: 3 additions & 1 deletion lib/tests/test_clone_logmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ ParameterizedTest(const gchar *msg, clone_logmsg, test_cloning_with_log_message)
LogMessage *original_log_message, *log_message, *cloned_log_message;
regex_t bad_hostname;
GSockAddr *addr = g_sockaddr_inet_new("10.10.10.10", 1010);
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);

parse_options.flags = LP_SYSLOG_PROTOCOL;
parse_options.bad_hostname = &bad_hostname;
Expand Down
28 changes: 21 additions & 7 deletions lib/tests/test_logqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ _threaded_feed(gpointer args)
{
LogQueue *q = args;
gint i;
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
LogMessage *msg, *tmpl;
struct timespec start, end;
glong diff;
Expand Down Expand Up @@ -96,7 +98,9 @@ _threaded_consume(gpointer st)
{
LogQueue *q = (LogQueue *) st;
LogMessage *msg;
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
gint msg_count = 0;

iv_init();
Expand Down Expand Up @@ -287,10 +291,14 @@ Test(logqueue, log_queue_fifo_rewind_all_and_memory_usage)
Test(logqueue, log_queue_fifo_should_drop_only_non_flow_controlled_messages,
.description = "Flow-controlled messages should never be dropped")
{
LogPathOptions flow_controlled_path = LOG_PATH_OPTIONS_INIT;
LogPathOptions flow_controlled_path;
FilterXEvalContext filterx_eval_context_flow_controlled_path;
log_path_options_init(&flow_controlled_path, &filterx_eval_context_flow_controlled_path);
flow_controlled_path.flow_control_requested = TRUE;

LogPathOptions non_flow_controlled_path = LOG_PATH_OPTIONS_INIT;
LogPathOptions non_flow_controlled_path;
FilterXEvalContext filterx_eval_context_non_flow_controlled_path;
log_path_options_init(&non_flow_controlled_path, &filterx_eval_context_non_flow_controlled_path);
non_flow_controlled_path.flow_control_requested = FALSE;

gint fifo_size = 5;
Expand Down Expand Up @@ -327,10 +335,14 @@ _flow_control_feed_thread(gpointer args)
{
LogQueue *q = args;
gint fifo_size = 5;
LogPathOptions flow_controlled_path = LOG_PATH_OPTIONS_INIT;
LogPathOptions flow_controlled_path;
FilterXEvalContext filterx_eval_context_flow_controlled_path;
log_path_options_init(&flow_controlled_path, &filterx_eval_context_flow_controlled_path);
flow_controlled_path.flow_control_requested = TRUE;

LogPathOptions non_flow_controlled_path = LOG_PATH_OPTIONS_INIT;
LogPathOptions non_flow_controlled_path;
FilterXEvalContext filterx_eval_context_non_flow_controlled_path;
log_path_options_init(&non_flow_controlled_path, &filterx_eval_context_non_flow_controlled_path);
non_flow_controlled_path.flow_control_requested = FALSE;

iv_init();
Expand Down Expand Up @@ -385,7 +397,9 @@ Test(logqueue, log_queue_fifo_should_drop_only_non_flow_controlled_messages_thre
Test(logqueue, log_queue_fifo_multiple_queues)
{
const gint fifo_size = 1;
LogPathOptions options = LOG_PATH_OPTIONS_INIT;
LogPathOptions options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&options, &filterx_eval_context);

StatsClusterKeyBuilder *driver_sck_builder = stats_cluster_key_builder_new();
StatsClusterKeyBuilder *queue_sck_builder = stats_cluster_key_builder_new();
Expand Down
4 changes: 3 additions & 1 deletion lib/tests/test_logscheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ Test(logscheduler, test_log_scheduler_can_be_constructed)
s = log_scheduler_new(&options, &test_pipe->super);

LogMessage *msg = create_sample_message();
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
log_scheduler_push(s, msg, &path_options);

msg = create_sample_message();
Expand Down
4 changes: 3 additions & 1 deletion modules/affile/tests/test_wildcard_file_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ test_deleted_file_state_event_new(void)

TestFileStateEvent *test_event;
WildcardFileReader *reader;
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;

/* MOCKS */

Expand Down Expand Up @@ -113,6 +114,7 @@ _init(void)
test_event = test_deleted_file_state_event_new();
reader = (WildcardFileReader *)wildcard_file_reader_new(TEST_FILE_NAME, NULL, NULL, NULL, cfg_new_snippet());
wildcard_file_reader_on_deleted_file_eof(reader, _eof, test_event);
log_path_options_init(&path_options, &filterx_eval_context);
cr_assert_eq(log_pipe_init(&reader->super.super), TRUE);
}

Expand Down
4 changes: 3 additions & 1 deletion modules/afsnmp/tests/test_snmptrapd_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ copy_str_into_log_message(const gchar *message)
static gboolean
_process_log_message(LogParser *parser, LogMessage *msg)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);
return log_parser_process_message(parser, &msg, &path_options);
}

Expand Down
4 changes: 3 additions & 1 deletion modules/correlation/tests/test_grouping_by.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ _create_input_msg(const gchar *prog)
void
_process_msg(LogParser *parser, const gchar *prog)
{
LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&path_options, &filterx_eval_context);

LogMessage *msg = _create_input_msg(prog);
/* NOTE: log_pipe_queue() consumes a reference */
Expand Down
6 changes: 5 additions & 1 deletion modules/csvparser/tests/test_csvparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,12 @@ ParameterizedTest(CsvParserTestParam *param, parser, test_csv_parser)

cr_assert(log_pipe_init(&pclone->super));

FilterXEvalContext filterx_eval_context;
LogPathOptions path_options;
log_path_options_init(&path_options, &filterx_eval_context);

nvtable = nv_table_ref(logmsg->payload);
success = log_parser_process(pclone, &logmsg, NULL, log_msg_get_value(logmsg, LM_V_MESSAGE, NULL), -1);
success = log_parser_process(pclone, &logmsg, &path_options, log_msg_get_value(logmsg, LM_V_MESSAGE, NULL), -1);
nv_table_unref(nvtable);

cr_assert_not((success && !param->expected_values[0]), "unexpected match; msg=%s\n", param->msg);
Expand Down
4 changes: 3 additions & 1 deletion modules/csvparser/tests/test_csvparser_from_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ create_parser_rule(const char *raw_parser_rule)
void
invoke_parser_rule(LogParser *pipe_, LogMessage *msg)
{
LogPathOptions po = LOG_PATH_OPTIONS_INIT;
LogPathOptions po;
FilterXEvalContext filterx_eval_context;
log_path_options_init(&po, &filterx_eval_context);
log_pipe_queue((LogPipe *) pipe_, log_msg_ref(msg), &po);
};

Expand Down
4 changes: 3 additions & 1 deletion modules/csvparser/tests/test_csvparser_statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
#include "apphook.h"
#include "cfg.h"

LogPathOptions path_options = LOG_PATH_OPTIONS_INIT;
LogPathOptions path_options;
FilterXEvalContext filterx_eval_context;

static LogParser *
_create_parser(GlobalConfig *cfg)
Expand Down Expand Up @@ -76,6 +77,7 @@ Test(test_filters_statistics, filter_stastistics)
configuration = cfg_new_snippet();
configuration->stats_options.level = 1;
cr_assert(cfg_init(configuration));
log_path_options_init(&path_options, &filterx_eval_context);

LogParser *parser = _create_parser(configuration);
cr_assert_eq(stats_counter_get(parser->super.discarded_messages), 0);
Expand Down
Loading

0 comments on commit 10c0aab

Please sign in to comment.