static void _init(void) { app_startup(); configuration = cfg_new_snippet(); cr_assert(cfg_load_module(configuration, "affile")); }
void setup(void) { app_startup(); setenv("TZ", "MET-1METDST", TRUE); tzset(); configuration = cfg_new_snippet(); configuration->stats_options.level = 1; cr_assert(cfg_init(configuration), "cfg_init failed!"); }
void init_and_load_kmsgformat_module(void) { configuration = cfg_new_snippet(); cfg_load_module(configuration, "linux-kmsg-format"); parse_options.format = "linux-kmsg"; msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); }
static void _init_cfg_with_persist_file(const gchar *persist_file) { main_thread_handle = get_thread_id(); cfg = cfg_new_snippet(); cfg->threaded = FALSE; cfg->state = persist_state_new(persist_file); cfg->keep_hostname = TRUE; persist_state_start(cfg->state); }
static gboolean _init_filters_from_file(AddContextualDataFilterSelector *self) { self->cfg = cfg_new_snippet(); if (!cfg_read_config(self->cfg, self->filters_path, FALSE, NULL)) { cfg_free(self->cfg); self->cfg = NULL; msg_error("Error parsing filters of rule engine", evt_tag_str(EVT_TAG_FILENAME, self->filters_path)); return FALSE; } return TRUE; }
static void _setup(void) { msg_init(FALSE); g_thread_init(NULL); debug_flag = TRUE; verbose_flag = TRUE; trace_flag = TRUE; log_msg_registry_init(); test_cfg = cfg_new_snippet(); g_assert(test_cfg); const gchar *persist_filename = ""; test_cfg->state = persist_state_new(persist_filename); _before_test(); }
void setup(void) { configuration = cfg_new_snippet(); app_startup(); }
void setup(void) { app_startup(); setlocale (LC_ALL, "C"); setenv("TZ", "CET-1", TRUE); tzset(); configuration = cfg_new_snippet(); /* year heuristics depends on the current time */ /* Dec 30 2015 */ GTimeVal faked_time = { .tv_sec = 1451473200, .tv_usec = 0 }; set_cached_time(&faked_time); } void teardown(void) { app_shutdown(); } TestSuite(date, .init = setup, .fini = teardown); ParameterizedTestParameters(date, test_date_parser) { static struct date_params params[] = { { "2015-01-26T16:14:49+03:00", NULL, NULL, LM_TS_RECVD, "2015-01-26T16:14:49+03:00" }, /* Various ISO8601 formats */ { "2015-01-26T16:14:49+0300", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+03:00" }, { "2015-01-26T16:14:49+0330", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+03:30" }, { "2015-01-26T16:14:49+0200", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+02:00" }, { "2015-01-26T16:14:49+03:00", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+03:00" }, { "2015-01-26T16:14:49+03:30", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+03:30" }, { "2015-01-26T16:14:49+02:00", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+02:00" }, { "2015-01-26T16:14:49Z", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+00:00" }, { "2015-01-26T16:14:49A", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49-01:00" }, { "2015-01-26T16:14:49B", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49-02:00" }, { "2015-01-26T16:14:49N", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+01:00" }, { "2015-01-26T16:14:49O", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+02:00" }, { "2015-01-26T16:14:49GMT", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49+00:00" }, { "2015-01-26T16:14:49PDT", NULL, NULL, LM_TS_STAMP, "2015-01-26T16:14:49-07:00" }, /* RFC 2822 */ { "Tue, 27 Jan 2015 11:48:46 +0200", NULL, "%a, %d %b %Y %T %z", LM_TS_STAMP, "2015-01-27T11:48:46+02:00" }, /* Apache-like */ { "21/Jan/2015:14:40:07 +0500", NULL, "%d/%b/%Y:%T %z", LM_TS_STAMP, "2015-01-21T14:40:07+05:00" }, /* Dates without timezones. America/Phoenix has no DST */ { "Tue, 27 Jan 2015 11:48:46", NULL, "%a, %d %b %Y %T", LM_TS_STAMP, "2015-01-27T11:48:46+01:00" }, { "Tue, 27 Jan 2015 11:48:46", "America/Phoenix", "%a, %d %b %Y %T", LM_TS_STAMP, "2015-01-27T11:48:46-07:00" }, { "Tue, 27 Jan 2015 11:48:46", "+05:00", "%a, %d %b %Y %T", LM_TS_STAMP, "2015-01-27T11:48:46+05:00" }, /* Try without the year. */ { "01/Jan:00:40:07 +0500", NULL, "%d/%b:%T %z", LM_TS_STAMP, "2016-01-01T00:40:07+05:00" }, { "01/Aug:00:40:07 +0500", NULL, "%d/%b:%T %z", LM_TS_STAMP, "2015-08-01T00:40:07+05:00" }, { "01/Sep:00:40:07 +0500", NULL, "%d/%b:%T %z", LM_TS_STAMP, "2015-09-01T00:40:07+05:00" }, { "01/Oct:00:40:07 +0500", NULL, "%d/%b:%T %z", LM_TS_STAMP, "2015-10-01T00:40:07+05:00" }, { "01/Nov:00:40:07 +0500", NULL, "%d/%b:%T %z", LM_TS_STAMP, "2015-11-01T00:40:07+05:00" }, { "1446128356 +01:00", NULL, "%s %z", LM_TS_STAMP, "2015-10-29T15:19:16+01:00" }, { "1446128356", "Europe/Budapest", "%s", LM_TS_STAMP, "2015-10-29T15:19:16+01:00" }, }; return cr_make_param_array(struct date_params, params, sizeof(params) / sizeof(struct date_params)); } ParameterizedTest(struct date_params *params, date, test_date_parser) { LogMessage *logmsg; LogParser *parser = _construct_parser(params->timezone_, params->format, params->time_stamp); gboolean success; GString *res = g_string_sized_new(128); logmsg = _construct_logmsg(params->msg); success = log_parser_process(parser, &logmsg, NULL, log_msg_get_value(logmsg, LM_V_MESSAGE, NULL), -1); cr_assert(success, "unable to parse format=%s msg=%s", params->format, params->msg); append_format_unix_time(&logmsg->timestamps[params->time_stamp], res, TS_FMT_ISO, -1, 0); cr_assert_str_eq(res->str, params->expected, "incorrect date parsed msg=%s format=%s, result=%s, expected=%s", params->msg, params->format, res->str, params->expected); g_string_free(res, TRUE); log_pipe_unref(&parser->super); log_msg_unref(logmsg); }
test_filter_returns_false_when_list_is_empty(top_srcdir); test_string_searched_for_is_not_in_the_list(top_srcdir); test_given_macro_is_not_available_in_this_message(top_srcdir); test_list_file_doesnt_exist(top_srcdir); test_list_file_contains_only_one_line(top_srcdir); test_list_file_contains_lot_of_lines(top_srcdir); test_filter_with_ip_address(top_srcdir); test_filter_with_long_line(top_srcdir); } int main(int argc G_GNUC_UNUSED, char *argv[] G_GNUC_UNUSED) { char *top_srcdir = TOP_SRCDIR; app_startup(); configuration = cfg_new_snippet(); cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); assert_not_null(top_srcdir, "The $top_srcdir environment variable MUST NOT be empty!"); run_testcases(top_srcdir); app_shutdown(); return 0; }