syslog-ng source
test_patterndb.c File Reference
#include <criterion/criterion.h>
#include <criterion/parameterized.h>
#include "libtest/msg_parse_lib.h"
#include "apphook.h"
#include "logmsg/logmsg.h"
#include "messages.h"
#include "filter/filter-expr.h"
#include "patterndb.h"
#include "pdb-file.h"
#include "plugin.h"
#include "cfg.h"
#include "timerwheel.h"
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <glib/gstdio.h>
#include "test_patterndb.h"
Include dependency graph for test_patterndb.c:

Classes

struct  PatternDBTestParam
 

Functions

void assert_output_message_nvpair_equals (gint ndx, const gchar *name, const gchar *value, LogMessageValueType type)
 
void assert_msg_matches_and_output_message_nvpair_equals_with_timeout (PatternDB *patterndb, const gchar *pattern, gint timeout, gint ndx, const gchar *name, const gchar *value, LogMessageValueType type)
 
void assert_msg_matches_and_no_such_output_message (PatternDB *patterndb, const gchar *pattern, gint ndx)
 
void assert_msg_matches_and_output_message_nvpair_equals (PatternDB *patterndb, const gchar *pattern, gint ndx, const gchar *name, const gchar *value, LogMessageValueType type)
 
void assert_output_message_has_tag (gint ndx, const gchar *tag, gboolean set)
 
void assert_msg_matches_and_output_message_has_tag_with_timeout (PatternDB *patterndb, const gchar *pattern, gint timeout, gint ndx, const gchar *tag, gboolean set)
 
void assert_msg_matches_and_output_message_has_tag (PatternDB *patterndb, const gchar *pattern, gint ndx, const gchar *tag, gboolean set)
 
 Test (pattern_db, test_simple_rule_without_context_or_actions)
 
 Test (pattern_db, test_correlation_rule_without_actions)
 
 Test (pattern_db, test_correlation_rule_with_action_on_match)
 
 Test (pattern_db, test_correlation_rule_with_action_on_timeout)
 
 Test (pattern_db, test_correlation_rule_with_action_condition)
 
 Test (pattern_db, test_correlation_rule_with_action_condition_filter)
 
 Test (pattern_db, test_correlation_rule_with_rate_limited_action)
 
 Test (pattern_db, test_simple_rule_with_action_on_match)
 
 Test (pattern_db, test_simple_rule_with_rate_limited_action)
 
 Test (pattern_db, test_simple_rule_with_action_condition)
 
 Test (pattern_db, test_correlation_rule_with_create_context)
 
 Test (pattern_db, test_patterndb_loads_a_syntactically_complete_xml_properly)
 
 Test (pattern_db, pdbtest_patterndb_message_property_inheritance_enabled)
 
 Test (pattern_db, test_patterndb_message_property_inheritance_disabled)
 
 Test (pattern_db, test_patterndb_message_property_inheritance_context)
 
 Test (pattern_db, test_patterndb_context_length_works_and_is_typed)
 
 ParameterizedTestParameters (pattern_db, test_rules)
 
 ParameterizedTest (PatternDBTestParam *param, pattern_db, test_rules)
 
 Test (pattern_db, test_tag_outside_of_rule_skeleton)
 
void test_pdb_get_filenames_setup (void)
 
void test_pdb_get_filenames_teardown (void)
 
 Test (test_pathutils, test_pdb_get_filenames,.init=test_pdb_get_filenames_setup,.fini=test_pdb_get_filenames_teardown)
 
 Test (pattern_db, match_in_program)
 
 Test (pattern_db, test_program_template)
 
void setup (void)
 
void teardown (void)
 
 TestSuite (pattern_db,.init=setup,.fini=teardown)
 

Variables

GPtrArray * messages
 
gboolean keep_patterndb_state = FALSE
 
const gchar * dirs []
 
const gchar * files []
 
size_t dirs_len = G_N_ELEMENTS(dirs)
 
size_t files_len = G_N_ELEMENTS(files)
 

Function Documentation

◆ assert_msg_matches_and_no_such_output_message()

void assert_msg_matches_and_no_such_output_message ( PatternDB *  patterndb,
const gchar *  pattern,
gint  ndx 
)

◆ assert_msg_matches_and_output_message_has_tag()

void assert_msg_matches_and_output_message_has_tag ( PatternDB *  patterndb,
const gchar *  pattern,
gint  ndx,
const gchar *  tag,
gboolean  set 
)

◆ assert_msg_matches_and_output_message_has_tag_with_timeout()

void assert_msg_matches_and_output_message_has_tag_with_timeout ( PatternDB *  patterndb,
const gchar *  pattern,
gint  timeout,
gint  ndx,
const gchar *  tag,
gboolean  set 
)

◆ assert_msg_matches_and_output_message_nvpair_equals()

void assert_msg_matches_and_output_message_nvpair_equals ( PatternDB *  patterndb,
const gchar *  pattern,
gint  ndx,
const gchar *  name,
const gchar *  value,
LogMessageValueType  type 
)

◆ assert_msg_matches_and_output_message_nvpair_equals_with_timeout()

void assert_msg_matches_and_output_message_nvpair_equals_with_timeout ( PatternDB *  patterndb,
const gchar *  pattern,
gint  timeout,
gint  ndx,
const gchar *  name,
const gchar *  value,
LogMessageValueType  type 
)

◆ assert_output_message_has_tag()

void assert_output_message_has_tag ( gint  ndx,
const gchar *  tag,
gboolean  set 
)

◆ assert_output_message_nvpair_equals()

void assert_output_message_nvpair_equals ( gint  ndx,
const gchar *  name,
const gchar *  value,
LogMessageValueType  type 
)

◆ ParameterizedTest()

ParameterizedTest ( PatternDBTestParam param,
pattern_db  ,
test_rules   
)

◆ ParameterizedTestParameters()

ParameterizedTestParameters ( pattern_db  ,
test_rules   
)

◆ setup()

void setup ( void  )

◆ teardown()

void teardown ( void  )

◆ Test() [1/20]

Test ( pattern_db  ,
match_in_program   
)

◆ Test() [2/20]

Test ( pattern_db  ,
pdbtest_patterndb_message_property_inheritance_enabled   
)

◆ Test() [3/20]

Test ( pattern_db  ,
test_correlation_rule_with_action_condition   
)

◆ Test() [4/20]

Test ( pattern_db  ,
test_correlation_rule_with_action_condition_filter   
)

◆ Test() [5/20]

Test ( pattern_db  ,
test_correlation_rule_with_action_on_match   
)

◆ Test() [6/20]

Test ( pattern_db  ,
test_correlation_rule_with_action_on_timeout   
)

◆ Test() [7/20]

Test ( pattern_db  ,
test_correlation_rule_with_create_context   
)

◆ Test() [8/20]

Test ( pattern_db  ,
test_correlation_rule_with_rate_limited_action   
)

◆ Test() [9/20]

Test ( pattern_db  ,
test_correlation_rule_without_actions   
)

◆ Test() [10/20]

Test ( pattern_db  ,
test_patterndb_context_length_works_and_is_typed   
)

◆ Test() [11/20]

Test ( pattern_db  ,
test_patterndb_loads_a_syntactically_complete_xml_properly   
)

◆ Test() [12/20]

Test ( pattern_db  ,
test_patterndb_message_property_inheritance_context   
)

◆ Test() [13/20]

Test ( pattern_db  ,
test_patterndb_message_property_inheritance_disabled   
)

◆ Test() [14/20]

Test ( pattern_db  ,
test_program_template   
)

◆ Test() [15/20]

Test ( pattern_db  ,
test_simple_rule_with_action_condition   
)

◆ Test() [16/20]

Test ( pattern_db  ,
test_simple_rule_with_action_on_match   
)

◆ Test() [17/20]

Test ( pattern_db  ,
test_simple_rule_with_rate_limited_action   
)

◆ Test() [18/20]

Test ( pattern_db  ,
test_simple_rule_without_context_or_actions   
)

◆ Test() [19/20]

Test ( pattern_db  ,
test_tag_outside_of_rule_skeleton   
)

◆ Test() [20/20]

Test ( test_pathutils  ,
test_pdb_get_filenames  ,
init = test_pdb_get_filenames_setup,
fini = test_pdb_get_filenames_teardown 
)

◆ test_pdb_get_filenames_setup()

void test_pdb_get_filenames_setup ( void  )

◆ test_pdb_get_filenames_teardown()

void test_pdb_get_filenames_teardown ( void  )

◆ TestSuite()

TestSuite ( pattern_db  ,
init = setup,
fini = teardown 
)

Variable Documentation

◆ dirs

const gchar* dirs[]
Initial value:
=
{
"pathutils_get_filenames",
"pathutils_get_filenames/testdir",
"pathutils_get_filenames/testdir2"
}

◆ dirs_len

size_t dirs_len = G_N_ELEMENTS(dirs)

◆ files

const gchar* files[]
Initial value:
=
{
"pathutils_get_filenames/test.file",
"pathutils_get_filenames/test2.file",
"pathutils_get_filenames/testdir/test.file",
"pathutils_get_filenames/testdir2/test23.file",
"pathutils_get_filenames/testdir2/test22.file"
}

◆ files_len

size_t files_len = G_N_ELEMENTS(files)

◆ keep_patterndb_state

gboolean keep_patterndb_state = FALSE

◆ messages

GPtrArray* messages